From 6639be7c2dd1332c4fad66b95886f7e6745532e8 Mon Sep 17 00:00:00 2001 From: Greg Fischer Date: Wed, 20 Oct 2021 13:48:22 -0600 Subject: [PATCH] Accept gl_ViewportMask in version 430 and later Was previously accepted only in 450 or later. Fixes #2785 --- Test/baseResults/spv.viewportArray2.tesc.out | 20 ++++++---------- Test/spv.viewportArray2.tesc | 3 +-- glslang/MachineIndependent/Initialize.cpp | 24 +++++++++++++++++--- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Test/baseResults/spv.viewportArray2.tesc.out b/Test/baseResults/spv.viewportArray2.tesc.out index 74235a57..e95ada49 100644 --- a/Test/baseResults/spv.viewportArray2.tesc.out +++ b/Test/baseResults/spv.viewportArray2.tesc.out @@ -1,8 +1,7 @@ spv.viewportArray2.tesc -Validation failed // Module Version 10000 // Generated by (magic number): 8000a -// Id's are bound by 25 +// Id's are bound by 23 Capability Tessellation Capability ShaderViewportIndexLayerNV @@ -11,23 +10,21 @@ Validation failed Extension "SPV_NV_viewport_array2" 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint TessellationControl 4 "main" 14 16 22 24 + EntryPoint TessellationControl 4 "main" 14 16 22 ExecutionMode 4 OutputVertices 4 - Source GLSL 450 + Source GLSL 430 SourceExtension "GL_NV_viewport_array2" Name 4 "main" Name 10 "gl_PerVertex" MemberName 10(gl_PerVertex) 0 "gl_ViewportMask" Name 14 "gl_out" Name 16 "gl_InvocationID" - Name 22 "gl_ViewportIndex" - Name 24 "gl_Layer" + Name 22 "gl_Layer" MemberDecorate 10(gl_PerVertex) 0 BuiltIn ViewportMaskNV Decorate 10(gl_PerVertex) Block Decorate 16(gl_InvocationID) BuiltIn InvocationId - Decorate 22(gl_ViewportIndex) BuiltIn ViewportIndex - Decorate 24(gl_Layer) BuiltIn Layer - Decorate 24(gl_Layer) ViewportRelativeNV + Decorate 22(gl_Layer) BuiltIn Layer + Decorate 22(gl_Layer) ViewportRelativeNV 2: TypeVoid 3: TypeFunction 2 6: TypeInt 32 1 @@ -44,14 +41,11 @@ Validation failed 18: 6(int) Constant 0 19: 6(int) Constant 1 20: TypePointer Output 6(int) -22(gl_ViewportIndex): 20(ptr) Variable Output - 23: 6(int) Constant 2 - 24(gl_Layer): 20(ptr) Variable Output + 22(gl_Layer): 20(ptr) Variable Output 4(main): 2 Function None 3 5: Label 17: 6(int) Load 16(gl_InvocationID) 21: 20(ptr) AccessChain 14(gl_out) 17 18 18 Store 21 19 - Store 22(gl_ViewportIndex) 23 Return FunctionEnd diff --git a/Test/spv.viewportArray2.tesc b/Test/spv.viewportArray2.tesc index 7fc208a4..24a1d8c9 100644 --- a/Test/spv.viewportArray2.tesc +++ b/Test/spv.viewportArray2.tesc @@ -1,4 +1,4 @@ -#version 450 +#version 430 #extension GL_NV_viewport_array2 :require layout(vertices = 4) out; @@ -12,5 +12,4 @@ layout (viewport_relative) out highp int gl_Layer; void main() { gl_out[gl_InvocationID].gl_ViewportMask[0] = 1; - gl_ViewportIndex = 2; } diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 9f925299..b633331a 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -5172,9 +5172,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV ); } - if (version >= 450) + if (version >= 430) stageBuiltins[EShLangVertex].append( "out int gl_ViewportMask[];" // GL_NV_viewport_array2 + ); + + if (version >= 450) + stageBuiltins[EShLangVertex].append( "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes @@ -5310,9 +5314,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "in int gl_InvocationID;" ); - if (version >= 450) + if (version >= 430) stageBuiltins[EShLangGeometry].append( "out int gl_ViewportMask[];" // GL_NV_viewport_array2 + ); + + if (version >= 450) + stageBuiltins[EShLangGeometry].append( "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes @@ -5388,7 +5396,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV if (version >= 450) stageBuiltins[EShLangTessControl].append( "float gl_CullDistance[];" + ); + if (version >= 430) + stageBuiltins[EShLangTessControl].append( "int gl_ViewportMask[];" // GL_NV_viewport_array2 + ); + if (version >= 450) + stageBuiltins[EShLangTessControl].append( "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes @@ -5491,9 +5505,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "out int gl_Layer;" "\n"); - if (version >= 450) + if (version >= 430) stageBuiltins[EShLangTessEvaluation].append( "out int gl_ViewportMask[];" // GL_NV_viewport_array2 + ); + + if (version >= 450) + stageBuiltins[EShLangTessEvaluation].append( "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes