xref: /aosp_15_r20/external/angle/third_party/glslang/src/Test/hlsl.structcopylogical.comp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1struct MyStruct {
2    uint a;
3    uint b;
4    uint c;
5};
6
7struct MyStructs {
8    uint count;
9    MyStruct data[];
10};
11
12StructuredBuffer<MyStructs> sb;
13StructuredBuffer<MyStruct> o;
14
15groupshared MyStruct s[128];
16static const MyStruct deflt = { 1u, 2u, 3u };
17
18[numthreads(128, 1, 1)]
19void main(uint id : SV_GroupIndex)
20{
21        s[0] = deflt;
22        uint count = sb.Load(0).count;
23        MyStruct ms = id > count ? s[id - count] : sb.Load(0).data[id];
24
25        InterlockedAdd(o[0].a, ms.a);
26        InterlockedAdd(o[0].b, ms.b);
27        InterlockedAdd(o[0].c, ms.c);
28}
29