From 855417d6fe815c840e9a35df83671d0720251c8e Mon Sep 17 00:00:00 2001 From: Pankaj Mistry Date: Thu, 28 Sep 2023 07:53:05 -0700 Subject: [PATCH] Cleaning the implementation of GL_EXT_texture_shadow_lod. Moving the parameter verifictation to a centralized place where all ther builtins are verified for correctness. Added verification for the new builtins with version and extension check These builtins are supported on GLSL since version 130 and GLES since version 300 --- .../glsl.es320.extTextureShadowLod.frag.out | 149 ++++++++++++++++ .../glsl.ext.textureShadowLod.frag.out | 160 ++++++++++++++++++ .../spv.ext.textureShadowLod.error.frag.out | 6 + ....out => spv.ext.textureShadowLod.frag.out} | 2 +- .../spv.ext.texture_shadow_lod.error.frag.out | 6 - Test/glsl.es320.extTextureShadowLod.frag | 22 +++ Test/glsl.ext.textureShadowLod.frag | 32 ++++ ...ag => spv.ext.textureShadowLod.error.frag} | 0 ...lod.frag => spv.ext.textureShadowLod.frag} | 0 glslang/MachineIndependent/Initialize.cpp | 75 ++------ glslang/MachineIndependent/Initialize.h | 5 - glslang/MachineIndependent/ParseHelper.cpp | 57 ++++++- glslang/MachineIndependent/SymbolTable.h | 15 -- gtests/AST.FromFile.cpp | 2 + gtests/Spv.FromFile.cpp | 4 +- 15 files changed, 443 insertions(+), 92 deletions(-) create mode 100644 Test/baseResults/glsl.es320.extTextureShadowLod.frag.out create mode 100644 Test/baseResults/glsl.ext.textureShadowLod.frag.out create mode 100644 Test/baseResults/spv.ext.textureShadowLod.error.frag.out rename Test/baseResults/{spv.ext.texture_shadow_lod.frag.out => spv.ext.textureShadowLod.frag.out} (99%) delete mode 100644 Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out create mode 100644 Test/glsl.es320.extTextureShadowLod.frag create mode 100644 Test/glsl.ext.textureShadowLod.frag rename Test/{spv.ext.texture_shadow_lod.error.frag => spv.ext.textureShadowLod.error.frag} (100%) rename Test/{spv.ext.texture_shadow_lod.frag => spv.ext.textureShadowLod.frag} (100%) diff --git a/Test/baseResults/glsl.es320.extTextureShadowLod.frag.out b/Test/baseResults/glsl.es320.extTextureShadowLod.frag.out new file mode 100644 index 0000000000..ae385ae196 --- /dev/null +++ b/Test/baseResults/glsl.es320.extTextureShadowLod.frag.out @@ -0,0 +1,149 @@ +glsl.es320.extTextureShadowLod.frag +Shader version: 320 +Requested GL_EXT_texture_shadow_lod +0:? Sequence +0:12 Function Definition: main( ( global void) +0:12 Function Parameters: +0:14 Sequence +0:14 move second child to first child ( temp lowp float) +0:14 'c' ( out lowp float) +0:14 texture ( global lowp float) +0:14 's2da' ( uniform lowp sampler2DArrayShadow) +0:14 'tc' ( smooth in lowp 4-component vector of float) +0:14 Constant: +0:14 0.000000 +0:15 move second child to first child ( temp lowp float) +0:15 'c' ( out lowp float) +0:15 texture ( global lowp float) +0:15 'sca' ( uniform lowp samplerCubeArrayShadow) +0:15 'tc' ( smooth in lowp 4-component vector of float) +0:15 Constant: +0:15 0.000000 +0:15 Constant: +0:15 0.000000 +0:16 move second child to first child ( temp lowp float) +0:16 'c' ( out lowp float) +0:16 textureOffset ( global lowp float) +0:16 's2da' ( uniform lowp sampler2DArrayShadow) +0:16 'tc' ( smooth in lowp 4-component vector of float) +0:16 Constant: +0:16 0 (const int) +0:16 0 (const int) +0:16 Constant: +0:16 0.000000 +0:17 move second child to first child ( temp lowp float) +0:17 'c' ( out lowp float) +0:17 textureLod ( global lowp float) +0:17 's2da' ( uniform lowp sampler2DArrayShadow) +0:17 'tc' ( smooth in lowp 4-component vector of float) +0:17 Constant: +0:17 0.000000 +0:18 move second child to first child ( temp lowp float) +0:18 'c' ( out lowp float) +0:18 textureLod ( global lowp float) +0:18 'sc' ( uniform lowp samplerCubeShadow) +0:18 'tc' ( smooth in lowp 4-component vector of float) +0:18 Constant: +0:18 0.000000 +0:19 move second child to first child ( temp lowp float) +0:19 'c' ( out lowp float) +0:19 textureLod ( global lowp float) +0:19 'sca' ( uniform lowp samplerCubeArrayShadow) +0:19 'tc' ( smooth in lowp 4-component vector of float) +0:19 Constant: +0:19 0.000000 +0:19 Constant: +0:19 0.000000 +0:20 move second child to first child ( temp lowp float) +0:20 'c' ( out lowp float) +0:20 textureLodOffset ( global lowp float) +0:20 's2da' ( uniform lowp sampler2DArrayShadow) +0:20 'tc' ( smooth in lowp 4-component vector of float) +0:20 Constant: +0:20 0.000000 +0:20 Constant: +0:20 0 (const int) +0:20 0 (const int) +0:? Linker Objects +0:? 's2da' ( uniform lowp sampler2DArrayShadow) +0:? 'sca' ( uniform lowp samplerCubeArrayShadow) +0:? 'sc' ( uniform lowp samplerCubeShadow) +0:? 'tc' ( smooth in lowp 4-component vector of float) +0:? 'c' ( out lowp float) + + +Linked fragment stage: + + +Shader version: 320 +Requested GL_EXT_texture_shadow_lod +0:? Sequence +0:12 Function Definition: main( ( global void) +0:12 Function Parameters: +0:14 Sequence +0:14 move second child to first child ( temp lowp float) +0:14 'c' ( out lowp float) +0:14 texture ( global lowp float) +0:14 's2da' ( uniform lowp sampler2DArrayShadow) +0:14 'tc' ( smooth in lowp 4-component vector of float) +0:14 Constant: +0:14 0.000000 +0:15 move second child to first child ( temp lowp float) +0:15 'c' ( out lowp float) +0:15 texture ( global lowp float) +0:15 'sca' ( uniform lowp samplerCubeArrayShadow) +0:15 'tc' ( smooth in lowp 4-component vector of float) +0:15 Constant: +0:15 0.000000 +0:15 Constant: +0:15 0.000000 +0:16 move second child to first child ( temp lowp float) +0:16 'c' ( out lowp float) +0:16 textureOffset ( global lowp float) +0:16 's2da' ( uniform lowp sampler2DArrayShadow) +0:16 'tc' ( smooth in lowp 4-component vector of float) +0:16 Constant: +0:16 0 (const int) +0:16 0 (const int) +0:16 Constant: +0:16 0.000000 +0:17 move second child to first child ( temp lowp float) +0:17 'c' ( out lowp float) +0:17 textureLod ( global lowp float) +0:17 's2da' ( uniform lowp sampler2DArrayShadow) +0:17 'tc' ( smooth in lowp 4-component vector of float) +0:17 Constant: +0:17 0.000000 +0:18 move second child to first child ( temp lowp float) +0:18 'c' ( out lowp float) +0:18 textureLod ( global lowp float) +0:18 'sc' ( uniform lowp samplerCubeShadow) +0:18 'tc' ( smooth in lowp 4-component vector of float) +0:18 Constant: +0:18 0.000000 +0:19 move second child to first child ( temp lowp float) +0:19 'c' ( out lowp float) +0:19 textureLod ( global lowp float) +0:19 'sca' ( uniform lowp samplerCubeArrayShadow) +0:19 'tc' ( smooth in lowp 4-component vector of float) +0:19 Constant: +0:19 0.000000 +0:19 Constant: +0:19 0.000000 +0:20 move second child to first child ( temp lowp float) +0:20 'c' ( out lowp float) +0:20 textureLodOffset ( global lowp float) +0:20 's2da' ( uniform lowp sampler2DArrayShadow) +0:20 'tc' ( smooth in lowp 4-component vector of float) +0:20 Constant: +0:20 0.000000 +0:20 Constant: +0:20 0 (const int) +0:20 0 (const int) +0:? Linker Objects +0:? 's2da' ( uniform lowp sampler2DArrayShadow) +0:? 'sca' ( uniform lowp samplerCubeArrayShadow) +0:? 'sc' ( uniform lowp samplerCubeShadow) +0:? 'tc' ( smooth in lowp 4-component vector of float) +0:? 'c' ( out lowp float) + diff --git a/Test/baseResults/glsl.ext.textureShadowLod.frag.out b/Test/baseResults/glsl.ext.textureShadowLod.frag.out new file mode 100644 index 0000000000..b84183f897 --- /dev/null +++ b/Test/baseResults/glsl.ext.textureShadowLod.frag.out @@ -0,0 +1,160 @@ +glsl.ext.textureShadowLod.frag +ERROR: 0:24: 'texture(..., float bias)' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:25: 'texture(..., float bias)' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:26: 'textureOffset for sampler2DArrayShadow' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:27: 'textureLod(..., float lod)' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:28: 'textureLod(..., float lod)' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:29: 'textureLod(..., float lod)' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 0:30: 'textureLodOffset for sampler2DArrayShadow' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 7 compilation errors. No code generated. + + +Shader version: 450 +Requested GL_EXT_texture_shadow_lod +ERROR: node is still EOpNull! +0:11 Function Definition: pass( ( global void) +0:11 Function Parameters: +0:12 Sequence +0:12 move second child to first child ( temp float) +0:12 'c' ( out float) +0:12 texture ( global float) +0:12 's2da' ( uniform sampler2DArrayShadow) +0:12 'tc' ( smooth in 4-component vector of float) +0:12 Constant: +0:12 0.000000 +0:13 move second child to first child ( temp float) +0:13 'c' ( out float) +0:13 texture ( global float) +0:13 'sca' ( uniform samplerCubeArrayShadow) +0:13 'tc' ( smooth in 4-component vector of float) +0:13 Constant: +0:13 0.000000 +0:13 Constant: +0:13 0.000000 +0:14 move second child to first child ( temp float) +0:14 'c' ( out float) +0:14 textureOffset ( global float) +0:14 's2da' ( uniform sampler2DArrayShadow) +0:14 'tc' ( smooth in 4-component vector of float) +0:14 Constant: +0:14 0 (const int) +0:14 0 (const int) +0:14 Constant: +0:14 0.000000 +0:15 move second child to first child ( temp float) +0:15 'c' ( out float) +0:15 textureLod ( global float) +0:15 's2da' ( uniform sampler2DArrayShadow) +0:15 'tc' ( smooth in 4-component vector of float) +0:15 Constant: +0:15 0.000000 +0:16 move second child to first child ( temp float) +0:16 'c' ( out float) +0:16 textureLod ( global float) +0:16 'sc' ( uniform samplerCubeShadow) +0:16 'tc' ( smooth in 4-component vector of float) +0:16 Constant: +0:16 0.000000 +0:17 move second child to first child ( temp float) +0:17 'c' ( out float) +0:17 textureLod ( global float) +0:17 'sca' ( uniform samplerCubeArrayShadow) +0:17 'tc' ( smooth in 4-component vector of float) +0:17 Constant: +0:17 0.000000 +0:17 Constant: +0:17 0.000000 +0:18 move second child to first child ( temp float) +0:18 'c' ( out float) +0:18 textureLodOffset ( global float) +0:18 's2da' ( uniform sampler2DArrayShadow) +0:18 'tc' ( smooth in 4-component vector of float) +0:18 Constant: +0:18 0.000000 +0:18 Constant: +0:18 0 (const int) +0:18 0 (const int) +0:22 Function Definition: fail( ( global void) +0:22 Function Parameters: +0:24 Sequence +0:24 move second child to first child ( temp float) +0:24 'c' ( out float) +0:24 texture ( global float) +0:24 's2da' ( uniform sampler2DArrayShadow) +0:24 'tc' ( smooth in 4-component vector of float) +0:24 Constant: +0:24 0.000000 +0:25 move second child to first child ( temp float) +0:25 'c' ( out float) +0:25 texture ( global float) +0:25 'sca' ( uniform samplerCubeArrayShadow) +0:25 'tc' ( smooth in 4-component vector of float) +0:25 Constant: +0:25 0.000000 +0:25 Constant: +0:25 0.000000 +0:26 move second child to first child ( temp float) +0:26 'c' ( out float) +0:26 textureOffset ( global float) +0:26 's2da' ( uniform sampler2DArrayShadow) +0:26 'tc' ( smooth in 4-component vector of float) +0:26 Constant: +0:26 0 (const int) +0:26 0 (const int) +0:26 Constant: +0:26 0.000000 +0:27 move second child to first child ( temp float) +0:27 'c' ( out float) +0:27 textureLod ( global float) +0:27 's2da' ( uniform sampler2DArrayShadow) +0:27 'tc' ( smooth in 4-component vector of float) +0:27 Constant: +0:27 0.000000 +0:28 move second child to first child ( temp float) +0:28 'c' ( out float) +0:28 textureLod ( global float) +0:28 'sc' ( uniform samplerCubeShadow) +0:28 'tc' ( smooth in 4-component vector of float) +0:28 Constant: +0:28 0.000000 +0:29 move second child to first child ( temp float) +0:29 'c' ( out float) +0:29 textureLod ( global float) +0:29 'sca' ( uniform samplerCubeArrayShadow) +0:29 'tc' ( smooth in 4-component vector of float) +0:29 Constant: +0:29 0.000000 +0:29 Constant: +0:29 0.000000 +0:30 move second child to first child ( temp float) +0:30 'c' ( out float) +0:30 textureLodOffset ( global float) +0:30 's2da' ( uniform sampler2DArrayShadow) +0:30 'tc' ( smooth in 4-component vector of float) +0:30 Constant: +0:30 0.000000 +0:30 Constant: +0:30 0 (const int) +0:30 0 (const int) +0:? Linker Objects +0:? 's2da' ( uniform sampler2DArrayShadow) +0:? 'sca' ( uniform samplerCubeArrayShadow) +0:? 'sc' ( uniform samplerCubeShadow) +0:? 'c' ( out float) +0:? 'tc' ( smooth in 4-component vector of float) + + +Linked fragment stage: + +ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point + +Shader version: 450 +Requested GL_EXT_texture_shadow_lod +ERROR: node is still EOpNull! +0:? Linker Objects +0:? 's2da' ( uniform sampler2DArrayShadow) +0:? 'sca' ( uniform samplerCubeArrayShadow) +0:? 'sc' ( uniform samplerCubeShadow) +0:? 'c' ( out float) +0:? 'tc' ( smooth in 4-component vector of float) + diff --git a/Test/baseResults/spv.ext.textureShadowLod.error.frag.out b/Test/baseResults/spv.ext.textureShadowLod.error.frag.out new file mode 100644 index 0000000000..18adb05962 --- /dev/null +++ b/Test/baseResults/spv.ext.textureShadowLod.error.frag.out @@ -0,0 +1,6 @@ +spv.ext.textureShadowLod.error.frag +ERROR: 0:11: 'textureLod(..., float lod)' : required extension not requested: GL_EXT_texture_shadow_lod +ERROR: 1 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/spv.ext.texture_shadow_lod.frag.out b/Test/baseResults/spv.ext.textureShadowLod.frag.out similarity index 99% rename from Test/baseResults/spv.ext.texture_shadow_lod.frag.out rename to Test/baseResults/spv.ext.textureShadowLod.frag.out index 0cc54a9b5e..ca4a872777 100644 --- a/Test/baseResults/spv.ext.texture_shadow_lod.frag.out +++ b/Test/baseResults/spv.ext.textureShadowLod.frag.out @@ -1,4 +1,4 @@ -spv.ext.texture_shadow_lod.frag +spv.ext.textureShadowLod.frag // Module Version 10000 // Generated by (magic number): 8000b // Id's are bound by 55 diff --git a/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out b/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out deleted file mode 100644 index b6aa88e3da..0000000000 --- a/Test/baseResults/spv.ext.texture_shadow_lod.error.frag.out +++ /dev/null @@ -1,6 +0,0 @@ -spv.ext.texture_shadow_lod.error.frag -ERROR: 0:11: 'textureLod' : required extension not requested: GL_EXT_texture_shadow_lod -ERROR: 1 compilation errors. No code generated. - - -SPIR-V is not generated for failed compile or link diff --git a/Test/glsl.es320.extTextureShadowLod.frag b/Test/glsl.es320.extTextureShadowLod.frag new file mode 100644 index 0000000000..49125633c8 --- /dev/null +++ b/Test/glsl.es320.extTextureShadowLod.frag @@ -0,0 +1,22 @@ +#version 320 es + +#extension GL_EXT_texture_shadow_lod : enable + + +uniform lowp sampler2DArrayShadow s2da; +uniform lowp samplerCubeArrayShadow sca; +uniform lowp samplerCubeShadow sc; + +in lowp vec4 tc; +out lowp float c; +void main() +{ + c = texture(s2da, tc, 0.0); + c = texture(sca, tc, 0.0, 0.0); + c = textureOffset(s2da, tc, ivec2(0.0), 0.0); + c = textureLod(s2da, tc, 0.0); + c = textureLod(sc, tc, 0.0); + c = textureLod(sca, tc, 0.0, 0.0); + c = textureLodOffset(s2da, tc, 0.0, ivec2(0.0)); + +} diff --git a/Test/glsl.ext.textureShadowLod.frag b/Test/glsl.ext.textureShadowLod.frag new file mode 100644 index 0000000000..79c22ff041 --- /dev/null +++ b/Test/glsl.ext.textureShadowLod.frag @@ -0,0 +1,32 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : enable + +uniform sampler2DArrayShadow s2da; +uniform samplerCubeArrayShadow sca; +uniform samplerCubeShadow sc; + +out float c; +in vec4 tc; + +void pass() { + c = texture(s2da, tc, 0.0); + c = texture(sca, tc, 0.0, 0.0); + c = textureOffset(s2da, tc, ivec2(0.0), 0.0); + c = textureLod(s2da, tc, 0.0); + c = textureLod(sc, tc, 0.0); + c = textureLod(sca, tc, 0.0, 0.0); + c = textureLodOffset(s2da, tc, 0.0, ivec2(0.0)); +} + +#extension GL_EXT_texture_shadow_lod : disable +void fail() { + // All these builtins should fail to compile + c = texture(s2da, tc, 0.0); + c = texture(sca, tc, 0.0, 0.0); + c = textureOffset(s2da, tc, ivec2(0.0), 0.0); + c = textureLod(s2da, tc, 0.0); + c = textureLod(sc, tc, 0.0); + c = textureLod(sca, tc, 0.0, 0.0); + c = textureLodOffset(s2da, tc, 0.0, ivec2(0.0)); +} + diff --git a/Test/spv.ext.texture_shadow_lod.error.frag b/Test/spv.ext.textureShadowLod.error.frag similarity index 100% rename from Test/spv.ext.texture_shadow_lod.error.frag rename to Test/spv.ext.textureShadowLod.error.frag diff --git a/Test/spv.ext.texture_shadow_lod.frag b/Test/spv.ext.textureShadowLod.frag similarity index 100% rename from Test/spv.ext.texture_shadow_lod.frag rename to Test/spv.ext.textureShadowLod.frag diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 25d87370bc..62bea7bb43 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) @@ -4137,6 +4108,19 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "\n"); } + // Builtins for GL_EXT_texture_shadow_lod + if ((profile == EEsProfile && version >= 300) || ((profile != EEsProfile && version >= 130))) { + commonBuiltins.append( + "float texture(sampler2DArrayShadow, vec4, float);" + "float texture(samplerCubeArrayShadow, vec4, float, float);" + "float textureLod(sampler2DArrayShadow, vec4, float);" + "float textureLod(samplerCubeShadow, vec4, float);" + "float textureLod(samplerCubeArrayShadow, vec4, float, float);" + "float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);" + "float textureOffset(sampler2DArrayShadow, vec4 , ivec2, float);" + "\n"); + } + if (profile != EEsProfile && version >= 450) { stageBuiltins[EShLangFragment].append(derivativesAndControl64bits); stageBuiltins[EShLangFragment].append( @@ -4848,32 +4832,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "\n"); } - // 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"; - } - if (version >= 320) { - textureShadowLodFunctions += "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(textureShadowLodFunctions); //============================================================================ // @@ -8796,13 +8754,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..592e9aa8ad 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -2172,6 +2172,37 @@ 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) { + featureString = fnCandidate.getName(); + if (callNode.getOp() == EOpTexture) + featureString += "(..., float bias)"; + else + featureString += "(..., float lod)"; + feature = featureString.c_str(); + + if ((fnCandidate[0].type->getSampler().dim == Esd2D && fnCandidate[0].type->getSampler().arrayed) || //2D Array Shadow + (fnCandidate[0].type->getSampler().dim == EsdCube && fnCandidate[0].type->getSampler().arrayed && fnCandidate.getParamCount() > 3) || // Cube Array Shadow + (fnCandidate[0].type->getSampler().dim == EsdCube && callNode.getOp() == EOpTextureLod)) { // Cube Shadow + requireExtensions(loc, 1, &E_GL_EXT_texture_shadow_lod, feature); + if (isEsProfile()) { + if (version < 320 && + !extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array)) + error(loc, "GL_EXT_texture_shadow_lod not supported for this ES version", feature, ""); + else + profileRequires(loc, EEsProfile, 320, nullptr, feature); + } else { // Desktop + profileRequires(loc, ~EEsProfile, 130, nullptr, feature); + } + } + } + break; + } + case EOpSparseTextureGather: case EOpSparseTextureGatherOffset: case EOpSparseTextureGatherOffsets: @@ -2286,12 +2317,36 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan if (callNode.getOp() == EOpTextureOffset) { TSampler s = arg0->getType().getSampler(); if (s.is2D() && s.isArrayed() && s.isShadow()) { - if (isEsProfile()) + if ( + ((*argp)[1]->getAsTyped()->getType().getBasicType() == EbtFloat) && + ((*argp)[1]->getAsTyped()->getType().getVectorSize() == 4) && + (fnCandidate.getParamCount() == 4)) { + featureString = fnCandidate.getName() + " for sampler2DArrayShadow"; + feature = featureString.c_str(); + requireExtensions(loc, 1, &E_GL_EXT_texture_shadow_lod, feature); + profileRequires(loc, EEsProfile, 300, nullptr, feature); + profileRequires(loc, ~EEsProfile, 130, nullptr, feature); + } + else if (isEsProfile()) error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "ES Profile"); else if (version <= 420) error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "version <= 420"); } } + + if (callNode.getOp() == EOpTextureLodOffset) { + 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, 300, nullptr, feature); + profileRequires(loc, ~EEsProfile, 130, 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); diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index 12e0137d0e..828dabec47 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -281,6 +281,8 @@ INSTANTIATE_TEST_SUITE_P( "glsl.es320.subgroupShuffleRelative.comp", "glsl.es320.subgroupQuad.comp", "glsl.es320.subgroupVote.comp", + "glsl.es320.extTextureShadowLod.frag", + "glsl.ext.textureShadowLod.frag", "terminate.frag", "terminate.vert", "negativeWorkGroupSize.comp", diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 3cce445630..3af3b9e69c 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -537,8 +537,8 @@ INSTANTIATE_TEST_SUITE_P( "spv.atomicAdd.bufferReference.comp", "spv.fragmentShaderBarycentric3.frag", "spv.fragmentShaderBarycentric4.frag", - "spv.ext.texture_shadow_lod.frag", - "spv.ext.texture_shadow_lod.error.frag", + "spv.ext.textureShadowLod.frag", + "spv.ext.textureShadowLod.error.frag", "spv.floatFetch.frag", "spv.atomicRvalue.error.vert", })),