GLSL: Make gl_Layer and gl_ViewportIndex always be outside blocks.

There was some ambiguity/contradiction in this behavior, and
Khronos decided glslang should always have these outside blocks,
rather than have stage/vendor/target variations.
This commit is contained in:
John Kessenich
2017-09-13 13:22:50 -06:00
parent aab3bcffea
commit ba6a3c290e
7 changed files with 104 additions and 115 deletions

View File

@@ -453,15 +453,13 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
return spv::BuiltInCullDistance;
case glslang::EbvViewportIndex:
if (!memberDeclaration) {
builder.addCapability(spv::CapabilityMultiViewport);
if (glslangIntermediate->getStage() == EShLangVertex ||
glslangIntermediate->getStage() == EShLangTessControl ||
glslangIntermediate->getStage() == EShLangTessEvaluation) {
builder.addCapability(spv::CapabilityMultiViewport);
if (glslangIntermediate->getStage() == EShLangVertex ||
glslangIntermediate->getStage() == EShLangTessControl ||
glslangIntermediate->getStage() == EShLangTessEvaluation) {
builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer);
builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT);
}
builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer);
builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT);
}
return spv::BuiltInViewportIndex;
@@ -478,17 +476,14 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
return spv::BuiltInSampleMask;
case glslang::EbvLayer:
if (!memberDeclaration) {
builder.addCapability(spv::CapabilityGeometry);
if (glslangIntermediate->getStage() == EShLangVertex ||
glslangIntermediate->getStage() == EShLangTessControl ||
glslangIntermediate->getStage() == EShLangTessEvaluation) {
builder.addCapability(spv::CapabilityGeometry);
if (glslangIntermediate->getStage() == EShLangVertex ||
glslangIntermediate->getStage() == EShLangTessControl ||
glslangIntermediate->getStage() == EShLangTessEvaluation) {
builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer);
builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT);
}
builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer);
builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT);
}
return spv::BuiltInLayer;
case glslang::EbvPosition: return spv::BuiltInPosition;
@@ -2485,10 +2480,6 @@ bool TGlslangToSpvTraverser::filterMember(const glslang::TType& member)
if (member.getFieldName() == "gl_ViewportMaskPerViewNV" &&
extensions.find("GL_NVX_multiview_per_view_attributes") == extensions.end())
return true;
if ((member.getFieldName() == "gl_ViewportIndex" || member.getFieldName() == "gl_Layer") &&
extensions.find(glslang::E_GL_ARB_shader_viewport_layer_array) == extensions.end() &&
extensions.find("GL_NV_viewport_array2") == extensions.end())
return true;
return false;
};
@@ -2936,8 +2927,6 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList&
case glslang::EbvCullDistance:
case glslang::EbvPointSize:
#ifdef NV_EXTENSIONS
case glslang::EbvLayer:
case glslang::EbvViewportIndex:
case glslang::EbvViewportMaskNV:
case glslang::EbvSecondaryPositionNV:
case glslang::EbvSecondaryViewportMaskNV: