Correct textureGather*() extension support:
authorJohn Kessenich <cepheus@frii.com>
Sat, 23 Nov 2013 21:10:51 +0000 (21:10 +0000)
committerJohn Kessenich <cepheus@frii.com>
Sat, 23 Nov 2013 21:10:51 +0000 (21:10 +0000)
 - 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

Test/130.frag
Test/400.frag
Test/baseResults/130.frag.out
Test/baseResults/400.frag.out
Test/baseResults/versionsErrors.frag.out
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/Scan.cpp
glslang/MachineIndependent/Versions.cpp
glslang/MachineIndependent/Versions.h
glslang/MachineIndependent/glslang.y

index 891bedd..251b756 100644 (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);
+}
index 49e460c..c8039f0 100644 (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
 }
index ae0773b..2dcb99e 100644 (file)
@@ -1,14 +1,20 @@
 130.frag\r
 Warning, version 130 is not yet complete; most features are present, but a few are missing.\r
-ERROR: 0:25: 'texture gather function' : not supported for this version or the enabled extensions \r
+ERROR: 0:25: 'textureGather(...)' : not supported for this version or the enabled extensions \r
 ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Color\r
 ERROR: 0:38: 'gl_Color' : redeclaring non-array as array \r
 ERROR: 0:39: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Color\r
-WARNING: 0:45: extension GL_ARB_texture_gather is being used for texture gather function\r
+WARNING: 0:45: extension GL_ARB_texture_gather is being used for textureGather(...)\r
 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)\r
 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)\r
 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)\r
-ERROR: 7 compilation errors.  No code generated.\r
+ERROR: 0:80: 'textureGatherOffset' : no matching overloaded function found \r
+ERROR: 0:80: 'assign' :  cannot convert from 'const float' to '4-component vector of float'\r
+ERROR: 0:81: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions \r
+ERROR: 0:84: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions \r
+ERROR: 0:85: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions \r
+WARNING: 0:88: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5\r
+ERROR: 12 compilation errors.  No code generated.\r
 \r
 \r
 ERROR: node is still EOpNull!\r
@@ -93,6 +99,123 @@ ERROR: node is still EOpNull!
 0:65        true (const bool)\r
 0:66      Constant:\r
 0:66        false (const bool)\r
+0:77  Function Definition: bar23( (void)\r
+0:77    Function Parameters: \r
+0:?     Sequence\r
+0:80      's' (4-component vector of float)\r
+0:81      move second child to first child (4-component vector of float)\r
+0:81        's' (4-component vector of float)\r
+0:81        Function Call: textureGatherOffset(sR21;vf2;vi2; (4-component vector of float)\r
+0:81          'samp2DR' (uniform sampler2DRect)\r
+0:81          Constant:\r
+0:81            0.300000\r
+0:81            0.300000\r
+0:81          Constant:\r
+0:81            1 (const int)\r
+0:81            1 (const int)\r
+0:82      move second child to first child (4-component vector of float)\r
+0:82        's' (4-component vector of float)\r
+0:82        Function Call: textureGatherOffset(s21;vf2;vi2; (4-component vector of float)\r
+0:82          'samp2D' (uniform sampler2D)\r
+0:82          Constant:\r
+0:82            0.300000\r
+0:82            0.300000\r
+0:82          Constant:\r
+0:82            1 (const int)\r
+0:82            1 (const int)\r
+0:83      move second child to first child (4-component vector of float)\r
+0:83        's' (4-component vector of float)\r
+0:83        Function Call: textureGatherOffset(sA21;vf3;vi2; (4-component vector of float)\r
+0:83          'samp2DA' (uniform sampler2DArray)\r
+0:83          Constant:\r
+0:83            0.300000\r
+0:83            0.300000\r
+0:83            0.300000\r
+0:83          Constant:\r
+0:83            1 (const int)\r
+0:83            1 (const int)\r
+0:84      move second child to first child (4-component vector of float)\r
+0:84        's' (4-component vector of float)\r
+0:84        Function Call: textureGatherOffset(sS21;vf2;f1;vi2; (4-component vector of float)\r
+0:84          'samp2DS' (uniform sampler2DShadow)\r
+0:84          Constant:\r
+0:84            0.300000\r
+0:84            0.300000\r
+0:84          Constant:\r
+0:84            1.300000\r
+0:84          Constant:\r
+0:84            1 (const int)\r
+0:84            1 (const int)\r
+0:85      move second child to first child (4-component vector of float)\r
+0:85        's' (4-component vector of float)\r
+0:85        Function Call: textureGatherOffset(s21;vf2;vi2;i1; (4-component vector of float)\r
+0:85          'samp2D' (uniform sampler2D)\r
+0:85          Constant:\r
+0:85            0.300000\r
+0:85            0.300000\r
+0:85          Constant:\r
+0:85            1 (const int)\r
+0:85            1 (const int)\r
+0:85          Constant:\r
+0:85            2 (const int)\r
+0:90  Function Definition: bar234( (void)\r
+0:90    Function Parameters: \r
+0:?     Sequence\r
+0:93      move second child to first child (4-component vector of float)\r
+0:93        's' (4-component vector of float)\r
+0:93        Function Call: textureGatherOffset(s21;vf2;vi2; (4-component vector of float)\r
+0:93          'samp2D' (uniform sampler2D)\r
+0:93          Constant:\r
+0:93            0.300000\r
+0:93            0.300000\r
+0:93          Constant:\r
+0:93            1 (const int)\r
+0:93            1 (const int)\r
+0:94      move second child to first child (4-component vector of float)\r
+0:94        's' (4-component vector of float)\r
+0:94        Function Call: textureGatherOffset(sA21;vf3;vi2; (4-component vector of float)\r
+0:94          'samp2DA' (uniform sampler2DArray)\r
+0:94          Constant:\r
+0:94            0.300000\r
+0:94            0.300000\r
+0:94            0.300000\r
+0:94          Constant:\r
+0:94            1 (const int)\r
+0:94            1 (const int)\r
+0:95      move second child to first child (4-component vector of float)\r
+0:95        's' (4-component vector of float)\r
+0:95        Function Call: textureGatherOffset(sR21;vf2;vi2; (4-component vector of float)\r
+0:95          'samp2DR' (uniform sampler2DRect)\r
+0:95          Constant:\r
+0:95            0.300000\r
+0:95            0.300000\r
+0:95          Constant:\r
+0:95            1 (const int)\r
+0:95            1 (const int)\r
+0:96      move second child to first child (4-component vector of float)\r
+0:96        's' (4-component vector of float)\r
+0:96        Function Call: textureGatherOffset(sS21;vf2;f1;vi2; (4-component vector of float)\r
+0:96          'samp2DS' (uniform sampler2DShadow)\r
+0:96          Constant:\r
+0:96            0.300000\r
+0:96            0.300000\r
+0:96          Constant:\r
+0:96            1.300000\r
+0:96          Constant:\r
+0:96            1 (const int)\r
+0:96            1 (const int)\r
+0:97      move second child to first child (4-component vector of float)\r
+0:97        's' (4-component vector of float)\r
+0:97        Function Call: textureGatherOffset(s21;vf2;vi2;i1; (4-component vector of float)\r
+0:97          'samp2D' (uniform sampler2D)\r
+0:97          Constant:\r
+0:97            0.300000\r
+0:97            0.300000\r
+0:97          Constant:\r
+0:97            1 (const int)\r
+0:97            1 (const int)\r
+0:97          Constant:\r
+0:97            2 (const int)\r
 0:?   Linker Objects\r
 0:?     'a' (3-component vector of float)\r
 0:?     'b' (float)\r
@@ -106,6 +229,10 @@ ERROR: node is still EOpNull!
 0:?     'sampC' (uniform samplerCube)\r
 0:?     'gl_Color' (smooth in 4-component vector of float)\r
 0:?     'gl_Color' (flat in 4-component vector of float)\r
+0:?     'samp2D' (uniform sampler2D)\r
+0:?     'samp2DS' (uniform sampler2DShadow)\r
+0:?     'samp2DR' (uniform sampler2DRect)\r
+0:?     'samp2DA' (uniform sampler2DArray)\r
 \r
 \r
 Linked fragment stage:\r
index 35cef8e..e6e3368 100644 (file)
@@ -1,18 +1,19 @@
 400.frag\r
 Warning, version 400 is not yet complete; some version-specific features are present, but many are missing.\r
-ERROR: 0:20: 'texture gather component' : must be a constant \r
-ERROR: 0:21: 'texture gather component' : must be 0, 1, 2, or 3 \r
-ERROR: 0:28: 'location qualifier on input' : not supported for this version or the enabled extensions \r
-ERROR: 0:36: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions \r
-ERROR: 0:38: 'redeclaration' : cannot apply layout qualifier to gl_Color\r
-ERROR: 0:39: 'redeclaration' : cannot change qualification of gl_ClipDistance\r
-ERROR: 0:41: 'gl_FragCoord' : cannot redeclare after use \r
-ERROR: 0:49: 'texel offset' : argument must be compile-time constant \r
-ERROR: 0:51: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
-ERROR: 0:51: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
-ERROR: 0:52: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
-ERROR: 0:52: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
-ERROR: 12 compilation errors.  No code generated.\r
+ERROR: 0:18: 'textureGatherOffsets(...)' : must be a compile-time constant: offsets argument\r
+ERROR: 0:22: 'textureGatherOffset(...)' : must be a compile-time constant: component argument\r
+ERROR: 0:23: 'textureGatherOffset(...)' : must be 0, 1, 2, or 3: component argument\r
+ERROR: 0:30: 'location qualifier on input' : not supported for this version or the enabled extensions \r
+ERROR: 0:38: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions \r
+ERROR: 0:40: 'redeclaration' : cannot apply layout qualifier to gl_Color\r
+ERROR: 0:41: 'redeclaration' : cannot change qualification of gl_ClipDistance\r
+ERROR: 0:43: 'gl_FragCoord' : cannot redeclare after use \r
+ERROR: 0:51: 'texel offset' : argument must be compile-time constant \r
+ERROR: 0:53: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
+ERROR: 0:53: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
+ERROR: 0:54: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
+ERROR: 0:54: 'texel offset' : value is out of range: [gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]\r
+ERROR: 13 compilation errors.  No code generated.\r
 \r
 \r
 gl_FragCoord pixel center is integer\r
@@ -37,63 +38,54 @@ ERROR: node is still EOpNull!
 0:14          'gl_ClipDistance' (smooth in unsized array of float)\r
 0:14          Constant:\r
 0:14            1 (const int)\r
-0:17      Sequence\r
-0:17        move second child to first child (4-component vector of uint)\r
-0:17          'uv4' (4-component vector of uint)\r
-0:17          Function Call: textureGatherOffsets(usR21;vf2;vi2[4];i1; (4-component vector of uint)\r
-0:17            'samp2dr' (uniform usampler2DRect)\r
-0:17            'c2D' (smooth in 2-component vector of float)\r
-0:17            'offsets' (4-element array of 2-component vector of int)\r
-0:17            Constant:\r
-0:17              2 (const int)\r
 0:18      Sequence\r
-0:18        move second child to first child (4-component vector of float)\r
-0:18          'v4' (4-component vector of float)\r
-0:18          Function Call: textureGather(s21;vf2; (4-component vector of float)\r
-0:18            direct index (sampler2D)\r
-0:18              'arrayedSampler' (uniform 5-element array of sampler2D)\r
-0:18              Constant:\r
-0:18                0 (const int)\r
+0:18        move second child to first child (4-component vector of uint)\r
+0:18          'uv4' (4-component vector of uint)\r
+0:18          Function Call: textureGatherOffsets(usR21;vf2;vi2[4];i1; (4-component vector of uint)\r
+0:18            'samp2dr' (uniform usampler2DRect)\r
 0:18            'c2D' (smooth in 2-component vector of float)\r
-0:19      Sequence\r
-0:19        move second child to first child (4-component vector of int)\r
-0:19          'iv4' (4-component vector of int)\r
-0:19          Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
-0:19            'isamp2DA' (uniform isampler2DArray)\r
-0:19            Constant:\r
-0:19              0.100000\r
-0:19              0.100000\r
-0:19              0.100000\r
-0:19            Constant:\r
-0:19              1 (const int)\r
-0:19              1 (const int)\r
-0:19            Constant:\r
-0:19              3 (const int)\r
-0:20      move second child to first child (4-component vector of int)\r
-0:20        'iv4' (4-component vector of int)\r
-0:20        Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
-0:20          'isamp2DA' (uniform isampler2DArray)\r
-0:20          Constant:\r
-0:20            0.100000\r
-0:20            0.100000\r
-0:20            0.100000\r
-0:20          Constant:\r
-0:20            1 (const int)\r
-0:20            1 (const int)\r
-0:20          'i' (flat in int)\r
-0:21      move second child to first child (4-component vector of int)\r
-0:21        'iv4' (4-component vector of int)\r
-0:21        Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
-0:21          'isamp2DA' (uniform isampler2DArray)\r
-0:21          Constant:\r
-0:21            0.100000\r
-0:21            0.100000\r
-0:21            0.100000\r
-0:21          Constant:\r
-0:21            1 (const int)\r
-0:21            1 (const int)\r
-0:21          Constant:\r
-0:21            4 (const int)\r
+0:18            'offsets' (4-element array of 2-component vector of int)\r
+0:18            Constant:\r
+0:18              2 (const int)\r
+0:19      move second child to first child (4-component vector of uint)\r
+0:19        'uv4' (4-component vector of uint)\r
+0:19        Function Call: textureGatherOffsets(usR21;vf2;vi2[4];i1; (4-component vector of uint)\r
+0:19          'samp2dr' (uniform usampler2DRect)\r
+0:19          'c2D' (smooth in 2-component vector of float)\r
+0:19          Constant:\r
+0:19            1 (const int)\r
+0:19            2 (const int)\r
+0:19            3 (const int)\r
+0:19            4 (const int)\r
+0:19            15 (const int)\r
+0:19            16 (const int)\r
+0:19            -2 (const int)\r
+0:19            0 (const int)\r
+0:19          Constant:\r
+0:19            2 (const int)\r
+0:20      Sequence\r
+0:20        move second child to first child (4-component vector of float)\r
+0:20          'v4' (4-component vector of float)\r
+0:20          Function Call: textureGather(s21;vf2; (4-component vector of float)\r
+0:20            direct index (sampler2D)\r
+0:20              'arrayedSampler' (uniform 5-element array of sampler2D)\r
+0:20              Constant:\r
+0:20                0 (const int)\r
+0:20            'c2D' (smooth in 2-component vector of float)\r
+0:21      Sequence\r
+0:21        move second child to first child (4-component vector of int)\r
+0:21          'iv4' (4-component vector of int)\r
+0:21          Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
+0:21            'isamp2DA' (uniform isampler2DArray)\r
+0:21            Constant:\r
+0:21              0.100000\r
+0:21              0.100000\r
+0:21              0.100000\r
+0:21            Constant:\r
+0:21              1 (const int)\r
+0:21              1 (const int)\r
+0:21            Constant:\r
+0:21              3 (const int)\r
 0:22      move second child to first child (4-component vector of int)\r
 0:22        'iv4' (4-component vector of int)\r
 0:22        Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
@@ -105,48 +97,50 @@ ERROR: node is still EOpNull!
 0:22          Constant:\r
 0:22            1 (const int)\r
 0:22            1 (const int)\r
-0:22          Constant:\r
-0:22            3 (const int)\r
+0:22          'i' (flat in int)\r
 0:23      move second child to first child (4-component vector of int)\r
 0:23        'iv4' (4-component vector of int)\r
-0:23        Function Call: textureGatherOffset(isA21;vf3;vi2; (4-component vector of int)\r
+0:23        Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
 0:23          'isamp2DA' (uniform isampler2DArray)\r
 0:23          Constant:\r
 0:23            0.100000\r
 0:23            0.100000\r
 0:23            0.100000\r
-0:23          Construct ivec2 (2-component vector of int)\r
-0:23            'i' (flat in int)\r
-0:25      Sequence\r
-0:25        move second child to first child (4-component vector of float)\r
-0:25          'c' (4-component vector of float)\r
-0:25          'gl_FragCoord' (gl_FragCoord 4-component vector of float)\r
-0:45  Function Definition: foo23( (void)\r
-0:45    Function Parameters: \r
+0:23          Constant:\r
+0:23            1 (const int)\r
+0:23            1 (const int)\r
+0:23          Constant:\r
+0:23            4 (const int)\r
+0:24      move second child to first child (4-component vector of int)\r
+0:24        'iv4' (4-component vector of int)\r
+0:24        Function Call: textureGatherOffset(isA21;vf3;vi2;i1; (4-component vector of int)\r
+0:24          'isamp2DA' (uniform isampler2DArray)\r
+0:24          Constant:\r
+0:24            0.100000\r
+0:24            0.100000\r
+0:24            0.100000\r
+0:24          Constant:\r
+0:24            1 (const int)\r
+0:24            1 (const int)\r
+0:24          Constant:\r
+0:24            3 (const int)\r
+0:25      move second child to first child (4-component vector of int)\r
+0:25        'iv4' (4-component vector of int)\r
+0:25        Function Call: textureGatherOffset(isA21;vf3;vi2; (4-component vector of int)\r
+0:25          'isamp2DA' (uniform isampler2DArray)\r
+0:25          Constant:\r
+0:25            0.100000\r
+0:25            0.100000\r
+0:25            0.100000\r
+0:25          Construct ivec2 (2-component vector of int)\r
+0:25            'i' (flat in int)\r
+0:27      Sequence\r
+0:27        move second child to first child (4-component vector of float)\r
+0:27          'c' (4-component vector of float)\r
+0:27          'gl_FragCoord' (gl_FragCoord 4-component vector of float)\r
+0:47  Function Definition: foo23( (void)\r
+0:47    Function Parameters: \r
 0:?     Sequence\r
-0:49      Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)\r
-0:49        'u2drs' (uniform sampler2DRectShadow)\r
-0:49        'outp' (out 4-component vector of float)\r
-0:49        Constant:\r
-0:49          0.000000\r
-0:49          0.000000\r
-0:49        Constant:\r
-0:49          0.000000\r
-0:49          0.000000\r
-0:49        Convert float to int (2-component vector of int)\r
-0:49          'c2D' (smooth in 2-component vector of float)\r
-0:50      Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)\r
-0:50        'u2drs' (uniform sampler2DRectShadow)\r
-0:50        'outp' (out 4-component vector of float)\r
-0:50        Constant:\r
-0:50          0.000000\r
-0:50          0.000000\r
-0:50        Constant:\r
-0:50          0.000000\r
-0:50          0.000000\r
-0:50        Constant:\r
-0:50          3 (const int)\r
-0:50          4 (const int)\r
 0:51      Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)\r
 0:51        'u2drs' (uniform sampler2DRectShadow)\r
 0:51        'outp' (out 4-component vector of float)\r
@@ -156,9 +150,8 @@ ERROR: node is still EOpNull!
 0:51        Constant:\r
 0:51          0.000000\r
 0:51          0.000000\r
-0:51        Constant:\r
-0:51          15 (const int)\r
-0:51          16 (const int)\r
+0:51        Convert float to int (2-component vector of int)\r
+0:51          'c2D' (smooth in 2-component vector of float)\r
 0:52      Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)\r
 0:52        'u2drs' (uniform sampler2DRectShadow)\r
 0:52        'outp' (out 4-component vector of float)\r
@@ -169,8 +162,32 @@ ERROR: node is still EOpNull!
 0:52          0.000000\r
 0:52          0.000000\r
 0:52        Constant:\r
-0:52          -10 (const int)\r
-0:52          20 (const int)\r
+0:52          3 (const int)\r
+0:52          4 (const int)\r
+0:53      Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)\r
+0:53        'u2drs' (uniform sampler2DRectShadow)\r
+0:53        'outp' (out 4-component vector of float)\r
+0:53        Constant:\r
+0:53          0.000000\r
+0:53          0.000000\r
+0:53        Constant:\r
+0:53          0.000000\r
+0:53          0.000000\r
+0:53        Constant:\r
+0:53          15 (const int)\r
+0:53          16 (const int)\r
+0:54      Function Call: textureProjGradOffset(sSR21;vf4;vf2;vf2;vi2; (float)\r
+0:54        'u2drs' (uniform sampler2DRectShadow)\r
+0:54        'outp' (out 4-component vector of float)\r
+0:54        Constant:\r
+0:54          0.000000\r
+0:54          0.000000\r
+0:54        Constant:\r
+0:54          0.000000\r
+0:54          0.000000\r
+0:54        Constant:\r
+0:54          -10 (const int)\r
+0:54          20 (const int)\r
 0:?   Linker Objects\r
 0:?     'c2D' (smooth in 2-component vector of float)\r
 0:?     'i' (flat in int)\r
index 034e065..91f035b 100644 (file)
@@ -2,9 +2,8 @@ versionsErrors.frag
 ERROR: #version: versions before 150 do not allow a profile token\r
 ERROR: 0:38: 'attribute' : not supported in this stage: fragment\r
 ERROR: 0:40: 'sampler2DRect' : Reserved word. \r
-ERROR: 0:40: 'rectangle texture' : not supported for this version or the enabled extensions \r
 ERROR: 0:44: 'floating-point suffix' : not supported for this version or the enabled extensions \r
-ERROR: 5 compilation errors.  No code generated.\r
+ERROR: 4 compilation errors.  No code generated.\r
 \r
 \r
 ERROR: node is still EOpNull!\r
index d825e9f..cbc04b6 100644 (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];
 
index a126ec7..0c80c18 100644 (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();
+
+            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
+                    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", "texture gather component", "");
+                        error(loc, "must be 0, 1, 2, or 3:", feature, "component argument");
                 } else
-                    error(loc, "must be a constant", "texture gather component", "");
+                    error(loc, "must be a compile-time constant:", feature, "component argument");
             }
         } else {
             // this is only for functions not starting "textureGather"...
index dc1692b..2c1eb54 100644 (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;
 
index 36aa151..2735e95 100644 (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;
+        }
     }
 }
 
index 3c8619d..e84d69b 100644 (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
index 6767dd9..4c81bf8 100644 (file)
@@ -1717,29 +1717,21 @@ type_specifier_nonarray
         $$.sampler.set(EbtUint, EsdCube, true);\r
     }\r
     | SAMPLER2DRECT {\r
-        parseContext.profileRequires($1.loc, ENoProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");\r
-\r
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());\r
         $$.basicType = EbtSampler;\r
         $$.sampler.set(EbtFloat, EsdRect);\r
     }\r
     | SAMPLER2DRECTSHADOW {\r
-        parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");\r
-\r
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());\r
         $$.basicType = EbtSampler;\r
         $$.sampler.set(EbtFloat, EsdRect, false, true);\r
     }\r
     | ISAMPLER2DRECT {\r
-        parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");\r
-\r
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());\r
         $$.basicType = EbtSampler;\r
         $$.sampler.set(EbtInt, EsdRect);\r
     }\r
     | USAMPLER2DRECT {\r
-        parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");\r
-\r
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());\r
         $$.basicType = EbtSampler;\r
         $$.sampler.set(EbtUint, EsdRect);\r