From 782aa830b686dde6203e60bb7f485fd2b0391eaf Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Wed, 12 Feb 2014 05:15:49 +0000
Subject: [PATCH] Correct which versions can support the extensions
 GL_ARB_separate_shader_objects and GL_ARB_shading_language_420pack.  They'd
 only gone back to 150, rather than 130/140.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25314 e7fa87d3-cd2b-0410-9028-fcbf551c1848
---
 Test/130.frag                              | 15 ++++++++
 Test/140.frag                              |  8 +++-
 Test/400.tese                              | 20 +++++-----
 Test/baseResults/120.frag.out              |  2 +-
 Test/baseResults/130.frag.out              | 43 +++++++++++++++++++++-
 Test/baseResults/140.frag.out              |  6 ++-
 glslang/Include/revision.h                 |  4 +-
 glslang/MachineIndependent/ParseHelper.cpp | 36 +++++++++---------
 glslang/MachineIndependent/Scan.cpp        |  6 +++
 glslang/MachineIndependent/glslang.y       |  8 ++--
 10 files changed, 111 insertions(+), 37 deletions(-)

diff --git a/Test/130.frag b/Test/130.frag
index 3569cf27b..7c6307508 100644
--- a/Test/130.frag
+++ b/Test/130.frag
@@ -116,3 +116,18 @@ void bar235()
     float f = texture(Scas, i, b.y);
     c = textureGrad(Isca, i, vec3(0.1), vec3(0.2));
 }
+
+#extension GL_ARB_shading_language_420pack : enable
+
+const int ai[3] = { 10, 23, 32 };
+layout(binding=0) uniform blockname { int a; } instanceName;  // ERROR
+uniform layout(binding=0) sampler2D bounds;
+
+void bar23444()
+{
+    mat4x3 m43;
+    float a1 = m43[3].y;
+    int a2 = m43.length();  // ERROR until shading_language_420pack is fully implemented
+    const float b = 2 * a1;
+    a.x = gl_MinProgramTexelOffset + gl_MaxProgramTexelOffset;    // ERROR until shading_language_420pack is fully implemented
+}
diff --git a/Test/140.frag b/Test/140.frag
index 1e29d4d4d..a252c2d9c 100644
--- a/Test/140.frag
+++ b/Test/140.frag
@@ -19,4 +19,10 @@ void main()
 
 in struct S { float f; } s; // ERROR
 
-float patch = 3.1;
\ No newline at end of file
+float patch = 3.1;
+
+layout(location=3) in vec4 vl;  // ERROR
+
+#extension GL_ARB_separate_shader_objects : enable
+
+layout(location=4) in vec4 vl2;
diff --git a/Test/400.tese b/Test/400.tese
index 42e3c4cad..e953ab5f1 100644
--- a/Test/400.tese
+++ b/Test/400.tese
@@ -51,16 +51,16 @@ patch sample in vec3 badp4;         // ERROR
 
 #extension GL_ARB_separate_shader_objects : enable
 
-in gl_PerVertex
-{
-float gl_ClipDistance[1];
-} gl_in[];                          // ERROR, no size
-
-in gl_PerVertex
-{
-float gl_ClipDistance[1];
-} gl_in[];
-
+in gl_PerVertex
+{
+float gl_ClipDistance[1];
+} gl_in[];                          // ERROR, no size
+
+in gl_PerVertex
+{
+float gl_ClipDistance[1];
+} gl_in[];
+
 layout(quads, cw) out;     // ERROR
 layout(triangles) out;     // ERROR
 layout(isolines) out;      // ERROR
diff --git a/Test/baseResults/120.frag.out b/Test/baseResults/120.frag.out
index 77e44d0d0..898015daa 100644
--- a/Test/baseResults/120.frag.out
+++ b/Test/baseResults/120.frag.out
@@ -17,7 +17,7 @@ ERROR: 0:79: ':' :  wrong operand types: no operation ':' exists that takes a le
 ERROR: 0:79: 'assign' :  cannot convert from '4X4 matrix of float' to 'fragColor 4-component vector of float'
 ERROR: 0:82: 'xr' : illegal - vector component fields not from the same set 
 ERROR: 0:83: 'xyxyx' : illegal vector field selection 
-ERROR: 0:83: 'scalar swizzle' : not supported with this profile: none
+ERROR: 0:83: 'scalar swizzle' : not supported for this version or the enabled extensions 
 ERROR: 0:83: 'xy' : vector field selection out of range 
 ERROR: 0:84: 'z' : vector field selection out of range 
 ERROR: 0:85: 'assign' :  l-value required 
diff --git a/Test/baseResults/130.frag.out b/Test/baseResults/130.frag.out
index 10f86800b..52be46365 100644
--- a/Test/baseResults/130.frag.out
+++ b/Test/baseResults/130.frag.out
@@ -14,7 +14,14 @@ ERROR: 0:81: 'textureGatherOffset(...)' : not supported for this version or the
 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.
+WARNING: 0:120: '#extension' : extension is only partially supported: GL_ARB_shading_language_420pack
+ERROR: 0:123: 'uniform block' : not supported for this version or the enabled extensions 
+ERROR: 0:130: '.' : field selection not allowed on matrix 
+ERROR: 0:130: 'm43' : can't use function syntax on variable 
+ERROR: 0:130: '=' :  cannot convert from 'const float' to 'int'
+ERROR: 0:132: 'gl_MinProgramTexelOffset' : undeclared identifier 
+ERROR: 0:132: 'gl_MaxProgramTexelOffset' : undeclared identifier 
+ERROR: 18 compilation errors.  No code generated.
 
 
 ERROR: node is still EOpNull!
@@ -284,6 +291,34 @@ ERROR: node is still EOpNull!
 0:117            0.200000
 0:117            0.200000
 0:117            0.200000
+0:126  Function Definition: bar23444( (void)
+0:126    Function Parameters: 
+0:?     Sequence
+0:129      Sequence
+0:129        move second child to first child (float)
+0:129          'a1' (float)
+0:129          direct index (float)
+0:129            direct index (3-component vector of float)
+0:129              'm43' (4X3 matrix of float)
+0:129              Constant:
+0:129                3 (const int)
+0:129            Constant:
+0:129              1 (const int)
+0:131      Sequence
+0:131        move second child to first child (float)
+0:131          'b' (const (read only) float)
+0:131          component-wise multiply (float)
+0:131            Constant:
+0:131              2.000000
+0:131            'a1' (float)
+0:132      move second child to first child (float)
+0:132        direct index (float)
+0:132          'a' (3-component vector of float)
+0:132          Constant:
+0:132            0 (const int)
+0:132        add (float)
+0:132          'gl_MinProgramTexelOffset' (float)
+0:132          'gl_MaxProgramTexelOffset' (float)
 0:?   Linker Objects
 0:?     'a' (3-component vector of float)
 0:?     'b' (float)
@@ -305,6 +340,12 @@ ERROR: node is still EOpNull!
 0:?     'Isca' (uniform isampler3DArray)
 0:?     'Usca' (uniform usamplerCubeArray)
 0:?     'Scas' (uniform samplerCubeArrayShadow)
+0:?     'ai' (const 3-element array of int)
+0:?       10 (const int)
+0:?       23 (const int)
+0:?       32 (const int)
+0:?     'instanceName' (layout(binding=0 column_major shared ) uniform block{layout(column_major shared ) uniform int a})
+0:?     'bounds' (layout(binding=0 ) uniform sampler2D)
 
 
 Linked fragment stage:
diff --git a/Test/baseResults/140.frag.out b/Test/baseResults/140.frag.out
index 6beb4c5b4..ba04a4eb5 100644
--- a/Test/baseResults/140.frag.out
+++ b/Test/baseResults/140.frag.out
@@ -3,7 +3,9 @@ Warning, version 140 is not yet complete; most features are present, but a few a
 WARNING: 0:3: varying deprecated in version 130; may be removed in future release
 ERROR: 0:17: '#error' : GL_ES is not set  
 ERROR: 0:20: 'fragment-shader struct input' : not supported for this version or the enabled extensions 
-ERROR: 2 compilation errors.  No code generated.
+ERROR: 0:24: 'location' : not supported for this version or the enabled extensions 
+ERROR: 0:24: 'location qualifier on input' : not supported for this version or the enabled extensions 
+ERROR: 4 compilation errors.  No code generated.
 
 
 ERROR: node is still EOpNull!
@@ -30,6 +32,8 @@ ERROR: node is still EOpNull!
 0:?     'gl_ClipDistance' (smooth in 5-element array of float)
 0:?     's' (smooth in structure{float f})
 0:?     'patch' (float)
+0:?     'vl' (layout(location=3 ) smooth in 4-component vector of float)
+0:?     'vl2' (layout(location=4 ) smooth in 4-component vector of float)
 
 
 Linked fragment stage:
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index 2084b06ab..8e56eb8e4 100644
--- a/glslang/Include/revision.h
+++ b/glslang/Include/revision.h
@@ -9,5 +9,5 @@
 // source have to figure out how to create revision.h just to get a build
 // going.  However, if it is not updated, it can be a version behind.
 
-#define GLSLANG_REVISION "25175"
-#define GLSLANG_DATE     "2014/01/30 19:42:25"
+#define GLSLANG_REVISION "25220"
+#define GLSLANG_DATE     "2014/02/03 09:28:23"
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index baf6e00e0..bb4560ea9 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -691,8 +691,8 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
     } else if (base->isVector() || base->isScalar()) {
         if (base->isScalar()) {
             const char* dotFeature = "scalar swizzle";
-            requireProfile(loc, ECoreProfile | ECompatibilityProfile, dotFeature);
-            profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shading_language_420pack, dotFeature);
+            requireProfile(loc, ~EEsProfile, dotFeature);
+            profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, dotFeature);
         }
 
         TVectorFields fields;
@@ -1863,7 +1863,7 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
         error(loc, "can only have one interpolation qualifier (flat, smooth, noperspective)", "", "");
 
     // Ordering
-    if (! force && version < 420) {
+    if (! force && version < 420 && ! extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)) {
         // non-function parameters
         if (src.invariant && (dst.isInterpolation() || dst.isAuxiliary() || dst.storage != EvqTemporary || dst.precision != EpqNone))
             error(loc, "invariant qualifier must appear first", "", "");
@@ -2317,8 +2317,8 @@ TSymbol* TParseContext::redeclareBuiltinVariable(TSourceLoc loc, const TString&
 void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes)
 {
     const char* feature = "built-in block redeclaration";
-    requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature);
-    profileRequires(loc, ECoreProfile | ECompatibilityProfile, 410, GL_ARB_separate_shader_objects, feature);
+    requireProfile(loc, ~EEsProfile, feature);
+    profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
 
     if (blockName != "gl_PerVertex" && blockName != "gl_PerFragment") {
         error(loc, "cannot redeclare block: ", "block declaration", blockName.c_str());
@@ -2863,16 +2863,16 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
             publicType.qualifier.layoutAlign = value;
         return;
     } else if (id == "location") {
-        requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "location");
-        profileRequires(loc, ECoreProfile | ECompatibilityProfile, 330, 0, "location");
+        profileRequires(loc, EEsProfile, 300, 0, "location");
+        profileRequires(loc, ~EEsProfile, 330, GL_ARB_separate_shader_objects, "location");
         if ((unsigned int)value >= TQualifier::layoutLocationEnd)
             error(loc, "location is too large", id.c_str(), "");
         else
             publicType.qualifier.layoutLocation = value;
         return;
     } else if (id == "binding") {
-        requireProfile(loc, ECoreProfile | ECompatibilityProfile, "binding");
-        profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shading_language_420pack, "binding");
+        requireProfile(loc, ~EEsProfile, "binding");
+        profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, "binding");
         if ((unsigned int)value >= TQualifier::layoutBindingEnd)
             error(loc, "binding is too large", id.c_str(), "");
         else
@@ -3182,9 +3182,9 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
                 requireStage(loc, EShLangVertex, feature);
             requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
             if (language == EShLangVertex)
-                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 330, 0, feature);
+                profileRequires(loc, ~EEsProfile, 330, GL_ARB_separate_shader_objects, feature);
             else
-                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 410, GL_ARB_separate_shader_objects, feature);
+                profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
             break;
         }
         case EvqVaryingOut:
@@ -3194,9 +3194,9 @@ void TParseContext::layoutQualifierCheck(TSourceLoc loc, const TQualifier& quali
                 requireStage(loc, EShLangFragment, feature);
             requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
             if (language == EShLangFragment)
-                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 330, 0, feature);
+                profileRequires(loc, ~EEsProfile, 330, GL_ARB_separate_shader_objects, feature);
             else
-                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 410, GL_ARB_separate_shader_objects, feature);
+                profileRequires(loc, ~EEsProfile, 410, GL_ARB_separate_shader_objects, feature);
             break;
         }
         case EvqUniform:
@@ -3542,8 +3542,8 @@ TIntermNode* TParseContext::executeInitializer(TSourceLoc loc, TString& identifi
     if (qualifier == EvqConst) {
         if (initializer->getType().getQualifier().storage != EvqConst) {
             const char* initFeature = "non-constant initializer";
-            requireProfile(loc, ECoreProfile | ECompatibilityProfile, initFeature);
-            profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shading_language_420pack, initFeature);
+            requireProfile(loc, ~EEsProfile, initFeature);
+            profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, initFeature);
             variable->getWritableType().getQualifier().storage = EvqConstReadOnly;
             qualifier = EvqConstReadOnly;
         }
@@ -3855,10 +3855,12 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
         profileRequires(loc, ENoProfile, 140, 0, "uniform block");
         break;
     case EvqVaryingIn:
-        requireProfile(loc, ECoreProfile | ECompatibilityProfile, "input block");
+        requireProfile(loc, ~EEsProfile, "input block");
+        profileRequires(loc, ~EEsProfile, 150, GL_ARB_separate_shader_objects, "input block");
         break;
     case EvqVaryingOut:
-        requireProfile(loc, ECoreProfile | ECompatibilityProfile, "output block");
+        requireProfile(loc, ~EEsProfile, "output block");
+        profileRequires(loc, ~EEsProfile, 150, GL_ARB_separate_shader_objects, "output block");
         break;
     default:
         error(loc, "only uniform, buffer, in, or out blocks are supported", blockName->c_str(), "");
diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp
index 8f528a5c9..fa2dd5b55 100644
--- a/glslang/MachineIndependent/Scan.cpp
+++ b/glslang/MachineIndependent/Scan.cpp
@@ -647,6 +647,12 @@ int TScanContext::tokenizeIdentifier()
         return keyword;
 
     case LAYOUT:
+        if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
+            (parseContext.profile != EEsProfile && parseContext.version < 140 &&
+            ! parseContext.extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)))
+            return identifierOrType();
+        return keyword;
+
     case SHARED:
         if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
             (parseContext.profile != EEsProfile && parseContext.version < 140))
diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y
index 11d603859..6b36fa4f7 100644
--- a/glslang/MachineIndependent/glslang.y
+++ b/glslang/MachineIndependent/glslang.y
@@ -2099,14 +2099,14 @@ initializer
     }
     | LEFT_BRACE initializer_list RIGHT_BRACE {
         const char* initFeature = "{ } style initializers";
-        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, initFeature);
-        parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shading_language_420pack, initFeature);
+        parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
+        parseContext.profileRequires($1.loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, initFeature);
         $$ = $2;
     }
     | LEFT_BRACE initializer_list COMMA RIGHT_BRACE {
         const char* initFeature = "{ } style initializers";
-        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, initFeature);
-        parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 420, GL_ARB_shading_language_420pack, initFeature);
+        parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
+        parseContext.profileRequires($1.loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, initFeature);
         $$ = $2;
     }
     ;
-- 
GitLab