GLSL/SPV: Fix #1196: Require resources to have layout(binding=X).
authorJohn Kessenich <cepheus@frii.com>
Thu, 22 Feb 2018 01:19:49 +0000 (18:19 -0700)
committerJohn Kessenich <cepheus@frii.com>
Thu, 22 Feb 2018 18:47:41 +0000 (11:47 -0700)
20 files changed:
Test/baseResults/310.comp.out
Test/baseResults/atomic_uint.frag.out
Test/baseResults/glspv.frag.out
Test/baseResults/link1.vk.frag.out
Test/baseResults/specExamples.vert.out
Test/baseResults/spv.debugInfo.frag.out
Test/baseResults/spv.glsl.register.noautoassign.frag.out
Test/baseResults/vulkan.frag.out
Test/baseResults/vulkan.vert.out
Test/glspv.frag
Test/glspv.vert
Test/link2.vk.frag
Test/runtests
Test/spv.glsl.register.noautoassign.frag
Test/spv.targetOpenGL.vert
Test/vulkan.frag
glslang/MachineIndependent/ParseHelper.cpp
gtests/Hlsl.FromFile.cpp
gtests/Spv.FromFile.cpp
gtests/TestFixture.h

index f2d48ef..c795d53 100644 (file)
@@ -40,7 +40,6 @@ ERROR: 0:119: 'r8ui' : does not apply to signed integer images
 ERROR: 0:128: 'atomic_uint' : samplers and atomic_uints cannot be output parameters 
 ERROR: 0:130: 'return' : type does not match, or is not convertible to, the function's return type 
 ERROR: 0:136: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: non_uniform_counter
-ERROR: 0:136: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:141: 'atomic_uint' : atomic counters can only be highp 
 ERROR: 0:141: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:143: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
@@ -84,7 +83,7 @@ WARNING: 0:238: '#define' : names containing consecutive underscores are reserve
 ERROR: 0:244: 'gl_DeviceIndex' : required extension not requested: GL_EXT_device_group
 ERROR: 0:245: 'gl_ViewIndex' : undeclared identifier 
 ERROR: 0:255: 'gl_ViewIndex' : undeclared identifier 
-ERROR: 83 compilation errors.  No code generated.
+ERROR: 82 compilation errors.  No code generated.
 
 
 Shader version: 310
index e2773f9..c705a06 100644 (file)
@@ -2,7 +2,6 @@ atomic_uint.frag
 ERROR: 0:10: 'atomic_uint' : samplers and atomic_uints cannot be output parameters 
 ERROR: 0:12: 'return' : type does not match, or is not convertible to, the function's return type 
 ERROR: 0:18: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: non_uniform_counter
-ERROR: 0:18: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:23: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:28: '+' :  wrong operand types: no operation '+' exists that takes a left-hand operand of type 'layout( binding=0 offset=0) uniform atomic_uint' and a right operand of type 'layout( binding=0 offset=0) uniform atomic_uint' (or there is no acceptable conversion)
 ERROR: 0:29: '-' :  wrong operand type no operation '-' exists that takes an operand of type layout( binding=0 offset=0) uniform atomic_uint (or there is no acceptable conversion)
@@ -10,14 +9,10 @@ ERROR: 0:31: '[]' : scalar integer expression required
 ERROR: 0:34: 'assign' :  l-value required "counter" (can't modify a uniform)
 ERROR: 0:34: 'assign' :  cannot convert from ' const int' to 'layout( binding=0 offset=0) uniform atomic_uint'
 ERROR: 0:37: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acin
-ERROR: 0:37: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:38: 'atomic_uint' : atomic_uints can only be used in uniform variables or function parameters: acg
-ERROR: 0:38: 'atomic_uint' : layout(binding=X) is required 
-ERROR: 0:40: 'atomic_uint' : layout(binding=X) is required 
-ERROR: 0:46: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:47: 'offset' : atomic counters sharing the same offset: 12
 ERROR: 0:48: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
-ERROR: 18 compilation errors.  No code generated.
+ERROR: 13 compilation errors.  No code generated.
 
 
 Shader version: 420
index 4939807..db75213 100755 (executable)
@@ -1,13 +1,15 @@
 glspv.frag
 ERROR: 0:4: '#error' : GL_SPIRV is set ( correct , not an error )  
 ERROR: 0:6: '#error' : GL_SPIR is 100  
+ERROR: 0:14: 'f' : non-opaque uniform variables need a layout(location=L) 
 ERROR: 0:21: 'noise1' : no matching overloaded function found 
 ERROR: 0:22: 'noise2' : no matching overloaded function found 
 ERROR: 0:23: 'noise3' : no matching overloaded function found 
 ERROR: 0:24: 'noise4' : no matching overloaded function found 
-ERROR: 0:27: 'input_attachment_index' : only allowed when using GLSL for Vulkan 
-ERROR: 0:27: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
-ERROR: 8 compilation errors.  No code generated.
+ERROR: 0:27: 'atomic_uint' : layout(binding=X) is required 
+ERROR: 0:28: 'input_attachment_index' : only allowed when using GLSL for Vulkan 
+ERROR: 0:28: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
+ERROR: 10 compilation errors.  No code generated.
 
 
 SPIR-V is not generated for failed compile or link
index 26a26af..5768687 100644 (file)
@@ -20,12 +20,12 @@ gl_FragCoord origin is upper left
 0:7    Sequence
 0:7      Branch: Return with expression
 0:7        texture ( global highp 4-component vector of float)
-0:7          's2D' ( uniform highp sampler2D)
+0:7          's2D' (layout( binding=1) uniform highp sampler2D)
 0:7          Constant:
 0:7            0.500000
 0:7            0.500000
 0:?   Linker Objects
-0:?     's2D' ( uniform highp sampler2D)
+0:?     's2D' (layout( binding=1) uniform highp sampler2D)
 
 
 Linked fragment stage:
@@ -45,12 +45,12 @@ gl_FragCoord origin is upper left
 0:7    Sequence
 0:7      Branch: Return with expression
 0:7        texture ( global highp 4-component vector of float)
-0:7          's2D' ( uniform highp sampler2D)
+0:7          's2D' (layout( binding=1) uniform highp sampler2D)
 0:7          Constant:
 0:7            0.500000
 0:7            0.500000
 0:?   Linker Objects
 0:?     'color' ( out highp 4-component vector of float)
-0:?     's2D' ( uniform highp sampler2D)
+0:?     's2D' (layout( binding=1) uniform highp sampler2D)
 
 SPIR-V is not generated for failed compile or link
index 71ce868..a100dd2 100644 (file)
@@ -19,7 +19,6 @@ ERROR: 0:85: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCount
 ERROR: 0:87: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:89: 'binding' : atomic_uint binding is too large 
 ERROR: 0:91: 'bar' : redefinition 
-ERROR: 0:92: 'atomic_uint' : layout(binding=X) is required 
 ERROR: 0:94: 'a2' : redefinition 
 ERROR: 0:95: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
 ERROR: 0:96: 'binding' : atomic_uint binding is too large; see gl_MaxAtomicCounterBindings 
@@ -32,7 +31,7 @@ ERROR: 0:134: '' : function does not return a value: funcA
 ERROR: 0:136: '' : function does not return a value: funcB
 ERROR: 0:153: '' : function does not return a value: func3
 ERROR: 0:170: 'coherent' : argument cannot drop memory qualifier when passed to formal parameter 
-ERROR: 33 compilation errors.  No code generated.
+ERROR: 32 compilation errors.  No code generated.
 
 
 Shader version: 430
index 15dd7cd..3be422c 100644 (file)
@@ -11,6 +11,7 @@ spv.debugInfo.frag
                1:             String  "spv.debugInfo.frag"
                               Source GLSL 450 1  "// OpModuleProcessed no-storage-format
 // OpModuleProcessed resource-set-binding 3
+// OpModuleProcessed auto-map-bindings
 // OpModuleProcessed auto-map-locations
 // OpModuleProcessed client opengl100
 // OpModuleProcessed target-env opengl
@@ -95,7 +96,9 @@ void main()
                               MemberDecorate 54(ubuf) 0 Offset 0
                               Decorate 54(ubuf) Block
                               Decorate 56 DescriptorSet 3
+                              Decorate 56 Binding 0
                               Decorate 69(s2d) DescriptorSet 3
+                              Decorate 69(s2d) Binding 1
                3:             TypeVoid
                4:             TypeFunction 3
                7:             TypeInt 32 1
index cde46b4..44722a5 100644 (file)
@@ -41,19 +41,25 @@ spv.glsl.register.noautoassign.frag
                               Name 137  "FragColor"
                               Name 141  "g_tTex_unused3"
                               Decorate 17(g_tTex1) DescriptorSet 0
-                              Decorate 17(g_tTex1) Binding 11
+                              Decorate 17(g_tTex1) Binding 17
                               Decorate 21(g_sSamp1) DescriptorSet 0
                               Decorate 21(g_sSamp1) Binding 5
                               Decorate 27(g_tTex2) DescriptorSet 0
+                              Decorate 27(g_tTex2) Binding 18
                               Decorate 29(g_sSamp2) DescriptorSet 0
+                              Decorate 29(g_sSamp2) Binding 6
                               Decorate 39(g_tTex3) DescriptorSet 0
-                              Decorate 39(g_tTex3) Binding 13
+                              Decorate 39(g_tTex3) Binding 19
                               Decorate 46(g_sSamp3) DescriptorSet 0
                               Decorate 46(g_sSamp3) Binding 7
                               Decorate 64(g_tTex4) DescriptorSet 0
+                              Decorate 64(g_tTex4) Binding 20
                               Decorate 69(g_sSamp4) DescriptorSet 0
+                              Decorate 69(g_sSamp4) Binding 8
                               Decorate 84(g_tTex5) DescriptorSet 0
+                              Decorate 84(g_tTex5) Binding 21
                               Decorate 86(g_sSamp5) DescriptorSet 0
+                              Decorate 86(g_sSamp5) Binding 9
                               MemberDecorate 93(MyStruct_t) 0 Offset 0
                               MemberDecorate 93(MyStruct_t) 1 Offset 4
                               MemberDecorate 93(MyStruct_t) 2 Offset 16
@@ -65,13 +71,16 @@ spv.glsl.register.noautoassign.frag
                               Decorate 97 DescriptorSet 0
                               Decorate 97 Binding 19
                               Decorate 119(g_tTex_unused1) DescriptorSet 0
-                              Decorate 119(g_tTex_unused1) Binding 10
+                              Decorate 119(g_tTex_unused1) Binding 22
                               Decorate 121(g_sSamp_unused1) DescriptorSet 0
+                              Decorate 121(g_sSamp_unused1) Binding 10
                               Decorate 126(g_tTex_unused2) DescriptorSet 0
-                              Decorate 126(g_tTex_unused2) Binding 12
+                              Decorate 126(g_tTex_unused2) Binding 23
                               Decorate 128(g_sSamp_unused2) DescriptorSet 0
+                              Decorate 128(g_sSamp_unused2) Binding 11
                               Decorate 137(FragColor) Location 0
                               Decorate 141(g_tTex_unused3) DescriptorSet 0
+                              Decorate 141(g_tTex_unused3) Binding 24
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeFloat 32
index 0440cf4..e46345c 100644 (file)
@@ -1,4 +1,11 @@
 vulkan.frag
+ERROR: 0:3: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:4: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:5: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:6: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:8: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:9: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:10: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:14: 'sampler2D' : sampler-constructor requires two arguments 
 ERROR: 0:15: 'sampler2D' : sampler-constructor first argument must be a scalar textureXXX type 
 ERROR: 0:16: 'sampler2D' : sampler-constructor first argument must be a scalar textureXXX type 
@@ -14,13 +21,19 @@ ERROR: 0:28: 'sampler2D' : sampler/image types can only be used in uniform varia
 ERROR: 0:29: 'sampler3D' : sampler-constructor cannot make an array of samplers 
 ERROR: 0:29: 'sampler3D' : sampler/image types can only be used in uniform variables or function parameters: s3d
 ERROR: 0:29: '=' :  cannot convert from ' const float' to ' global 4-element array of highp sampler3D'
+ERROR: 0:31: 'location' : SPIR-V requires location for user input/output 
 ERROR: 0:39: 'push_constant' : can only be used with a uniform 
 ERROR: 0:43: 'non-opaque uniforms outside a block' : not allowed when using GLSL for Vulkan 
 ERROR: 0:43: 'push_constant' : can only be used with a block 
 ERROR: 0:45: 'push_constant' : cannot declare a default, can only be used on a block 
+ERROR: 0:51: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:52: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:52: 'input_attachment_index' : can only be used with a subpass 
+ERROR: 0:53: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:53: 'input_attachment_index' : can only be used with a subpass 
+ERROR: 0:54: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:54: 'subpass' : requires an input_attachment_index layout qualifier 
+ERROR: 0:55: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:60: 'subpassLoadMS' : no matching overloaded function found 
 ERROR: 0:61: 'subpassLoad' : no matching overloaded function found 
 ERROR: 0:63: 'subpassLoadMS' : no matching overloaded function found 
@@ -43,7 +56,7 @@ ERROR: 0:101: 'noise1' : no matching overloaded function found
 ERROR: 0:102: 'noise2' : no matching overloaded function found 
 ERROR: 0:103: 'noise3' : no matching overloaded function found 
 ERROR: 0:104: 'noise4' : no matching overloaded function found 
-ERROR: 42 compilation errors.  No code generated.
+ERROR: 55 compilation errors.  No code generated.
 
 
 ERROR: Linking fragment stage: Only one push_constant block is allowed per stage
index 0b2ea53..0f64d64 100644 (file)
@@ -1,12 +1,20 @@
 vulkan.vert
 ERROR: 0:3: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:3: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:4: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:4: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:5: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:5: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:6: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:6: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:7: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:7: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:8: 'subpass input' : not supported in this stage: vertex
+ERROR: 0:8: 'binding' : sampler/texture/image requires layout(binding=X) 
+ERROR: 0:10: 'location' : SPIR-V requires location for user input/output 
 ERROR: 0:12: 'constant_id' : can only be applied to a scalar 
 ERROR: 0:13: 'constant_id' : specialization-constant id already used 
+ERROR: 0:13: 'binding' : sampler/texture/image requires layout(binding=X) 
 ERROR: 0:13: 'constant_id' : can only be applied to 'const'-qualified scalar 
 ERROR: 0:13: 'constant_id' : cannot be applied to this type 
 ERROR: 0:14: 'constant_id' : specialization-constant id is too large 
@@ -26,7 +34,9 @@ ERROR: 0:49: '[]' : only outermost dimension of an array of arrays can be a spec
 ERROR: 0:50: '[]' : only outermost dimension of an array of arrays can be a specialization constant 
 ERROR: 0:51: '[]' : only outermost dimension of an array of arrays can be a specialization constant 
 ERROR: 0:54: '[]' : only outermost dimension of an array of arrays can be a specialization constant 
-ERROR: 27 compilation errors.  No code generated.
+ERROR: 0:54: 'location' : SPIR-V requires location for user input/output 
+ERROR: 0:58: 'location' : SPIR-V requires location for user input/output 
+ERROR: 37 compilation errors.  No code generated.
 
 
 SPIR-V is not generated for failed compile or link
index 86c9f6a..7a73cb8 100644 (file)
@@ -11,10 +11,10 @@ void main()
 {\r
 }\r
 \r
-uniform float f; // ERROR, no location\r
+uniform float f;                           // ERROR, no location\r
 layout(location = 2) uniform float g;\r
-uniform sampler2D s1;\r
-layout(location = 3) uniform sampler2D s2;\r
+uniform sampler2D s1;                      // ERROR, no binding\r
+layout(location = 3) uniform sampler2D s2; // ERROR, no binding\r
 \r
 void noise()\r
 {\r
@@ -24,4 +24,5 @@ void noise()
     noise4(1);\r
 }\r
 \r
+uniform atomic_uint atomic;                // ERROR, no binding\r
 layout(input_attachment_index = 1) uniform subpassInput sub; // ERROR, no inputs\r
index d2724ca..b448146 100644 (file)
@@ -5,8 +5,8 @@ layout(push_constant) uniform Material { int a; } mat;            // ERROR, can'
 layout(set = 0, binding = 0, std140) uniform Bt1 { int a; } bt1;\r
 layout(set = 1, binding = 0, std140) uniform Bt2 { int a; } bt2;  // ERROR, set has to be 0\r
 \r
-layout(shared) uniform Bt3 { int a; } bt3;                        // ERROR, no shared\r
-layout(packed) uniform Bt4 { int a; } bt4;                        // ERROR, no shared\r
+layout(shared) uniform Bt3 { int a; } bt3;                        // ERROR, no shared, no binding\r
+layout(packed) uniform Bt4 { int a; } bt4;                        // ERROR, no shared, no binding\r
 \r
 void main()\r
 {\r
index b1630cb..febbe7c 100644 (file)
@@ -1,6 +1,6 @@
 #version 450\r
 \r
-uniform sampler2D s2D;\r
+layout(binding=1) uniform sampler2D s2D;\r
 \r
 vec4 getColor()\r
 {\r
index af08a4d..9f3583e 100755 (executable)
@@ -126,7 +126,7 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out $TARGETDIR/spv.looseUniformNoLoc
 # Testing debug information
 #
 echo Testing SPV Debug Information
-$EXE -g --relaxed-errors --suppress-warnings --aml --hlsl-offsets --nsf \
+$EXE -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf \
      -G -H spv.debugInfo.frag --rsb frag 3 > $TARGETDIR/spv.debugInfo.frag.out
 diff -b $BASEDIR/spv.debugInfo.frag.out $TARGETDIR/spv.debugInfo.frag.out || HASERROR=1
 $EXE -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \
index f754d8a..c385fbb 100644 (file)
@@ -1,23 +1,23 @@
 #version 450
 
 uniform layout(binding=0) sampler       g_sSamp1;
-uniform sampler       g_sSamp2;
+uniform layout(binding=1) sampler       g_sSamp2;
 uniform layout(binding=2) sampler       g_sSamp3[2];
-uniform sampler       g_sSamp4[3];
-uniform sampler       g_sSamp5;
+uniform layout(binding=3) sampler       g_sSamp4[3];
+uniform layout(binding=4) sampler       g_sSamp5;
 
-uniform sampler       g_sSamp_unused1;
-uniform sampler       g_sSamp_unused2;
+uniform layout(binding=5) sampler       g_sSamp_unused1;
+uniform layout(binding=6) sampler       g_sSamp_unused2;
 
-uniform layout(binding=1) texture1D          g_tTex1;
-uniform texture1D  g_tTex2;
-uniform layout(binding=3) texture1D          g_tTex3[2];
-uniform texture1D          g_tTex4[3];
-uniform texture1D          g_tTex5;
+uniform layout(binding=7) texture1D          g_tTex1;
+uniform layout(binding=8) texture1D          g_tTex2;
+uniform layout(binding=9) texture1D          g_tTex3[2];
+uniform layout(binding=10) texture1D          g_tTex4[3];
+uniform layout(binding=11) texture1D          g_tTex5;
 
-uniform layout(binding=0)  texture1D          g_tTex_unused1;
-uniform layout(binding=2)  texture1D          g_tTex_unused2;
-uniform texture1D          g_tTex_unused3;
+uniform layout(binding=12) texture1D          g_tTex_unused1;
+uniform layout(binding=13) texture1D          g_tTex_unused2;
+uniform layout(binding=14) texture1D          g_tTex_unused3;
 
 struct MyStruct_t {
     int a;
index 6d68a33..501a3e5 100755 (executable)
@@ -2,8 +2,8 @@
 \r
 layout(constant_id = 3) const int a = 2;\r
 layout(location = 2) uniform float f;\r
-layout(location = 4) uniform sampler2D s1;\r
-uniform sampler2D s2;\r
+layout(location = 4, binding = 1) uniform sampler2D s1;\r
+layout(binding = 2) uniform sampler2D s2;\r
 \r
 void main()\r
 {\r
index 14c0c30..74a5aa1 100644 (file)
@@ -1,9 +1,9 @@
 #version 450\r
 \r
-uniform sampler s;\r
-uniform sampler sA[4];\r
-uniform texture2D t2d;\r
-uniform texture3D t3d[4];\r
+uniform sampler s;         // ERROR, no binding\r
+uniform sampler sA[4];     // ERROR, no binding\r
+uniform texture2D t2d;     // ERROR, no binding\r
+uniform texture3D t3d[4];  // ERROR, no binding\r
 int i;\r
 uniform samplerShadow sShadow;\r
 uniform texture3D t3d5[5];\r
@@ -28,7 +28,7 @@ void badConst()
 sampler2D s2D = sampler2D(t2d, s);            // ERROR, no sampler constructor\r
 sampler3D s3d[4] = sampler3D[4](t3d, sA[2]);  // ERROR, no sampler constructor\r
 \r
-out vec4 color;\r
+out vec4 color; // ERROR, no location\r
 \r
 void main()\r
 {\r
index 8016e2e..5382f43 100644 (file)
@@ -4663,12 +4663,23 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
                 return;
             }
         }
-    }
+    } else if (!intermediate.getAutoMapBindings()) {
+        // some types require bindings
 
-    // atomic_uint
-    if (type.getBasicType() == EbtAtomicUint) {
-        if (! type.getQualifier().hasBinding())
+        // atomic_uint
+        if (type.getBasicType() == EbtAtomicUint)
             error(loc, "layout(binding=X) is required", "atomic_uint", "");
+
+        // SPIR-V
+        if (spvVersion.spv > 0) {
+            if (qualifier.isUniformOrBuffer()) {
+                if (type.getBasicType() == EbtBlock && !qualifier.layoutPushConstant &&
+                                                       !qualifier.layoutAttachment)
+                    error(loc, "uniform/buffer blocks require layout(binding=X)", "binding", "");
+                else if (spvVersion.vulkan > 0 && type.getBasicType() == EbtSampler)
+                    error(loc, "sampler/texture/image requires layout(binding=X)", "binding", "");
+            }
+        }
     }
 
     // "The offset qualifier can only be used on block members of blocks..."
index 173d42c..2c92bdb 100644 (file)
@@ -67,7 +67,7 @@ TEST_P(HlslCompileTest, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
                             Source::HLSL, Semantics::Vulkan,
-                            Target::BothASTAndSpv, GetParam().entryPoint);
+                            Target::BothASTAndSpv, true, GetParam().entryPoint);
 }
 
 TEST_P(HlslCompileAndFlattenTest, FromFile)
@@ -83,7 +83,7 @@ TEST_P(HlslLegalizeTest, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
                             Source::HLSL, Semantics::Vulkan,
-                            Target::Spv, GetParam().entryPoint,
+                            Target::Spv, true, GetParam().entryPoint,
                             "/baseLegalResults/", false);
 }
 
index c11f5b8..8cf1da8 100644 (file)
@@ -101,7 +101,7 @@ TEST_P(VulkanSemantics, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
                             Source::GLSL, Semantics::Vulkan,
-                            Target::Spv);
+                            Target::Spv, false);
 }
 
 // GLSL-level Vulkan semantics test. Expected to error out before generating
@@ -110,7 +110,7 @@ TEST_P(OpenGLSemantics, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
                             Source::GLSL, Semantics::OpenGL,
-                            Target::Spv);
+                            Target::Spv, false);
 }
 
 // GLSL-level Vulkan semantics test that need to see the AST for validation.
@@ -168,8 +168,8 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
 TEST_P(CompileVulkanToSpirvTestNV, FromFile)
 {
     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
-        Source::GLSL, Semantics::Vulkan,
-        Target::Spv);
+                            Source::GLSL, Semantics::Vulkan,
+                            Target::Spv);
 }
 #endif
 
index 2dac99b..9e77df8 100644 (file)
@@ -199,12 +199,16 @@ public:
             const std::string& entryPointName, EShMessages controls,
             bool flattenUniformArrays = false,
             EShTextureSamplerTransformMode texSampTransMode = EShTexSampTransKeep,
-            bool disableOptimizer = true)
+            bool disableOptimizer = true,
+            bool automap = true)
     {
         const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
 
         glslang::TShader shader(kind);
-        shader.setAutoMapLocations(true);
+        if (automap) {
+            shader.setAutoMapLocations(true);
+            shader.setAutoMapBindings(true);
+        }
         shader.setTextureSamplerTransformMode(texSampTransMode);
         shader.setFlattenUniformArrays(flattenUniformArrays);
 
@@ -302,6 +306,7 @@ public:
         const EShLanguage kind = GetShaderStage(GetSuffix(shaderName));
 
         glslang::TShader shader(kind);
+        shader.setAutoMapBindings(true);
         shader.setAutoMapLocations(true);
 
         bool success = compile(&shader, code, entryPointName, controls);
@@ -384,6 +389,7 @@ public:
                                  Source source,
                                  Semantics semantics,
                                  Target target,
+                                 bool automap = true,
                                  const std::string& entryPointName="",
                                  const std::string& baseDir="/baseResults/",
                                  const bool disableOptimizer = true)
@@ -397,7 +403,8 @@ public:
         tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
 
         const EShMessages controls = DeriveOptions(source, semantics, target);
-        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransKeep, disableOptimizer);
+        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransKeep,
+                                              disableOptimizer, automap);
 
         // Generate the hybrid output in the way of glslangValidator.
         std::ostringstream stream;
@@ -592,7 +599,8 @@ public:
         tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
 
         const EShMessages controls = DeriveOptions(source, semantics, target);
-        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false, EShTexSampTransUpgradeTextureRemoveSampler);
+        GlslangResult result = compileAndLink(testName, input, entryPointName, controls, false,
+                                              EShTexSampTransUpgradeTextureRemoveSampler);
 
         // Generate the hybrid output in the way of glslangValidator.
         std::ostringstream stream;