mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Avoid spuriously adding Geometry capability for vert, tesc, tese (#2462)
Use of gl_Layer and gl_ViewportIndex in tessellation and vertex shaders should not trigger the addition of the Geometry capability. Fixes #2461 Added tests for use of gl_Layer and gl_ViewportIndex in a tessellation evaluation shader. Several tests for NVIDIA features for tessellation, vertex, or mesh shaders now lose the Geometry or MultiViewport capabilities. This is ok because the functionality is already covered by the ShaderViewportIndexLayerNV capability. The spv.meshShaderPerViewBuiltins.mesh test now fails validation because the validator does not know that PrimitiveId (and possibly other) builtins are enabled by the MeshShadingNV capability. I filed https://github.com/KhronosGroup/SPIRV-Headers/issues/179 to fix the grammar upstream.
This commit is contained in:
parent
639f5461e3
commit
fb53f83503
@ -725,7 +725,10 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
return spv::BuiltInCullDistance;
|
||||
|
||||
case glslang::EbvViewportIndex:
|
||||
builder.addCapability(spv::CapabilityMultiViewport);
|
||||
if (glslangIntermediate->getStage() == EShLangGeometry ||
|
||||
glslangIntermediate->getStage() == EShLangFragment) {
|
||||
builder.addCapability(spv::CapabilityMultiViewport);
|
||||
}
|
||||
if (glslangIntermediate->getStage() == EShLangVertex ||
|
||||
glslangIntermediate->getStage() == EShLangTessControl ||
|
||||
glslangIntermediate->getStage() == EShLangTessEvaluation) {
|
||||
@ -754,7 +757,10 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
if (glslangIntermediate->getStage() == EShLangMeshNV) {
|
||||
return spv::BuiltInLayer;
|
||||
}
|
||||
builder.addCapability(spv::CapabilityGeometry);
|
||||
if (glslangIntermediate->getStage() == EShLangGeometry ||
|
||||
glslangIntermediate->getStage() == EShLangFragment) {
|
||||
builder.addCapability(spv::CapabilityGeometry);
|
||||
}
|
||||
if (glslangIntermediate->getStage() == EShLangVertex ||
|
||||
glslangIntermediate->getStage() == EShLangTessControl ||
|
||||
glslangIntermediate->getStage() == EShLangTessEvaluation) {
|
||||
|
30
Test/baseResults/spv.layer.tese.out
Normal file
30
Test/baseResults/spv.layer.tese.out
Normal file
@ -0,0 +1,30 @@
|
||||
spv.layer.tese
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 8000a
|
||||
// Id's are bound by 10
|
||||
|
||||
Capability Tessellation
|
||||
Capability ShaderViewportIndexLayerNV
|
||||
Extension "SPV_EXT_shader_viewport_index_layer"
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint TessellationEvaluation 4 "main" 8
|
||||
ExecutionMode 4 Triangles
|
||||
ExecutionMode 4 SpacingEqual
|
||||
ExecutionMode 4 VertexOrderCcw
|
||||
Source GLSL 450
|
||||
SourceExtension "GL_ARB_shader_viewport_layer_array"
|
||||
Name 4 "main"
|
||||
Name 8 "gl_Layer"
|
||||
Decorate 8(gl_Layer) BuiltIn Layer
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 1
|
||||
7: TypePointer Output 6(int)
|
||||
8(gl_Layer): 7(ptr) Variable Output
|
||||
9: 6(int) Constant 1
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
Store 8(gl_Layer) 9
|
||||
Return
|
||||
FunctionEnd
|
@ -5,7 +5,6 @@ spv.meshShaderBuiltins.mesh
|
||||
|
||||
Capability ClipDistance
|
||||
Capability CullDistance
|
||||
Capability MultiViewport
|
||||
Capability DrawParameters
|
||||
Capability ShaderViewportMaskNV
|
||||
Capability MeshShadingNV
|
||||
|
@ -1,9 +1,9 @@
|
||||
spv.meshShaderPerViewBuiltins.mesh
|
||||
Validation failed
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 8000a
|
||||
// Id's are bound by 126
|
||||
|
||||
Capability MultiViewport
|
||||
Capability PerViewAttributesNV
|
||||
Capability MeshShadingNV
|
||||
Extension "SPV_NVX_multiview_per_view_attributes"
|
||||
|
@ -5,7 +5,6 @@ spv.meshShaderRedeclBuiltins.mesh
|
||||
|
||||
Capability ClipDistance
|
||||
Capability CullDistance
|
||||
Capability MultiViewport
|
||||
Capability ShaderViewportMaskNV
|
||||
Capability MeshShadingNV
|
||||
Extension "SPV_NV_mesh_shader"
|
||||
|
@ -3,7 +3,6 @@ spv.stereoViewRendering.tesc
|
||||
// Generated by (magic number): 8000a
|
||||
// Id's are bound by 42
|
||||
|
||||
Capability Geometry
|
||||
Capability Tessellation
|
||||
Capability ShaderViewportIndexLayerNV
|
||||
Capability ShaderViewportMaskNV
|
||||
|
@ -4,7 +4,6 @@ spv.stereoViewRendering.vert
|
||||
// Id's are bound by 27
|
||||
|
||||
Capability Shader
|
||||
Capability Geometry
|
||||
Capability ShaderViewportIndexLayerNV
|
||||
Capability ShaderViewportMaskNV
|
||||
Capability ShaderStereoViewNV
|
||||
|
@ -4,9 +4,7 @@ Validation failed
|
||||
// Generated by (magic number): 8000a
|
||||
// Id's are bound by 25
|
||||
|
||||
Capability Geometry
|
||||
Capability Tessellation
|
||||
Capability MultiViewport
|
||||
Capability ShaderViewportIndexLayerNV
|
||||
Capability ShaderViewportMaskNV
|
||||
Extension "SPV_EXT_shader_viewport_index_layer"
|
||||
|
@ -4,8 +4,6 @@ spv.viewportArray2.vert
|
||||
// Id's are bound by 19
|
||||
|
||||
Capability Shader
|
||||
Capability Geometry
|
||||
Capability MultiViewport
|
||||
Capability ShaderViewportIndexLayerNV
|
||||
Capability ShaderViewportMaskNV
|
||||
Extension "SPV_EXT_shader_viewport_index_layer"
|
||||
|
30
Test/baseResults/spv.viewportindex.tese.out
Normal file
30
Test/baseResults/spv.viewportindex.tese.out
Normal file
@ -0,0 +1,30 @@
|
||||
spv.viewportindex.tese
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 8000a
|
||||
// Id's are bound by 10
|
||||
|
||||
Capability Tessellation
|
||||
Capability ShaderViewportIndexLayerNV
|
||||
Extension "SPV_EXT_shader_viewport_index_layer"
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint TessellationEvaluation 4 "main" 8
|
||||
ExecutionMode 4 Triangles
|
||||
ExecutionMode 4 SpacingEqual
|
||||
ExecutionMode 4 VertexOrderCcw
|
||||
Source GLSL 450
|
||||
SourceExtension "GL_ARB_shader_viewport_layer_array"
|
||||
Name 4 "main"
|
||||
Name 8 "gl_ViewportIndex"
|
||||
Decorate 8(gl_ViewportIndex) BuiltIn ViewportIndex
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 32 1
|
||||
7: TypePointer Output 6(int)
|
||||
8(gl_ViewportIndex): 7(ptr) Variable Output
|
||||
9: 6(int) Constant 1
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
Store 8(gl_ViewportIndex) 9
|
||||
Return
|
||||
FunctionEnd
|
8
Test/spv.layer.tese
Normal file
8
Test/spv.layer.tese
Normal file
@ -0,0 +1,8 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_ARB_shader_viewport_layer_array : require
|
||||
|
||||
layout(triangles) in;
|
||||
void main() {
|
||||
gl_Layer = 1;
|
||||
}
|
8
Test/spv.viewportindex.tese
Normal file
8
Test/spv.viewportindex.tese
Normal file
@ -0,0 +1,8 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_ARB_shader_viewport_layer_array : require
|
||||
|
||||
layout(triangles) in;
|
||||
void main() {
|
||||
gl_ViewportIndex = 1;
|
||||
}
|
@ -352,6 +352,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
"spv.int64.frag",
|
||||
"spv.intcoopmat.comp",
|
||||
"spv.intOps.vert",
|
||||
"spv.layer.tese",
|
||||
"spv.layoutNested.vert",
|
||||
"spv.length.frag",
|
||||
"spv.localAggregates.frag",
|
||||
@ -439,6 +440,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
"spv.terminate.frag",
|
||||
"spv.precise.tese",
|
||||
"spv.precise.tesc",
|
||||
"spv.viewportindex.tese",
|
||||
"spv.volatileAtomic.comp",
|
||||
"spv.vulkan100.subgroupArithmetic.comp",
|
||||
"spv.vulkan100.subgroupPartitioned.comp",
|
||||
|
Loading…
Reference in New Issue
Block a user