Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extension GL_ARB_texture_query_lod. #2194

Merged
merged 1 commit into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Test/150.frag
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,58 @@ void packingFail()
{
uint u19 = packSnorm2x16(v2a); // Error, extension GL_ARB_shading_language_packing is disabled
}

// Testing extension GL_ARB_texture_query_lod
uniform sampler1D samp1D;
uniform sampler2DShadow samp2Ds;

void qlodFail()
{
vec2 lod;
float pf;
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
}

#extension GL_ARB_texture_query_lod : enable

uniform isampler2D isamp2D;
uniform usampler3D usamp3D;
uniform samplerCube sampCube;
uniform isampler1DArray isamp1DA;
uniform usampler2DArray usamp2DA;

uniform sampler1DShadow samp1Ds;
uniform samplerCubeShadow sampCubes;
uniform sampler1DArrayShadow samp1DAs;
uniform sampler2DArrayShadow samp2DAs;

uniform samplerBuffer sampBuf;
uniform sampler2DRect sampRect;

void qlodPass()
{
vec2 lod;
float pf;
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(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
}
32 changes: 9 additions & 23 deletions Test/330.frag
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,15 @@ layout(location=27, index=0) in vec4 indexIn; // ERROR, not on in
layout(location=0, index=0) in; // ERROR, not just on in
layout(location=0, index=0) out; // ERROR, need a variable
layout(location=26, index=0) out indexBlock { int a; } indexBlockI; // ERROR, not on a block

uniform sampler1D samp1D;
uniform sampler2DShadow samp2Ds;

void qlod()
{
vec2 lod;
float pf;
vec2 pf2;
vec3 pf3;

lod = textureQueryLod(samp1D, pf); // ERROR, not until 400
pmistryNV marked this conversation as resolved.
Show resolved Hide resolved
lod = textureQueryLod(samp2Ds, pf2); // ERROR, not until 400
}

int precise; // okay, not a keyword yet
struct SKeyMem { int precise; } KeyMem; // okay, not a keyword yet

void fooKeyMem()
{
KeyMem.precise;
}


int precise; // okay, not a keyword yet
struct SKeyMem { int precise; } KeyMem; // okay, not a keyword yet

void fooKeyMem()
{
KeyMem.precise;
}

layout(location=28, index=2) out vec4 outIndex2; // ERROR index out of range

layout(location=4) uniform vec4 ucolor0; // ERROR: extension is not enabled
Expand Down
109 changes: 108 additions & 1 deletion Test/baseResults/150.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ 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: 12 compilation errors. No code generated.
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: 'assign' : cannot convert from ' const float' to ' temp 2-component vector of float'
ERROR: 18 compilation errors. No code generated.


Shader version: 150
Requested GL_ARB_gpu_shader_fp64
Requested GL_ARB_shader_bit_encoding
Requested GL_ARB_shading_language_packing
Requested GL_ARB_texture_query_lod
gl_FragCoord pixel center is integer
gl_FragCoord origin is upper left
ERROR: node is still EOpNull!
Expand Down Expand Up @@ -210,6 +217,79 @@ ERROR: node is still EOpNull!
0:100 'u19' ( temp uint)
0:100 packSnorm2x16 ( global uint)
0:100 'v2a' ( global 2-component vector of float)
0:107 Function Definition: qlodFail( ( global void)
0:107 Function Parameters:
0:? Sequence
0:114 move second child to first child ( temp 2-component vector of float)
0:114 'lod' ( temp 2-component vector of float)
0:114 textureQueryLod ( global 2-component vector of float)
0:114 'samp1D' ( uniform sampler1D)
0:114 'pf' ( temp float)
0:115 move second child to first child ( temp 2-component vector of float)
0:115 'lod' ( temp 2-component vector of float)
0:115 textureQueryLod ( global 2-component vector of float)
0:115 'samp2Ds' ( uniform sampler2DShadow)
0:115 'pf2' ( temp 2-component vector of float)
0:134 Function Definition: qlodPass( ( global void)
0:134 Function Parameters:
0:? Sequence
0:141 move second child to first child ( temp 2-component vector of float)
0:141 'lod' ( temp 2-component vector of float)
0:141 textureQueryLod ( global 2-component vector of float)
0:141 'samp1D' ( uniform sampler1D)
0:141 'pf' ( temp float)
0:142 move second child to first child ( temp 2-component vector of float)
0:142 'lod' ( temp 2-component vector of float)
0:142 textureQueryLod ( global 2-component vector of float)
0:142 'isamp2D' ( uniform isampler2D)
0:142 'pf2' ( temp 2-component vector of float)
0:143 move second child to first child ( temp 2-component vector of float)
0:143 'lod' ( temp 2-component vector of float)
0:143 textureQueryLod ( global 2-component vector of float)
0:143 'usamp3D' ( uniform usampler3D)
0:143 'pf3' ( temp 3-component vector of float)
0:144 move second child to first child ( temp 2-component vector of float)
0:144 'lod' ( temp 2-component vector of float)
0:144 textureQueryLod ( global 2-component vector of float)
0:144 'sampCube' ( uniform samplerCube)
0:144 'pf3' ( temp 3-component vector of float)
0:145 move second child to first child ( temp 2-component vector of float)
0:145 'lod' ( temp 2-component vector of float)
0:145 textureQueryLod ( global 2-component vector of float)
0:145 'isamp1DA' ( uniform isampler1DArray)
0:145 'pf' ( temp float)
0:146 move second child to first child ( temp 2-component vector of float)
0:146 'lod' ( temp 2-component vector of float)
0:146 textureQueryLod ( global 2-component vector of float)
0:146 'usamp2DA' ( uniform usampler2DArray)
0:146 'pf2' ( temp 2-component vector of float)
0:148 move second child to first child ( temp 2-component vector of float)
0:148 'lod' ( temp 2-component vector of float)
0:148 textureQueryLod ( global 2-component vector of float)
0:148 'samp1Ds' ( uniform sampler1DShadow)
0:148 'pf' ( temp float)
0:149 move second child to first child ( temp 2-component vector of float)
0:149 'lod' ( temp 2-component vector of float)
0:149 textureQueryLod ( global 2-component vector of float)
0:149 'samp2Ds' ( uniform sampler2DShadow)
0:149 'pf2' ( temp 2-component vector of float)
0:150 move second child to first child ( temp 2-component vector of float)
0:150 'lod' ( temp 2-component vector of float)
0:150 textureQueryLod ( global 2-component vector of float)
0:150 'sampCubes' ( uniform samplerCubeShadow)
0:150 'pf3' ( temp 3-component vector of float)
0:151 move second child to first child ( temp 2-component vector of float)
0:151 'lod' ( temp 2-component vector of float)
0:151 textureQueryLod ( global 2-component vector of float)
0:151 'samp1DAs' ( uniform sampler1DArrayShadow)
0:151 'pf' ( temp float)
0:152 move second child to first child ( temp 2-component vector of float)
0:152 'lod' ( temp 2-component vector of float)
0:152 textureQueryLod ( global 2-component vector of float)
0:152 'samp2DAs' ( uniform sampler2DArrayShadow)
0:152 'pf2' ( temp 2-component vector of float)
0:154 'lod' ( temp 2-component vector of float)
0:155 'lod' ( temp 2-component vector of float)
0:? Linker Objects
0:? 'gl_FragCoord' ( gl_FragCoord 4-component vector of float FragCoord)
0:? 'foo' ( smooth in 4-component vector of float)
Expand Down Expand Up @@ -237,6 +317,19 @@ ERROR: node is still EOpNull!
0:? 'uv2c' ( global 2-component vector of uint)
0:? 'v2a' ( global 2-component vector of float)
0:? 'uy' ( global uint)
0:? 'samp1D' ( uniform sampler1D)
0:? 'samp2Ds' ( uniform sampler2DShadow)
0:? 'isamp2D' ( uniform isampler2D)
0:? 'usamp3D' ( uniform usampler3D)
0:? 'sampCube' ( uniform samplerCube)
0:? 'isamp1DA' ( uniform isampler1DArray)
0:? 'usamp2DA' ( uniform usampler2DArray)
0:? 'samp1Ds' ( uniform sampler1DShadow)
0:? 'sampCubes' ( uniform samplerCubeShadow)
0:? 'samp1DAs' ( uniform sampler1DArrayShadow)
0:? 'samp2DAs' ( uniform sampler2DArrayShadow)
0:? 'sampBuf' ( uniform samplerBuffer)
0:? 'sampRect' ( uniform sampler2DRect)


Linked fragment stage:
Expand All @@ -246,6 +339,7 @@ Shader version: 150
Requested GL_ARB_gpu_shader_fp64
Requested GL_ARB_shader_bit_encoding
Requested GL_ARB_shading_language_packing
Requested GL_ARB_texture_query_lod
gl_FragCoord pixel center is integer
gl_FragCoord origin is upper left
ERROR: node is still EOpNull!
Expand Down Expand Up @@ -308,4 +402,17 @@ ERROR: node is still EOpNull!
0:? 'uv2c' ( global 2-component vector of uint)
0:? 'v2a' ( global 2-component vector of float)
0:? 'uy' ( global uint)
0:? 'samp1D' ( uniform sampler1D)
0:? 'samp2Ds' ( uniform sampler2DShadow)
0:? 'isamp2D' ( uniform isampler2D)
0:? 'usamp3D' ( uniform usampler3D)
0:? 'sampCube' ( uniform samplerCube)
0:? 'isamp1DA' ( uniform isampler1DArray)
0:? 'usamp2DA' ( uniform usampler2DArray)
0:? 'samp1Ds' ( uniform sampler1DShadow)
0:? 'sampCubes' ( uniform samplerCubeShadow)
0:? 'samp1DAs' ( uniform sampler1DArrayShadow)
0:? 'samp2DAs' ( uniform sampler2DArrayShadow)
0:? 'sampBuf' ( uniform samplerBuffer)
0:? 'sampRect' ( uniform sampler2DRect)

33 changes: 10 additions & 23 deletions Test/baseResults/330.frag.out
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ ERROR: 0:126: 'index' : can only be used on an output
ERROR: 0:126: 'location/component/index' : cannot declare a default, use a full declaration
ERROR: 0:127: 'location/component/index' : cannot declare a default, use a full declaration
ERROR: 0:128: 'output block' : not supported in this stage: fragment
ERROR: 0:140: 'textureQueryLod' : no matching overloaded function found
ERROR: 0:140: 'assign' : cannot convert from ' const float' to ' temp 2-component vector of float'
ERROR: 0:141: 'textureQueryLod' : no matching overloaded function found
ERROR: 0:141: 'assign' : cannot convert from ' const float' to ' temp 2-component vector of float'
ERROR: 0:152: 'index' : value must be 0 or 1
ERROR: 0:154: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions
ERROR: 0:160: 'location' : cannot apply to uniform or buffer block
ERROR: 43 compilation errors. No code generated.
ERROR: 0:138: 'index' : value must be 0 or 1
ERROR: 0:140: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions
ERROR: 0:146: 'location' : cannot apply to uniform or buffer block
ERROR: 39 compilation errors. No code generated.


Shader version: 330
Expand Down Expand Up @@ -80,18 +76,13 @@ ERROR: node is still EOpNull!
0:24 move second child to first child ( temp 4-component vector of float)
0:24 'outVar' (layout( location=0 index=0) out 4-component vector of float)
0:24 'inVar' ( smooth in 4-component vector of float)
0:133 Function Definition: qlod( ( global void)
0:133 Function Definition: fooKeyMem( ( global void)
0:133 Function Parameters:
0:? Sequence
0:140 'lod' ( temp 2-component vector of float)
0:141 'lod' ( temp 2-component vector of float)
0:147 Function Definition: fooKeyMem( ( global void)
0:147 Function Parameters:
0:149 Sequence
0:149 precise: direct index for structure ( global int)
0:149 'KeyMem' ( global structure{ global int precise})
0:149 Constant:
0:149 0 (const int)
0:135 Sequence
0:135 precise: direct index for structure ( global int)
0:135 'KeyMem' ( global structure{ global int precise})
0:135 Constant:
0:135 0 (const int)
0:? Linker Objects
0:? 'inVar' ( smooth in 4-component vector of float)
0:? 'outVar' (layout( location=0 index=0) out 4-component vector of float)
Expand Down Expand Up @@ -124,8 +115,6 @@ ERROR: node is still EOpNull!
0:? 'outVar4' (layout( location=0 index=1) out 4-component vector of float)
0:? 'indexIn' (layout( location=27 index=0) smooth in 4-component vector of float)
0:? 'indexBlockI' (layout( location=26 index=0) out block{ out int a})
0:? 'samp1D' ( uniform sampler1D)
0:? 'samp2Ds' ( uniform sampler2DShadow)
0:? 'precise' ( global int)
0:? 'KeyMem' ( global structure{ global int precise})
0:? 'outIndex2' (layout( location=28 index=0) out 4-component vector of float)
Expand Down Expand Up @@ -193,8 +182,6 @@ ERROR: node is still EOpNull!
0:? 'outVar4' (layout( location=0 index=1) out 4-component vector of float)
0:? 'indexIn' (layout( location=27 index=0) smooth in 4-component vector of float)
0:? 'indexBlockI' (layout( location=26 index=0) out block{ out int a})
0:? 'samp1D' ( uniform sampler1D)
0:? 'samp2Ds' ( uniform sampler2DShadow)
0:? 'precise' ( global int)
0:? 'KeyMem' ( global structure{ global int precise})
0:? 'outIndex2' (layout( location=28 index=0) out 4-component vector of float)
Expand Down
9 changes: 7 additions & 2 deletions glslang/MachineIndependent/Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5849,9 +5849,9 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int

//
// textureQueryLod(), fragment stage only
//
// Also enabled with extension GL_ARB_texture_query_lod

if (profile != EEsProfile && version >= 400 && sampler.isCombined() && sampler.dim != EsdRect &&
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)
Expand Down Expand Up @@ -7555,6 +7555,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable);
}

if (profile != EEsProfile && version < 400) {
symbolTable.setFunctionExtensions("textureQueryLod", 1, &E_GL_ARB_texture_query_lod);
}

if (profile != EEsProfile && version >= 460) {
symbolTable.setFunctionExtensions("rayQueryInitializeEXT", 1, &E_GL_EXT_ray_query);
symbolTable.setFunctionExtensions("rayQueryTerminateEXT", 1, &E_GL_EXT_ray_query);
Expand Down Expand Up @@ -8071,6 +8075,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_ARB_compute_shader);
}


symbolTable.setFunctionExtensions("controlBarrier", 1, &E_GL_KHR_memory_scope_semantics);
symbolTable.setFunctionExtensions("debugPrintfEXT", 1, &E_GL_EXT_debug_printf);

Expand Down
2 changes: 2 additions & 0 deletions glslang/MachineIndependent/Versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_shader_image_size] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_storage_buffer_object] = EBhDisable;
extensionBehavior[E_GL_ARB_shading_language_packing] = EBhDisable;
extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable;

extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable;
extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable;
Expand Down Expand Up @@ -417,6 +418,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_ARB_uniform_buffer_object 1\n"
"#define GL_ARB_shader_bit_encoding 1\n"
"#define GL_ARB_shader_storage_buffer_object 1\n"
"#define GL_ARB_texture_query_lod 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_EXT_shader_image_load_formatted 1\n"
"#define GL_EXT_post_depth_coverage 1\n"
Expand Down
1 change: 1 addition & 0 deletions glslang/MachineIndependent/Versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const char* const E_GL_ARB_shader_bit_encoding = "GL_ARB_shader_bit_enc
const char* const E_GL_ARB_shader_image_size = "GL_ARB_shader_image_size";
const char* const E_GL_ARB_shader_storage_buffer_object = "GL_ARB_shader_storage_buffer_object";
const char* const E_GL_ARB_shading_language_packing = "GL_ARB_shading_language_packing";
const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_lod";

const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
Expand Down