From 7bf5fcc541859438703fca4141e6952603ce875e Mon Sep 17 00:00:00 2001 From: Rex Xu Date: Mon, 12 Nov 2018 15:15:57 +0800 Subject: [PATCH] Fix parser issue: redeclare gl_FragStencilRefARB is not supported --- Test/spv.shaderStencilExport.frag | 2 ++ glslang/MachineIndependent/ParseHelper.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Test/spv.shaderStencilExport.frag b/Test/spv.shaderStencilExport.frag index 62e0f573a..e3ad4d67f 100644 --- a/Test/spv.shaderStencilExport.frag +++ b/Test/spv.shaderStencilExport.frag @@ -2,6 +2,8 @@ #extension GL_ARB_shader_stencil_export: enable +out int gl_FragStencilRefARB; + void main() { gl_FragStencilRefARB = 100; diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index fba75dda2..56b45cabc 100755 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -3872,6 +3872,8 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS identifier == "gl_BackSecondaryColor" || identifier == "gl_SecondaryColor" || (identifier == "gl_Color" && language == EShLangFragment) || + (identifier == "gl_FragStencilRefARB" && (nonEsRedecls && version >= 140) + && language == EShLangFragment) || #ifdef NV_EXTENSIONS identifier == "gl_SampleMask" || identifier == "gl_Layer" || @@ -3954,6 +3956,12 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS error(loc, "all redeclarations must use the same depth layout on", "redeclaration", symbol->getName().c_str()); } } + else if (identifier == "gl_FragStencilRefARB") { + if (qualifier.hasLayout()) + error(loc, "cannot apply layout qualifier to", "redeclaration", symbol->getName().c_str()); + if (qualifier.storage != EvqVaryingOut) + error(loc, "cannot change output storage qualification of", "redeclaration", symbol->getName().c_str()); + } #ifdef NV_EXTENSIONS else if (identifier == "gl_SampleMask") { if (!publicType.layoutOverrideCoverage) {