diff --git a/Test/100.frag b/Test/100.frag index e07f75bc..57c5c88e 100644 --- a/Test/100.frag +++ b/Test/100.frag @@ -100,4 +100,14 @@ void foo236() dFdx(v[0]); dFdy(3.2); fwidth(f13); + gl_FragDepth = f13; // ERROR + gl_FragDepthEXT = f13; // ERROR } + +#extension GL_EXT_frag_depth : enable + +void foo239() +{ + gl_FragDepth = f13; // ERROR + gl_FragDepthEXT = f13; +} \ No newline at end of file diff --git a/Test/baseResults/100.frag.out b/Test/baseResults/100.frag.out index ae6b0143..db43e6a7 100644 --- a/Test/baseResults/100.frag.out +++ b/Test/baseResults/100.frag.out @@ -45,7 +45,10 @@ ERROR: 0:80: 'sampler/image' : type requires declaration of default precision qu ERROR: 0:91: 'dFdx' : required extension not requested: GL_OES_standard_derivatives ERROR: 0:92: 'dFdy' : required extension not requested: GL_OES_standard_derivatives ERROR: 0:93: 'fwidth' : required extension not requested: GL_OES_standard_derivatives -ERROR: 40 compilation errors. No code generated. +ERROR: 0:103: 'gl_FragDepth' : undeclared identifier +ERROR: 0:104: 'gl_FragDepthEXT' : required extension not requested: GL_EXT_frag_depth +ERROR: 0:111: 'gl_FragDepth' : undeclared identifier +ERROR: 43 compilation errors. No code generated. ERROR: node is still EOpNull! 0:3 Sequence @@ -166,6 +169,21 @@ ERROR: node is still EOpNull! 0:101 0.000000 0:102 fwidth (mediump float) 0:102 'f13' (invariant mediump float) +0:103 move second child to first child (mediump float) +0:103 'gl_FragDepth' (mediump float) +0:103 'f13' (invariant mediump float) +0:104 move second child to first child (highp float) +0:104 'gl_FragDepthEXT' (gl_FragDepth highp float) +0:104 'f13' (invariant mediump float) +0:109 Function Definition: foo239( (void) +0:109 Function Parameters: +0:111 Sequence +0:111 move second child to first child (mediump float) +0:111 'gl_FragDepth' (mediump float) +0:111 'f13' (invariant mediump float) +0:112 move second child to first child (highp float) +0:112 'gl_FragDepthEXT' (gl_FragDepth highp float) +0:112 'f13' (invariant mediump float) 0:? Linker Objects 0:? 'a' (3-element array of mediump int) 0:? 'uint' (mediump int) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 83eb4ccf..6c600b2c 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -1425,6 +1425,9 @@ void TBuiltIns::initialize(int version, EProfile profile) "mediump vec2 gl_PointCoord;" // needs qualifier fixed later "highp float gl_FragDepth;" // needs qualifier fixed later ); + stageBuiltins[EShLangFragment].append( + "highp float gl_FragDepthEXT;" // GL_EXT_frag_depth + ); } stageBuiltins[EShLangFragment].append("\n"); @@ -2138,16 +2141,18 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb break; case EShLangFragment: - SpecialQualifier("gl_FrontFacing", EvqFace, symbolTable); - SpecialQualifier("gl_FragCoord", EvqFragCoord, symbolTable); - SpecialQualifier("gl_PointCoord", EvqPointCoord, symbolTable); - SpecialQualifier("gl_FragColor", EvqFragColor, symbolTable); - SpecialQualifier("gl_FragDepth", EvqFragDepth, symbolTable); + SpecialQualifier("gl_FrontFacing", EvqFace, symbolTable); + SpecialQualifier("gl_FragCoord", EvqFragCoord, symbolTable); + SpecialQualifier("gl_PointCoord", EvqPointCoord, symbolTable); + SpecialQualifier("gl_FragColor", EvqFragColor, symbolTable); + SpecialQualifier("gl_FragDepth", EvqFragDepth, symbolTable); + SpecialQualifier("gl_FragDepthEXT", EvqFragDepth, symbolTable); if (version == 100) { symbolTable.setFunctionExtensions("dFdx", 1, &GL_OES_standard_derivatives); symbolTable.setFunctionExtensions("dFdy", 1, &GL_OES_standard_derivatives); symbolTable.setFunctionExtensions("fwidth", 1, &GL_OES_standard_derivatives); } + symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &GL_EXT_frag_depth); break; case EShLangCompute: diff --git a/glslang/MachineIndependent/SymbolTable.h b/glslang/MachineIndependent/SymbolTable.h index d36a5968..0206ef9c 100644 --- a/glslang/MachineIndependent/SymbolTable.h +++ b/glslang/MachineIndependent/SymbolTable.h @@ -574,6 +574,13 @@ public: table[level]->setFunctionExtensions(name, num, extensions); } + void setVariableExtensions(const char* name, int num, const char* const extensions[]) + { + TSymbol* symbol = find(TString(name)); + if (symbol) + symbol->setExtensions(num, extensions); + } + int getMaxSymbolId() { return uniqueId; } void dump(TInfoSink &infoSink) const; void copyTable(const TSymbolTable& copyOf); diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 03b239e1..4574c4e9 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -151,6 +151,7 @@ void TParseContext::initializeExtensionBehavior() { extensionBehavior[GL_OES_texture_3D] = EBhDisable; extensionBehavior[GL_OES_standard_derivatives] = EBhDisable; + extensionBehavior[GL_EXT_frag_depth] = EBhDisable; extensionBehavior[GL_ARB_texture_rectangle] = EBhDisable; extensionBehavior[GL_3DL_array_objects] = EBhDisable; @@ -167,7 +168,8 @@ const char* TParseContext::getPreamble() return "#define GL_ES 1\n" "#define GL_OES_texture_3D 1\n" - "#define GL_OES_standard_derivatives 1\n"; + "#define GL_OES_standard_derivatives 1\n" + "#define GL_EXT_frag_depth 1\n"; } else { return "#define GL_FRAGMENT_PRECISION_HIGH 1\n" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index 393dbe4f..8e2ffcc0 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -74,6 +74,7 @@ typedef enum { // const char* const GL_OES_texture_3D = "GL_OES_texture_3D"; const char* const GL_OES_standard_derivatives = "GL_OES_standard_derivatives"; +const char* const GL_EXT_frag_depth = "GL_EXT_frag_depth"; const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle"; const char* const GL_3DL_array_objects = "GL_3DL_array_objects";