Merge pull request #2892 from greg-lunarg/mb
[platform/upstream/glslang.git] / Test / spv.meshShaderSharedMem.mesh
1 #version 450
2
3 #define MAX_VER  81
4 #define MAX_PRIM 32
5
6 #define BARRIER() \
7     memoryBarrierShared(); \
8     barrier();
9
10 #extension GL_NV_mesh_shader : enable
11
12 layout(local_size_x = 32) in;
13
14 layout(max_vertices=MAX_VER) out;
15 layout(max_primitives=MAX_PRIM) out;
16 layout(triangles) out;
17
18 // test use of shared memory in mesh shaders:
19
20 writeonly uniform image2D uni_image;
21 uniform block0 {
22     uint    uni_value;
23 };
24
25 shared vec4 mem[10];
26
27 void main()
28 {
29     uint iid = gl_LocalInvocationID.x;
30     uint gid = gl_WorkGroupID.x;
31
32     for (uint i = 0; i < 10; ++i) {
33         mem[i] = vec4(i+uni_value);
34     }
35     imageStore(uni_image, ivec2(iid), mem[gid]);
36     imageStore(uni_image, ivec2(iid), mem[gid+1]);
37
38     BARRIER();
39 }