xref: /aosp_15_r20/external/skia/resources/sksl/compute/AtomicDeclarations.compute (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1layout(local_size_x = 64) in;
2
3struct S {
4    atomicUint structMemberAtomic;          // valid
5    atomicUint structMemberAtomicArray[2];  // valid
6};
7
8struct NestedS {
9    S nestedStructWithAtomicMember;  // valid
10};
11
12layout(metal, binding = 0) buffer ssbo {
13    atomicUint ssboAtomic;          // valid
14    atomicUint ssboAtomicArray[2];  // valid
15    S ssboStructWithAtomicMember;         // valid
16    S ssboStructWithAtomicMemberArray[2]; // valid
17    NestedS ssboNestedStructWithAtomicMember;  // valid
18};
19
20workgroup atomicUint wgAtomic;          // valid
21workgroup atomicUint wgAtomicArray[2];  // valid
22workgroup NestedS wgNestedStructWithAtomicMember;  // valid;
23
24void main() {
25    // Do something with each workgroup atomic to prevent them from getting eliminated as
26    // dead globals.
27    atomicAdd(wgAtomicArray[1], atomicLoad(wgAtomic));
28    atomicAdd(wgAtomicArray[0], atomicLoad(wgAtomicArray[1]));
29    atomicAdd(wgNestedStructWithAtomicMember.nestedStructWithAtomicMember.structMemberAtomic, 1);
30}
31