Finish GL_ARB_shading_language_420pack: *ProgramTexelOffset built-in constants. ...
authorJohn Kessenich <cepheus@frii.com>
Sun, 11 May 2014 01:07:31 +0000 (01:07 +0000)
committerJohn Kessenich <cepheus@frii.com>
Sun, 11 May 2014 01:07:31 +0000 (01:07 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@26602 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/420.vert
Test/430.vert
Test/baseResults/130.frag.out
Test/baseResults/420.vert.out
Test/baseResults/cppNest.vert.out
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/Intermediate.cpp
glslang/MachineIndependent/ShaderLang.cpp
glslang/MachineIndependent/Versions.cpp

index 9acc802..de3534f 100644 (file)
@@ -96,3 +96,6 @@ void bar23444()
     const float b = 2 * a1;
     int a = gl_MinProgramTexelOffset + gl_MaxProgramTexelOffset;
 }
+
+const int comma0 = (2, 3);  // ERROR
+int comma1[(2, 3)];   // ERROR
index 3b2ebf6..145aabf 100644 (file)
@@ -71,7 +71,7 @@ layout(std140) uniform blocke {
     layout(offset = 32) vec3   b;                          // ERROR\r
 } spinste;\r
 \r
-int aconste[gl_MaxTransformFeedbackBuffers];               // ERROR ??\r
+int aconste[gl_MaxTransformFeedbackBuffers];               // ERROR\r
 int bconste[gl_MaxTransformFeedbackInterleavedComponents]; // ERROR\r
 \r
 out bblck2 {\r
index 3190094..6b1dca5 100644 (file)
@@ -14,10 +14,7 @@ ERROR: 0:84: 'textureGatherOffset(...)' : not supported for this version or the
 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: 0:120: 'line continuation' : not supported for this version or the enabled extensions \r
-WARNING: 0:123: '#extension' : extension is only partially supported: GL_ARB_shading_language_420pack\r
 ERROR: 0:126: 'uniform block' : not supported for this version or the enabled extensions \r
-ERROR: 0:138: 'gl_MinProgramTexelOffset' : undeclared identifier \r
-ERROR: 0:138: 'gl_MaxProgramTexelOffset' : undeclared identifier \r
 ERROR: 0:140: 'length' : does not operate on this type: bool\r
 ERROR: 0:140: 'boolb' : can't use function syntax on variable \r
 ERROR: 0:141: 'length' : does not operate on this type: float\r
@@ -28,7 +25,7 @@ ERROR: 0:143: 'length' : method does not accept any arguments
 ERROR: 0:146: 'gl_FogFragCoord' : identifiers starting with "gl_" are reserved \r
 ERROR: 0:151: 'int' : must be qualified as flat in\r
 ERROR: 0:151: 'redeclaration' : cannot change the type of gl_FogFragCoord\r
-ERROR: 26 compilation errors.  No code generated.\r
+ERROR: 24 compilation errors.  No code generated.\r
 \r
 \r
 Shader version: 130\r
@@ -343,9 +340,8 @@ ERROR: node is still EOpNull!
 0:138          'a' (3-component vector of float)\r
 0:138          Constant:\r
 0:138            0 (const int)\r
-0:138        add (float)\r
-0:138          'gl_MinProgramTexelOffset' (float)\r
-0:138          'gl_MaxProgramTexelOffset' (float)\r
+0:138        Constant:\r
+0:138          -1.000000\r
 0:140      Constant:\r
 0:140        0.000000\r
 0:141      Constant:\r
@@ -698,9 +694,8 @@ ERROR: node is still EOpNull!
 0:138          'a' (3-component vector of float)\r
 0:138          Constant:\r
 0:138            0 (const int)\r
-0:138        add (float)\r
-0:138          'gl_MinProgramTexelOffset' (float)\r
-0:138          'gl_MaxProgramTexelOffset' (float)\r
+0:138        Constant:\r
+0:138          -1.000000\r
 0:140      Constant:\r
 0:140        0.000000\r
 0:141      Constant:\r
index b065ffc..0041a24 100644 (file)
@@ -31,9 +31,9 @@ ERROR: 0:76: 'binding' : sampler binding not less than gl_MaxCombinedTextureImag
 ERROR: 0:85: 'patch' : not supported in this stage: vertex\r
 ERROR: 0:85: '' : vertex input cannot be further qualified \r
 ERROR: 0:86: 'patch' : not supported in this stage: vertex\r
-ERROR: 0:97: 'gl_MinProgramTexelOffset' : undeclared identifier \r
-ERROR: 0:97: 'gl_MaxProgramTexelOffset' : undeclared identifier \r
-ERROR: 0:97: '=' :  cannot convert from 'float' to 'int'\r
+ERROR: 0:100: '=' : global const initializers must be constant 'const int'\r
+ERROR: 0:101: '' : constant expression required \r
+ERROR: 0:101: '' : array size must be a constant integer expression \r
 ERROR: 33 compilation errors.  No code generated.\r
 \r
 \r
@@ -141,6 +141,11 @@ ERROR: node is still EOpNull!
 0:96            Constant:\r
 0:96              2.000000\r
 0:96            'a1' (float)\r
+0:97      Sequence\r
+0:97        move second child to first child (int)\r
+0:97          'a' (int)\r
+0:97          Constant:\r
+0:97            -1 (const int)\r
 0:?   Linker Objects\r
 0:?     'v2' (smooth out 2-component vector of float)\r
 0:?     'bad' (in 10-element array of 4-component vector of float)\r
@@ -173,6 +178,8 @@ ERROR: node is still EOpNull!
 0:?     'anon@3' (out block{out implicitly-sized array of float gl_ClipDistance, })\r
 0:?     'patchIn' (patch in 4-component vector of float)\r
 0:?     'patchOut' (smooth patch out 4-component vector of float)\r
+0:?     'comma0' (int)\r
+0:?     'comma1' (1-element array of int)\r
 0:?     'gl_VertexID' (gl_VertexId int)\r
 0:?     'gl_InstanceID' (gl_InstanceId int)\r
 \r
@@ -284,6 +291,11 @@ ERROR: node is still EOpNull!
 0:96            Constant:\r
 0:96              2.000000\r
 0:96            'a1' (float)\r
+0:97      Sequence\r
+0:97        move second child to first child (int)\r
+0:97          'a' (int)\r
+0:97          Constant:\r
+0:97            -1 (const int)\r
 0:?   Linker Objects\r
 0:?     'v2' (smooth out 2-component vector of float)\r
 0:?     'bad' (in 10-element array of 4-component vector of float)\r
@@ -316,6 +328,8 @@ ERROR: node is still EOpNull!
 0:?     'anon@3' (out block{out 1-element array of float gl_ClipDistance, })\r
 0:?     'patchIn' (patch in 4-component vector of float)\r
 0:?     'patchOut' (smooth patch out 4-component vector of float)\r
+0:?     'comma0' (int)\r
+0:?     'comma1' (1-element array of int)\r
 0:?     'gl_VertexID' (gl_VertexId int)\r
 0:?     'gl_InstanceID' (gl_InstanceId int)\r
 \r
index d6d320e..4fbf61e 100644 (file)
@@ -64,8 +64,14 @@ ERROR: node is still EOpNull!
 0:175  Function Definition: foo985( (void)\r
 0:175    Function Parameters: \r
 0:175    Sequence\r
-0:175      Constant:\r
-0:175        6 (const int)\r
+0:175      add (int)\r
+0:175        Constant:\r
+0:175          2 (const int)\r
+0:175        Comma (int)\r
+0:175          Constant:\r
+0:175            3 (const int)\r
+0:175          Constant:\r
+0:175            4 (const int)\r
 0:?   Linker Objects\r
 0:?     'sum' (float)\r
 0:?     'selected4' (int)\r
@@ -132,8 +138,14 @@ ERROR: node is still EOpNull!
 0:175  Function Definition: foo985( (void)\r
 0:175    Function Parameters: \r
 0:175    Sequence\r
-0:175      Constant:\r
-0:175        6 (const int)\r
+0:175      add (int)\r
+0:175        Constant:\r
+0:175          2 (const int)\r
+0:175        Comma (int)\r
+0:175          Constant:\r
+0:175            3 (const int)\r
+0:175          Constant:\r
+0:175            4 (const int)\r
 0:?   Linker Objects\r
 0:?     'sum' (float)\r
 0:?     'selected4' (int)\r
index 9e01cdf..2ffa9e3 100644 (file)
@@ -1978,6 +1978,12 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
             s.append(builtInConstant);
             snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingComponents = %d;", resources.maxVaryingComponents);
             s.append(builtInConstant);
+
+            // GL_ARB_shading_language_420pack
+            snprintf(builtInConstant, maxSize, "const mediump int  gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
+            s.append(builtInConstant);
         }
 
         // geometry
@@ -2338,7 +2344,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
 }
 
 //
-// Add context-dependent (resource-specific) built-ins not yet handled.  These
+// Add context-dependent (resource-specific) built-ins not handled by the above.  These
 // would be ones that need to be programmatically added because they cannot 
 // be added by simple text strings.  For these, also
 // 1) Map built-in functions to operators, for those that will turn into an operation node
@@ -2352,9 +2358,12 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &GL_ARB_enhanced_layouts);
         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &GL_ARB_enhanced_layouts);
     }
+    if (profile != EEsProfile && version >= 130 && version < 420) {
+        symbolTable.setVariableExtensions("gl_MinProgramTexelOffset", 1, &GL_ARB_shading_language_420pack);
+        symbolTable.setVariableExtensions("gl_MaxProgramTexelOffset", 1, &GL_ARB_shading_language_420pack);
+    }
 
     switch(language) {
-
     case EShLangFragment:
         // Set up gl_FragData based on current array size.
         if (version == 100 || IncludeLegacy(version, profile) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
index 6143334..7a9514b 100644 (file)
@@ -96,7 +96,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
     }
     
     //
-    // Need a new node holding things together then.  Make
+    // Need a new node holding things together.  Make
     // one and promote it to the right type.
     //
     TIntermBinary* node = new TIntermBinary(op);
@@ -113,6 +113,7 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
         
     //
     // If they are both constants, they must be folded.
+    // (Unless it's the sequence (comma) operator, but that's handled in addComma().)
     //
 
     TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
@@ -716,18 +717,21 @@ TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nod
 
 TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc loc)
 {
-    if (left->getType().getQualifier().storage == EvqConst && 
-        right->getType().getQualifier().storage == EvqConst) {
+    // However, the lowest precedence operators of the sequence operator ( , ) and the assignment operators 
+    // ... are not included in the operators that can create a constant expression.
+    //
+    //if (left->getType().getQualifier().storage == EvqConst && 
+    //    right->getType().getQualifier().storage == EvqConst) {
 
-        return right;
-    } else {
-        TIntermTyped *commaAggregate = growAggregate(left, right, loc);
-        commaAggregate->getAsAggregate()->setOperator(EOpComma);
-        commaAggregate->setType(right->getType());
-        commaAggregate->getWritableType().getQualifier().makeTemporary();
+    //    return right;
+    //}
 
-        return commaAggregate;
-    }
+    TIntermTyped *commaAggregate = growAggregate(left, right, loc);
+    commaAggregate->getAsAggregate()->setOperator(EOpComma);
+    commaAggregate->setType(right->getType());
+    commaAggregate->getWritableType().getQualifier().makeTemporary();
+
+    return commaAggregate;
 }
 
 TIntermTyped* TIntermediate::addMethod(TIntermTyped* object, const TType& type, const TString* name, TSourceLoc loc)
index 943ede0..73b6276 100644 (file)
@@ -124,7 +124,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
                            TSymbolTable& symbolTable)
 {
     TIntermediate intermediate(language, version, profile);
-       
+    
     TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
     TPpContext ppContext(parseContext);
     TScanContext scanContext(parseContext);
@@ -181,7 +181,7 @@ void InitializeStageSymbolTable(TBuiltIns& builtIns, int version, EProfile profi
 bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable,  TSymbolTable** symbolTables, int version, EProfile profile)
 {
     TBuiltIns builtIns;
-       builtIns.initialize(version, profile);
+    builtIns.initialize(version, profile);
 
     // do the common tables
     InitializeSymbolTable(builtIns.getCommonString(), version, profile, EShLangVertex, infoSink, *commonTable[EPcGeneral]);
@@ -207,9 +207,9 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf
 {
     TBuiltIns builtIns;
     
-       builtIns.initialize(*resources, version, profile, language);
+    builtIns.initialize(*resources, version, profile, language);
     InitializeSymbolTable(builtIns.getCommonString(), version, profile, language, infoSink, symbolTable);
-       IdentifyBuiltIns(version, profile, language, symbolTable, *resources);
+    IdentifyBuiltIns(version, profile, language, symbolTable, *resources);
 
     return true;
 }
index e5721e3..6b0074f 100644 (file)
@@ -157,7 +157,7 @@ void TParseContext::initializeExtensionBehavior()
 
     extensionBehavior[GL_ARB_texture_rectangle]        = EBhDisable;
     extensionBehavior[GL_3DL_array_objects]            = EBhDisable;
-    extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisablePartial;
+    extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisable;
     extensionBehavior[GL_ARB_texture_gather]           = EBhDisable;
     extensionBehavior[GL_ARB_gpu_shader5]              = EBhDisablePartial;
     extensionBehavior[GL_ARB_separate_shader_objects]  = EBhDisable;