diff --git a/Test/baseResults/310.comp.out b/Test/baseResults/310.comp.out index f2d48efd..c795d53f 100644 --- a/Test/baseResults/310.comp.out +++ b/Test/baseResults/310.comp.out @@ -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 diff --git a/Test/baseResults/atomic_uint.frag.out b/Test/baseResults/atomic_uint.frag.out index e2773f9e..c705a063 100644 --- a/Test/baseResults/atomic_uint.frag.out +++ b/Test/baseResults/atomic_uint.frag.out @@ -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 diff --git a/Test/baseResults/glspv.frag.out b/Test/baseResults/glspv.frag.out index 49398073..db752133 100755 --- a/Test/baseResults/glspv.frag.out +++ b/Test/baseResults/glspv.frag.out @@ -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 diff --git a/Test/baseResults/link1.vk.frag.out b/Test/baseResults/link1.vk.frag.out index 26a26af8..57686875 100644 --- a/Test/baseResults/link1.vk.frag.out +++ b/Test/baseResults/link1.vk.frag.out @@ -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 diff --git a/Test/baseResults/specExamples.vert.out b/Test/baseResults/specExamples.vert.out index 71ce8689..a100dd2e 100644 --- a/Test/baseResults/specExamples.vert.out +++ b/Test/baseResults/specExamples.vert.out @@ -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 diff --git a/Test/baseResults/spv.debugInfo.frag.out b/Test/baseResults/spv.debugInfo.frag.out index 15dd7cde..3be422c9 100644 --- a/Test/baseResults/spv.debugInfo.frag.out +++ b/Test/baseResults/spv.debugInfo.frag.out @@ -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 diff --git a/Test/baseResults/spv.glsl.register.noautoassign.frag.out b/Test/baseResults/spv.glsl.register.noautoassign.frag.out index cde46b4f..44722a53 100644 --- a/Test/baseResults/spv.glsl.register.noautoassign.frag.out +++ b/Test/baseResults/spv.glsl.register.noautoassign.frag.out @@ -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 diff --git a/Test/baseResults/vulkan.frag.out b/Test/baseResults/vulkan.frag.out index 0440cf49..e46345ce 100644 --- a/Test/baseResults/vulkan.frag.out +++ b/Test/baseResults/vulkan.frag.out @@ -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 diff --git a/Test/baseResults/vulkan.vert.out b/Test/baseResults/vulkan.vert.out index 0b2ea530..0f64d64d 100644 --- a/Test/baseResults/vulkan.vert.out +++ b/Test/baseResults/vulkan.vert.out @@ -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 diff --git a/Test/glspv.frag b/Test/glspv.frag index 86c9f6ab..7a73cb8d 100644 --- a/Test/glspv.frag +++ b/Test/glspv.frag @@ -11,10 +11,10 @@ void main() { } -uniform float f; // ERROR, no location +uniform float f; // ERROR, no location layout(location = 2) uniform float g; -uniform sampler2D s1; -layout(location = 3) uniform sampler2D s2; +uniform sampler2D s1; // ERROR, no binding +layout(location = 3) uniform sampler2D s2; // ERROR, no binding void noise() { @@ -24,4 +24,5 @@ void noise() noise4(1); } +uniform atomic_uint atomic; // ERROR, no binding layout(input_attachment_index = 1) uniform subpassInput sub; // ERROR, no inputs diff --git a/Test/glspv.vert b/Test/glspv.vert index d2724ca2..b4481465 100644 --- a/Test/glspv.vert +++ b/Test/glspv.vert @@ -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; layout(set = 1, binding = 0, std140) uniform Bt2 { int a; } bt2; // ERROR, set has to be 0 -layout(shared) uniform Bt3 { int a; } bt3; // ERROR, no shared -layout(packed) uniform Bt4 { int a; } bt4; // ERROR, no shared +layout(shared) uniform Bt3 { int a; } bt3; // ERROR, no shared, no binding +layout(packed) uniform Bt4 { int a; } bt4; // ERROR, no shared, no binding void main() { diff --git a/Test/link2.vk.frag b/Test/link2.vk.frag index b1630cb5..febbe7c4 100644 --- a/Test/link2.vk.frag +++ b/Test/link2.vk.frag @@ -1,6 +1,6 @@ #version 450 -uniform sampler2D s2D; +layout(binding=1) uniform sampler2D s2D; vec4 getColor() { diff --git a/Test/runtests b/Test/runtests index af08a4df..9f3583e6 100755 --- a/Test/runtests +++ b/Test/runtests @@ -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 \ diff --git a/Test/spv.glsl.register.noautoassign.frag b/Test/spv.glsl.register.noautoassign.frag index f754d8aa..c385fbb9 100644 --- a/Test/spv.glsl.register.noautoassign.frag +++ b/Test/spv.glsl.register.noautoassign.frag @@ -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; diff --git a/Test/spv.targetOpenGL.vert b/Test/spv.targetOpenGL.vert index 6d68a339..501a3e56 100755 --- a/Test/spv.targetOpenGL.vert +++ b/Test/spv.targetOpenGL.vert @@ -2,8 +2,8 @@ layout(constant_id = 3) const int a = 2; layout(location = 2) uniform float f; -layout(location = 4) uniform sampler2D s1; -uniform sampler2D s2; +layout(location = 4, binding = 1) uniform sampler2D s1; +layout(binding = 2) uniform sampler2D s2; void main() { diff --git a/Test/vulkan.frag b/Test/vulkan.frag index 14c0c301..74a5aa1a 100644 --- a/Test/vulkan.frag +++ b/Test/vulkan.frag @@ -1,9 +1,9 @@ #version 450 -uniform sampler s; -uniform sampler sA[4]; -uniform texture2D t2d; -uniform texture3D t3d[4]; +uniform sampler s; // ERROR, no binding +uniform sampler sA[4]; // ERROR, no binding +uniform texture2D t2d; // ERROR, no binding +uniform texture3D t3d[4]; // ERROR, no binding int i; uniform samplerShadow sShadow; uniform texture3D t3d5[5]; @@ -28,7 +28,7 @@ void badConst() sampler2D s2D = sampler2D(t2d, s); // ERROR, no sampler constructor sampler3D s3d[4] = sampler3D[4](t3d, sA[2]); // ERROR, no sampler constructor -out vec4 color; +out vec4 color; // ERROR, no location void main() { diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 8016e2ea..5382f437 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -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..." diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 173d42c7..2c92bdb7 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -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); } diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index c11f5b83..8cf1da83 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -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 diff --git a/gtests/TestFixture.h b/gtests/TestFixture.h index 2dac99bc..9e77df83 100644 --- a/gtests/TestFixture.h +++ b/gtests/TestFixture.h @@ -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;