GL_ARB_enhanced_layouts, final. #extension tests, built-in constants, and bug fix...
authorJohn Kessenich <cepheus@frii.com>
Mon, 3 Feb 2014 16:28:23 +0000 (16:28 +0000)
committerJohn Kessenich <cepheus@frii.com>
Mon, 3 Feb 2014 16:28:23 +0000 (16:28 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25220 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Test/430.vert
Test/440.frag
Test/baseResults/430.vert.out
Test/baseResults/440.frag.out
Todo.txt
glslang/Include/revision.h
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/ParseHelper.cpp

index bde1231..3b2ebf6 100644 (file)
@@ -44,4 +44,101 @@ layout(location = 53) out float cg; // ERROR, collision at 31
 layout(location = 10) in vec4 alias1;\r
 layout(location = 10) in vec4 alias2;  // okay for vertex input on desktop\r
 \r
-out float gl_ClipDistance[17];  // ERROR, size too big
\ No newline at end of file
+out float gl_ClipDistance[17];  // ERROR, size too big\r
+\r
+// enhanced_layouts (most tests are in 440.*)\r
+\r
+layout(location = start*start - 2 - 4) in vec4 v6e;    // ERROR\r
+\r
+layout(location = 28) in inblock2e {\r
+    layout(location = 25) float f2;                     // ERROR\r
+} ininst2e;\r
+\r
+in ublock4e {\r
+    layout(location = 50) float f1;                      // ERROR\r
+    layout(location = 51) float f2;                      // ERROR\r
+} in4e;\r
+\r
+layout(align=16, std140) uniform  ubl4e { int a; } inst4e;// ERROR\r
+\r
+layout(align=32) uniform ubl9e {                          // ERROR\r
+    layout(offset=12, align=4) float f;                   // ERROR\r
+    layout(offset=20) float g;                            // ERROR\r
+} inst9e;\r
+\r
+layout(std140) uniform blocke {\r
+                        vec4   a;\r
+    layout(offset = 32) vec3   b;                          // ERROR\r
+} spinste;\r
+\r
+int aconste[gl_MaxTransformFeedbackBuffers];               // ERROR ??\r
+int bconste[gl_MaxTransformFeedbackInterleavedComponents]; // ERROR\r
+\r
+out bblck2 {\r
+    layout(xfb_offset=64) vec4 bbv;                              // ERROR\r
+} bbinst2;\r
+\r
+layout(xfb_buffer = 3, xfb_stride = 64) out;                     // ERROR\r
+\r
+layout(xfb_buffer=2, xfb_offset=48, xfb_stride=80) out vec4 bge; // ERROR\r
+layout(              xfb_offset=32, xfb_stride=64) out vec4 bhe; // ERROR\r
+\r
+layout(xfb_stride=80, xfb_buffer=2, xfb_offset=16) out bblck4e { // ERROR\r
+    vec4 bbv1;\r
+    vec4 bbv2;\r
+} bbinst4e;\r
+\r
+out bblck5e {\r
+    layout(xfb_offset=0) vec4 bbv1;                               // ERROR\r
+    layout(xfb_stride=64, xfb_buffer=3, xfb_offset=48) vec4 bbv2; // ERROR\r
+} bbinst5e;\r
+\r
+#extension GL_ARB_enhanced_layouts : enable\r
+\r
+layout(align=16, std140) uniform  ubl4 { int a; } inst4;\r
+layout(std430) uniform;\r
+\r
+layout(align=32) uniform ubl9 {\r
+    layout(offset=12, align=4) float f;\r
+    layout(offset=20) float g;\r
+} inst9;\r
+\r
+layout(std140) uniform block {\r
+                        vec4   a;     // a takes offsets 0-15\r
+    layout(offset = 32) vec3   b;     // b takes offsets 32-43\r
+} spinst;\r
+\r
+int aconst[gl_MaxTransformFeedbackBuffers];\r
+int bconst[gl_MaxTransformFeedbackInterleavedComponents];\r
+\r
+const int start2 = 5;\r
+layout(location = start2 * start2 - 2 - 4) in vec4 v6;\r
+\r
+layout(location = 28) in inblock2 {\r
+    bool b1;\r
+    float f1;\r
+    layout(location = 25) float f2;\r
+} ininst2;\r
+\r
+in ublock4 {\r
+    layout(location = 50) float f1;\r
+    layout(location = 51) float f2;\r
+} in4;\r
+\r
+out bblck2g {\r
+    layout(xfb_offset=64) vec4 bbv;\r
+} bbinst2g;\r
+\r
+layout(xfb_buffer = 1, xfb_stride = 80) out;  // default buffer is 3\r
+\r
+layout(xfb_buffer=1, xfb_offset=48, xfb_stride=80) out vec4 bg;\r
+layout(              xfb_offset=32, xfb_stride=80) out vec4 bh;\r
+\r
+layout(xfb_stride=80, xfb_buffer=1, xfb_offset=16) out bblck4 {\r
+    vec4 bbv1;\r
+} bbinst4;\r
+\r
+out bblck5 {\r
+    layout(xfb_offset=0) vec4 bbv1;\r
+    layout(xfb_stride=80, xfb_buffer=1, xfb_offset=64) vec4 bbv2;\r
+} bbinst5;\r
index a32706c..818d3ff 100644 (file)
@@ -134,3 +134,6 @@ layout(std430, align = 128) uniform block24301 {
     float  h;\r
     dvec3  i;\r
 } specExample4301;\r
+\r
+int aconst[gl_MaxTransformFeedbackBuffers];\r
+int bconst[gl_MaxTransformFeedbackInterleavedComponents];\r
index 9176bfa..8c5ad3b 100644 (file)
@@ -13,9 +13,41 @@ ERROR: 0:30: '' : cannot use layout qualifiers on a function parameter
 ERROR: 0:31: '' : cannot use auxiliary or interpolation qualifiers on a function parameter \r
 ERROR: 0:42: 'location' : overlapping use of location 53\r
 ERROR: 0:47: 'gl_ClipDistance array size' : must be less than gl_MaxClipDistances (8)\r
-ERROR: 13 compilation errors.  No code generated.\r
+ERROR: 0:51: 'start' : undeclared identifier \r
+ERROR: 0:51: '' : constant expression required \r
+ERROR: 0:51: 'layout-id value' : scalar integer expression required \r
+ERROR: 0:54: 'location on block member' : not supported for this version or the enabled extensions \r
+ERROR: 0:58: 'location on block member' : not supported for this version or the enabled extensions \r
+ERROR: 0:59: 'location on block member' : not supported for this version or the enabled extensions \r
+ERROR: 0:62: 'uniform buffer-member align' : not supported for this version or the enabled extensions \r
+ERROR: 0:64: 'uniform buffer-member align' : not supported for this version or the enabled extensions \r
+ERROR: 0:65: 'uniform buffer-member offset' : not supported for this version or the enabled extensions \r
+ERROR: 0:65: 'uniform buffer-member align' : not supported for this version or the enabled extensions \r
+ERROR: 0:66: 'uniform buffer-member offset' : not supported for this version or the enabled extensions \r
+ERROR: 0:64: 'offset/align' : can only be used with std140 or std430 layout packing \r
+ERROR: 0:65: 'align' : can only be used with std140 or std430 layout packing \r
+ERROR: 0:71: 'uniform buffer-member offset' : not supported for this version or the enabled extensions \r
+ERROR: 0:74: 'gl_MaxTransformFeedbackBuffers' : required extension not requested: GL_ARB_enhanced_layouts\r
+ERROR: 0:75: 'gl_MaxTransformFeedbackInterleavedComponents' : required extension not requested: GL_ARB_enhanced_layouts\r
+ERROR: 0:78: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:81: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:81: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:83: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:83: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:83: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:84: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:84: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:86: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:86: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:86: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:92: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:93: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:93: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 0:93: 'transform feedback qualifier' : not supported for this version or the enabled extensions \r
+ERROR: 44 compilation errors.  No code generated.\r
 \r
 \r
+in xfb mode\r
 ERROR: node is still EOpNull!\r
 0:14  Function Definition: foo( (void)\r
 0:14    Function Parameters: \r
@@ -47,6 +79,34 @@ ERROR: node is still EOpNull!
 0:?     'cg' (layout(location=53 ) smooth out float)\r
 0:?     'alias1' (layout(location=10 ) in 4-component vector of float)\r
 0:?     'alias2' (layout(location=10 ) in 4-component vector of float)\r
+0:?     'v6e' (layout(location=0 ) in 4-component vector of float)\r
+0:?     'ininst2e' (in block{layout(location=25 ) in float f2})\r
+0:?     'in4e' (in block{layout(location=50 ) in float f1, layout(location=51 ) in float f2})\r
+0:?     'inst4e' (layout(column_major std140 align=16 ) uniform block{layout(column_major std140 offset=0 align=16 ) uniform int a})\r
+0:?     'inst9e' (layout(column_major shared align=32 ) uniform block{layout(column_major shared offset=12 align=4 ) uniform float f, layout(column_major shared offset=20 ) uniform float g})\r
+0:?     'spinste' (layout(column_major std140 ) uniform block{layout(column_major std140 offset=0 ) uniform 4-component vector of float a, layout(column_major std140 offset=32 ) uniform 3-component vector of float b})\r
+0:?     'aconste' (4-element array of int)\r
+0:?     'bconste' (64-element array of int)\r
+0:?     'bbinst2' (out block{layout(xfb_buffer=0 xfb_offset=64 ) out 4-component vector of float bbv})\r
+0:?     'bge' (layout(xfb_buffer=2 xfb_offset=48 xfb_stride=80 ) smooth out 4-component vector of float)\r
+0:?     'bhe' (layout(xfb_buffer=3 xfb_offset=32 xfb_stride=64 ) smooth out 4-component vector of float)\r
+0:?     'bbinst4e' (layout(xfb_stride=80 ) out block{layout(xfb_buffer=2 xfb_offset=16 ) out 4-component vector of float bbv1, layout(xfb_buffer=2 xfb_offset=32 ) out 4-component vector of float bbv2})\r
+0:?     'bbinst5e' (out block{layout(xfb_buffer=3 xfb_offset=0 ) out 4-component vector of float bbv1, layout(xfb_buffer=3 xfb_offset=48 xfb_stride=64 ) out 4-component vector of float bbv2})\r
+0:?     'inst4' (layout(column_major std140 align=16 ) uniform block{layout(column_major std140 offset=0 align=16 ) uniform int a})\r
+0:?     'inst9' (layout(column_major std430 align=32 ) uniform block{layout(column_major std430 offset=12 align=4 ) uniform float f, layout(column_major std430 offset=20 align=32 ) uniform float g})\r
+0:?     'spinst' (layout(column_major std140 ) uniform block{layout(column_major std140 offset=0 ) uniform 4-component vector of float a, layout(column_major std140 offset=32 ) uniform 3-component vector of float b})\r
+0:?     'aconst' (4-element array of int)\r
+0:?     'bconst' (64-element array of int)\r
+0:?     'start2' (const int)\r
+0:?       5 (const int)\r
+0:?     'v6' (layout(location=19 ) in 4-component vector of float)\r
+0:?     'ininst2' (in block{layout(location=28 component=0 ) in bool b1, layout(location=29 component=0 ) in float f1, layout(location=25 ) in float f2})\r
+0:?     'in4' (in block{layout(location=50 ) in float f1, layout(location=51 ) in float f2})\r
+0:?     'bbinst2g' (out block{layout(xfb_buffer=3 xfb_offset=64 ) out 4-component vector of float bbv})\r
+0:?     'bg' (layout(xfb_buffer=1 xfb_offset=48 xfb_stride=80 ) smooth out 4-component vector of float)\r
+0:?     'bh' (layout(xfb_buffer=1 xfb_offset=32 xfb_stride=80 ) smooth out 4-component vector of float)\r
+0:?     'bbinst4' (layout(xfb_stride=80 ) out block{layout(xfb_buffer=1 xfb_offset=16 ) out 4-component vector of float bbv1})\r
+0:?     'bbinst5' (out block{layout(xfb_buffer=1 xfb_offset=0 ) out 4-component vector of float bbv1, layout(xfb_buffer=1 xfb_offset=64 xfb_stride=80 ) out 4-component vector of float bbv2})\r
 0:?     'gl_VertexID' (gl_VertexId int)\r
 0:?     'gl_InstanceID' (gl_InstanceId int)\r
 \r
@@ -54,5 +114,8 @@ ERROR: node is still EOpNull!
 Linked vertex stage:\r
 \r
 ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point\r
+ERROR: Linking vertex stage: xfb_stride is too small to hold all buffer entries:\r
+ERROR:     xfb_buffer 3, xfb_stride 64, minimum stride needed: 80\r
 \r
+in xfb mode\r
 \r
index c020f07..0da5c06 100644 (file)
@@ -82,6 +82,8 @@ ERROR: node is still EOpNull!
 0:?     'specExample430' (layout(column_major std430 ) uniform block{layout(column_major std430 offset=0 ) uniform 4-component vector of float a, layout(column_major std430 offset=32 ) uniform 3-component vector of float b, layout(column_major std430 offset=48 ) uniform 2-component vector of float d, layout(column_major std430 offset=64 align=16 ) uniform float e, layout(column_major std430 offset=72 align=2 ) uniform double f, layout(column_major std430 offset=80 ) uniform float h, layout(column_major std430 offset=128 align=64 ) uniform 3-component vector of double i, layout(column_major std430 offset=168 align=8 ) uniform float j})\r
 0:?     'specExample4300' (layout(column_major std430 align=128 ) uniform block{layout(column_major std430 offset=0 align=128 ) uniform 4-component vector of float a, layout(column_major std430 offset=128 align=128 ) uniform 3-component vector of float b, layout(column_major std430 offset=256 align=128 ) uniform 2-component vector of float d, layout(column_major std430 offset=384 align=128 ) uniform float e, layout(column_major std430 offset=512 align=128 ) uniform double f, layout(column_major std430 offset=640 align=128 ) uniform float h, layout(column_major std430 offset=768 align=128 ) uniform 3-component vector of double i})\r
 0:?     'specExample4301' (layout(column_major std430 align=128 ) uniform block{layout(column_major std430 offset=0 align=128 ) uniform 4-component vector of float a, layout(column_major std430 offset=128 align=128 ) uniform 3-component vector of float b, layout(column_major std430 offset=256 align=128 ) uniform 2-component vector of float d, layout(column_major std430 offset=512 align=128 ) uniform float e, layout(column_major std430 offset=520 align=8 ) uniform double f, layout(column_major std430 offset=640 align=128 ) uniform float h, layout(column_major std430 offset=768 align=128 ) uniform 3-component vector of double i})\r
+0:?     'aconst' (4-element array of int)\r
+0:?     'bconst' (64-element array of int)\r
 \r
 \r
 Linked fragment stage:\r
index 83c1a8c..49fe4c9 100644 (file)
--- a/Todo.txt
+++ b/Todo.txt
@@ -237,12 +237,12 @@ Shader Functionality to Implement/Finish
       + Add missing type in grammar, ATOMIC_UINT, and missing qualifiers COHERENT, VOLATILE, RESTRICT, READONLY, and WRITEONLY.
       + Add missing initializer lists to grammar.
     GLSL 4.4
-      - Incorporate the ARB_enhanced_layouts extension, which adds
+      + Incorporate the ARB_enhanced_layouts extension, which adds
         + compile-time constant expressions for layout qualifier integers
-        - new offset and align layout qualifiers for control over buffer block layouts
+        + new offset and align layout qualifiers for control over buffer block layouts
         + add location layout qualifier for input and output blocks and block members
         + new component layout qualifier for finer-grained layout control of input and output variables and blocks
-        - new xfb_buffer, xfb_stride, and xfb_offsetlayout qualifiers to allow the shader to control 
+        + new xfb_buffer, xfb_stride, and xfb_offsetlayout qualifiers to allow the shader to control 
           transform feedback buffering.
       + Bug 10530: To be consistent with ES, include sample types as valid in a precision statement. 
         Note the defaults are irrelevant, as precision qualifiers are not required or have any meaning.
index a8b56f3..2084b06 100644 (file)
@@ -9,5 +9,5 @@
 // source have to figure out how to create revision.h just to get a build\r
 // going.  However, if it is not updated, it can be a version behind.\r
 \r
-#define GLSLANG_REVISION "25092"\r
-#define GLSLANG_DATE     "2014/01/28 14:13:59"\r
+#define GLSLANG_REVISION "25175"\r
+#define GLSLANG_DATE     "2014/01/30 19:42:25"\r
index 728599e..fb62f4e 100644 (file)
@@ -1882,6 +1882,8 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
             s.append(builtInConstant);
         }
     } else {
+        // non-ES profile
+
         snprintf(builtInConstant, maxSize, "const int  gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
         s.append(builtInConstant);
 
@@ -2111,6 +2113,14 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
             snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers);
             s.append(builtInConstant);
         }
+
+        // enhanced layouts
+        if (version >= 430) {
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackBuffers = %d;", resources.maxTransformFeedbackBuffers);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackInterleavedComponents = %d;", resources.maxTransformFeedbackInterleavedComponents);
+            s.append(builtInConstant);
+        }
     }
 
     s.append("\n");
@@ -2140,6 +2150,8 @@ void SpecialQualifier(const char* name, TStorageQualifier qualifier, TSymbolTabl
 // 1) Programmatically add symbols that could not be added by simple text strings above.
 // 2) Map built-in functions to operators, for those that will turn into an operation node
 //    instead of remaining a function call.
+// 3) Tag extension-related symbols added to their base version with their extensions, so
+//    that if an early version has the extension turned off, there is an error reported on use.
 //
 void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymbolTable& symbolTable)
 {
@@ -2326,10 +2338,19 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
 //
 // Add context-dependent (resource-specific) built-ins not yet handled.  These
 // would be ones that need to be programmatically added because they cannot 
-// be added by simple text strings.
+// 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
+//    instead of remaining a function call.
+// 2) Tag extension-related symbols added to their base version with their extensions, so
+//    that if an early version has the extension turned off, there is an error reported on use.
 //
 void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
 {
+    if (version >= 430 && version < 440) {
+        symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &GL_ARB_enhanced_layouts);
+        symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &GL_ARB_enhanced_layouts);
+    }
+
     switch(language) {
 
     case EShLangFragment:
index 91ef2dd..baf6e00 100644 (file)
@@ -2827,12 +2827,16 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
 
     integerCheck(node, feature);
     const TIntermConstantUnion* constUnion = node->getAsConstantUnion();
-    assert(constUnion);
-    int value = node->getAsConstantUnion()->getConstArray()[0].getIConst();
-
-    if (! constUnion->isLiteral()) {
-        requireProfile(loc, ECoreProfile | ECompatibilityProfile, nonLiteralFeature);
-        profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, nonLiteralFeature);
+    int value;
+    if (constUnion) {
+        value = constUnion->getConstArray()[0].getIConst();
+        if (! constUnion->isLiteral()) {
+            requireProfile(loc, ECoreProfile | ECompatibilityProfile, nonLiteralFeature);
+            profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, GL_ARB_enhanced_layouts, nonLiteralFeature);
+        }
+    } else {
+        // grammar should have give out the error message
+        value = 0;
     }
 
     if (value < 0) {
@@ -2967,6 +2971,20 @@ void TParseContext::setLayoutQualifier(TSourceLoc loc, TPublicType& publicType,
 }
 
 // Merge any layout qualifier information from src into dst, leaving everything else in dst alone
+//
+// "More than one layout qualifier may appear in a single declaration.
+// Additionally, the same layout-qualifier-name can occur multiple times 
+// within a layout qualifier or across multiple layout qualifiers in the 
+// same declaration. When the same layout-qualifier-name occurs 
+// multiple times, in a single declaration, the last occurrence overrides 
+// the former occurrence(s).  Further, if such a layout-qualifier-name 
+// will effect subsequent declarations or other observable behavior, it 
+// is only the last occurrence that will have any effect, behaving as if 
+// the earlier occurrence(s) within the declaration are not present.  
+// This is also true for overriding layout-qualifier-names, where one 
+// overrides the other (e.g., row_major vs. column_major); only the last 
+// occurrence has any effect."    
+//
 void TParseContext::mergeObjectLayoutQualifiers(TSourceLoc loc, TQualifier& dst, const TQualifier& src, bool inheritOnly)
 {
     if (src.hasMatrix())