File: spv.structCopy.comp

package info (click to toggle)
glslang 16.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 51,084 kB
  • sloc: cpp: 90,714; yacc: 4,243; sh: 603; python: 305; ansic: 94; javascript: 74; makefile: 17
file content (37 lines) | stat: -rw-r--r-- 572 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#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);
}