diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 4fc8b56c..d2a9085d 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -1823,7 +1823,15 @@ bool TGlslangToSpvTraverser::visitSelection(glslang::TVisit /* visit */, glslang node->getFalseBlock()->traverse(this); spv::Id falseValue = accessChainLoad(node->getTrueBlock()->getAsTyped()->getType()); - spv::Id select = builder.createTriOp(spv::OpSelect, convertGlslangToSpvType(node->getType()), condition, trueValue, falseValue); + // smear condition to vector, if necessary (AST is always scalar) + if (builder.isVector(trueValue)) + condition = builder.smearScalar(spv::NoPrecision, condition, + builder.makeVectorType(builder.makeBoolType(), + builder.getNumComponents(trueValue))); + + spv::Id select = builder.createTriOp(spv::OpSelect, + convertGlslangToSpvType(node->getType()), condition, + trueValue, falseValue); builder.clearAccessChain(); builder.setAccessChainRValue(select); }; diff --git a/Test/baseResults/spv.bool.vert.out b/Test/baseResults/spv.bool.vert.out index 2810ff1e..1e87c421 100644 --- a/Test/baseResults/spv.bool.vert.out +++ b/Test/baseResults/spv.bool.vert.out @@ -3,7 +3,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 44 +// Id's are bound by 46 Capability Shader 1: ExtInstImport "GLSL.std.450" @@ -56,7 +56,8 @@ Warning, version 450 is not yet complete; most version-specific features are pre 38: 18(fvec4) ConstantComposite 37 37 37 37 39: 17(float) Constant 1065353216 40: 18(fvec4) ConstantComposite 39 39 39 39 - 42: TypePointer Output 18(fvec4) + 41: TypeVector 6(bool) 4 + 44: TypePointer Output 18(fvec4) 4(main): 2 Function None 3 5: Label 30(param): 7(ptr) Variable Function @@ -65,9 +66,10 @@ Warning, version 450 is not yet complete; most version-specific features are pre 35: 6(bool) INotEqual 33 34 Store 30(param) 35 36: 6(bool) FunctionCall 10(foo(b1;) 30(param) - 41: 18(fvec4) Select 36 38 40 - 43: 42(ptr) AccessChain 24 26 - Store 43 41 + 42: 41(bvec4) CompositeConstruct 36 36 36 36 + 43: 18(fvec4) Select 42 38 40 + 45: 44(ptr) AccessChain 24 26 + Store 45 43 Return FunctionEnd 10(foo(b1;): 6(bool) Function None 8 diff --git a/Test/baseResults/spv.deepRvalue.frag.out b/Test/baseResults/spv.deepRvalue.frag.out index b6613ef5..b8f4d061 100644 --- a/Test/baseResults/spv.deepRvalue.frag.out +++ b/Test/baseResults/spv.deepRvalue.frag.out @@ -1,12 +1,12 @@ spv.deepRvalue.frag // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 150 +// Id's are bound by 152 Capability Shader 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Fragment 4 "main" 144 + EntryPoint Fragment 4 "main" 146 ExecutionMode 4 OriginUpperLeft Source GLSL 330 Name 4 "main" @@ -21,12 +21,12 @@ spv.deepRvalue.frag Name 106 "h" Name 107 "i" Name 111 "samp2D" - Name 129 "str" - MemberName 129(str) 0 "a" - MemberName 129(str) 1 "b" - MemberName 129(str) 2 "c" - Name 131 "t" - Name 144 "gl_FragColor" + Name 131 "str" + MemberName 131(str) 0 "a" + MemberName 131(str) 1 "b" + MemberName 131(str) 2 "c" + Name 133 "t" + Name 146 "gl_FragColor" Decorate 111(samp2D) DescriptorSet 0 2: TypeVoid 3: TypeFunction 2 @@ -77,19 +77,20 @@ spv.deepRvalue.frag 115: 113(fvec2) ConstantComposite 114 114 119: 6(float) Constant 1036831949 120: TypeBool - 128: TypeArray 113(fvec2) 84 - 129(str): TypeStruct 81(int) 128 120(bool) - 130: TypePointer Function 129(str) - 132: 113(fvec2) ConstantComposite 10 11 - 133: 6(float) Constant 1082130432 - 134: 113(fvec2) ConstantComposite 133 12 - 135: 6(float) Constant 1086324736 - 136: 113(fvec2) ConstantComposite 135 13 - 137: 128 ConstantComposite 132 134 136 - 138: 120(bool) ConstantTrue - 139: 129(str) ConstantComposite 82 137 138 - 143: TypePointer Output 7(fvec4) -144(gl_FragColor): 143(ptr) Variable Output + 124: TypeVector 120(bool) 4 + 130: TypeArray 113(fvec2) 84 + 131(str): TypeStruct 81(int) 130 120(bool) + 132: TypePointer Function 131(str) + 134: 113(fvec2) ConstantComposite 10 11 + 135: 6(float) Constant 1082130432 + 136: 113(fvec2) ConstantComposite 135 12 + 137: 6(float) Constant 1086324736 + 138: 113(fvec2) ConstantComposite 137 13 + 139: 130 ConstantComposite 134 136 138 + 140: 120(bool) ConstantTrue + 141: 131(str) ConstantComposite 82 139 140 + 145: TypePointer Output 7(fvec4) +146(gl_FragColor): 145(ptr) Variable Output 4(main): 2 Function None 3 5: Label 35(m): 34(ptr) Variable Function @@ -98,7 +99,7 @@ spv.deepRvalue.frag 87(g): 79(ptr) Variable Function 106(h): 79(ptr) Variable Function 107(i): 79(ptr) Variable Function - 131(t): 130(ptr) Variable Function + 133(t): 132(ptr) Variable Function Store 9(v1) 14 Store 15(v2) 20 Store 21(v3) 26 @@ -174,21 +175,22 @@ spv.deepRvalue.frag 121: 120(bool) FOrdGreaterThan 118 119 122: 7(fvec4) Load 9(v1) 123: 7(fvec4) Load 15(v2) - 124: 7(fvec4) Select 121 122 123 - 125: 6(float) CompositeExtract 124 3 - 126: 6(float) Load 107(i) - 127: 6(float) FAdd 126 125 - Store 107(i) 127 - Store 131(t) 139 - 140: 6(float) CompositeExtract 139 1 2 1 - 141: 6(float) Load 107(i) - 142: 6(float) FAdd 141 140 - Store 107(i) 142 - 145: 6(float) Load 80(f) - 146: 6(float) Load 87(g) - 147: 6(float) Load 106(h) - 148: 6(float) Load 107(i) - 149: 7(fvec4) CompositeConstruct 145 146 147 148 - Store 144(gl_FragColor) 149 + 125: 124(bvec4) CompositeConstruct 121 121 121 121 + 126: 7(fvec4) Select 125 122 123 + 127: 6(float) CompositeExtract 126 3 + 128: 6(float) Load 107(i) + 129: 6(float) FAdd 128 127 + Store 107(i) 129 + Store 133(t) 141 + 142: 6(float) CompositeExtract 141 1 2 1 + 143: 6(float) Load 107(i) + 144: 6(float) FAdd 143 142 + Store 107(i) 144 + 147: 6(float) Load 80(f) + 148: 6(float) Load 87(g) + 149: 6(float) Load 106(h) + 150: 6(float) Load 107(i) + 151: 7(fvec4) CompositeConstruct 147 148 149 150 + Store 146(gl_FragColor) 151 Return FunctionEnd diff --git a/Test/baseResults/spv.image.frag.out b/Test/baseResults/spv.image.frag.out index ee29baf2..b4f673bc 100644 --- a/Test/baseResults/spv.image.frag.out +++ b/Test/baseResults/spv.image.frag.out @@ -3,7 +3,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 374 +// Id's are bound by 376 Capability Shader Capability SampledRect @@ -16,7 +16,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre Capability StorageImageWriteWithoutFormat 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Fragment 4 "main" 132 142 152 248 362 373 + EntryPoint Fragment 4 "main" 132 142 152 248 362 375 ExecutionMode 4 OriginUpperLeft Source GLSL 450 Name 4 "main" @@ -42,7 +42,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre Name 248 "value" Name 357 "wo2D" Name 362 "fragData" - Name 373 "ic4D" + Name 375 "ic4D" Decorate 15(i1D) DescriptorSet 0 Decorate 15(i1D) Binding 0 Decorate 27(i2D) DescriptorSet 0 @@ -76,7 +76,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre Decorate 357(wo2D) DescriptorSet 0 Decorate 357(wo2D) Binding 1 Decorate 357(wo2D) NonReadable - Decorate 373(ic4D) Flat + Decorate 375(ic4D) Flat 2: TypeVoid 3: TypeFunction 2 6: TypeInt 32 1 @@ -164,9 +164,10 @@ Warning, version 450 is not yet complete; most version-specific features are pre 361: TypePointer Output 125(fvec4) 362(fragData): 361(ptr) Variable Output 367: TypeBool - 371: TypeVector 6(int) 4 - 372: TypePointer Input 371(ivec4) - 373(ic4D): 372(ptr) Variable Input + 370: TypeVector 367(bool) 4 + 373: TypeVector 6(int) 4 + 374: TypePointer Input 373(ivec4) + 375(ic4D): 374(ptr) Variable Input 4(main): 2 Function None 3 5: Label 9(iv): 8(ptr) Variable Function @@ -503,7 +504,8 @@ Warning, version 450 is not yet complete; most version-specific features are pre 366: 18(int) Bitcast 365 368: 367(bool) INotEqual 363 366 369: 125(fvec4) Load 127(v) - 370: 125(fvec4) Select 368 369 129 - Store 362(fragData) 370 + 371: 370(bvec4) CompositeConstruct 368 368 368 368 + 372: 125(fvec4) Select 371 369 129 + Store 362(fragData) 372 Return FunctionEnd diff --git a/Test/baseResults/spv.specConstantOperations.vert.out b/Test/baseResults/spv.specConstantOperations.vert.out index 597820b9..ab83e61e 100644 --- a/Test/baseResults/spv.specConstantOperations.vert.out +++ b/Test/baseResults/spv.specConstantOperations.vert.out @@ -3,7 +3,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 160 +// Id's are bound by 162 Capability Shader Capability Float64 @@ -168,7 +168,9 @@ Warning, version 450 is not yet complete; most version-specific features are pre 156: 154(fvec2) ConstantComposite 155 155 157: 39(float) Constant 1073741824 158: 154(fvec2) ConstantComposite 157 157 - 159: 154(fvec2) SpecConstantOp 169 153 156 158 + 159: TypeVector 22(bool) 2 + 160: 159(bvec2) SpecConstantComposite 153 153 + 161: 154(fvec2) SpecConstantOp 169 160 156 158 4(main): 2 Function None 3 5: Label Return diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 6dd31fca..f6389098 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -3,4 +3,4 @@ // For the date, it uses the current date (when then script is run). #define GLSLANG_REVISION "Overload400-PrecQual.1939" -#define GLSLANG_DATE "28-Mar-2017" +#define GLSLANG_DATE "30-Mar-2017"