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

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