diff --git a/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out b/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out index b6aa88e3da..e4398610d3 100644 --- a/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out +++ b/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out @@ -1,5 +1,5 @@ spv.ext.texture_shadow_lod.error.frag -ERROR: 0:11: 'textureLod' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:11: 'textureLod(..., float lod)' : required extension not requested: GL_EXT_texture_shadow_lod ERROR: 1 compilation errors. No code generated. diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 25d87370bc..6d6c5f3fd3 100755 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -52,9 +52,6 @@ // #include "Initialize.h" -#include "../Include/intermediate.h" -#include "ScanContext.h" -#include "preprocessor/PpContext.h" namespace glslang { @@ -324,32 +321,6 @@ const CustomFunction CustomFunctions[] = { { EOpNull } }; -// Creates a parser that is separate from the main parsing context and meant for temporary use -struct TempParser { - TempParser(const TString& str, EShLanguage language, int version, EProfile profile, SpvVersion spvVersion) - : interm(language), parseContext(table, interm, false, version, profile, spvVersion, language, sink, true, - EShMsgDefault, &dummyEntryPoint), - inputStr(str.data()), stringSize(str.size()) - { - table.push(); - parseContext.setScanContext(&scanContext); - parseContext.setPpContext(&context); - parseContext.parseShaderStrings(context, input, false); - } - - TSymbolTable table; - TIntermediate interm; - TInfoSink sink; - TString dummyEntryPoint; - TParseContext parseContext; - TShader::ForbidIncluder includer; - TPpContext context{parseContext, "", includer}; - TScanContext scanContext{parseContext}; - const char* inputStr; - size_t stringSize; - TInputScanner input{1, &inputStr, &stringSize}; -}; - // For the given table of functions, add all the indicated prototypes for each // one, to be returned in the passed in decls. void AddTabledBuiltin(TString& decls, const BuiltInFunction& function) @@ -4851,29 +4822,28 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV // GL_EXT_texture_shadow_lod overloads if (profile == EEsProfile) { // ES if (version >= 300) { - textureShadowLodFunctions += "float texture(sampler2DArrayShadow, vec4, float);" - "float textureOffset(sampler2DArrayShadow, vec4, ivec2, float);" - "float textureLod(sampler2DArrayShadow, vec4, float);" - "float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);" - "\n"; + commonBuiltins.append("float texture(sampler2DArrayShadow, vec4, float);" + "float textureOffset(sampler2DArrayShadow, vec4, ivec2, float);" + "float textureLod(sampler2DArrayShadow, vec4, float);" + "float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);" + "\n"); } if (version >= 320) { - textureShadowLodFunctions += "float texture(samplerCubeArrayShadow, vec4, float, float);" - "float textureLod(samplerCubeShadow, vec4, float);" - "float textureLod(samplerCubeArrayShadow, vec4, float, float);" - "\n"; + commonBuiltins.append("float texture(samplerCubeArrayShadow, vec4, float, float);" + "float textureLod(samplerCubeShadow, vec4, float);" + "float textureLod(samplerCubeArrayShadow, vec4, float, float);" + "\n"); } } else if (version >= 130) { // Desktop - textureShadowLodFunctions += "float texture(sampler2DArrayShadow, vec4, float);" - "float texture(samplerCubeArrayShadow, vec4, float, float);" - "float textureOffset(sampler2DArrayShadow, vec4, ivec2, float);" - "float textureLod(sampler2DArrayShadow, vec4, float);" - "float textureLod(samplerCubeShadow, vec4, float);" - "float textureLod(samplerCubeArrayShadow, vec4, float, float);" - "float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);" - "\n"; + commonBuiltins.append("float texture(sampler2DArrayShadow, vec4, float);" + "float texture(samplerCubeArrayShadow, vec4, float, float);" + "float textureOffset(sampler2DArrayShadow, vec4, ivec2, float);" + "float textureLod(sampler2DArrayShadow, vec4, float);" + "float textureLod(samplerCubeShadow, vec4, float);" + "float textureLod(samplerCubeArrayShadow, vec4, float, float);" + "float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);" + "\n"); } - commonBuiltins.append(textureShadowLodFunctions); //============================================================================ // @@ -8796,13 +8766,6 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion symbolTable.setFunctionExtensions("textureBlockMatchSADQCOM", 1, &E_GL_QCOM_image_processing); symbolTable.setFunctionExtensions("textureBlockMatchSSDQCOM", 1, &E_GL_QCOM_image_processing); } - - { - TempParser parser(textureShadowLodFunctions, language, version, profile, spvVersion); - parser.table.processAllSymbols([&symbolTable](TSymbol* sym) { - symbolTable.setSingleFunctionExtensions(sym->getMangledName().data(), 1, &E_GL_EXT_texture_shadow_lod); - }); - } break; case EShLangCompute: diff --git a/glslang/MachineIndependent/Initialize.h b/glslang/MachineIndependent/Initialize.h index b5652d37b3..42c32ddbb7 100644 --- a/glslang/MachineIndependent/Initialize.h +++ b/glslang/MachineIndependent/Initialize.h @@ -105,11 +105,6 @@ class TBuiltIns : public TBuiltInParseables { const char* postfixes[5]; const char* prefixes[EbtNumTypes]; int dimMap[EsdNumDims]; - -private: - // Holds the function declarations for GL_EXT_texture_shadow_lod - // This extension is somewhat unique in the sense it defines overloads for built-in functions, rather than new functions. - TString textureShadowLodFunctions; }; // change this back to false if depending on textual spellings of texturing calls when consuming the AST diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index f81440dcd9..a57b643d47 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -2172,6 +2172,43 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan } break; } + + case EOpTexture: + case EOpTextureLod: + { + if ((fnCandidate.getParamCount() > 2) && + ((*argp)[1]->getAsTyped()->getType().getBasicType() == EbtFloat) && + ((*argp)[1]->getAsTyped()->getType().getVectorSize() == 4) && + fnCandidate[0].type->getSampler().shadow && + !isEsProfile() && version >= 400) { + + featureString = fnCandidate.getName(); + if (callNode.getOp() == EOpTexture) + featureString += "(..., float bias)"; + else + featureString += "(..., float lod)"; + feature = featureString.c_str(); + + //2D Array Shadow + if (fnCandidate[0].type->getSampler().dim == Esd2D && fnCandidate[0].type->getSampler().arrayed) + { + profileRequires(loc, ~EEsProfile, 400, nullptr, feature); + requireExtensions(loc, 1, &E_GL_EXT_texture_shadow_lod, feature); + } else if(fnCandidate[0].type->getSampler().dim == EsdCube && fnCandidate[0].type->getSampler().arrayed) { + // Cube Array Shadow + if (fnCandidate.getParamCount() > 3 ) { + profileRequires(loc, ~EEsProfile, 400, nullptr, feature); + requireExtensions(loc, 1, &E_GL_EXT_texture_shadow_lod, feature); + } + } else if (fnCandidate[0].type->getSampler().dim == EsdCube && callNode.getOp() == EOpTextureLod) { + // Cube Array + profileRequires(loc, ~EEsProfile, 400, nullptr, feature); + requireExtensions(loc, 1, &E_GL_EXT_texture_shadow_lod, feature); + } + } + break; + } + case EOpSparseTextureGather: case EOpSparseTextureGatherOffset: case EOpSparseTextureGatherOffsets: @@ -2292,6 +2329,19 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "version <= 420"); } } + if (callNode.getOp() == EOpTextureLodOffset || + callNode.getOp() == EOpTextureOffset) { + TSampler s = arg0->getType().getSampler(); + if (s.is2D() && s.isArrayed() && s.isShadow() && + ((*argp)[1]->getAsTyped()->getType().getBasicType() == EbtFloat) && + ((*argp)[1]->getAsTyped()->getType().getVectorSize() == 4) && + (fnCandidate.getParamCount() == 4)) { + featureString = fnCandidate.getName() + " for sampler2DArrayShadow"; + feature = featureString.c_str(); + profileRequires(loc, ~EEsProfile, 400, nullptr, feature); + requireExtensions(loc, 1, &E_GL_EXT_texture_shadow_lod, feature); + } + } } break; diff --git a/glslang/MachineIndependent/SymbolTable.h b/glslang/MachineIndependent/SymbolTable.h index 9c453c8268..94c3929da2 100644 --- a/glslang/MachineIndependent/SymbolTable.h +++ b/glslang/MachineIndependent/SymbolTable.h @@ -492,12 +492,6 @@ class TSymbolTableLevel { return (*it).second; } - template void processAllSymbols(ProcSymFn procSym) const - { - for (auto itr : level) - procSym(itr.second); - } - void findFunctionNameList(const TString& name, TVector& list) { size_t parenAt = name.find_first_of('('); @@ -807,15 +801,6 @@ class TSymbolTable { return symbol; } - template void processAllSymbols(ProcSymFn procSym) - { - int level = currentLevel(); - do { - table[level]->processAllSymbols(procSym); - --level; - } while (level >= 0); - } - void retargetSymbol(const TString& from, const TString& to) { int level = currentLevel(); table[level]->retargetSymbol(from, to);