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-emit-spirv.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 57ad1a988..0a3dab78a 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -784,18 +784,9 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex switch (irOpCode) { case kIROp_IntCast: - { - auto typeStyle = getTypeStyle(basicType->getBaseType()); - if (typeStyle == kIROp_FloatType) - { - return SpvOpConvertFToU; - } - else if (typeStyle == kIROp_IntType) - { - return SpvOpUConvert; - } - break; - } + return SpvOpUConvert; + case kIROp_FloatCast: + return SpvOpFConvert; default: break; } -- cgit v1.2.3