From 697fdf015f295c5cde868797816d528615b0a8fe Mon Sep 17 00:00:00 2001 From: "t.jung" Date: Wed, 14 Nov 2018 13:04:39 +0100 Subject: [PATCH] HLSL: fix invalid spir-v vector * scalar for float1 Missing check for float results in always emitting OpIMul even for float types --- SPIRV/GlslangToSpv.cpp | 4 +++- Test/baseResults/hlsl.float1.frag.out | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index c58013b5..3569001c 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -4633,7 +4633,9 @@ spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, OpD assert(builder.isScalar(right)); needMatchingVectors = false; binOp = spv::OpVectorTimesScalar; - } else + } else if (isFloat) + binOp = spv::OpFMul; + else binOp = spv::OpIMul; break; case glslang::EOpVectorTimesMatrix: diff --git a/Test/baseResults/hlsl.float1.frag.out b/Test/baseResults/hlsl.float1.frag.out index 31febfd4..49827dcf 100644 --- a/Test/baseResults/hlsl.float1.frag.out +++ b/Test/baseResults/hlsl.float1.frag.out @@ -64,10 +64,6 @@ gl_FragCoord origin is upper left 0:? 'f1' ( global 1-component vector of float) 0:? 'scalar' ( global float) -error: SPIRV-Tools Validation Errors -error: Expected int scalar or vector type as Result Type: IMul - %20 = OpIMul %float %18 %19 - // Module Version 10000 // Generated by (magic number): 80007 // Id's are bound by 27 @@ -106,10 +102,10 @@ error: Expected int scalar or vector type as Result Type: IMul 12: Label 18: 6(float) Load 14(f1) 19: 6(float) Load 16(scalar) - 20: 6(float) IMul 18 19 + 20: 6(float) FMul 18 19 21: 6(float) Load 9(inFloat1) 22: 6(float) Load 10(inScalar) - 23: 6(float) IMul 21 22 + 23: 6(float) FMul 21 22 24: 6(float) FAdd 20 23 ReturnValue 24 FunctionEnd