From 1c4e1acdd48779b94c1008ba2456c63975e5fb7d Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 12 Mar 2024 10:32:35 -0700 Subject: [SPIRV] Use VectorTimesScalar opcode. (#3737) * [SPIRV] Use VectorTimesScalar opcode. * Fix. --- source/slang/slang-emit-spirv.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/slang') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 8063975e2..252f0e917 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -4981,6 +4981,18 @@ struct SPIRVEmitContext const auto lVec = as(l->getDataType()); auto r = operands[1]; const auto rVec = as(r->getDataType()); + if (op == kIROp_Mul && isFloatingPoint) + { + if (lVec && !rVec) + { + return emitInst(parent, instToRegister, SpvOpVectorTimesScalar, type, kResultID, operands); + } + else if (!lVec && rVec) + { + IRInst* newOperands[2] = { operands[1], operands[0] }; + return emitInst(parent, instToRegister, SpvOpVectorTimesScalar, type, kResultID, ArrayView(newOperands, 2)); + } + } const auto go = [&](const auto l, const auto r) { return emitInst(parent, instToRegister, opCode, type, kResultID, l, r); }; -- cgit v1.2.3