Tie "location = " to the right stages/versions/extensions. Also add "#define extensi...
authorJohn Kessenich <cepheus@frii.com>
Tue, 22 Oct 2013 00:21:04 +0000 (00:21 +0000)
committerJohn Kessenich <cepheus@frii.com>
Tue, 22 Oct 2013 00:21:04 +0000 (00:21 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23633 e7fa87d3-cd2b-0410-9028-fcbf551c1848

14 files changed:
Install/Windows/glslangValidator.exe
Test/400.frag
Test/430.comp
Test/430.vert [new file with mode: 0644]
Test/baseResults/300layout.frag.out
Test/baseResults/300layout.vert.out
Test/baseResults/400.frag.out
Test/baseResults/430.comp.out
Test/baseResults/430.vert.out [new file with mode: 0644]
Test/baseResults/specExamples.vert.out
Test/testlist
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/Versions.cpp
glslang/MachineIndependent/Versions.h

index 44ac8af..9cb8d50 100644 (file)
Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ
index f1e48c0..b2d8398 100644 (file)
@@ -22,3 +22,13 @@ void main()
     iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 1+2);
     iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(i));
 }
+
+layout(location = 4) in vec4 vl; // ERROR, not supported
+
+#ifdef GL_ARB_separate_shader_objects
+#extension GL_ARB_separate_shader_objects : enable
+#endif
+
+layout(location = 4) in vec4 vl2;
+
+layout(location = 3) uniform vec3 uv3;
index 05e7bdc..7905454 100644 (file)
@@ -8,3 +8,5 @@ void main()
        memoryBarrierImage();\r
        groupMemoryBarrier();\r
 }\r
+\r
+layout(location = 2) in vec3 v3;\r
diff --git a/Test/430.vert b/Test/430.vert
new file mode 100644 (file)
index 0000000..217eb23
--- /dev/null
@@ -0,0 +1,8 @@
+#version 430 core\r
+\r
+layout(location = 3) vec4 v4;  // ERROR\r
+\r
+layout(location = 3) uniform vec4 uv4;\r
+\r
+layout(location = 2) in   inb1 { vec4 v; } b1;  // ERROR\r
+layout(location = 2) out outb1 { vec4 v; } b2;  // ERROR\r
index ae7d9ab..814e3d1 100644 (file)
@@ -1,4 +1,4 @@
-ERROR: 0:4: 'input location layout qualifier' : not supported in this stage: fragment\r
+ERROR: 0:4: 'location qualifier on input' : not supported in this stage: fragment\r
 ERROR: 1 compilation errors.  No code generated.\r
 \r
 ERROR: node is still EOpNull!\r
index d0f8e43..e8d6c5d 100644 (file)
@@ -7,7 +7,7 @@ ERROR: 0:19: 'badf' : member of uniform block cannot have an auxiliary or interp
 ERROR: 0:20: 'badg' : member storage qualifier cannot contradict block storage qualifier \r
 ERROR: 0:28: 'T3' : nameless block contains a member that already has a name at global scope \r
 ERROR: 0:35: 'output block' : not supported with this profile: es\r
-ERROR: 0:39: 'output location layout qualifier' : not supported in this stage: vertex\r
+ERROR: 0:39: 'location qualifier on output' : not supported in this stage: vertex\r
 ERROR: 0:47: 'shared' : not supported with this profile: es\r
 ERROR: 0:47: 'shared' : not supported in this stage: vertex\r
 ERROR: 12 compilation errors.  No code generated.\r
index 8a60576..5fdb4fc 100644 (file)
@@ -1,7 +1,9 @@
 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: 2 compilation errors.  No code generated.\r
+ERROR: 0:26: 'location qualifier on input' : not supported for this version or the enabled extensions \r
+ERROR: 0:34: 'location qualifier on uniform or buffer' : not supported for this version or the enabled extensions \r
+ERROR: 4 compilation errors.  No code generated.\r
 \r
 ERROR: node is still EOpNull!\r
 0:10  Function Definition: main( (void)\r
@@ -110,4 +112,7 @@ ERROR: node is still EOpNull!
 0:?     'arrayedSampler' (uniform 5-element array of sampler2D)\r
 0:?     'samp2dr' (uniform usampler2DRect)\r
 0:?     'isamp2DA' (uniform isampler2DArray)\r
+0:?     'vl' (layout(location=4 ) smooth in 4-component vector of float)\r
+0:?     'vl2' (layout(location=4 ) smooth in 4-component vector of float)\r
+0:?     'uv3' (layout(location=3 ) uniform 3-component vector of float)\r
 \r
index fedcba8..e1f238a 100644 (file)
@@ -1,5 +1,8 @@
 Warning, version 430 is not yet complete; some version-specific features are present, but many are missing.\r
-0:? Sequence\r
+ERROR: 0:12: 'location qualifier on input' : not supported in this stage: compute\r
+ERROR: 1 compilation errors.  No code generated.\r
+\r
+ERROR: node is still EOpNull!\r
 0:3  Function Definition: main( (void)\r
 0:3    Function Parameters: \r
 0:5    Sequence\r
@@ -9,4 +12,5 @@ Warning, version 430 is not yet complete; some version-specific features are pre
 0:8      MemoryBarrierImage (void)\r
 0:9      GroupMemoryBarrier (void)\r
 0:?   Linker Objects\r
+0:?     'v3' (layout(location=2 ) in 3-component vector of float)\r
 \r
diff --git a/Test/baseResults/430.vert.out b/Test/baseResults/430.vert.out
new file mode 100644 (file)
index 0000000..26ca75e
--- /dev/null
@@ -0,0 +1,15 @@
+Warning, version 430 is not yet complete; some version-specific features are present, but many are missing.\r
+ERROR: 0:3: 'v4' : location qualifiers only appy to uniform, buffer, in, or out storage qualifiers \r
+ERROR: 0:7: 'location qualifier on input block' : not supported for this version or the enabled extensions \r
+ERROR: 0:8: 'location qualifier on output block' : not supported for this version or the enabled extensions \r
+ERROR: 3 compilation errors.  No code generated.\r
+\r
+ERROR: node is still EOpNull!\r
+0:?   Linker Objects\r
+0:?     'v4' (layout(location=3 ) 4-component vector of float)\r
+0:?     'uv4' (layout(location=3 ) uniform 4-component vector of float)\r
+0:?     'b1' (layout(location=2 ) in block)\r
+0:?     'b2' (layout(location=2 ) out block)\r
+0:?     'gl_VertexID' (gl_VertexId int)\r
+0:?     'gl_InstanceID' (gl_InstanceId int)\r
+\r
index 6562573..50603c5 100644 (file)
@@ -1,6 +1,6 @@
 Warning, version 430 is not yet complete; some version-specific features are present, but many are missing.\r
 ERROR: 0:23: 'transforms' : redeclaration of array with size \r
-ERROR: 0:29: 's' : location qualifiers only appy to uniform, in, or out storage qualifiers \r
+ERROR: 0:29: 's' : location qualifiers only appy to uniform, buffer, in, or out storage qualifiers \r
 ERROR: 0:31: 'triangles' : unrecognized layout identifier \r
 ERROR: 0:31: 'invocations' : there is no such layout identifier taking an assigned value \r
 ERROR: 0:33: 'lines' : unrecognized layout identifier \r
index b6b3ad7..0e0f2e1 100644 (file)
@@ -55,6 +55,7 @@ numeral.frag
 400.tese
 410.geom
 420.tese
+430.vert
 430.comp
 dce.frag
 ../../LunarGLASS/test/aggOps.frag
index c16c35d..87a3e93 100644 (file)
@@ -106,16 +106,6 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb,
     globalOutputDefaults.clear();
 }
 
-// Get code that is not part of a shared symbol table, is specific to this shader,
-// or needed by CPP (which does not use a shared symbol table).
-const char* TParseContext::getPreamble()
-{
-    if (profile == EEsProfile)
-        return "#define GL_ES 1\n";
-    else
-        return 0;
-}
-
 //
 // Parse an array of strings using yyparse, going through the
 // preprocessor to tokenize the shader strings, then through
@@ -2190,8 +2180,50 @@ void TParseContext::layoutCheck(TSourceLoc loc, const TSymbol& symbol)
     const TQualifier& qualifier = type.getQualifier();
     
     if (qualifier.hasLocation()) {
-        // TODO: location = functionality, when is it allowed?
+        switch (qualifier.storage) {
+        case EvqVaryingIn:
+        {
+            const char* feature = "location qualifier on input";
+            if (profile == EEsProfile)
+                requireStage(loc, EShLangVertex, feature);
+            requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
+            if (language == EShLangVertex)
+                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 330, 0, feature);
+            else
+                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 410, GL_ARB_separate_shader_objects, feature);
+            if (type.getBasicType() == EbtBlock)
+                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, 0 /* TODO ARB_enhanced_layouts*/, "location qualifier on input block");
+            break;
+        }
+        case EvqVaryingOut:
+        {
+            const char* feature = "location qualifier on output";
+            if (profile == EEsProfile)
+                requireStage(loc, EShLangFragment, feature);
+            requireStage(loc, (EShLanguageMask)~EShLangComputeMask, feature);
+            if (language == EShLangFragment)
+                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 330, 0, feature);
+            else
+                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 410, GL_ARB_separate_shader_objects, feature);
+            if (type.getBasicType() == EbtBlock)
+                profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, 0 /* TODO ARB_enhanced_layouts*/, "location qualifier on output block");
+            break;
+        }
+        case EvqUniform:
+        case EvqBuffer:
+        {
+            const char* feature = "location qualifier on uniform or buffer";
+            requireProfile(loc, ECoreProfile | ECompatibilityProfile, feature);
+            profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, 0, feature);
+            if (symbol.getAsVariable() == 0)
+                error(loc, "can only be used on variable declaration", feature, "");
+            break;
+        }
+        default:
+            break;
+        }
     }
+
     if (qualifier.hasBinding()) {
         // Binding checking, from the spec:
         //
@@ -2716,7 +2748,7 @@ void TParseContext::addBlock(TSourceLoc loc, TTypeList& typeList, const TString*
         requireProfile(loc, ECoreProfile | ECompatibilityProfile, "output block");
         break;
     default:
-        error(loc, "only uniform, in, or out interface blocks are supported", blockName->c_str(), "");
+        error(loc, "only uniform, buffer, in, or out blocks are supported", blockName->c_str(), "");
         return;
     }
 
@@ -2911,8 +2943,8 @@ void TParseContext::updateQualifierDefaults(TSourceLoc loc, TQualifier qualifier
 }
 
 //
-// Update defaults for qualifiers when declared with a type, and optionally an id.
-// (But, not the case of just a qualifier; this is called when a type is present.)
+// Update defaults for qualifiers when declared with a type, and optionally an identifier.
+// (But, not the case of just a qualifier; only when a type is present.)
 //
 void TParseContext::updateTypedDefaults(TSourceLoc loc, TQualifier qualifier, const TString* id)
 {
@@ -2925,27 +2957,24 @@ void TParseContext::updateTypedDefaults(TSourceLoc loc, TQualifier qualifier, co
         return;
     }
 
-    if (qualifier.storage == EvqUniform) {
+    switch (qualifier.storage) {
+    case EvqBuffer:
+    case EvqUniform:
         if (qualifier.layoutMatrix != ElmNone)
             error(loc, "cannot specify matrix layout on a variable declaration", id->c_str(), "");
         if (qualifier.layoutPacking != ElpNone)
             error(loc, "cannot specify packing on a variable declaration", id->c_str(), "");
-    } else if (qualifier.storage == EvqVaryingIn) {
-        if (qualifier.hasLocation()) {
-            if (profile == EEsProfile)
-                requireStage(loc, EShLangVertex, "input location layout qualifier");
-        }
-    } else if (qualifier.storage == EvqVaryingOut) {
-        if (qualifier.hasLocation()) {
-            if (profile == EEsProfile)
-                requireStage(loc, EShLangFragment, "output location layout qualifier");
-        }
-    } else {
+        break;
+    case EvqVaryingIn:
+        break;
+    case EvqVaryingOut:
+        break;
+    default:
         if (qualifier.layoutMatrix != ElmNone ||
             qualifier.layoutPacking != ElpNone)
-            error(loc, "layout qualifiers for matrix layout and packing only apply to uniform blocks", id->c_str(), "");
+            error(loc, "layout qualifiers for matrix layout and packing only apply to uniform or buffer blocks", id->c_str(), "");
         else if (qualifier.hasLocation())
-            error(loc, "location qualifiers only appy to uniform, in, or out storage qualifiers", id->c_str(), "");
+            error(loc, "location qualifiers only appy to uniform, buffer, in, or out storage qualifiers", id->c_str(), "");
     }
 
     if (cantHaveId)
index 7e0b493..10384d9 100644 (file)
 //    the first function below:
 // 
 //     extensionBehavior[XXX_extension_X] = EBhDisable;
+//
+// 3) Add any preprocessor directives etc. in the next function, TParseContext::getPreamble():
+//
+//           "#define XXX_extension_X 1\n"
+//
+//    The new-line is important, as that ends preprocess tokens.
 // 
-// 3) Insert a profile check in the feature's path (unless all profiles support the feature,
+// 4) Insert a profile check in the feature's path (unless all profiles support the feature,
 //    for some version level).  That is, call requireProfile() to constrain the profiles, e.g.:
 // 
 //         // ... in a path specific to Feature F...
@@ -86,7 +92,7 @@
 //                        ECoreProfile | ECompatibilityProfile,
 //                        "Feature F");
 // 
-// 4) For each profile that supports the feature, insert version/extension checks:
+// 5) For each profile that supports the feature, insert version/extension checks:
 // 
 //    The mostly likely scenario is that Feature F can only be used with a
 //    particular profile if XXX_extension_X is present or the version is
 // 
 //        ~EEsProfile
 //
-// 5) If built-in symbols are added by the extension, add them in Initialize.cpp; see
+// 6) If built-in symbols are added by the extension, add them in Initialize.cpp; see
 //    the comment at the top of that file for where to put them.
 //
 
@@ -142,6 +148,23 @@ void TParseContext::initializeExtensionBehavior()
     extensionBehavior[GL_3DL_array_objects]            = EBhDisable;
     extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisable;
     extensionBehavior[GL_ARB_texture_gather]           = EBhDisable;
+    extensionBehavior[GL_ARB_separate_shader_objects]  = EBhDisable;
+}
+
+// Get code that is not part of a shared symbol table, is specific to this shader,
+// or needed by the preprocessor (which does not use a shared symbol table).
+const char* TParseContext::getPreamble()
+{
+    if (profile == EEsProfile) {
+        return 
+            "#define GL_ES 1\n";
+    } else {
+        return 
+            "#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_separate_shader_objects 1\n";
+    }
 }
 
 //
index 44e81f3..bd0a5d0 100644 (file)
@@ -75,6 +75,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_separate_shader_objects  = "GL_ARB_separate_shader_objects";
 
 } // end namespace glslang