diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 276899c4..9f272ee5 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -480,16 +480,18 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI return spv::BuiltInCullDistance; case glslang::EbvViewportIndex: - builder.addCapability(spv::CapabilityMultiViewport); + if (!memberDeclaration) { + builder.addCapability(spv::CapabilityMultiViewport); #ifdef NV_EXTENSIONS - if (glslangIntermediate->getStage() == EShLangVertex || - glslangIntermediate->getStage() == EShLangTessControl || - glslangIntermediate->getStage() == EShLangTessEvaluation) - { - builder.addExtension(spv::E_SPV_NV_viewport_array2); - builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV); - } + if (glslangIntermediate->getStage() == EShLangVertex || + glslangIntermediate->getStage() == EShLangTessControl || + glslangIntermediate->getStage() == EShLangTessEvaluation) { + + builder.addExtension(spv::E_SPV_NV_viewport_array2); + builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV); + } #endif + } return spv::BuiltInViewportIndex; case glslang::EbvSampleId: @@ -505,19 +507,19 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI return spv::BuiltInSampleMask; case glslang::EbvLayer: - builder.addCapability(spv::CapabilityGeometry); + if (!memberDeclaration) { + builder.addCapability(spv::CapabilityGeometry); #ifdef NV_EXTENSIONS - if (!memberDeclaration) - { if (glslangIntermediate->getStage() == EShLangVertex || glslangIntermediate->getStage() == EShLangTessControl || - glslangIntermediate->getStage() == EShLangTessEvaluation) - { + glslangIntermediate->getStage() == EShLangTessEvaluation) { + builder.addExtension(spv::E_SPV_NV_viewport_array2); builder.addCapability(spv::CapabilityShaderViewportIndexLayerNV); } - } #endif + } + return spv::BuiltInLayer; case glslang::EbvPosition: return spv::BuiltInPosition; @@ -640,8 +642,10 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI #ifdef NV_EXTENSIONS case glslang::EbvViewportMaskNV: - builder.addExtension(spv::E_SPV_NV_viewport_array2); - builder.addCapability(spv::CapabilityShaderViewportMaskNV); + if (!memberDeclaration) { + builder.addExtension(spv::E_SPV_NV_viewport_array2); + builder.addCapability(spv::CapabilityShaderViewportMaskNV); + } return spv::BuiltInViewportMaskNV; case glslang::EbvSecondaryPositionNV: if (!memberDeclaration) { @@ -2690,6 +2694,7 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList& case glslang::EbvPointSize: #ifdef NV_EXTENSIONS case glslang::EbvLayer: + case glslang::EbvViewportIndex: case glslang::EbvViewportMaskNV: case glslang::EbvSecondaryPositionNV: case glslang::EbvSecondaryViewportMaskNV: diff --git a/Test/baseResults/spv.stereoViewRendering.tesc.out b/Test/baseResults/spv.stereoViewRendering.tesc.out index 5d5a3d0b..9048cc72 100644 --- a/Test/baseResults/spv.stereoViewRendering.tesc.out +++ b/Test/baseResults/spv.stereoViewRendering.tesc.out @@ -5,7 +5,6 @@ Warning, version 450 is not yet complete; most version-specific features are pre // Generated by (magic number): 80001 // Id's are bound by 39 - Capability Geometry Capability Tessellation Capability ShaderViewportMaskNV Capability ShaderStereoViewNV diff --git a/Test/baseResults/spv.viewportArray2.tesc.out b/Test/baseResults/spv.viewportArray2.tesc.out index 6d73fc39..fdfa2b88 100644 --- a/Test/baseResults/spv.viewportArray2.tesc.out +++ b/Test/baseResults/spv.viewportArray2.tesc.out @@ -5,7 +5,6 @@ Warning, version 450 is not yet complete; most version-specific features are pre // Generated by (magic number): 80001 // Id's are bound by 25 - Capability Geometry Capability Tessellation Capability MultiViewport Capability ShaderViewportIndexLayerNV