Merge pull request #2908 from Biswa96/cmake-spirv-remap
[platform/upstream/glslang.git] / Test / spv.meshShaderPerViewBuiltins.mesh
1 #version 450
2
3 #define MAX_VER  81
4 #define MAX_PRIM 32
5 #define MAX_VIEWS gl_MaxMeshViewCountNV
6
7 #define BARRIER() \
8     memoryBarrierShared(); \
9     barrier();
10
11 #extension GL_NV_mesh_shader : enable
12
13 layout(local_size_x = 32) in;
14
15 layout(max_vertices=MAX_VER) out;
16 layout(max_primitives=MAX_PRIM) out;
17 layout(triangles) out;
18
19 // test use of per-view builtin attributes
20
21 void main()
22 {
23     uint iid = gl_LocalInvocationID.x;
24     uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS];
25
26     gl_MeshVerticesNV[iid].gl_PositionPerViewNV[viewID]          = vec4(1.0, 2.0, 3.0, 4.0);
27     gl_MeshVerticesNV[iid].gl_ClipDistancePerViewNV[viewID][2]   = 5.0;
28     gl_MeshVerticesNV[iid].gl_CullDistancePerViewNV[viewID][3]   = 6.0;
29     gl_MeshPrimitivesNV[iid].gl_LayerPerViewNV[viewID]           = 7;
30     gl_MeshPrimitivesNV[iid].gl_ViewportMaskPerViewNV[viewID][0] = 8;
31
32     BARRIER();
33
34     gl_MeshVerticesNV[iid+1].gl_PositionPerViewNV[viewID]          = gl_MeshVerticesNV[iid].gl_PositionPerViewNV[viewID];
35     gl_MeshVerticesNV[iid+1].gl_ClipDistancePerViewNV[viewID][2]   = gl_MeshVerticesNV[iid].gl_ClipDistancePerViewNV[viewID][2];
36     gl_MeshVerticesNV[iid+1].gl_CullDistancePerViewNV[viewID][3]   = gl_MeshVerticesNV[iid].gl_CullDistancePerViewNV[viewID][3];
37     gl_MeshPrimitivesNV[iid+1].gl_LayerPerViewNV[viewID]           = gl_MeshPrimitivesNV[iid].gl_LayerPerViewNV[viewID];
38     gl_MeshPrimitivesNV[iid+1].gl_ViewportMaskPerViewNV[viewID][0] = gl_MeshPrimitivesNV[iid].gl_ViewportMaskPerViewNV[viewID][0];
39
40     BARRIER();
41 }
42