Front-end: Fix default layout(component) widths and correct for doubles.
authorJohn Kessenich <cepheus@frii.com>
Thu, 21 Jul 2016 21:43:00 +0000 (15:43 -0600)
committerJohn Kessenich <cepheus@frii.com>
Thu, 21 Jul 2016 21:43:00 +0000 (15:43 -0600)
Replaces PR #372.

Test/440.vert
Test/baseResults/440.vert.out
glslang/Include/revision.h
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/linkValidate.cpp

index c1a396f..bfcdfd2 100644 (file)
@@ -63,16 +63,16 @@ layout(location = 1, component = 1) out;                 // ERROR, no global set
 layout(location = 50, component = 3) out int be;\r
 layout(location = 50, component = 0) out vec3 bf;\r
 \r
-//layout(location = 51, component = 1) out double dfo;     // ERROR, odd component\r
-//layout(location = 52, component = 2) out dvec2 dvo;      // ERROR, overflow\r
-//layout(location = 53) out double dfo2;\r
-//layout(location = 53, component = 2) out vec2 ffv2;      // okay, fits\r
-//layout(location = 54) out dvec4 dvec4out;                // uses up location 55 too\r
-//layout(location = 55) out float overf;                   // ERROR, collides with previous dvec4\r
-//layout(location = 56, component = 1) out vec2 df2o;\r
-//layout(location = 56, component = 3) out float sf2o;\r
-//layout(location = 57, component = 2) out vec2 dv3o;\r
-//layout(location = 57, component = 3) out float sf4o;     // ERROR, overlapping component\r
+layout(location = 51, component = 1) out double dfo;     // ERROR, odd component\r
+layout(location = 52, component = 2) out dvec2 dvo;      // ERROR, overflow\r
+layout(location = 53) out double dfo2;\r
+layout(location = 53, component = 2) out vec2 ffv2;      // okay, fits\r
+layout(location = 54) out dvec4 dvec4out;                // uses up location 55 too\r
+layout(location = 55) out float overf;                   // ERROR, collides with previous dvec4\r
+layout(location = 56, component = 1) out vec2 df2o;\r
+layout(location = 56, component = 3) out float sf2o;\r
+layout(location = 57, component = 2) out vec2 dv3o;\r
+layout(location = 57, component = 3) out float sf4o;     // ERROR, overlapping component\r
 \r
 out bblck1 {\r
     vec4 bbv;\r
index b5a8f2e..d4cbb0b 100644 (file)
@@ -19,6 +19,10 @@ ERROR: 0:55: 'component' : type overflows the available 4 components
 ERROR: 0:57: 'component' : cannot apply to a matrix, structure, or block 
 ERROR: 0:58: 'component' : cannot apply to a matrix, structure, or block 
 ERROR: 0:61: 'location/component/index' : cannot declare a default, use a full declaration 
+ERROR: 0:66: 'component' : doubles cannot start on an odd-numbered component 
+ERROR: 0:67: 'component' : type overflows the available 4 components 
+ERROR: 0:71: 'location' : overlapping use of location 55
+ERROR: 0:75: 'location' : overlapping use of location 57
 ERROR: 0:92: 'xfb layout qualifier' : can only be used on an output 
 ERROR: 0:98: 'xfb_offset' : cannot declare a default, use a full declaration 
 ERROR: 0:108: 'xfb_buffer' : member cannot contradict block (or what block inherited from global) 
@@ -49,7 +53,7 @@ ERROR: 0:184: 'assign' :  l-value required "gl_BaseVertexARB" (can't modify shad
 ERROR: 0:185: 'assign' :  l-value required "gl_BaseInstanceARB" (can't modify shader input)
 ERROR: 0:186: 'assign' :  l-value required "gl_DrawIDARB" (can't modify shader input)
 ERROR: 0:187: 'glBaseInstanceARB' : undeclared identifier 
-ERROR: 49 compilation errors.  No code generated.
+ERROR: 53 compilation errors.  No code generated.
 
 
 Shader version: 440
@@ -119,6 +123,16 @@ ERROR: node is still EOpNull!
 0:?     'bd' (out block{layout(location=40 component=2 ) out float u, layout(location=40 component=0 ) out float v, layout(location=40 component=3 ) out float w, layout(location=40 component=1 ) out 2-component vector of float x, layout(location=41 component=3 ) out 2-component vector of float y, layout(location=42 component=1 ) out 4-component vector of float z, layout(location=42 component=1 ) out 4X4 matrix of float ba, layout(location=43 component=1 ) out structure{global int a} Ss})
 0:?     'be' (layout(location=50 component=3 ) smooth out int)
 0:?     'bf' (layout(location=50 component=0 ) smooth out 3-component vector of float)
+0:?     'dfo' (layout(location=51 component=1 ) smooth out double)
+0:?     'dvo' (layout(location=52 component=2 ) smooth out 2-component vector of double)
+0:?     'dfo2' (layout(location=53 ) smooth out double)
+0:?     'ffv2' (layout(location=53 component=2 ) smooth out 2-component vector of float)
+0:?     'dvec4out' (layout(location=54 ) smooth out 4-component vector of double)
+0:?     'overf' (layout(location=55 ) smooth out float)
+0:?     'df2o' (layout(location=56 component=1 ) smooth out 2-component vector of float)
+0:?     'sf2o' (layout(location=56 component=3 ) smooth out float)
+0:?     'dv3o' (layout(location=57 component=2 ) smooth out 2-component vector of float)
+0:?     'sf4o' (layout(location=57 component=3 ) smooth out float)
 0:?     'bbinst1' (out block{out 4-component vector of float bbv})
 0:?     'bbinst2' (out block{layout(xfb_buffer=0 xfb_offset=64 ) out 4-component vector of float bbv})
 0:?     'bbinst3' (out block{layout(xfb_buffer=3 xfb_offset=16 ) out 4-component vector of float bbv})
@@ -219,6 +233,16 @@ ERROR: node is still EOpNull!
 0:?     'bd' (out block{layout(location=40 component=2 ) out float u, layout(location=40 component=0 ) out float v, layout(location=40 component=3 ) out float w, layout(location=40 component=1 ) out 2-component vector of float x, layout(location=41 component=3 ) out 2-component vector of float y, layout(location=42 component=1 ) out 4-component vector of float z, layout(location=42 component=1 ) out 4X4 matrix of float ba, layout(location=43 component=1 ) out structure{global int a} Ss})
 0:?     'be' (layout(location=50 component=3 ) smooth out int)
 0:?     'bf' (layout(location=50 component=0 ) smooth out 3-component vector of float)
+0:?     'dfo' (layout(location=51 component=1 ) smooth out double)
+0:?     'dvo' (layout(location=52 component=2 ) smooth out 2-component vector of double)
+0:?     'dfo2' (layout(location=53 ) smooth out double)
+0:?     'ffv2' (layout(location=53 component=2 ) smooth out 2-component vector of float)
+0:?     'dvec4out' (layout(location=54 ) smooth out 4-component vector of double)
+0:?     'overf' (layout(location=55 ) smooth out float)
+0:?     'df2o' (layout(location=56 component=1 ) smooth out 2-component vector of float)
+0:?     'sf2o' (layout(location=56 component=3 ) smooth out float)
+0:?     'dv3o' (layout(location=57 component=2 ) smooth out 2-component vector of float)
+0:?     'sf4o' (layout(location=57 component=3 ) smooth out float)
 0:?     'bbinst1' (out block{out 4-component vector of float bbv})
 0:?     'bbinst2' (out block{layout(xfb_buffer=0 xfb_offset=64 ) out 4-component vector of float bbv})
 0:?     'bbinst3' (out block{layout(xfb_buffer=3 xfb_offset=16 ) out 4-component vector of float bbv})
index 9d2eef7..8bc17dd 100644 (file)
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "SPIRV99.1331"
+#define GLSLANG_REVISION "SPIRV99.1332"
 #define GLSLANG_DATE "21-Jul-2016"
index b93d39d..274f919 100644 (file)
@@ -4475,12 +4475,17 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
         }
         if (qualifier.hasComponent()) {
             // "It is a compile-time error if this sequence of components gets larger than 3."
-            if (qualifier.layoutComponent + type.getVectorSize() > 4)
+            if (qualifier.layoutComponent + type.getVectorSize() * (type.getBasicType() == EbtDouble ? 2 : 1) > 4)
                 error(loc, "type overflows the available 4 components", "component", "");
 
             // "It is a compile-time error to apply the component qualifier to a matrix, a structure, a block, or an array containing any of these."
             if (type.isMatrix() || type.getBasicType() == EbtBlock || type.getBasicType() == EbtStruct)
                 error(loc, "cannot apply to a matrix, structure, or block", "component", "");
+
+            // " It is a compile-time error to use component 1 or 3 as the beginning of a double or dvec2."
+            if (type.getBasicType() == EbtDouble)
+                if (qualifier.layoutComponent & 1)
+                    error(loc, "doubles cannot start on an odd-numbered component", "component", "");
         }
 
         switch (qualifier.storage) {
index ce2a38c..af21fbb 100644 (file)
@@ -664,12 +664,19 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
             size = computeTypeLocationSize(type);
     }
 
+    // locations...
     TRange locationRange(qualifier.layoutLocation, qualifier.layoutLocation + size - 1);
+
+    // components in this location slot...    
     TRange componentRange(0, 3);
-    if (qualifier.hasComponent()) {
-        componentRange.start = qualifier.layoutComponent;
-        componentRange.last = componentRange.start + type.getVectorSize() - 1;
+    if (qualifier.hasComponent() || type.getVectorSize() > 0) {
+        int consumedComponents = type.getVectorSize() * (type.getBasicType() == EbtDouble ? 2 : 1);
+        if (qualifier.hasComponent())
+            componentRange.start = qualifier.layoutComponent;
+        componentRange.last  = componentRange.start + consumedComponents - 1;
     }
+
+    // both...
     TIoRange range(locationRange, componentRange, type.getBasicType(), qualifier.hasIndex() ? qualifier.layoutIndex : 0);
 
     // check for collisions, except for vertex inputs on desktop