Correct textureGather*() extension support:

- add extension behavior and warning message for partial extension support
 - add partial support for gpu_shader5 for textureGather*
 - add interactions between texture rectangle and textureGather*
 - add checks to distinguish between gpu_shader5 and texture_gather extension feature differences


git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24183 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-11-23 21:10:51 +00:00
parent 5b9f98854c
commit d6bef9186b
11 changed files with 347 additions and 140 deletions

View File

@ -65,3 +65,34 @@ void bar2()
int(bl4) <= int(bl4); // true
int(bl4.x) > int(bl4.y); // false
}
#extension GL_ARB_texture_gather : enable
#extension GL_ARB_texture_rectangle : enable
uniform sampler2D samp2D;
uniform sampler2DShadow samp2DS;
uniform sampler2DRect samp2DR;
uniform sampler2DArray samp2DA;
void bar23()
{
vec4 s;
s = textureGatherOffset(sampC, vec3(0.3), ivec2(1)); // ERROR
s = textureGatherOffset(samp2DR, vec2(0.3), ivec2(1)); // ERROR
s = textureGatherOffset(samp2D, vec2(0.3), ivec2(1));
s = textureGatherOffset(samp2DA, vec3(0.3), ivec2(1));
s = textureGatherOffset(samp2DS, vec2(0.3), 1.3, ivec2(1)); // ERROR
s = textureGatherOffset(samp2D, vec2(0.3), ivec2(1), 2); // ERROR
}
#extension GL_ARB_gpu_shader5 : enable
void bar234()
{
vec4 s;
s = textureGatherOffset(samp2D, vec2(0.3), ivec2(1));
s = textureGatherOffset(samp2DA, vec3(0.3), ivec2(1));
s = textureGatherOffset(samp2DR, vec2(0.3), ivec2(1));
s = textureGatherOffset(samp2DS, vec2(0.3), 1.3, ivec2(1));
s = textureGatherOffset(samp2D, vec2(0.3), ivec2(1), 2);
}

View File

@ -14,7 +14,9 @@ void main()
outp.x = gl_ClipDistance[1];
ivec2 offsets[4];
uvec4 uv4 = textureGatherOffsets(samp2dr, c2D, offsets, 2);
const ivec2 constOffsets[4] = ivec2[4](ivec2(1,2), ivec2(3,4), ivec2(15,16), ivec2(-2,0));
uvec4 uv4 = textureGatherOffsets(samp2dr, c2D, offsets, 2); // ERROR, offsets not constant
uv4 = textureGatherOffsets(samp2dr, c2D, constOffsets, 2);
vec4 v4 = textureGather(arrayedSampler[0], c2D);
ivec4 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 3);
iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), i); // ERROR, last argument not const
@ -46,8 +48,8 @@ void foo23()
{
const ivec2[3] offsets = ivec2[3](ivec2(1,2), ivec2(3,4), ivec2(15,16));
textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), ivec2(c2D)); // ERROR, offset not constant
textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), ivec2(c2D)); // ERROR, offset not constant
textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[1]);
textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[2]);
textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[2]); // ERROR, offset out of range
textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), ivec2(-10, 20)); // ERROR, offset out of range
}

View File

@ -1,14 +1,20 @@
130.frag
Warning, version 130 is not yet complete; most features are present, but a few are missing.
ERROR: 0:25: 'texture gather function' : not supported for this version or the enabled extensions
ERROR: 0:25: 'textureGather(...)' : not supported for this version or the enabled extensions
ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Color
ERROR: 0:38: 'gl_Color' : redeclaring non-array as array
ERROR: 0:39: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Color
WARNING: 0:45: extension GL_ARB_texture_gather is being used for texture gather function
WARNING: 0:45: extension GL_ARB_texture_gather is being used for textureGather(...)
ERROR: 0:62: '<' : wrong operand types: no operation '<' exists that takes a left-hand operand of type '3-component vector of bool' and a right operand of type '3-component vector of bool' (or there is no acceptable conversion)
ERROR: 0:63: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type '3-component vector of uint' and a right operand of type '3-component vector of uint' (or there is no acceptable conversion)
ERROR: 0:64: '>=' : wrong operand types: no operation '>=' exists that takes a left-hand operand of type 'const 2-component vector of uint' and a right operand of type 'const 2-component vector of uint' (or there is no acceptable conversion)
ERROR: 7 compilation errors. No code generated.
ERROR: 0:80: 'textureGatherOffset' : no matching overloaded function found
ERROR: 0:80: 'assign' : cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:81: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions
ERROR: 0:84: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions
ERROR: 0:85: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions
WARNING: 0:88: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5
ERROR: 12 compilation errors. No code generated.
ERROR: node is still EOpNull!
@ -93,6 +99,123 @@ ERROR: node is still EOpNull!
0:65 true (const bool)
0:66 Constant:
0:66 false (const bool)
0:77 Function Definition: bar23( (void)
0:77 Function Parameters:
0:? Sequence
0:80 's' (4-component vector of float)
0:81 move second child to first child (4-component vector of float)
0:81 's' (4-component vector of float)
0:81 Function Call: textureGatherOffset(sR21;vf2;vi2; (4-component vector of float)
0:81 'samp2DR' (uniform sampler2DRect)
0:81 Constant:
0:81 0.300000
0:81 0.300000
0:81 Constant:
0:81 1 (const int)
0:81 1 (const int)
0:82 move second child to first child (4-component vector of float)
0:82 's' (4-component vector of float)
0:82 Function Call: textureGatherOffset(s21;vf2;vi2; (4-component vector of float)
0:82 'samp2D' (uniform sampler2D)
0:82 Constant:
0:82 0.300000
0:82 0.300000
0:82 Constant:
0:82 1 (const int)
0:82 1 (const int)
0:83 move second child to first child (4-component vector of float)
0:83 's' (4-component vector of float)
0:83 Function Call: textureGatherOffset(sA21;vf3;vi2; (4-component vector of float)
0:83 'samp2DA' (uniform sampler2DArray)
0:83 Constant:
0:83 0.300000
0:83 0.300000
0:83 0.300000
0:83 Constant:
0:83 1 (const int)
0:83 1 (const int)
0:84 move second child to first child (4-component vector of float)
0:84 's' (4-component vector of float)
0:84 Function Call: textureGatherOffset(sS21;vf2;f1;vi2; (4-component vector of float)
0:84 'samp2DS' (uniform sampler2DShadow)
0:84 Constant:
0:84 0.300000
0:84 0.300000
0:84 Constant:
0:84 1.300000
0:84 Constant:
0:84 1 (const int)
0:84 1 (const int)
0:85 move second child to first child (4-component vector of float)
0:85 's' (4-component vector of float)
0:85 Function Call: textureGatherOffset(s21;vf2;vi2;i1; (4-component vector of float)
0:85 'samp2D' (uniform sampler2D)
0:85 Constant:
0:85 0.300000
0:85 0.300000
0:85 Constant:
0:85 1 (const int)
0:85 1 (const int)
0:85 Constant:
0:85 2 (const int)
0:90 Function Definition: bar234( (void)
0:90 Function Parameters:
0:? Sequence
0:93 move second child to first child (4-component vector of float)
0:93 's' (4-component vector of float)
0:93 Function Call: textureGatherOffset(s21;vf2;vi2; (4-component vector of float)
0:93 'samp2D' (uniform sampler2D)
0:93 Constant:
0:93 0.300000
0:93 0.300000
0:93 Constant:
0:93 1 (const int)
0:93 1 (const int)
0:94 move second child to first child (4-component vector of float)
0:94 's' (4-component vector of float)
0:94 Function Call: textureGatherOffset(sA21;vf3;vi2; (4-component vector of float)
0:94 'samp2DA' (uniform sampler2DArray)
0:94 Constant:
0:94 0.300000
0:94 0.300000
0:94 0.300000
0:94 Constant:
0:94 1 (const int)
0:94 1 (const int)
0:95 move second child to first child (4-component vector of float)
0:95 's' (4-component vector of float)
0:95 Function Call: textureGatherOffset(sR21;vf2;vi2; (4-component vector of float)
0:95 'samp2DR' (uniform sampler2DRect)
0:95 Constant:
0:95 0.300000
0:95 0.300000
0:95 Constant:
0:95 1 (const int)
0:95 1 (const int)
0:96 move second child to first child (4-component vector of float)
0:96 's' (4-component vector of float)
0:96 Function Call: textureGatherOffset(sS21;vf2;f1;vi2; (4-component vector of float)
0:96 'samp2DS' (uniform sampler2DShadow)
0:96 Constant:
0:96 0.300000
0:96 0.300000
0:96 Constant:
0:96 1.300000
0:96 Constant:
0:96 1 (const int)
0:96 1 (const int)
0:97 move second child to first child (4-component vector of float)
0:97 's' (4-component vector of float)
0:97 Function Call: textureGatherOffset(s21;vf2;vi2;i1; (4-component vector of float)
0:97 'samp2D' (uniform sampler2D)
0:97 Constant:
0:97 0.300000
0:97 0.300000
0:97 Constant:
0:97 1 (const int)
0:97 1 (const int)
0:97 Constant:
0:97 2 (const int)
0:? Linker Objects
0:? 'a' (3-component vector of float)
0:? 'b' (float)
@ -106,6 +229,10 @@ ERROR: node is still EOpNull!
0:? 'sampC' (uniform samplerCube)
0:? 'gl_Color' (smooth in 4-component vector of float)
0:? 'gl_Color' (flat in 4-component vector of float)
0:? 'samp2D' (uniform sampler2D)
0:? 'samp2DS' (uniform sampler2DShadow)
0:? 'samp2DR' (uniform sampler2DRect)
0:? 'samp2DA' (uniform sampler2DArray)
Linked fragment stage:

View File

@ -1,18 +1,19 @@
400.frag
Warning, version 400 is not yet complete; some version-specific features are present, but many are missing.
ERROR: 0:20: 'texture gather component' : must be a constant
ERROR: 0:21: 'texture gather component' : must be 0, 1, 2, or 3
ERROR: 0:28: 'location qualifier on input' : not supported for this version or the enabled extensions
ERROR: 0:36: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions
ERROR: 0:38: 'redeclaration' : cannot apply layout qualifier to gl_Color
ERROR: 0:39: 'redeclaration' : cannot change qualification of gl_ClipDistance
ERROR: 0:41: 'gl_FragCoord' : cannot redeclare after use
ERROR: 0:49: 'texel offset' : argument must be compile-time constant
ERROR: 0:51: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:51: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:52: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:52: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 12 compilation errors. No code generated.
ERROR: 0:18: 'textureGatherOffsets(...)' : must be a compile-time constant: offsets argument
ERROR: 0:22: 'textureGatherOffset(...)' : must be a compile-time constant: component argument
ERROR: 0:23: 'textureGatherOffset(...)' : must be 0, 1, 2, or 3: component argument
ERROR: 0:30: 'location qualifier on input' : not supported for this version or the enabled extensions
ERROR: 0:38: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions
ERROR: 0:40: 'redeclaration' : cannot apply layout qualifier to gl_Color
ERROR: 0:41: 'redeclaration' : cannot change qualification of gl_ClipDistance
ERROR: 0:43: 'gl_FragCoord' : cannot redeclare after use
ERROR: 0:51: 'texel offset' : argument must be compile-time constant
ERROR: 0:53: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:53: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:54: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 0:54: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]
ERROR: 13 compilation errors. No code generated.
gl_FragCoord pixel center is integer
@ -37,63 +38,54 @@ ERROR: node is still EOpNull!
0:14 'gl_ClipDistance' (smooth in unsized array of float)
0:14 Constant:
0:14 1 (const int)
0:17 Sequence
0:17 move second child to first child (4-component vector of uint)
0:17 'uv4' (4-component vector of uint)
0:17 Function Call: textureGatherOffsets(usR21;vf2;vi2[4];i1; (4-component vector of uint)
0:17 'samp2dr' (uniform usampler2DRect)
0:17 'c2D' (smooth in 2-component vector of float)
0:17 'offsets' (4-element array of 2-component vector of int)
0:17 Constant:
0:17 2 (const int)
0:18 Sequence
0:18 move second child to first child (4-component vector of float)
0:18 'v4' (4-component vector of float)
0:18 Function Call: textureGather(s21;vf2; (4-component vector of float)
0:18 direct index (sampler2D)
0:18 'arrayedSampler' (uniform 5-element array of sampler2D)
0:18 Constant:
0:18 0 (const int)
0:18 move second child to first child (4-component vector of uint)
0:18 'uv4' (4-component vector of uint)
0:18 Function Call: textureGatherOffsets(usR21;vf2;vi2[4];i1; (4-component vector of uint)
0:18 'samp2dr' (uniform usampler2DRect)
0:18 'c2D' (smooth in 2-component vector of float)
0:19 Sequence
0:19 move second child to first child (4-component vector of int)
0:19 'iv4' (4-component vector of int)
0:19 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
0:19 'isamp2DA' (uniform isampler2DArray)
0:19 Constant:
0:19 0.100000
0:19 0.100000
0:19 0.100000
0:19 Constant:
0:19 1 (const int)
0:19 1 (const int)
0:19 Constant:
0:19 3 (const int)
0:20 move second child to first child (4-component vector of int)
0:20 'iv4' (4-component vector of int)
0:20 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
0:20 'isamp2DA' (uniform isampler2DArray)
0:20 Constant:
0:20 0.100000
0:20 0.100000
0:20 0.100000
0:20 Constant:
0:20 1 (const int)
0:20 1 (const int)
0:20 'i' (flat in int)
0:21 move second child to first child (4-component vector of int)
0:21 'iv4' (4-component vector of int)
0:21 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
0:21 'isamp2DA' (uniform isampler2DArray)
0:21 Constant:
0:21 0.100000
0:21 0.100000
0:21 0.100000
0:21 Constant:
0:21 1 (const int)
0:21 1 (const int)
0:21 Constant:
0:21 4 (const int)
0:18 'offsets' (4-element array of 2-component vector of int)
0:18 Constant:
0:18 2 (const int)
0:19 move second child to first child (4-component vector of uint)
0:19 'uv4' (4-component vector of uint)
0:19 Function Call: textureGatherOffsets(usR21;vf2;vi2[4];i1; (4-component vector of uint)
0:19 'samp2dr' (uniform usampler2DRect)
0:19 'c2D' (smooth in 2-component vector of float)
0:19 Constant:
0:19 1 (const int)
0:19 2 (const int)
0:19 3 (const int)
0:19 4 (const int)
0:19 15 (const int)
0:19 16 (const int)
0:19 -2 (const int)
0:19 0 (const int)
0:19 Constant:
0:19 2 (const int)
0:20 Sequence
0:20 move second child to first child (4-component vector of float)
0:20 'v4' (4-component vector of float)
0:20 Function Call: textureGather(s21;vf2; (4-component vector of float)
0:20 direct index (sampler2D)
0:20 'arrayedSampler' (uniform 5-element array of sampler2D)
0:20 Constant:
0:20 0 (const int)
0:20 'c2D' (smooth in 2-component vector of float)
0:21 Sequence
0:21 move second child to first child (4-component vector of int)
0:21 'iv4' (4-component vector of int)
0:21 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
0:21 'isamp2DA' (uniform isampler2DArray)
0:21 Constant:
0:21 0.100000
0:21 0.100000
0:21 0.100000
0:21 Constant:
0:21 1 (const int)
0:21 1 (const int)
0:21 Constant:
0:21 3 (const int)
0:22 move second child to first child (4-component vector of int)
0:22 'iv4' (4-component vector of int)
0:22 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
@ -105,48 +97,50 @@ ERROR: node is still EOpNull!
0:22 Constant:
0:22 1 (const int)
0:22 1 (const int)
0:22 Constant:
0:22 3 (const int)
0:22 'i' (flat in int)
0:23 move second child to first child (4-component vector of int)
0:23 'iv4' (4-component vector of int)
0:23 Function Call: textureGatherOffset(isA21;vf3;vi2; (4-component vector of int)
0:23 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
0:23 'isamp2DA' (uniform isampler2DArray)
0:23 Constant:
0:23 0.100000
0:23 0.100000
0:23 0.100000
0:23 Construct ivec2 (2-component vector of int)
0:23 'i' (flat in int)
0:25 Sequence
0:25 move second child to first child (4-component vector of float)
0:25 'c' (4-component vector of float)
0:25 'gl_FragCoord' (gl_FragCoord 4-component vector of float)
0:45 Function Definition: foo23( (void)
0:45 Function Parameters:
0:23 Constant:
0:23 1 (const int)
0:23 1 (const int)
0:23 Constant:
0:23 4 (const int)
0:24 move second child to first child (4-component vector of int)
0:24 'iv4' (4-component vector of int)
0:24 Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)
0:24 'isamp2DA' (uniform isampler2DArray)
0:24 Constant:
0:24 0.100000
0:24 0.100000
0:24 0.100000
0:24 Constant:
0:24 1 (const int)
0:24 1 (const int)
0:24 Constant:
0:24 3 (const int)
0:25 move second child to first child (4-component vector of int)
0:25 'iv4' (4-component vector of int)
0:25 Function Call: textureGatherOffset(isA21;vf3;vi2; (4-component vector of int)
0:25 'isamp2DA' (uniform isampler2DArray)
0:25 Constant:
0:25 0.100000
0:25 0.100000
0:25 0.100000
0:25 Construct ivec2 (2-component vector of int)
0:25 'i' (flat in int)
0:27 Sequence
0:27 move second child to first child (4-component vector of float)
0:27 'c' (4-component vector of float)
0:27 'gl_FragCoord' (gl_FragCoord 4-component vector of float)
0:47 Function Definition: foo23( (void)
0:47 Function Parameters:
0:? Sequence
0:49 Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)
0:49 'u2drs' (uniform sampler2DRectShadow)
0:49 'outp' (out 4-component vector of float)
0:49 Constant:
0:49 0.000000
0:49 0.000000
0:49 Constant:
0:49 0.000000
0:49 0.000000
0:49 Convert float to int (2-component vector of int)
0:49 'c2D' (smooth in 2-component vector of float)
0:50 Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)
0:50 'u2drs' (uniform sampler2DRectShadow)
0:50 'outp' (out 4-component vector of float)
0:50 Constant:
0:50 0.000000
0:50 0.000000
0:50 Constant:
0:50 0.000000
0:50 0.000000
0:50 Constant:
0:50 3 (const int)
0:50 4 (const int)
0:51 Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)
0:51 'u2drs' (uniform sampler2DRectShadow)
0:51 'outp' (out 4-component vector of float)
@ -156,9 +150,8 @@ ERROR: node is still EOpNull!
0:51 Constant:
0:51 0.000000
0:51 0.000000
0:51 Constant:
0:51 15 (const int)
0:51 16 (const int)
0:51 Convert float to int (2-component vector of int)
0:51 'c2D' (smooth in 2-component vector of float)
0:52 Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)
0:52 'u2drs' (uniform sampler2DRectShadow)
0:52 'outp' (out 4-component vector of float)
@ -169,8 +162,32 @@ ERROR: node is still EOpNull!
0:52 0.000000
0:52 0.000000
0:52 Constant:
0:52 -10 (const int)
0:52 20 (const int)
0:52 3 (const int)
0:52 4 (const int)
0:53 Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)
0:53 'u2drs' (uniform sampler2DRectShadow)
0:53 'outp' (out 4-component vector of float)
0:53 Constant:
0:53 0.000000
0:53 0.000000
0:53 Constant:
0:53 0.000000
0:53 0.000000
0:53 Constant:
0:53 15 (const int)
0:53 16 (const int)
0:54 Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)
0:54 'u2drs' (uniform sampler2DRectShadow)
0:54 'outp' (out 4-component vector of float)
0:54 Constant:
0:54 0.000000
0:54 0.000000
0:54 Constant:
0:54 0.000000
0:54 0.000000
0:54 Constant:
0:54 -10 (const int)
0:54 20 (const int)
0:? Linker Objects
0:? 'c2D' (smooth in 2-component vector of float)
0:? 'i' (flat in int)

View File

@ -2,9 +2,8 @@ versionsErrors.frag
ERROR: #version: versions before 150 do not allow a profile token
ERROR: 0:38: 'attribute' : not supported in this stage: fragment
ERROR: 0:40: 'sampler2DRect' : Reserved word.
ERROR: 0:40: 'rectangle texture' : not supported for this version or the enabled extensions
ERROR: 0:44: 'floating-point suffix' : not supported for this version or the enabled extensions
ERROR: 5 compilation errors. No code generated.
ERROR: 4 compilation errors. No code generated.
ERROR: node is still EOpNull!

View File

@ -1498,8 +1498,6 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
continue;
if (dim == EsdRect && version < 140)
continue;
if (dim != Esd2D && ms)
continue;
if ((dim == Esd3D || dim == EsdRect) && arrayed)
@ -1518,6 +1516,9 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
if (shadow && bType > 0)
continue;
if (dim == EsdRect && version < 140 && bType > 0)
continue;
//
// Now, make all the function prototypes for the type we just built...
//
@ -1800,6 +1801,9 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int vers
if (sampler.ms)
return;
if (version < 140 && sampler.dim == EsdRect && sampler.type != EbtFloat)
return;
// make one string per stage to contain all functions of the passed-in type for that stage
TString functions[EShLangCount];

View File

@ -982,18 +982,45 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
if (fnCandidate.getName().compare(0, 7, "texture") == 0) {
if (fnCandidate.getName().compare(0, 13, "textureGather") == 0) {
const char* feature = "texture gather function";
TString featureString = fnCandidate.getName() + "(...)";
const char* feature = featureString.c_str();
requireProfile(loc, ~EEsProfile, feature);
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature); // TODO: GL_ARB_gpu_shader5
int lastArgIndex = fnCandidate.getParamCount() - 1;
if (fnCandidate[lastArgIndex].type->getBasicType() == EbtInt && fnCandidate[lastArgIndex].type->isScalar()) {
// the last integral argument to a texture gather must be a constant int between 0 and 3
if (callNode.getSequence()[lastArgIndex]->getAsConstantUnion()) {
int value = callNode.getSequence()[lastArgIndex]->getAsConstantUnion()->getConstArray()[0].getIConst();
if (value < 0 || value > 3)
error(loc, "must be 0, 1, 2, or 3", "texture gather component", "");
int compArg = -1; // track which argument, if any, is the constant component argument
if (fnCandidate.getName().compare("textureGatherOffset") == 0) {
// GL_ARB_texture_gather is good enough for 2D non-shadow textures with no component argument
if (fnCandidate[0].type->getSampler().dim == Esd2D && ! fnCandidate[0].type->getSampler().shadow && fnCandidate.getParamCount() == 3)
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature);
else
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 3;
} else if (fnCandidate.getName().compare("textureGatherOffsets") == 0) {
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 3;
// check for constant offsets
int offsetArg = fnCandidate[0].type->getSampler().shadow ? 3 : 2;
if (! callNode.getSequence()[offsetArg]->getAsConstantUnion())
error(loc, "must be a compile-time constant:", feature, "offsets argument");
} else if (fnCandidate.getName().compare("textureGather") == 0) {
// More than two arguments needs gpu_shader5, and rectangular or shadow needs gpu_shader5,
// otherwise, need GL_ARB_texture_gather.
if (fnCandidate.getParamCount() > 2 || fnCandidate[0].type->getSampler().dim == EsdRect || fnCandidate[0].type->getSampler().shadow) {
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
if (! fnCandidate[0].type->getSampler().shadow)
compArg = 2;
} else
error(loc, "must be a constant", "texture gather component", "");
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature);
}
if (compArg > 0 && compArg < fnCandidate.getParamCount()) {
if (callNode.getSequence()[compArg]->getAsConstantUnion()) {
int value = callNode.getSequence()[compArg]->getAsConstantUnion()->getConstArray()[0].getIConst();
if (value < 0 || value > 3)
error(loc, "must be 0, 1, 2, or 3:", feature, "component argument");
} else
error(loc, "must be a compile-time constant:", feature, "component argument");
}
} else {
// this is only for functions not starting "textureGather"...

View File

@ -798,8 +798,9 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER2DRECT:
case SAMPLER2DRECTSHADOW:
afterType = true;
if (parseContext.profile == EEsProfile ||
(parseContext.profile != EEsProfile && parseContext.version < 140))
if (parseContext.profile == EEsProfile)
reservedWord();
else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionsTurnedOn(1, &GL_ARB_texture_rectangle))
reservedWord();
return keyword;

View File

@ -157,8 +157,9 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[GL_ARB_texture_rectangle] = EBhDisable;
extensionBehavior[GL_3DL_array_objects] = EBhDisable;
extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisable;
extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisablePartial;
extensionBehavior[GL_ARB_texture_gather] = EBhDisable;
extensionBehavior[GL_ARB_gpu_shader5] = EBhDisablePartial;
extensionBehavior[GL_ARB_separate_shader_objects] = EBhDisable;
}
@ -180,6 +181,7 @@ const char* TParseContext::getPreamble()
"#define GL_ARB_texture_rectangle 1\n"
"#define GL_ARB_shading_language_420pack 1\n"
"#define GL_ARB_texture_gather 1\n"
"#define GL_ARB_gpu_shader5 1\n"
"#define GL_ARB_separate_shader_objects 1\n";
}
}
@ -435,8 +437,11 @@ void TParseContext::updateExtensionBehavior(const char* extension, const char* b
}
return;
} else
} else {
if (iter->second == EBhDisablePartial)
warn(getCurrentLoc(), "extension is only partially supported:", "#extension", extension);
iter->second = behavior;
}
}
}

View File

@ -65,7 +65,8 @@ typedef enum {
EBhRequire,
EBhEnable,
EBhWarn,
EBhDisable
EBhDisable,
EBhDisablePartial // use as initial state of an extension that is only partially implemented
} TExtensionBehavior;
//
@ -82,6 +83,7 @@ const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";
const char* const GL_3DL_array_objects = "GL_3DL_array_objects";
const char* const GL_ARB_shading_language_420pack = "GL_ARB_shading_language_420pack";
const char* const GL_ARB_texture_gather = "GL_ARB_texture_gather";
const char* const GL_ARB_gpu_shader5 = "GL_ARB_gpu_shader5";
const char* const GL_ARB_separate_shader_objects = "GL_ARB_separate_shader_objects";
} // end namespace glslang

View File

@ -1717,29 +1717,21 @@ type_specifier_nonarray
$$.sampler.set(EbtUint, EsdCube, true);
}
| SAMPLER2DRECT {
parseContext.profileRequires($1.loc, ENoProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtSampler;
$$.sampler.set(EbtFloat, EsdRect);
}
| SAMPLER2DRECTSHADOW {
parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtSampler;
$$.sampler.set(EbtFloat, EsdRect, false, true);
}
| ISAMPLER2DRECT {
parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtSampler;
$$.sampler.set(EbtInt, EsdRect);
}
| USAMPLER2DRECT {
parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
$$.basicType = EbtSampler;
$$.sampler.set(EbtUint, EsdRect);