xref: /aosp_15_r20/external/skia/tests/sksl/compute/MatrixMultiply.wgsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1diagnostic(off, derivative_uniformity);
2diagnostic(off, chromium.unreachable_code);
3struct CSIn {
4  @builtin(global_invocation_id) sk_GlobalInvocationID: vec3<u32>,
5};
6struct sizeBuffer {
7  sizes: array<vec2<i32>>,
8};
9@group(0) @binding(0) var<storage, read_write> _storage0 : sizeBuffer;
10struct inputs1 {
11  data1: array<f32>,
12};
13@group(0) @binding(1) var<storage, read> _storage1 : inputs1;
14struct inputs2 {
15  data2: array<f32>,
16};
17@group(0) @binding(2) var<storage, read> _storage2 : inputs2;
18struct result {
19  resultData: array<f32>,
20};
21@group(0) @binding(3) var<storage, read_write> _storage3 : result;
22fn _skslMain(_stageIn: CSIn) {
23  {
24    _storage0.sizes[2] = vec2<i32>(_storage0.sizes[0].x, _storage0.sizes[1].y);
25    let resultCell: vec2<i32> = vec2<i32>(i32(_stageIn.sk_GlobalInvocationID.x), i32(_stageIn.sk_GlobalInvocationID.y));
26    var result: f32 = 0.0;
27    {
28      var i: i32 = 0;
29      loop {
30        if i < _storage0.sizes[0].y {
31          {
32            let a: i32 = i + resultCell.x * _storage0.sizes[0].y;
33            let b: i32 = resultCell.y + i * _storage0.sizes[1].y;
34            result = result + _storage1.data1[a] * _storage2.data2[b];
35          }
36        } else {
37          break;
38        }
39        continuing {
40          i = i + i32(1);
41        }
42      }
43    }
44    let index: i32 = resultCell.y + resultCell.x * _storage0.sizes[1].y;
45    _storage3.resultData[index] = result;
46  }
47}
48@compute @workgroup_size(16, 16, 1) fn main(_stageIn: CSIn) {
49  _skslMain(_stageIn);
50}
51