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

@ -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