From aa3e6bdbe024355b07f6a61806024b248528fe4b Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Fri, 30 May 2025 01:04:27 -0400 Subject: Fix SPIRV `OpSpecConstantOp` emit (#7158) * Fix SPIRV specialization constant with floating-point operations * Improve test * WIP * Restrict `OpSpecConstantOp` allowed operations based on SPIRV specifications * Fix typo on floating type check * Emit error on float to int spec cosnt int val casts --- source/slang/slang-ir-clone.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir-clone.cpp') diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp index 1a020ec26..74a972c1d 100644 --- a/source/slang/slang-ir-clone.cpp +++ b/source/slang/slang-ir-clone.cpp @@ -79,6 +79,12 @@ IRInst* cloneInstAndOperands(IRCloneEnv* env, IRBuilder* builder, IRInst* oldIns // SLANG_ASSERT(!as(oldInst)); + const auto canBeSpecConst = canOperationBeSpecConst( + oldInst->getOp(), + oldInst->getDataType(), + nullptr, + oldInst->getOperands()); + // Next we will iterate over the operands of `oldInst` // to find their replacements and install them as // the operands of `newInst`. @@ -94,7 +100,7 @@ IRInst* cloneInstAndOperands(IRCloneEnv* env, IRBuilder* builder, IRInst* oldIns newOperands[ii] = newOperand; - if (isArithmeticInst(oldInst)) + if (canBeSpecConst) newType = maybeAddRateType(builder, newOperand->getFullType(), newType); } -- cgit v1.2.3