mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 20:10:06 +00:00
adcc7e8163
There are 3 separate tests added to cover the 3 cases in visitSelection(). With SPIR-V versions prior to 1.4, control flow is generated, with GLSL generating code to execute only the appropriate branch of the conditional while HLSL executes both branches and uses the control flow to select the appropriate one. Finally, with SPIR-V versions newer than 1.4, OpSelect can be used on structs. Note that the hlsl.structcopy.comp and hlsl.structcopylogical.comp tests have identical shader code, but are compiled with different versions of SPIR-V and result in different codepaths being used and different SPIR-V generated.
38 lines
572 B
Plaintext
38 lines
572 B
Plaintext
#version 460
|
|
layout(local_size_x = 512, local_size_y = 1) in;
|
|
layout(std430) buffer;
|
|
|
|
struct MyStruct {
|
|
uint a;
|
|
uint b;
|
|
uint c;
|
|
};
|
|
|
|
layout(binding = 0) buffer MyStructs {
|
|
uint count;
|
|
MyStruct data[];
|
|
}
|
|
my_structs;
|
|
|
|
layout(binding = 1) buffer Output {
|
|
uint a;
|
|
uint b;
|
|
uint c;
|
|
}
|
|
o;
|
|
|
|
shared MyStruct s[512];
|
|
|
|
void main() {
|
|
s[0] = MyStruct(1, 2, 3);
|
|
|
|
uint id = gl_GlobalInvocationID.x;
|
|
MyStruct ms =
|
|
id > my_structs.count ? s[id - my_structs.count] : my_structs.data[id];
|
|
|
|
atomicAdd(o.a, ms.a);
|
|
atomicAdd(o.b, ms.b);
|
|
atomicAdd(o.c, ms.c);
|
|
}
|
|
|