Fix interaction between GL_EXT_mesh_shader and GL_EXT_fragment_shading_rate

Before this change, using gl_MeshPrimitivesEXT in mesh shader would
unconditionally create gl_MeshPrimitivesEXT.gl_PrimitiveShadingRateEXT
field and add PrimitiveShadingRateKHR capability to the output SPIRV
file, which would subsequently trigger validation errors when creating
the shader module unless the application requested primitive shading
rate feature.

What should happen instead is that unless GL_EXT_fragment_shading_rate
extension is enabled, we should not allow using
gl_PrimitiveShadingRateEXT and should not emit the associated fields
into the output.

This change fixes this by using existing filterMember mechanism that is
already used in a few other cases like this, and adjusting the required
extension on the field member which will generate an error when
gl_PrimitiveShadingRateEXT is used without enabling the extension.
This commit is contained in:
Arseny Kapoulkine 2023-08-07 10:38:17 -07:00 committed by GitHub
parent 79a9f7f652
commit 34d4f78f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 373 additions and 19 deletions

View File

@ -4648,6 +4648,12 @@ bool TGlslangToSpvTraverser::filterMember(const glslang::TType& member)
extensions.find("GL_NV_stereo_view_rendering") == extensions.end())
return true;
if (glslangIntermediate->getStage() == EShLangMesh) {
if (member.getFieldName() == "gl_PrimitiveShadingRateEXT" &&
extensions.find("GL_EXT_fragment_shading_rate") == extensions.end())
return true;
}
if (glslangIntermediate->getStage() != EShLangMesh) {
if (member.getFieldName() == "gl_ViewportMask" &&
extensions.find("GL_NV_viewport_array2") == extensions.end())

View File

@ -13,10 +13,8 @@ spv.460.subgroupEXT.mesh
Capability GroupNonUniformShuffleRelative
Capability GroupNonUniformClustered
Capability GroupNonUniformQuad
Capability FragmentShadingRateKHR
Capability MeshShadingEXT
Extension "SPV_EXT_mesh_shader"
Extension "SPV_KHR_fragment_shading_rate"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshEXT 4 "main" 35 41 57 109 147 161 162 167 168 171 172 173 174 175
@ -65,7 +63,6 @@ spv.460.subgroupEXT.mesh
MemberName 106(gl_MeshPerPrimitiveEXT) 1 "gl_Layer"
MemberName 106(gl_MeshPerPrimitiveEXT) 2 "gl_ViewportIndex"
MemberName 106(gl_MeshPerPrimitiveEXT) 3 "gl_CullPrimitiveEXT"
MemberName 106(gl_MeshPerPrimitiveEXT) 4 "gl_PrimitiveShadingRateEXT"
Name 109 "gl_MeshPrimitivesEXT"
Name 147 "gl_PrimitiveTriangleIndicesEXT"
Name 161 "gl_SubgroupSize"
@ -95,8 +92,6 @@ spv.460.subgroupEXT.mesh
MemberDecorate 106(gl_MeshPerPrimitiveEXT) 2 BuiltIn ViewportIndex
MemberDecorate 106(gl_MeshPerPrimitiveEXT) 3 PerPrimitiveNV
MemberDecorate 106(gl_MeshPerPrimitiveEXT) 3 BuiltIn CullPrimitiveEXT
MemberDecorate 106(gl_MeshPerPrimitiveEXT) 4 PerPrimitiveNV
MemberDecorate 106(gl_MeshPerPrimitiveEXT) 4 BuiltIn PrimitiveShadingRateKHR
Decorate 106(gl_MeshPerPrimitiveEXT) Block
Decorate 147(gl_PrimitiveTriangleIndicesEXT) BuiltIn PrimitiveTriangleIndicesEXT
Decorate 161(gl_SubgroupSize) RelaxedPrecision
@ -151,7 +146,7 @@ spv.460.subgroupEXT.mesh
79: 30(int) Constant 264
80: 30(int) Constant 2
105: TypeBool
106(gl_MeshPerPrimitiveEXT): TypeStruct 59(int) 59(int) 59(int) 105(bool) 59(int)
106(gl_MeshPerPrimitiveEXT): TypeStruct 59(int) 59(int) 59(int) 105(bool)
107: TypeArray 106(gl_MeshPerPrimitiveEXT) 47
108: TypePointer Output 107
109(gl_MeshPrimitivesEXT): 108(ptr) Variable Output

View File

@ -5,12 +5,10 @@ spv.ext.meshShaderBuiltins.mesh
Capability ClipDistance
Capability CullDistance
Capability FragmentShadingRateKHR
Capability DrawParameters
Capability MultiView
Capability MeshShadingEXT
Extension "SPV_EXT_mesh_shader"
Extension "SPV_KHR_fragment_shading_rate"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshEXT 4 "main" 13 19 24 41 93 134 152 155
@ -43,7 +41,6 @@ spv.ext.meshShaderBuiltins.mesh
MemberName 90(gl_MeshPerPrimitiveEXT) 1 "gl_Layer"
MemberName 90(gl_MeshPerPrimitiveEXT) 2 "gl_ViewportIndex"
MemberName 90(gl_MeshPerPrimitiveEXT) 3 "gl_CullPrimitiveEXT"
MemberName 90(gl_MeshPerPrimitiveEXT) 4 "gl_PrimitiveShadingRateEXT"
Name 93 "gl_MeshPrimitivesEXT"
Name 134 "gl_PrimitiveTriangleIndicesEXT"
Name 150 "id"
@ -66,8 +63,6 @@ spv.ext.meshShaderBuiltins.mesh
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 2 BuiltIn ViewportIndex
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 3 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 3 BuiltIn CullPrimitiveEXT
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 4 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 4 BuiltIn PrimitiveShadingRateKHR
Decorate 90(gl_MeshPerPrimitiveEXT) Block
Decorate 134(gl_PrimitiveTriangleIndicesEXT) BuiltIn PrimitiveTriangleIndicesEXT
Decorate 152(gl_DrawIDARB) BuiltIn DrawIndex
@ -113,7 +108,7 @@ spv.ext.meshShaderBuiltins.mesh
63: 8(int) Constant 264
64: 8(int) Constant 2
89: TypeBool
90(gl_MeshPerPrimitiveEXT): TypeStruct 43(int) 43(int) 43(int) 89(bool) 43(int)
90(gl_MeshPerPrimitiveEXT): TypeStruct 43(int) 43(int) 43(int) 89(bool)
91: TypeArray 90(gl_MeshPerPrimitiveEXT) 29
92: TypePointer Output 91
93(gl_MeshPrimitivesEXT): 92(ptr) Variable Output

View File

@ -0,0 +1,281 @@
spv.ext.meshShaderBuiltinsShadingRate.mesh
// Module Version 10400
// Generated by (magic number): 8000b
// Id's are bound by 164
Capability ClipDistance
Capability CullDistance
Capability FragmentShadingRateKHR
Capability DrawParameters
Capability MultiView
Capability MeshShadingEXT
Extension "SPV_EXT_mesh_shader"
Extension "SPV_KHR_fragment_shading_rate"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshEXT 4 "main" 13 19 24 41 93 140 158 161
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source GLSL 460
SourceExtension "GL_ARB_shader_draw_parameters"
SourceExtension "GL_EXT_fragment_shading_rate"
SourceExtension "GL_EXT_mesh_shader"
SourceExtension "GL_EXT_multiview"
Name 4 "main"
Name 6 "testAdditionalBuiltins("
Name 10 "iid"
Name 13 "gl_LocalInvocationID"
Name 18 "gid"
Name 19 "gl_WorkGroupID"
Name 23 "numWorkGrous"
Name 24 "gl_NumWorkGroups"
Name 26 "vertexCount"
Name 28 "primitiveCount"
Name 38 "gl_MeshPerVertexEXT"
MemberName 38(gl_MeshPerVertexEXT) 0 "gl_Position"
MemberName 38(gl_MeshPerVertexEXT) 1 "gl_PointSize"
MemberName 38(gl_MeshPerVertexEXT) 2 "gl_ClipDistance"
MemberName 38(gl_MeshPerVertexEXT) 3 "gl_CullDistance"
Name 41 "gl_MeshVerticesEXT"
Name 90 "gl_MeshPerPrimitiveEXT"
MemberName 90(gl_MeshPerPrimitiveEXT) 0 "gl_PrimitiveID"
MemberName 90(gl_MeshPerPrimitiveEXT) 1 "gl_Layer"
MemberName 90(gl_MeshPerPrimitiveEXT) 2 "gl_ViewportIndex"
MemberName 90(gl_MeshPerPrimitiveEXT) 3 "gl_CullPrimitiveEXT"
MemberName 90(gl_MeshPerPrimitiveEXT) 4 "gl_PrimitiveShadingRateEXT"
Name 93 "gl_MeshPrimitivesEXT"
Name 140 "gl_PrimitiveTriangleIndicesEXT"
Name 156 "id"
Name 158 "gl_DrawIDARB"
Name 160 "viewIdx"
Name 161 "gl_ViewIndex"
Decorate 13(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 19(gl_WorkGroupID) BuiltIn WorkgroupId
Decorate 24(gl_NumWorkGroups) BuiltIn NumWorkgroups
MemberDecorate 38(gl_MeshPerVertexEXT) 0 BuiltIn Position
MemberDecorate 38(gl_MeshPerVertexEXT) 1 BuiltIn PointSize
MemberDecorate 38(gl_MeshPerVertexEXT) 2 BuiltIn ClipDistance
MemberDecorate 38(gl_MeshPerVertexEXT) 3 BuiltIn CullDistance
Decorate 38(gl_MeshPerVertexEXT) Block
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 0 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 0 BuiltIn PrimitiveId
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 1 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 1 BuiltIn Layer
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 2 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 2 BuiltIn ViewportIndex
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 3 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 3 BuiltIn CullPrimitiveEXT
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 4 PerPrimitiveNV
MemberDecorate 90(gl_MeshPerPrimitiveEXT) 4 BuiltIn PrimitiveShadingRateKHR
Decorate 90(gl_MeshPerPrimitiveEXT) Block
Decorate 140(gl_PrimitiveTriangleIndicesEXT) BuiltIn PrimitiveTriangleIndicesEXT
Decorate 158(gl_DrawIDARB) BuiltIn DrawIndex
Decorate 161(gl_ViewIndex) BuiltIn ViewIndex
Decorate 163 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
8: TypeInt 32 0
9: TypePointer Function 8(int)
11: TypeVector 8(int) 3
12: TypePointer Input 11(ivec3)
13(gl_LocalInvocationID): 12(ptr) Variable Input
14: 8(int) Constant 0
15: TypePointer Input 8(int)
19(gl_WorkGroupID): 12(ptr) Variable Input
22: TypePointer Function 11(ivec3)
24(gl_NumWorkGroups): 12(ptr) Variable Input
27: 8(int) Constant 81
29: 8(int) Constant 32
32: TypeFloat 32
33: TypeVector 32(float) 4
34: 8(int) Constant 4
35: TypeArray 32(float) 34
36: 8(int) Constant 3
37: TypeArray 32(float) 36
38(gl_MeshPerVertexEXT): TypeStruct 33(fvec4) 32(float) 35 37
39: TypeArray 38(gl_MeshPerVertexEXT) 27
40: TypePointer Output 39
41(gl_MeshVerticesEXT): 40(ptr) Variable Output
43: TypeInt 32 1
44: 43(int) Constant 0
45: 32(float) Constant 1065353216
46: 33(fvec4) ConstantComposite 45 45 45 45
47: TypePointer Output 33(fvec4)
50: 43(int) Constant 1
51: 32(float) Constant 1073741824
52: TypePointer Output 32(float)
55: 43(int) Constant 2
56: 43(int) Constant 3
57: 32(float) Constant 1077936128
60: 32(float) Constant 1082130432
62: 8(int) Constant 1
63: 8(int) Constant 264
64: 8(int) Constant 2
89: TypeBool
90(gl_MeshPerPrimitiveEXT): TypeStruct 43(int) 43(int) 43(int) 89(bool) 43(int)
91: TypeArray 90(gl_MeshPerPrimitiveEXT) 29
92: TypePointer Output 91
93(gl_MeshPrimitivesEXT): 92(ptr) Variable Output
95: 43(int) Constant 6
96: TypePointer Output 43(int)
99: 43(int) Constant 7
102: 43(int) Constant 8
105: 89(bool) ConstantFalse
106: TypePointer Output 89(bool)
109: 43(int) Constant 4
138: TypeArray 11(ivec3) 29
139: TypePointer Output 138
140(gl_PrimitiveTriangleIndicesEXT): 139(ptr) Variable Output
141: 8(int) Constant 257
142: 11(ivec3) ConstantComposite 141 141 141
143: TypePointer Output 11(ivec3)
147: 11(ivec3) ConstantComposite 64 64 64
155: TypePointer Function 43(int)
157: TypePointer Input 43(int)
158(gl_DrawIDARB): 157(ptr) Variable Input
161(gl_ViewIndex): 157(ptr) Variable Input
163: 11(ivec3) ConstantComposite 29 62 62
4(main): 2 Function None 3
5: Label
10(iid): 9(ptr) Variable Function
18(gid): 9(ptr) Variable Function
23(numWorkGrous): 22(ptr) Variable Function
26(vertexCount): 9(ptr) Variable Function
28(primitiveCount): 9(ptr) Variable Function
16: 15(ptr) AccessChain 13(gl_LocalInvocationID) 14
17: 8(int) Load 16
Store 10(iid) 17
20: 15(ptr) AccessChain 19(gl_WorkGroupID) 14
21: 8(int) Load 20
Store 18(gid) 21
25: 11(ivec3) Load 24(gl_NumWorkGroups)
Store 23(numWorkGrous) 25
Store 26(vertexCount) 27
Store 28(primitiveCount) 29
30: 8(int) Load 26(vertexCount)
31: 8(int) Load 28(primitiveCount)
SetMeshOutputsEXT 30 31
42: 8(int) Load 10(iid)
48: 47(ptr) AccessChain 41(gl_MeshVerticesEXT) 42 44
Store 48 46
49: 8(int) Load 10(iid)
53: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 49 50
Store 53 51
54: 8(int) Load 10(iid)
58: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 54 55 56
Store 58 57
59: 8(int) Load 10(iid)
61: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 59 56 55
Store 61 60
MemoryBarrier 62 63
ControlBarrier 64 64 63
65: 8(int) Load 10(iid)
66: 8(int) IAdd 65 62
67: 8(int) Load 10(iid)
68: 47(ptr) AccessChain 41(gl_MeshVerticesEXT) 67 44
69: 33(fvec4) Load 68
70: 47(ptr) AccessChain 41(gl_MeshVerticesEXT) 66 44
Store 70 69
71: 8(int) Load 10(iid)
72: 8(int) IAdd 71 62
73: 8(int) Load 10(iid)
74: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 73 50
75: 32(float) Load 74
76: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 72 50
Store 76 75
77: 8(int) Load 10(iid)
78: 8(int) IAdd 77 62
79: 8(int) Load 10(iid)
80: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 79 55 56
81: 32(float) Load 80
82: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 78 55 56
Store 82 81
83: 8(int) Load 10(iid)
84: 8(int) IAdd 83 62
85: 8(int) Load 10(iid)
86: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 85 56 55
87: 32(float) Load 86
88: 52(ptr) AccessChain 41(gl_MeshVerticesEXT) 84 56 55
Store 88 87
MemoryBarrier 62 63
ControlBarrier 64 64 63
94: 8(int) Load 10(iid)
97: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 94 44
Store 97 95
98: 8(int) Load 10(iid)
100: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 98 50
Store 100 99
101: 8(int) Load 10(iid)
103: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 101 55
Store 103 102
104: 8(int) Load 10(iid)
107: 106(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 104 56
Store 107 105
108: 8(int) Load 10(iid)
110: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 108 109
Store 110 44
MemoryBarrier 62 63
ControlBarrier 64 64 63
111: 8(int) Load 10(iid)
112: 8(int) IAdd 111 62
113: 8(int) Load 10(iid)
114: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 113 44
115: 43(int) Load 114
116: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 112 44
Store 116 115
117: 8(int) Load 10(iid)
118: 8(int) IAdd 117 62
119: 8(int) Load 10(iid)
120: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 119 50
121: 43(int) Load 120
122: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 118 50
Store 122 121
123: 8(int) Load 10(iid)
124: 8(int) IAdd 123 62
125: 8(int) Load 10(iid)
126: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 125 55
127: 43(int) Load 126
128: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 124 55
Store 128 127
129: 8(int) Load 10(iid)
130: 8(int) IAdd 129 62
131: 8(int) Load 10(iid)
132: 106(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 131 56
133: 89(bool) Load 132
134: 106(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 130 56
Store 134 133
135: 8(int) Load 10(iid)
136: 8(int) IAdd 135 62
137: 96(ptr) AccessChain 93(gl_MeshPrimitivesEXT) 136 109
Store 137 44
MemoryBarrier 62 63
ControlBarrier 64 64 63
144: 143(ptr) AccessChain 140(gl_PrimitiveTriangleIndicesEXT) 44
Store 144 142
145: 8(int) Load 28(primitiveCount)
146: 8(int) ISub 145 62
148: 143(ptr) AccessChain 140(gl_PrimitiveTriangleIndicesEXT) 146
Store 148 147
149: 8(int) Load 18(gid)
150: 8(int) Load 18(gid)
151: 8(int) ISub 150 62
152: 143(ptr) AccessChain 140(gl_PrimitiveTriangleIndicesEXT) 151
153: 11(ivec3) Load 152
154: 143(ptr) AccessChain 140(gl_PrimitiveTriangleIndicesEXT) 149
Store 154 153
MemoryBarrier 62 63
ControlBarrier 64 64 63
Return
FunctionEnd
6(testAdditionalBuiltins(): 2 Function None 3
7: Label
156(id): 155(ptr) Variable Function
160(viewIdx): 155(ptr) Variable Function
159: 43(int) Load 158(gl_DrawIDARB)
Store 156(id) 159
162: 43(int) Load 161(gl_ViewIndex)
Store 160(viewIdx) 162
Return
FunctionEnd

View File

@ -5,10 +5,8 @@ spv.ext.meshShaderRedeclBuiltins.mesh
Capability ClipDistance
Capability CullDistance
Capability FragmentShadingRateKHR
Capability MeshShadingEXT
Extension "SPV_EXT_mesh_shader"
Extension "SPV_KHR_fragment_shading_rate"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshEXT 4 "main" 11 17 29 81 122
@ -34,7 +32,6 @@ spv.ext.meshShaderRedeclBuiltins.mesh
MemberName 78(gl_MeshPerPrimitiveEXT) 1 "gl_Layer"
MemberName 78(gl_MeshPerPrimitiveEXT) 2 "gl_ViewportIndex"
MemberName 78(gl_MeshPerPrimitiveEXT) 3 "gl_CullPrimitiveEXT"
MemberName 78(gl_MeshPerPrimitiveEXT) 4 "gl_PrimitiveShadingRateEXT"
Name 81 "gl_MeshPrimitivesEXT"
Name 122 "gl_PrimitivePointIndicesEXT"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
@ -52,8 +49,6 @@ spv.ext.meshShaderRedeclBuiltins.mesh
MemberDecorate 78(gl_MeshPerPrimitiveEXT) 2 BuiltIn ViewportIndex
MemberDecorate 78(gl_MeshPerPrimitiveEXT) 3 PerPrimitiveNV
MemberDecorate 78(gl_MeshPerPrimitiveEXT) 3 BuiltIn CullPrimitiveEXT
MemberDecorate 78(gl_MeshPerPrimitiveEXT) 4 PerPrimitiveNV
MemberDecorate 78(gl_MeshPerPrimitiveEXT) 4 BuiltIn PrimitiveShadingRateKHR
Decorate 78(gl_MeshPerPrimitiveEXT) Block
Decorate 122(gl_PrimitivePointIndicesEXT) BuiltIn PrimitivePointIndicesEXT
Decorate 127 BuiltIn WorkgroupSize
@ -93,7 +88,7 @@ spv.ext.meshShaderRedeclBuiltins.mesh
51: 6(int) Constant 264
52: 6(int) Constant 2
77: TypeBool
78(gl_MeshPerPrimitiveEXT): TypeStruct 31(int) 31(int) 31(int) 77(bool) 31(int)
78(gl_MeshPerPrimitiveEXT): TypeStruct 31(int) 31(int) 31(int) 77(bool)
79: TypeArray 78(gl_MeshPerPrimitiveEXT) 21
80: TypePointer Output 79
81(gl_MeshPrimitivesEXT): 80(ptr) Variable Output

View File

@ -0,0 +1,77 @@
#version 460
#define MAX_VER 81
#define MAX_PRIM 32
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_EXT_mesh_shader : enable
#extension GL_EXT_fragment_shading_rate : enable
layout(local_size_x = 32, local_size_y=1, local_size_z=1) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of builtins in mesh shaders:
void main()
{
uint iid = gl_LocalInvocationID.x;
uint gid = gl_WorkGroupID.x;
uvec3 numWorkGrous = gl_NumWorkGroups;
uint vertexCount = MAX_VER; // vertexCount <= max_vertices
uint primitiveCount = MAX_PRIM; // primitiveCount <= max_primtives
SetMeshOutputsEXT(vertexCount, primitiveCount);
gl_MeshVerticesEXT[iid].gl_Position = vec4(1.0);
gl_MeshVerticesEXT[iid].gl_PointSize = 2.0;
gl_MeshVerticesEXT[iid].gl_ClipDistance[3] = 3.0;
gl_MeshVerticesEXT[iid].gl_CullDistance[2] = 4.0;
BARRIER();
gl_MeshVerticesEXT[iid+1].gl_Position = gl_MeshVerticesEXT[iid].gl_Position;
gl_MeshVerticesEXT[iid+1].gl_PointSize = gl_MeshVerticesEXT[iid].gl_PointSize;
gl_MeshVerticesEXT[iid+1].gl_ClipDistance[3] = gl_MeshVerticesEXT[iid].gl_ClipDistance[3];
gl_MeshVerticesEXT[iid+1].gl_CullDistance[2] = gl_MeshVerticesEXT[iid].gl_CullDistance[2];
BARRIER();
gl_MeshPrimitivesEXT[iid].gl_PrimitiveID = 6;
gl_MeshPrimitivesEXT[iid].gl_Layer = 7;
gl_MeshPrimitivesEXT[iid].gl_ViewportIndex = 8;
gl_MeshPrimitivesEXT[iid].gl_CullPrimitiveEXT = false;
gl_MeshPrimitivesEXT[iid].gl_PrimitiveShadingRateEXT = 0;
BARRIER();
gl_MeshPrimitivesEXT[iid+1].gl_PrimitiveID = gl_MeshPrimitivesEXT[iid].gl_PrimitiveID;
gl_MeshPrimitivesEXT[iid+1].gl_Layer = gl_MeshPrimitivesEXT[iid].gl_Layer;
gl_MeshPrimitivesEXT[iid+1].gl_ViewportIndex = gl_MeshPrimitivesEXT[iid].gl_ViewportIndex;
gl_MeshPrimitivesEXT[iid+1].gl_CullPrimitiveEXT = gl_MeshPrimitivesEXT[iid].gl_CullPrimitiveEXT;
gl_MeshPrimitivesEXT[iid+1].gl_PrimitiveShadingRateEXT = 0;
BARRIER();
// check bound limits
gl_PrimitiveTriangleIndicesEXT[0] = uvec3(257); // should truncate 257 -> 1, range is between [0, vertexCount-1]
gl_PrimitiveTriangleIndicesEXT[primitiveCount - 1] = uvec3(2); // array size is primitiveCount*3 for triangle
gl_PrimitiveTriangleIndicesEXT[gid] = gl_PrimitiveTriangleIndicesEXT[gid-1];
BARRIER();
}
// test use of builtins enabled by other extensions
#extension GL_ARB_shader_draw_parameters : enable
#extension GL_EXT_multiview : enable
void testAdditionalBuiltins()
{
int id = gl_DrawIDARB; // GL_ARB_shader_draw_parameters
int viewIdx = gl_ViewIndex; // GL_EXT_multiview
}

View File

@ -9206,7 +9206,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_Layer", 1, &E_GL_EXT_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_ViewportIndex", 1, &E_GL_EXT_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_CullPrimitiveEXT", 1, &E_GL_EXT_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_PrimitiveShadingRateEXT", 1, &E_GL_EXT_mesh_shader);
// note: technically this member requires both GL_EXT_mesh_shader and GL_EXT_fragment_shading_rate
// since setVariableExtensions only needs *one of* the extensions to validate, it's more useful to specify EXT_fragment_shading_rate
// GL_EXT_mesh_shader will be required in practice by use of other fields of gl_MeshPrimitivesEXT
symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_PrimitiveShadingRateEXT", 1, &E_GL_EXT_fragment_shading_rate);
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_PrimitiveID", EbvPrimitiveId, symbolTable);
BuiltInVariable("gl_MeshPrimitivesEXT", "gl_Layer", EbvLayer, symbolTable);

View File

@ -660,6 +660,7 @@ INSTANTIATE_TEST_SUITE_P(
// SPV_EXT_mesh_shader
"spv.ext.meshShaderBuiltins.mesh",
"spv.ext.meshShaderBuiltinsShadingRate.mesh",
"spv.ext.meshShaderRedeclBuiltins.mesh",
"spv.ext.meshShaderTaskMem.mesh",
"spv.ext.meshShaderUserDefined.mesh",