• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1layout(set=0, binding=0) buffer sizeBuffer {
2    int2[] sizes;  // in1, in2, out
3};
4layout(set=0, binding=1) readonly buffer inputs1  {
5    float data1[];
6};
7layout(set=0, binding=2) readonly buffer inputs2 {
8    float data2[];
9};
10layout(set=0, binding=3) writeonly buffer result {
11    float resultData[];
12};
13
14void main() {
15    sizes[2] = int2(sizes[0].x, sizes[1].y);
16
17    int2 resultCell = int2(sk_GlobalInvocationID.x, sk_GlobalInvocationID.y);
18    float result = 0.0;
19    for (int i = 0; i < sizes[0].y; ++i) {
20      int a = i + resultCell.x * sizes[0].y;
21      int b = resultCell.y + i * sizes[1].y;
22      result += data1[a] * data2[b];
23    }
24
25    int index = resultCell.y + resultCell.x * sizes[1].y;
26    resultData[index] = result;
27}
28