| layout(set=0, binding=0) buffer sizeBuffer { |
| int2[] sizes; // in1, in2, out |
| }; |
| layout(set=0, binding=1) readonly buffer inputs1 { |
| float data1[]; |
| }; |
| layout(set=0, binding=2) readonly buffer inputs2 { |
| float data2[]; |
| }; |
| layout(set=0, binding=3) writeonly buffer result { |
| float resultData[]; |
| }; |
| |
| void main() { |
| sizes[2] = int2(sizes[0].x, sizes[1].y); |
| |
| int2 resultCell = int2(sk_GlobalInvocationID.x, sk_GlobalInvocationID.y); |
| float result = 0.0; |
| for (int i = 0; i < sizes[0].y; ++i) { |
| int a = i + resultCell.x * sizes[0].y; |
| int b = resultCell.y + i * sizes[1].y; |
| result += data1[a] * data2[b]; |
| } |
| |
| int index = resultCell.y + resultCell.x * sizes[1].y; |
| resultData[index] = result; |
| } |