HLSL: Move to fine-grained control for defining input/output/uniform IO types.
authorJohn Kessenich <cepheus@frii.com>
Mon, 6 Feb 2017 03:27:30 +0000 (20:27 -0700)
committerJohn Kessenich <cepheus@frii.com>
Tue, 7 Feb 2017 06:13:16 +0000 (23:13 -0700)
Test/baseResults/hlsl.array.flatten.frag.out
Test/baseResults/hlsl.float4.frag.out
Test/baseResults/hlsl.struct.frag.out
Test/baseResults/hlsl.struct.split-1.vert.out
Test/baseResults/hlsl.struct.split.call.vert.out
Test/baseResults/hlsl.struct.split.trivial.vert.out
Test/baseResults/hlsl.structin.vert.out
glslang/Include/Types.h
glslang/Include/revision.h
hlsl/hlslParseHelper.cpp
hlsl/hlslParseHelper.h

index 5ea13cc..3b5a2a7 100644 (file)
@@ -87,7 +87,7 @@ gl_FragCoord origin is upper left
 0:35        move second child to first child (temp 4-element array of float)
 0:35          'local_float_array' (temp 4-element array of float)
 0:35          g_floats: direct index for structure (layout(offset=384 ) uniform 4-element array of float)
-0:35            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
+0:35            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(binding=10 offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
 0:35            Constant:
 0:35              2 (const uint)
 0:37      move second child to first child (temp 4-component vector of float)
@@ -165,7 +165,7 @@ gl_FragCoord origin is upper left
 0:?     'g_samp_explicit[0]' (layout(binding=5 ) uniform sampler)
 0:?     'g_samp_explicit[1]' (layout(binding=6 ) uniform sampler)
 0:?     'g_samp_explicit[2]' (layout(binding=7 ) uniform sampler)
-0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
+0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(binding=10 offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
 0:?     'not_flattened_a' (global 5-element array of int)
 0:?     'color' (layout(location=0 ) out 4-component vector of float)
 
@@ -261,7 +261,7 @@ gl_FragCoord origin is upper left
 0:35        move second child to first child (temp 4-element array of float)
 0:35          'local_float_array' (temp 4-element array of float)
 0:35          g_floats: direct index for structure (layout(offset=384 ) uniform 4-element array of float)
-0:35            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
+0:35            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(binding=10 offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
 0:35            Constant:
 0:35              2 (const uint)
 0:37      move second child to first child (temp 4-component vector of float)
@@ -339,7 +339,7 @@ gl_FragCoord origin is upper left
 0:?     'g_samp_explicit[0]' (layout(binding=5 ) uniform sampler)
 0:?     'g_samp_explicit[1]' (layout(binding=6 ) uniform sampler)
 0:?     'g_samp_explicit[2]' (layout(binding=7 ) uniform sampler)
-0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
+0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-element array of 3X3 matrix of float g_mats, layout(binding=10 offset=192 ) uniform 4-element array of 3X3 matrix of float g_mats_explicit, layout(offset=384 ) uniform 4-element array of float g_floats})
 0:?     'not_flattened_a' (global 5-element array of int)
 0:?     'color' (layout(location=0 ) out 4-component vector of float)
 
index 9a83da4..590c4a6 100755 (executable)
@@ -13,11 +13,11 @@ gl_FragCoord origin is upper left
 0:10        component-wise multiply (temp 4-component vector of float)
 0:10          'input' (in 4-component vector of float)
 0:10          AmbientColor: direct index for structure (layout(offset=0 ) uniform 4-component vector of float)
-0:10            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(offset=32 ) uniform 4-component vector of float ff3, layout(offset=48 ) uniform 4-component vector of float ff4})
+0:10            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(binding=0 offset=32 ) uniform 4-component vector of float ff3, layout(binding=1 offset=48 ) uniform 4-component vector of float ff4})
 0:10            Constant:
 0:10              0 (const uint)
 0:?   Linker Objects
-0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(offset=32 ) uniform 4-component vector of float ff3, layout(offset=48 ) uniform 4-component vector of float ff4})
+0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(binding=0 offset=32 ) uniform 4-component vector of float ff3, layout(binding=1 offset=48 ) uniform 4-component vector of float ff4})
 
 
 Linked fragment stage:
@@ -35,11 +35,11 @@ gl_FragCoord origin is upper left
 0:10        component-wise multiply (temp 4-component vector of float)
 0:10          'input' (in 4-component vector of float)
 0:10          AmbientColor: direct index for structure (layout(offset=0 ) uniform 4-component vector of float)
-0:10            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(offset=32 ) uniform 4-component vector of float ff3, layout(offset=48 ) uniform 4-component vector of float ff4})
+0:10            'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(binding=0 offset=32 ) uniform 4-component vector of float ff3, layout(binding=1 offset=48 ) uniform 4-component vector of float ff4})
 0:10            Constant:
 0:10              0 (const uint)
 0:?   Linker Objects
-0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(offset=32 ) uniform 4-component vector of float ff3, layout(offset=48 ) uniform 4-component vector of float ff4})
+0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform 4-component vector of float AmbientColor, layout(offset=16 ) uniform bool ff1, layout(offset=20 ) uniform float ff2, layout(binding=0 offset=32 ) uniform 4-component vector of float ff3, layout(binding=1 offset=48 ) uniform 4-component vector of float ff4})
 
 // Module Version 10000
 // Generated by (magic number): 80001
index c6bf413..c9161d0 100755 (executable)
@@ -38,7 +38,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              0 (const int)
 0:34          a: direct index for structure (smooth temp 4-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              0 (const int)
 0:34        move second child to first child (temp bool)
@@ -47,7 +47,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              1 (const int)
 0:34          b: direct index for structure (flat temp bool)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              1 (const int)
 0:34        move second child to first child (temp 1-component vector of float)
@@ -56,7 +56,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              2 (const int)
 0:34          c: direct index for structure (centroid noperspective temp 1-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              2 (const int)
 0:34        move second child to first child (temp 2-component vector of float)
@@ -65,7 +65,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              3 (const int)
 0:34          d: direct index for structure (centroid sample temp 2-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              3 (const int)
 0:34        move second child to first child (temp bool)
@@ -79,8 +79,8 @@ gl_FragCoord origin is upper left
 0:?             's' (temp structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              5 (const int)
-0:34          ff2: direct index for structure (layout(offset=4 ) temp bool)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34          ff2: direct index for structure (temp bool)
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              4 (const int)
 0:34        move second child to first child (temp bool)
@@ -88,8 +88,8 @@ gl_FragCoord origin is upper left
 0:?             's' (temp structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              6 (const int)
-0:34          ff3: direct index for structure (layout(binding=0 offset=4 ) temp bool)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34          ff3: direct index for structure (temp bool)
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              5 (const int)
 0:34        move second child to first child (temp 4-component vector of float)
@@ -97,8 +97,8 @@ gl_FragCoord origin is upper left
 0:?             's' (temp structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              7 (const int)
-0:34          ff4: direct index for structure (layout(binding=0 offset=4 ) temp 4-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34          ff4: direct index for structure (temp 4-component vector of float)
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              6 (const int)
 0:34      move second child to first child (temp 4-component vector of float)
@@ -110,8 +110,8 @@ gl_FragCoord origin is upper left
 0:?     's2' (global structure{temp 4-component vector of float i})
 0:?     '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
 0:?     'input' (layout(location=0 ) in 4-component vector of float)
-0:?     's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
-0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d} s1, layout(offset=48 ) uniform float ff5, layout(offset=52 ) uniform float ff6})
+0:?     's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
+0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d} s1, layout(binding=5 offset=1620 ) uniform float ff5, layout(binding=8 offset=1636 ) uniform float ff6})
 0:?     's_ff1' (in bool Face)
 
 
@@ -153,7 +153,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              0 (const int)
 0:34          a: direct index for structure (smooth temp 4-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              0 (const int)
 0:34        move second child to first child (temp bool)
@@ -162,7 +162,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              1 (const int)
 0:34          b: direct index for structure (flat temp bool)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              1 (const int)
 0:34        move second child to first child (temp 1-component vector of float)
@@ -171,7 +171,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              2 (const int)
 0:34          c: direct index for structure (centroid noperspective temp 1-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              2 (const int)
 0:34        move second child to first child (temp 2-component vector of float)
@@ -180,7 +180,7 @@ gl_FragCoord origin is upper left
 0:34            Constant:
 0:34              3 (const int)
 0:34          d: direct index for structure (centroid sample temp 2-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              3 (const int)
 0:34        move second child to first child (temp bool)
@@ -194,8 +194,8 @@ gl_FragCoord origin is upper left
 0:?             's' (temp structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              5 (const int)
-0:34          ff2: direct index for structure (layout(offset=4 ) temp bool)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34          ff2: direct index for structure (temp bool)
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              4 (const int)
 0:34        move second child to first child (temp bool)
@@ -203,8 +203,8 @@ gl_FragCoord origin is upper left
 0:?             's' (temp structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              6 (const int)
-0:34          ff3: direct index for structure (layout(binding=0 offset=4 ) temp bool)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34          ff3: direct index for structure (temp bool)
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              5 (const int)
 0:34        move second child to first child (temp 4-component vector of float)
@@ -212,8 +212,8 @@ gl_FragCoord origin is upper left
 0:?             's' (temp structure{temp 4-component vector of float a, temp bool b, temp 1-component vector of float c, temp 2-component vector of float d, temp bool ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              7 (const int)
-0:34          ff4: direct index for structure (layout(binding=0 offset=4 ) temp 4-component vector of float)
-0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
+0:34          ff4: direct index for structure (temp 4-component vector of float)
+0:34            's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
 0:34            Constant:
 0:34              6 (const int)
 0:34      move second child to first child (temp 4-component vector of float)
@@ -225,8 +225,8 @@ gl_FragCoord origin is upper left
 0:?     's2' (global structure{temp 4-component vector of float i})
 0:?     '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
 0:?     'input' (layout(location=0 ) in 4-component vector of float)
-0:?     's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, layout(offset=4 ) temp bool ff2, layout(binding=0 offset=4 ) temp bool ff3, layout(binding=0 offset=4 ) temp 4-component vector of float ff4})
-0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d} s1, layout(offset=48 ) uniform float ff5, layout(offset=52 ) uniform float ff6})
+0:?     's' (layout(location=1 ) in structure{smooth temp 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool ff2, temp bool ff3, temp 4-component vector of float ff4})
+0:?     'anon@0' (layout(row_major std140 ) uniform block{layout(offset=0 ) uniform structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d} s1, layout(binding=5 offset=1620 ) uniform float ff5, layout(binding=8 offset=1636 ) uniform float ff6})
 0:?     's_ff1' (in bool Face)
 
 // Module Version 10000
@@ -292,8 +292,8 @@ gl_FragCoord origin is upper left
                               MemberDecorate 93(myS) 2 Offset 16
                               MemberDecorate 93(myS) 3 Offset 32
                               MemberDecorate 94($Global) 0 Offset 0
-                              MemberDecorate 94($Global) 1 Offset 48
-                              MemberDecorate 94($Global) 2 Offset 52
+                              MemberDecorate 94($Global) 1 Offset 1620
+                              MemberDecorate 94($Global) 2 Offset 1636
                               Decorate 94($Global) Block
                               Decorate 96 DescriptorSet 0
                2:             TypeVoid
index 2c89ffa..43fb6de 100644 (file)
@@ -52,16 +52,16 @@ Shader version: 450
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:17            Constant:
 0:17              1 (const int)
-0:?           'Pos_in' (in 4-component vector of float Position)
+0:?           'Pos_in' (layout(location=1 ) in 4-component vector of float)
 0:17        move second child to first child (temp int)
 0:17          x1_in: direct index for structure (temp int)
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:17            Constant:
 0:17              2 (const int)
-0:?           'x1_in' (layout(location=1 ) in int)
+0:?           'x1_in' (layout(location=2 ) in int)
 0:17      move second child to first child (temp 4-component vector of float)
 0:?         'Pos_loose' (temp 4-component vector of float)
-0:?         'Pos_loose' (in 4-component vector of float Position)
+0:?         'Pos_loose' (layout(location=3 ) in 4-component vector of float)
 0:17      Sequence
 0:17        move second child to first child (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
 0:17          'flattenTemp' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
@@ -95,9 +95,9 @@ Shader version: 450
 0:?   Linker Objects
 0:?     '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
 0:?     'x0_in' (layout(location=0 ) in int)
-0:?     'Pos_in' (in 4-component vector of float Position)
-0:?     'x1_in' (layout(location=1 ) in int)
-0:?     'Pos_loose' (in 4-component vector of float Position)
+0:?     'Pos_in' (layout(location=1 ) in 4-component vector of float)
+0:?     'x1_in' (layout(location=2 ) in int)
+0:?     'Pos_loose' (layout(location=3 ) in 4-component vector of float)
 
 
 Linked vertex stage:
@@ -156,16 +156,16 @@ Shader version: 450
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:17            Constant:
 0:17              1 (const int)
-0:?           'Pos_in' (in 4-component vector of float Position)
+0:?           'Pos_in' (layout(location=1 ) in 4-component vector of float)
 0:17        move second child to first child (temp int)
 0:17          x1_in: direct index for structure (temp int)
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:17            Constant:
 0:17              2 (const int)
-0:?           'x1_in' (layout(location=1 ) in int)
+0:?           'x1_in' (layout(location=2 ) in int)
 0:17      move second child to first child (temp 4-component vector of float)
 0:?         'Pos_loose' (temp 4-component vector of float)
-0:?         'Pos_loose' (in 4-component vector of float Position)
+0:?         'Pos_loose' (layout(location=3 ) in 4-component vector of float)
 0:17      Sequence
 0:17        move second child to first child (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
 0:17          'flattenTemp' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
@@ -199,9 +199,9 @@ Shader version: 450
 0:?   Linker Objects
 0:?     '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
 0:?     'x0_in' (layout(location=0 ) in int)
-0:?     'Pos_in' (in 4-component vector of float Position)
-0:?     'x1_in' (layout(location=1 ) in int)
-0:?     'Pos_loose' (in 4-component vector of float Position)
+0:?     'Pos_in' (layout(location=1 ) in 4-component vector of float)
+0:?     'x1_in' (layout(location=2 ) in int)
+0:?     'Pos_loose' (layout(location=3 ) in 4-component vector of float)
 
 // Module Version 10000
 // Generated by (magic number): 80001
@@ -239,9 +239,9 @@ Shader version: 450
                               Name 61  "@entryPointOutput"
                               Name 67  "@entryPointOutput_Pos_out"
                               Decorate 40(x0_in) Location 0
-                              Decorate 44(Pos_in) BuiltIn Position
-                              Decorate 47(x1_in) Location 1
-                              Decorate 51(Pos_loose) BuiltIn Position
+                              Decorate 44(Pos_in) Location 1
+                              Decorate 47(x1_in) Location 2
+                              Decorate 51(Pos_loose) Location 3
                               Decorate 61(@entryPointOutput) Location 0
                               Decorate 67(@entryPointOutput_Pos_out) BuiltIn Position
                2:             TypeVoid
index 5b13b8e..6a23b89 100644 (file)
@@ -66,13 +66,13 @@ Shader version: 450
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:22            Constant:
 0:22              1 (const int)
-0:?           'Pos_in' (in 4-component vector of float Position)
+0:?           'Pos_in' (layout(location=1 ) in 4-component vector of float)
 0:22        move second child to first child (temp int)
 0:22          x1_in: direct index for structure (temp int)
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:22            Constant:
 0:22              2 (const int)
-0:?           'x1_in' (layout(location=1 ) in int)
+0:?           'x1_in' (layout(location=2 ) in int)
 0:22      Sequence
 0:22        move second child to first child (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
 0:22          'flattenTemp' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
@@ -105,8 +105,8 @@ Shader version: 450
 0:?   Linker Objects
 0:?     '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
 0:?     'x0_in' (layout(location=0 ) in int)
-0:?     'Pos_in' (in 4-component vector of float Position)
-0:?     'x1_in' (layout(location=1 ) in int)
+0:?     'Pos_in' (layout(location=1 ) in 4-component vector of float)
+0:?     'x1_in' (layout(location=2 ) in int)
 
 
 Linked vertex stage:
@@ -179,13 +179,13 @@ Shader version: 450
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:22            Constant:
 0:22              1 (const int)
-0:?           'Pos_in' (in 4-component vector of float Position)
+0:?           'Pos_in' (layout(location=1 ) in 4-component vector of float)
 0:22        move second child to first child (temp int)
 0:22          x1_in: direct index for structure (temp int)
 0:?             'vsin' (temp structure{temp int x0_in, temp 4-component vector of float Pos_in, temp int x1_in})
 0:22            Constant:
 0:22              2 (const int)
-0:?           'x1_in' (layout(location=1 ) in int)
+0:?           'x1_in' (layout(location=2 ) in int)
 0:22      Sequence
 0:22        move second child to first child (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
 0:22          'flattenTemp' (temp structure{temp int x0_out, temp 4-component vector of float Pos_out, temp int x1_out})
@@ -218,8 +218,8 @@ Shader version: 450
 0:?   Linker Objects
 0:?     '@entryPointOutput' (layout(location=0 ) out structure{temp int x0_out, temp int x1_out})
 0:?     'x0_in' (layout(location=0 ) in int)
-0:?     'Pos_in' (in 4-component vector of float Position)
-0:?     'x1_in' (layout(location=1 ) in int)
+0:?     'Pos_in' (layout(location=1 ) in 4-component vector of float)
+0:?     'x1_in' (layout(location=2 ) in int)
 
 // Module Version 10000
 // Generated by (magic number): 80001
@@ -258,8 +258,8 @@ Shader version: 450
                               Name 68  "@entryPointOutput"
                               Name 74  "@entryPointOutput_Pos_out"
                               Decorate 52(x0_in) Location 0
-                              Decorate 56(Pos_in) BuiltIn Position
-                              Decorate 59(x1_in) Location 1
+                              Decorate 56(Pos_in) Location 1
+                              Decorate 59(x1_in) Location 2
                               Decorate 68(@entryPointOutput) Location 0
                               Decorate 74(@entryPointOutput_Pos_out) BuiltIn Position
                2:             TypeVoid
index ad80d5c..6b9eb3e 100644 (file)
@@ -28,10 +28,10 @@ Shader version: 450
 0:?             'vsin' (temp structure{temp 4-component vector of float Pos_in})
 0:16            Constant:
 0:16              0 (const int)
-0:?           'Pos_in' (in 4-component vector of float Position)
+0:?           'Pos_in' (layout(location=0 ) in 4-component vector of float)
 0:16      move second child to first child (temp 4-component vector of float)
 0:?         'Pos_loose' (temp 4-component vector of float)
-0:?         'Pos_loose' (in 4-component vector of float Position)
+0:?         'Pos_loose' (layout(location=1 ) in 4-component vector of float)
 0:16      Sequence
 0:16        move second child to first child (temp 4-component vector of float)
 0:?           '@entryPointOutput_Pos' (out 4-component vector of float Position)
@@ -42,8 +42,8 @@ Shader version: 450
 0:16            Constant:
 0:16              0 (const int)
 0:?   Linker Objects
-0:?     'Pos_in' (in 4-component vector of float Position)
-0:?     'Pos_loose' (in 4-component vector of float Position)
+0:?     'Pos_in' (layout(location=0 ) in 4-component vector of float)
+0:?     'Pos_loose' (layout(location=1 ) in 4-component vector of float)
 
 
 Linked vertex stage:
@@ -78,10 +78,10 @@ Shader version: 450
 0:?             'vsin' (temp structure{temp 4-component vector of float Pos_in})
 0:16            Constant:
 0:16              0 (const int)
-0:?           'Pos_in' (in 4-component vector of float Position)
+0:?           'Pos_in' (layout(location=0 ) in 4-component vector of float)
 0:16      move second child to first child (temp 4-component vector of float)
 0:?         'Pos_loose' (temp 4-component vector of float)
-0:?         'Pos_loose' (in 4-component vector of float Position)
+0:?         'Pos_loose' (layout(location=1 ) in 4-component vector of float)
 0:16      Sequence
 0:16        move second child to first child (temp 4-component vector of float)
 0:?           '@entryPointOutput_Pos' (out 4-component vector of float Position)
@@ -92,8 +92,8 @@ Shader version: 450
 0:16            Constant:
 0:16              0 (const int)
 0:?   Linker Objects
-0:?     'Pos_in' (in 4-component vector of float Position)
-0:?     'Pos_loose' (in 4-component vector of float Position)
+0:?     'Pos_in' (layout(location=0 ) in 4-component vector of float)
+0:?     'Pos_loose' (layout(location=1 ) in 4-component vector of float)
 
 // Module Version 10000
 // Generated by (magic number): 80001
@@ -119,8 +119,8 @@ Shader version: 450
                               Name 38  "@entryPointOutput_Pos"
                               Name 39  "param"
                               Name 41  "param"
-                              Decorate 31(Pos_in) BuiltIn Position
-                              Decorate 35(Pos_loose) BuiltIn Position
+                              Decorate 31(Pos_in) Location 0
+                              Decorate 35(Pos_loose) Location 1
                               Decorate 38(@entryPointOutput_Pos) BuiltIn Position
                2:             TypeVoid
                3:             TypeFunction 2
index 7b088d3..50e4b9c 100755 (executable)
@@ -79,7 +79,7 @@ Shader version: 450
 0:?             'vi' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
 0:8            Constant:
 0:8              2 (const int)
-0:?           'b' (layout(location=4 ) smooth in 4-component vector of float)
+0:?           'b' (layout(location=4 ) in 4-component vector of float)
 0:8      move second child to first child (temp 4-component vector of float)
 0:?         'e' (temp 4-component vector of float)
 0:?         'e' (layout(location=5 ) in 4-component vector of float)
@@ -125,7 +125,7 @@ Shader version: 450
 0:?     'm[0]' (layout(location=1 ) in 4-component vector of float)
 0:?     'm[1]' (layout(location=2 ) in 4-component vector of float)
 0:?     'coord' (layout(location=3 ) in 2-component vector of uint)
-0:?     'b' (layout(location=4 ) smooth in 4-component vector of float)
+0:?     'b' (layout(location=4 ) in 4-component vector of float)
 0:?     'e' (layout(location=5 ) in 4-component vector of float)
 
 
@@ -212,7 +212,7 @@ Shader version: 450
 0:?             'vi' (temp structure{temp 2-element array of 4-component vector of float m, temp 2-component vector of uint coord, temp 4-component vector of float b})
 0:8            Constant:
 0:8              2 (const int)
-0:?           'b' (layout(location=4 ) smooth in 4-component vector of float)
+0:?           'b' (layout(location=4 ) in 4-component vector of float)
 0:8      move second child to first child (temp 4-component vector of float)
 0:?         'e' (temp 4-component vector of float)
 0:?         'e' (layout(location=5 ) in 4-component vector of float)
@@ -258,7 +258,7 @@ Shader version: 450
 0:?     'm[0]' (layout(location=1 ) in 4-component vector of float)
 0:?     'm[1]' (layout(location=2 ) in 4-component vector of float)
 0:?     'coord' (layout(location=3 ) in 2-component vector of uint)
-0:?     'b' (layout(location=4 ) smooth in 4-component vector of float)
+0:?     'b' (layout(location=4 ) in 4-component vector of float)
 0:?     'e' (layout(location=5 ) in 4-component vector of float)
 
 // Module Version 10000
index 3fbf611..a1ba542 100644 (file)
@@ -401,21 +401,16 @@ public:
     // drop qualifiers that don't belong in a temporary variable
     void makeTemporary()
     {
-        makeNonIo();
-        storage      = EvqTemporary;
+        storage = EvqTemporary;
+        builtIn = EbvNone;
+        clearInterstage();
+        clearMemory();
         specConstant = false;
-        coherent     = false;
-        volatil      = false;
-        restrict     = false;
-        readonly     = false;
-        writeonly    = false;
+        clearLayout();
     }
 
-    // Remove IO related data from qualifier.
-    void makeNonIo()  //?? remove?
+    void clearInterstage()
     {
-        // This preserves the storage type
-        builtIn      = EbvNone;
         centroid     = false;
         smooth       = false;
         flat         = false;
@@ -425,16 +420,15 @@ public:
 #endif
         patch        = false;
         sample       = false;
-        clearLayout();
     }
 
-    // Return true if there is data which would be scrubbed by makeNonIo
-    bool hasIoData() const // ?? remove?
+    void clearMemory()
     {
-        return builtIn != EbvNone ||
-            hasLayout()           ||
-            isInterpolation()     ||
-            isAuxiliary();
+        coherent     = false;
+        volatil      = false;
+        restrict     = false;
+        readonly     = false;
+        writeonly    = false;
     }
 
     // Drop just the storage qualification, which perhaps should
@@ -591,37 +585,43 @@ public:
     }
 
     // Implementing an embedded layout-qualifier class here, since C++ can't have a real class bitfield
-    void clearLayout()
+    void clearLayout()  // all layout
     {
-        layoutMatrix = ElmNone;
-        layoutPacking = ElpNone;
-        layoutOffset = layoutNotSet;
-        layoutAlign = layoutNotSet;
+        clearUniformLayout();
+
+        layoutPushConstant = false;
+#ifdef NV_EXTENSIONS
+        layoutPassthrough = false;
+        layoutViewportRelative = false;
+        // -2048 as the default value indicating layoutSecondaryViewportRelative is not set
+        layoutSecondaryViewportRelativeOffset = -2048;
+#endif
 
+        clearInterstageLayout();
+
+        layoutSpecConstantId = layoutSpecConstantIdEnd;
+
+        layoutFormat = ElfNone;
+    }
+    void clearInterstageLayout()
+    {
         layoutLocation = layoutLocationEnd;
         layoutComponent = layoutComponentEnd;
-        layoutSet = layoutSetEnd;
-        layoutBinding = layoutBindingEnd;
         layoutIndex = layoutIndexEnd;
-
+        clearStreamLayout();
+        clearXfbLayout();
+    }
+    void clearStreamLayout()
+    {
         layoutStream = layoutStreamEnd;
-
+    }
+    void clearXfbLayout()
+    {
         layoutXfbBuffer = layoutXfbBufferEnd;
         layoutXfbStride = layoutXfbStrideEnd;
         layoutXfbOffset = layoutXfbOffsetEnd;
-        layoutAttachment = layoutAttachmentEnd;
-        layoutSpecConstantId = layoutSpecConstantIdEnd;
-
-        layoutFormat = ElfNone;
-
-        layoutPushConstant = false;
-#ifdef NV_EXTENSIONS
-        layoutPassthrough = false;
-        layoutViewportRelative = false;
-        // -2048 as the default vaule indicating layoutSecondaryViewportRelative is not set
-        layoutSecondaryViewportRelativeOffset = -2048;
-#endif
     }
+
     bool hasLayout() const
     {
         return hasUniformLayout() ||
@@ -685,8 +685,21 @@ public:
                hasPacking() ||
                hasOffset() ||
                hasBinding() ||
+               hasSet() ||
                hasAlign();
     }
+    void clearUniformLayout() // only uniform specific
+    {
+        layoutMatrix = ElmNone;
+        layoutPacking = ElpNone;
+        layoutOffset = layoutNotSet;
+        layoutAlign = layoutNotSet;
+
+        layoutSet = layoutSetEnd;
+        layoutBinding = layoutBindingEnd;
+        layoutAttachment = layoutAttachmentEnd;
+    }
+
     bool hasMatrix() const
     {
         return layoutMatrix != ElmNone;
@@ -1220,7 +1233,7 @@ public:
     // Make complete copy of the whole type graph rooted at 'copyOf'.
     void deepCopy(const TType& copyOf)
     {
-        TMap<TTypeList*,TTypeList*> copied;  // to enable copying a type graph as a graph, not a tree  //?? turn off again?
+        TMap<TTypeList*,TTypeList*> copied;  // to enable copying a type graph as a graph, not a tree
         deepCopy(copyOf, copied);
     }
 
index 866cab1..a46f045 100644 (file)
@@ -3,4 +3,4 @@
 // For the date, it uses the current date (when then script is run).
 
 #define GLSLANG_REVISION "Overload400-PrecQual.1791"
-#define GLSLANG_DATE "04-Feb-2017"
+#define GLSLANG_DATE "05-Feb-2017"
index 691ec19..1f7bd6a 100755 (executable)
@@ -161,7 +161,7 @@ bool HlslParseContext::shouldConvertLValue(const TIntermNode* node) const
 
 void HlslParseContext::growGlobalUniformBlock(TSourceLoc& loc, TType& memberType, TString& memberName)
 {
-    memberType.getQualifier().makeNonIo();  //?? losing offsets is okay?
+    correctUniform(memberType.getQualifier());
     TParseContextBase::growGlobalUniformBlock(loc, memberType, memberName);
 }
 
@@ -1690,63 +1690,43 @@ void HlslParseContext::handleFunctionBody(const TSourceLoc& loc, TFunction& func
 void HlslParseContext::remapEntryPointIO(TFunction& function, TVariable*& returnValue,
     TVector<TVariable*>& inputs, TVector<TVariable*>& outputs)
 {
-    const auto makeIoVariable = [this](const char* name, TType& type) {
-        const auto remapType = [&](TType& type) {
-            const auto remapBuiltInType = [&](TType& type) {
-                switch (type.getQualifier().builtIn) {
-                case EbvFragDepthGreater:
-                    intermediate.setDepth(EldGreater);
-                    type.getQualifier().builtIn = EbvFragDepth;
-                    break;
-                case EbvFragDepthLesser:
-                    intermediate.setDepth(EldLess);
-                    type.getQualifier().builtIn = EbvFragDepth;
-                    break;
-                default:
-                    break;
-                }
-            };
-            remapBuiltInType(type);
-            if (type.isStruct()) {
-                auto& members = *type.getStruct();
-                for (auto member = members.begin(); member != members.end(); ++member)
-                    remapBuiltInType(*member->type);  // TODO: lack-of-recursion structure depth problem
-            }
-        };
-
+    // Do the actual work to make a type be a shader input or output variable,
+    // and clear the original to be non-IO (for use as a normal function parameter/return).
+    const auto makeIoVariable = [this](const char* name, TType& type, TStorageQualifier storage) {
         TVariable* ioVariable = makeInternalVariable(name, type);
-        // We might have already lost the IO-aspect of the deep parts of this type,
-        // get them back and also make them if that hadn't been done yet.
-        // (The shallow part of IO is already safely copied into the return value.)
-        type.getQualifier().makeNonIo();
+        clearUniformInputOutput(type.getQualifier());
         if (type.getStruct() != nullptr) {
-            auto newList = ioTypeMap.find(ioVariable->getType().getStruct());
-            if (newList != ioTypeMap.end())
-                ioVariable->getWritableType().setStruct(newList->second);
+            auto newLists = ioTypeMap.find(ioVariable->getType().getStruct());
+            if (newLists != ioTypeMap.end()) {
+                if (storage == EvqVaryingIn && newLists->second.input)
+                    ioVariable->getWritableType().setStruct(newLists->second.input);
+                else if (storage == EvqVaryingOut && newLists->second.output)
+                    ioVariable->getWritableType().setStruct(newLists->second.output);
+            }
         }
-        remapType(ioVariable->getWritableType());
+        if (storage == EvqVaryingIn)
+            correctInput(ioVariable->getWritableType().getQualifier());
+        else
+            correctOutput(ioVariable->getWritableType().getQualifier());
+        ioVariable->getWritableType().getQualifier().storage = storage;
         return ioVariable;
     };
 
     // return value is actually a shader-scoped output (out)
     if (function.getType().getBasicType() == EbtVoid)
         returnValue = nullptr;
-    else {
-        returnValue = makeIoVariable("@entryPointOutput", function.getWritableType());
-        returnValue->getWritableType().getQualifier().storage = EvqVaryingOut;
-    }
+    else
+        returnValue = makeIoVariable("@entryPointOutput", function.getWritableType(), EvqVaryingOut);
 
     // parameters are actually shader-scoped inputs and outputs (in or out)
     for (int i = 0; i < function.getParamCount(); i++) {
         TType& paramType = *function[i].type;
         if (paramType.getQualifier().isParamInput()) {
-            TVariable* argAsGlobal = makeIoVariable(function[i].name->c_str(), paramType);
-            argAsGlobal->getWritableType().getQualifier().storage = EvqVaryingIn;
+            TVariable* argAsGlobal = makeIoVariable(function[i].name->c_str(), paramType, EvqVaryingIn);
             inputs.push_back(argAsGlobal);
         }
         if (paramType.getQualifier().isParamOutput()) {
-            TVariable* argAsGlobal = makeIoVariable(function[i].name->c_str(), paramType);
-            argAsGlobal->getWritableType().getQualifier().storage = EvqVaryingOut;
+            TVariable* argAsGlobal = makeIoVariable(function[i].name->c_str(), paramType, EvqVaryingOut);
             outputs.push_back(argAsGlobal);
         }
     }
@@ -1758,11 +1738,11 @@ void HlslParseContext::remapNonEntryPointIO(TFunction& function)
 {
     // return value
     if (function.getType().getBasicType() != EbtVoid)
-        function.getWritableType().getQualifier().makeNonIo();
+        clearUniformInputOutput(function.getWritableType().getQualifier());
 
     // parameters
     for (int i = 0; i < function.getParamCount(); i++)
-        function[i].type->getQualifier().makeNonIo();
+        clearUniformInputOutput(function[i].type->getQualifier());
 }
 
 // Handle function returns, including type conversions to the function return type
@@ -5379,40 +5359,81 @@ void HlslParseContext::declareStruct(const TSourceLoc& loc, TString& structName,
 
     // See if we need IO aliases for the structure typeList
 
-    bool hasIo = false;
+    const auto condAlloc = [](bool pred, TTypeList*& list) {
+        if (pred && list == nullptr)
+            list = new TTypeList;
+    };
+
+    tIoKinds newLists = { nullptr, nullptr, nullptr }; // allocate for each kind found
     for (auto member = type.getStruct()->begin(); member != type.getStruct()->end(); ++member) {
-        if (member->type->getQualifier().hasIoData()) {
-            hasIo = true;
-            break;
-        }
+        condAlloc(hasUniform(member->type->getQualifier()), newLists.uniform);
+        condAlloc(  hasInput(member->type->getQualifier()), newLists.input);
+        condAlloc( hasOutput(member->type->getQualifier()), newLists.output);
+
         if (member->type->isStruct()) {
-            if (ioTypeMap.find(member->type->getStruct()) != ioTypeMap.end()) {
-                hasIo = true;
-                break;
+            auto it = ioTypeMap.find(member->type->getStruct());
+            if (it != ioTypeMap.end()) {
+                condAlloc(it->second.uniform != nullptr, newLists.uniform);
+                condAlloc(it->second.input   != nullptr, newLists.input);
+                condAlloc(it->second.output  != nullptr, newLists.output);
             }
         }
     }
-    if (!hasIo)
+    if (newLists.uniform == nullptr &&
+        newLists.input   == nullptr &&
+        newLists.output  == nullptr)
         return;
 
     // We have IO involved.
 
     // Make a pure typeList for the symbol table, and cache side copies of IO versions.
-    TTypeList* newList = new TTypeList;
     for (auto member = type.getStruct()->begin(); member != type.getStruct()->end(); ++member) {
-        TType* memberType = new TType;
-        memberType->shallowCopy(*member->type);
-        TTypeLoc newMember = { memberType, member->loc };
+        const auto inheritStruct = [&](TTypeList* s, TTypeLoc& ioMember) {
+            if (s != nullptr) {
+                ioMember.type = new TType;
+                ioMember.type->shallowCopy(*member->type);
+                ioMember.type->setStruct(s);
+            }
+        };
+        const auto newMember = [&](TTypeLoc& m) {
+            if (m.type == nullptr) {
+                m.type = new TType;
+                m.type->shallowCopy(*member->type);
+            }
+        };
+
+        TTypeLoc newUniformMember = { nullptr, member->loc };
+        TTypeLoc newInputMember   = { nullptr, member->loc };
+        TTypeLoc newOutputMember  = { nullptr, member->loc };
         if (member->type->isStruct()) {
             // swap in an IO child if there is one
             auto it = ioTypeMap.find(member->type->getStruct());
-            if (it != ioTypeMap.end())
-                newMember.type->setStruct(it->second);
+            if (it != ioTypeMap.end()) {
+                inheritStruct(it->second.uniform, newUniformMember);
+                inheritStruct(it->second.input,   newInputMember);
+                inheritStruct(it->second.output,  newOutputMember);
+            }
+        }
+        if (newLists.uniform) {
+            newMember(newUniformMember);
+            correctUniform(newUniformMember.type->getQualifier());
+            newLists.uniform->push_back(newUniformMember);
+        }
+        if (newLists.input) {
+            newMember(newInputMember);
+            correctInput(newInputMember.type->getQualifier());
+            newLists.input->push_back(newInputMember);
         }
-        newList->push_back(newMember);
-        member->type->getQualifier().makeNonIo();
+        if (newLists.output) {
+            newMember(newOutputMember);
+            correctOutput(newOutputMember.type->getQualifier());
+            newLists.output->push_back(newOutputMember);
+        }
+
+        // make original pure
+        clearUniformInputOutput(member->type->getQualifier());
     }
-    ioTypeMap[type.getStruct()] = newList;
+    ioTypeMap[type.getStruct()] = newLists;
 }
 
 //
@@ -5441,11 +5462,16 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& i
 
     const bool flattenVar = shouldFlattenUniform(type);
 
-    // make non-IO version of type
+    // correct IO in the type
     switch (type.getQualifier().storage) {
     case EvqGlobal:
     case EvqTemporary:
-        type.getQualifier().makeNonIo();
+        clearUniformInputOutput(type.getQualifier());
+        break;
+    case EvqUniform:
+    case EvqBuffer:
+        correctUniform(type.getQualifier());
+        break;
     default:
         break;
     }
@@ -6514,6 +6540,187 @@ void HlslParseContext::renameShaderFunction(TString*& name) const
         name = NewPoolTString(intermediate.getEntryPointName().c_str());
 }
 
+// Return true if this has uniform-interface like decorations.
+bool HlslParseContext::hasUniform(const TQualifier& qualifier) const
+{
+    return qualifier.hasUniformLayout() ||
+           qualifier.layoutPushConstant;
+}
+
+// Potentially not the opposite of hasUniform(), as if some characteristic is
+// ever used for more than one thing (e.g., uniform or input), hasUniform() should
+// say it exists, but clearUniform() should leave it in place.
+void HlslParseContext::clearUniform(TQualifier& qualifier)
+{
+    qualifier.clearUniformLayout();
+    qualifier.layoutPushConstant = false;
+}
+
+// Return false if builtIn by itself doesn't force this qualifier to be an input qualifier.
+bool HlslParseContext::isInputBuiltIn(const TQualifier& qualifier) const
+{
+    switch (qualifier.builtIn) {
+    case EbvPosition:
+    case EbvPointSize:
+        return language != EShLangVertex && language != EShLangCompute && language != EShLangFragment;
+    case EbvClipDistance:
+    case EbvCullDistance:
+        return language != EShLangVertex && language != EShLangCompute;
+    case EbvFragCoord:
+    case EbvFace:
+    case EbvHelperInvocation:
+    case EbvLayer:
+    case EbvPointCoord:
+    case EbvSampleId:
+    case EbvSampleMask:
+    case EbvSamplePosition:
+    case EbvViewportIndex:
+        return language == EShLangFragment;
+    case EbvGlobalInvocationId:
+    case EbvLocalInvocationIndex:
+    case EbvLocalInvocationId:
+    case EbvNumWorkGroups:
+    case EbvWorkGroupId:
+    case EbvWorkGroupSize:
+        return language == EShLangCompute;
+    case EbvInvocationId:
+        return language == EShLangTessControl || language == EShLangTessEvaluation || language == EShLangGeometry;
+    case EbvPatchVertices:
+        return language == EShLangTessControl || language == EShLangTessEvaluation;
+    case EbvInstanceId:
+    case EbvInstanceIndex:
+    case EbvVertexId:
+    case EbvVertexIndex:
+        return language == EShLangVertex;
+    case EbvPrimitiveId:
+        return language == EShLangGeometry || language == EShLangFragment;
+    case EbvTessLevelInner:
+    case EbvTessLevelOuter:
+        return language == EShLangTessEvaluation;
+    default:
+        return false;
+    }
+}
+
+// Return true if there are decorations to preserve for input-like storage,
+// except for builtIn.
+bool HlslParseContext::hasInput(const TQualifier& qualifier) const
+{
+    if (qualifier.hasAnyLocation())
+        return true;
+
+    if (language != EShLangVertex && language != EShLangCompute &&
+        (qualifier.isInterpolation() || qualifier.isAuxiliary()))
+        return true;
+
+    if (isInputBuiltIn(qualifier))
+        return true;
+
+    return false;
+}
+
+// Return false if builtIn by itself doesn't force this qualifier to be an output qualifier.
+bool HlslParseContext::isOutputBuiltIn(const TQualifier& qualifier) const
+{
+    switch (qualifier.builtIn) {
+    case EbvPosition:
+    case EbvPointSize:
+    case EbvClipVertex:
+    case EbvClipDistance:
+    case EbvCullDistance:
+        return language != EShLangFragment && language != EShLangCompute;
+    case EbvFragDepth:
+    case EbvSampleMask:
+        return language == EShLangFragment;
+    case EbvLayer:
+    case EbvViewportIndex:
+        return language == EShLangGeometry;
+    case EbvPrimitiveId:
+        return language == EShLangGeometry || language == EShLangTessControl || language == EShLangTessEvaluation;
+    case EbvTessLevelInner:
+    case EbvTessLevelOuter:
+        return language == EShLangTessControl;
+    default:
+        return false;
+    }
+}
+
+// Return true if there are decorations to preserve for output-like storage,
+// except for builtIn.
+bool HlslParseContext::hasOutput(const TQualifier& qualifier) const
+{
+    if (qualifier.hasAnyLocation())
+        return true;
+
+    if (language != EShLangFragment && language != EShLangCompute &&
+        (qualifier.hasXfb() || qualifier.isInterpolation() || qualifier.isAuxiliary()))
+        return true;
+
+    if (language == EShLangGeometry && qualifier.hasStream())
+        return true;
+
+    if (isOutputBuiltIn(qualifier))
+        return true;
+
+    return false;
+}
+
+// Make the IO decorations etc. be appropriate only for an input interface.
+void HlslParseContext::correctInput(TQualifier& qualifier)
+{
+    clearUniform(qualifier);
+    if (language == EShLangVertex)
+        qualifier.clearInterstage();
+    qualifier.clearStreamLayout();
+    qualifier.clearXfbLayout();
+
+    if (! isInputBuiltIn(qualifier))
+        qualifier.builtIn = EbvNone;
+}
+
+// Make the IO decorations etc. be appropriate only for an output interface.
+void HlslParseContext::correctOutput(TQualifier& qualifier)
+{
+    clearUniform(qualifier);
+    if (language == EShLangFragment)
+        qualifier.clearInterstage();
+    if (language != EShLangGeometry)
+        qualifier.clearStreamLayout();
+    if (language == EShLangFragment)
+        qualifier.clearXfbLayout();
+
+    switch (qualifier.builtIn) {
+    case EbvFragDepthGreater:
+        intermediate.setDepth(EldGreater);
+        qualifier.builtIn = EbvFragDepth;
+        break;
+    case EbvFragDepthLesser:
+        intermediate.setDepth(EldLess);
+        qualifier.builtIn = EbvFragDepth;
+        break;
+    default:
+        break;
+    }
+
+    if (! isOutputBuiltIn(qualifier))
+        qualifier.builtIn = EbvNone;
+}
+
+// Make the IO decorations etc. be appropriate only for uniform type interfaces.
+void HlslParseContext::correctUniform(TQualifier& qualifier)
+{
+    qualifier.builtIn = EbvNone;
+    qualifier.clearInterstage();
+    qualifier.clearInterstageLayout();
+}
+
+// Clear out all IO/Uniform stuff, so this has nothing to do with being an IO interface.
+void HlslParseContext::clearUniformInputOutput(TQualifier& qualifier)
+{
+    clearUniform(qualifier);
+    correctUniform(qualifier);
+}
+
 // post-processing
 void HlslParseContext::finish()
 {
index 23f8b95..d0bfcdf 100755 (executable)
@@ -231,6 +231,17 @@ protected:
     int flattenStruct(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
     int flattenArray(const TSourceLoc& loc, const TVariable& variable, const TType&, TFlattenData&, TString name);
 
+    bool hasUniform(const TQualifier& qualifier) const;
+    void clearUniform(TQualifier& qualifier);
+    bool isInputBuiltIn(const TQualifier& qualifier) const;
+    bool hasInput(const TQualifier& qualifier) const;
+    void correctOutput(TQualifier& qualifier);
+    bool isOutputBuiltIn(const TQualifier& qualifier) const;
+    bool hasOutput(const TQualifier& qualifier) const;
+    void correctInput(TQualifier& qualifier);
+    void correctUniform(TQualifier& qualifier);
+    void clearUniformInputOutput(TQualifier& qualifier);
+
     void finish() override; // post-processing
 
     // Current state of parsing
@@ -296,8 +307,15 @@ protected:
     TVector<int> flattenLevel;  // nested postfix operator level for flattening
     TVector<int> flattenOffset; // cumulative offset for flattening
 
-    // IO-type map.
-    TMap<const TTypeList*, TTypeList*> ioTypeMap;
+    // IO-type map. Maps a pure symbol-table form of a structure-member list into
+    // each of the (up to) three kinds of IO, as each as different allowed decorations,
+    // but HLSL allows mixing all in the same structure.
+    struct tIoKinds {
+        TTypeList* input;
+        TTypeList* output;
+        TTypeList* uniform;
+    };
+    TMap<const TTypeList*, tIoKinds> ioTypeMap;
 
     // Structure splitting data:
     TMap<int, TVariable*>              splitIoVars;  // variables with the builtin interstage IO removed, indexed by unique ID.
@@ -319,7 +337,7 @@ protected:
         }
     };
 
-    TMap<tInterstageIoData, TVariable*> interstageBuiltInIo; // individual builtin interstage IO vars, inxed by builtin type.
+    TMap<tInterstageIoData, TVariable*> interstageBuiltInIo; // individual builtin interstage IO vars, indexed by builtin type.
 
     // We have to move array references to structs containing builtin interstage IO to the split variables.
     // This is only handled for one level.  This stores the index, because we'll need it in the future, since