summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-clone.cpp
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-05-30 01:04:27 -0400
committerGitHub <noreply@github.com>2025-05-29 22:04:27 -0700
commitaa3e6bdbe024355b07f6a61806024b248528fe4b (patch)
tree3f11539df4dfd0dfcb7df2b4e7ce877ab9b84179 /source/slang/slang-ir-clone.cpp
parent61f66c116ab10fdfd37492056aab7dfa4276a0b7 (diff)
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
Diffstat (limited to 'source/slang/slang-ir-clone.cpp')
-rw-r--r--source/slang/slang-ir-clone.cpp8
1 files changed, 7 insertions, 1 deletions
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<IRConstant>(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);
}