Debian Codegraph @

third_party/spirv-cross/samples/cpp/atomics.comp

raw
1 #version 310 es
2 layout(local_size_x = 64) in;
3
4 layout(set = 0, binding = 0, std430) readonly buffer SSBO0
5 {
6 float inputs[];
7 };
8
9 layout(set = 0, binding = 1, std430) writeonly buffer SSBO1
10 {
11 float outputs[];
12 };
13
14 layout(set = 0, binding = 2, std430) buffer SSBO2
15 {
16 uint counter;
17 };
18
19 void main()
20 {
21 // Builds a tightly packed list of all values less than 10.0.
22 // The output order is random.
23 float value = inputs[gl_GlobalInvocationID.x];
24 if (value < 10.0)
25 {
26 uint output_index = atomicAdd(counter, 1u);
27 outputs[output_index] = value;
28 }
29 }