diff --git a/Test/150.frag b/Test/150.frag index 228e4f0d3..90b1e2740 100644 --- a/Test/150.frag +++ b/Test/150.frag @@ -111,8 +111,8 @@ void qlodFail() vec2 pf2; vec3 pf3; - lod = textureQueryLod(samp1D, pf); // ERROR, extension GL_ARB_texture_query_lod needed - lod = textureQueryLod(samp2Ds, pf2); // ERROR, extension GL_ARB_texture_query_lod needed + lod = textureQueryLOD(samp1D, pf); // ERROR, extension GL_ARB_texture_query_lod needed + lod = textureQueryLOD(samp2Ds, pf2); // ERROR, extension GL_ARB_texture_query_lod needed } #extension GL_ARB_texture_query_lod : enable @@ -138,21 +138,21 @@ void qlodPass() vec2 pf2; vec3 pf3; - lod = textureQueryLod(samp1D, pf); - lod = textureQueryLod(isamp2D, pf2); - lod = textureQueryLod(usamp3D, pf3); - lod = textureQueryLod(sampCube, pf3); - lod = textureQueryLod(isamp1DA, pf); - lod = textureQueryLod(usamp2DA, pf2); + lod = textureQueryLOD(samp1D, pf); + lod = textureQueryLOD(isamp2D, pf2); + lod = textureQueryLOD(usamp3D, pf3); + lod = textureQueryLOD(sampCube, pf3); + lod = textureQueryLOD(isamp1DA, pf); + lod = textureQueryLOD(usamp2DA, pf2); - lod = textureQueryLod(samp1Ds, pf); - lod = textureQueryLod(samp2Ds, pf2); - lod = textureQueryLod(sampCubes, pf3); - lod = textureQueryLod(samp1DAs, pf); - lod = textureQueryLod(samp2DAs, pf2); + lod = textureQueryLOD(samp1Ds, pf); + lod = textureQueryLOD(samp2Ds, pf2); + lod = textureQueryLOD(sampCubes, pf3); + lod = textureQueryLOD(samp1DAs, pf); + lod = textureQueryLOD(samp2DAs, pf2); - lod = textureQueryLod(sampBuf, pf); // ERROR - lod = textureQueryLod(sampRect, pf2); // ERROR + lod = textureQueryLOD(sampBuf, pf); // ERROR + lod = textureQueryLOD(sampRect, pf2); // ERROR } // Test extension GL_EXT_shader_integer_mix diff --git a/Test/baseResults/150.frag.out b/Test/baseResults/150.frag.out index 2192e14aa..3e666586d 100644 --- a/Test/baseResults/150.frag.out +++ b/Test/baseResults/150.frag.out @@ -10,11 +10,11 @@ ERROR: 0:53: 'double' : must be qualified as flat in ERROR: 0:57: '=' : cannot convert from ' global double' to ' global int' ERROR: 0:80: 'floatBitsToInt' : required extension not requested: GL_ARB_shader_bit_encoding ERROR: 0:100: 'packSnorm2x16' : required extension not requested: GL_ARB_shading_language_packing -ERROR: 0:114: 'textureQueryLod' : required extension not requested: GL_ARB_texture_query_lod -ERROR: 0:115: 'textureQueryLod' : required extension not requested: GL_ARB_texture_query_lod -ERROR: 0:154: 'textureQueryLod' : no matching overloaded function found +ERROR: 0:114: 'textureQueryLOD' : required extension not requested: GL_ARB_texture_query_lod +ERROR: 0:115: 'textureQueryLOD' : required extension not requested: GL_ARB_texture_query_lod +ERROR: 0:154: 'textureQueryLOD' : no matching overloaded function found ERROR: 0:154: 'assign' : cannot convert from ' const float' to ' temp 2-component vector of float' -ERROR: 0:155: 'textureQueryLod' : no matching overloaded function found +ERROR: 0:155: 'textureQueryLOD' : no matching overloaded function found ERROR: 0:155: 'assign' : cannot convert from ' const float' to ' temp 2-component vector of float' ERROR: 0:183: 'mix' : required extension not requested: GL_EXT_shader_integer_mix ERROR: 18 compilation errors. No code generated. diff --git a/Test/baseResults/textureQueryLOD.frag.out b/Test/baseResults/textureQueryLOD.frag.out new file mode 100644 index 000000000..b565a0055 --- /dev/null +++ b/Test/baseResults/textureQueryLOD.frag.out @@ -0,0 +1,115 @@ +textureQueryLOD.frag +WARNING: 0:7: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5 + +Shader version: 150 +Requested GL_ARB_gpu_shader5 +Requested GL_ARB_texture_query_lod +0:? Sequence +0:24 Function Definition: main( ( global void) +0:24 Function Parameters: +0:26 Sequence +0:26 switch +0:26 condition +0:26 'funct' ( uniform int) +0:26 body +0:26 Sequence +0:28 case: with expression +0:28 Constant: +0:28 0 (const int) +0:? Sequence +0:29 Sequence +0:29 move second child to first child ( temp 2-component vector of int) +0:29 'iv2' ( temp 2-component vector of int) +0:29 textureSize ( global 2-component vector of int) +0:29 'sampler' ( uniform sampler2DShadow) +0:29 Constant: +0:29 0 (const int) +0:31 Sequence +0:31 move second child to first child ( temp 2-component vector of float) +0:31 'fv2' ( temp 2-component vector of float) +0:31 textureQueryLod ( global 2-component vector of float) +0:31 'sampler' ( uniform sampler2DShadow) +0:31 Constant: +0:31 0.000000 +0:31 0.000000 +0:33 move second child to first child ( temp 4-component vector of float) +0:33 'color' ( out 4-component vector of float) +0:33 Construct vec4 ( temp 4-component vector of float) +0:33 Convert int to float ( temp 2-component vector of float) +0:33 'iv2' ( temp 2-component vector of int) +0:33 'fv2' ( temp 2-component vector of float) +0:34 Branch: Break +0:35 default: +0:? Sequence +0:36 move second child to first child ( temp 4-component vector of float) +0:36 'color' ( out 4-component vector of float) +0:36 Constant: +0:36 1.000000 +0:36 1.000000 +0:36 1.000000 +0:36 1.000000 +0:37 Branch: Break +0:? Linker Objects +0:? 'vUV' ( smooth in 2-component vector of float) +0:? 'color' ( out 4-component vector of float) +0:? 'sampler' ( uniform sampler2DShadow) +0:? 'funct' ( uniform int) + + +Linked fragment stage: + + +Shader version: 150 +Requested GL_ARB_gpu_shader5 +Requested GL_ARB_texture_query_lod +0:? Sequence +0:24 Function Definition: main( ( global void) +0:24 Function Parameters: +0:26 Sequence +0:26 switch +0:26 condition +0:26 'funct' ( uniform int) +0:26 body +0:26 Sequence +0:28 case: with expression +0:28 Constant: +0:28 0 (const int) +0:? Sequence +0:29 Sequence +0:29 move second child to first child ( temp 2-component vector of int) +0:29 'iv2' ( temp 2-component vector of int) +0:29 textureSize ( global 2-component vector of int) +0:29 'sampler' ( uniform sampler2DShadow) +0:29 Constant: +0:29 0 (const int) +0:31 Sequence +0:31 move second child to first child ( temp 2-component vector of float) +0:31 'fv2' ( temp 2-component vector of float) +0:31 textureQueryLod ( global 2-component vector of float) +0:31 'sampler' ( uniform sampler2DShadow) +0:31 Constant: +0:31 0.000000 +0:31 0.000000 +0:33 move second child to first child ( temp 4-component vector of float) +0:33 'color' ( out 4-component vector of float) +0:33 Construct vec4 ( temp 4-component vector of float) +0:33 Convert int to float ( temp 2-component vector of float) +0:33 'iv2' ( temp 2-component vector of int) +0:33 'fv2' ( temp 2-component vector of float) +0:34 Branch: Break +0:35 default: +0:? Sequence +0:36 move second child to first child ( temp 4-component vector of float) +0:36 'color' ( out 4-component vector of float) +0:36 Constant: +0:36 1.000000 +0:36 1.000000 +0:36 1.000000 +0:36 1.000000 +0:37 Branch: Break +0:? Linker Objects +0:? 'vUV' ( smooth in 2-component vector of float) +0:? 'color' ( out 4-component vector of float) +0:? 'sampler' ( uniform sampler2DShadow) +0:? 'funct' ( uniform int) + diff --git a/Test/textureQueryLOD.frag b/Test/textureQueryLOD.frag new file mode 100644 index 000000000..0d0ae3c76 --- /dev/null +++ b/Test/textureQueryLOD.frag @@ -0,0 +1,39 @@ +#version 150 + +#ifdef GL_ARB_texture_query_lod +#extension GL_ARB_texture_query_lod : enable +#endif +#ifdef GL_ARB_gpu_shader5 +#extension GL_ARB_gpu_shader5 : enable +#endif + +#ifdef GL_ES +precision highp float; +#endif + +in vec2 vUV; // vert->frag +out vec4 color; // frag->fb +#define UV vUV + +#define bias 1.5 +#define TEX 128.0 +#define offset ivec2(1,1) +uniform highp sampler2DShadow sampler; +uniform int funct; + +void main (void) +{ + switch (funct) + { + case 0: + ivec2 iv2 = textureSize(sampler, 0); +#ifdef GL_ARB_texture_query_lod + vec2 fv2 = textureQueryLOD(sampler, vec2(0.0, 0.0)); +#endif + color = vec4(iv2,fv2); + break; + default: + color = vec4(1.0, 1.0, 1.0, 1.0); + break; + } +} diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index a79925d3e..71321ce3f 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -316,6 +316,7 @@ const CustomFunction CustomFunctions[] = { { EOpTextureQuerySize, "textureSize", nullptr }, { EOpTextureQueryLod, "textureQueryLod", nullptr }, + { EOpTextureQueryLod, "textureQueryLOD", nullptr }, // extension GL_ARB_texture_query_lod { EOpTextureQueryLevels, "textureQueryLevels", nullptr }, { EOpTextureQuerySamples, "textureSamples", nullptr }, { EOpTexture, "texture", nullptr }, @@ -6307,38 +6308,44 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int // // textureQueryLod(), fragment stage only // Also enabled with extension GL_ARB_texture_query_lod + // Extension GL_ARB_texture_query_lod says that textureQueryLOD() also exist at extension. if (profile != EEsProfile && version >= 150 && sampler.isCombined() && sampler.dim != EsdRect && ! sampler.isMultiSample() && ! sampler.isBuffer()) { - for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) { - if (f16TexAddr && sampler.type != EbtFloat16) - continue; - stageBuiltins[EShLangFragment].append("vec2 textureQueryLod("); - stageBuiltins[EShLangFragment].append(typeName); - if (dimMap[sampler.dim] == 1) - if (f16TexAddr) - stageBuiltins[EShLangFragment].append(", float16_t"); - else - stageBuiltins[EShLangFragment].append(", float"); - else { - if (f16TexAddr) - stageBuiltins[EShLangFragment].append(", f16vec"); - else - stageBuiltins[EShLangFragment].append(", vec"); - stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]); - } - stageBuiltins[EShLangFragment].append(");\n"); - } - stageBuiltins[EShLangCompute].append("vec2 textureQueryLod("); - stageBuiltins[EShLangCompute].append(typeName); - if (dimMap[sampler.dim] == 1) - stageBuiltins[EShLangCompute].append(", float"); - else { - stageBuiltins[EShLangCompute].append(", vec"); - stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]); + const TString funcName[2] = {"vec2 textureQueryLod(", "vec2 textureQueryLOD("}; + + for (int i = 0; i < 2; ++i){ + for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) { + if (f16TexAddr && sampler.type != EbtFloat16) + continue; + stageBuiltins[EShLangFragment].append(funcName[i]); + stageBuiltins[EShLangFragment].append(typeName); + if (dimMap[sampler.dim] == 1) + if (f16TexAddr) + stageBuiltins[EShLangFragment].append(", float16_t"); + else + stageBuiltins[EShLangFragment].append(", float"); + else { + if (f16TexAddr) + stageBuiltins[EShLangFragment].append(", f16vec"); + else + stageBuiltins[EShLangFragment].append(", vec"); + stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]); + } + stageBuiltins[EShLangFragment].append(");\n"); + } + + stageBuiltins[EShLangCompute].append(funcName[i]); + stageBuiltins[EShLangCompute].append(typeName); + if (dimMap[sampler.dim] == 1) + stageBuiltins[EShLangCompute].append(", float"); + else { + stageBuiltins[EShLangCompute].append(", vec"); + stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]); + } + stageBuiltins[EShLangCompute].append(");\n"); } - stageBuiltins[EShLangCompute].append(");\n"); } // @@ -8118,7 +8125,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion } if (profile != EEsProfile && version < 400) { - symbolTable.setFunctionExtensions("textureQueryLod", 1, &E_GL_ARB_texture_query_lod); + symbolTable.setFunctionExtensions("textureQueryLOD", 1, &E_GL_ARB_texture_query_lod); } if (profile != EEsProfile && version >= 460) { diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index b63825b68..7737627f0 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -284,6 +284,7 @@ INSTANTIATE_TEST_SUITE_P( "textureoffset_sampler2darrayshadow.vert", "atomicAdd.comp", "GL_ARB_gpu_shader5.u2i.vert", + "textureQueryLOD.frag", })), FileNameAsCustomTestSuffix );