summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-01-23 16:57:44 -0800
committerGitHub <noreply@github.com>2024-01-23 16:57:44 -0800
commit4d217907665180537ea217f9f2213c9d53a22b99 (patch)
tree02de5405c4fc4cd3cdd3b4ef4496b7c33a4e9728 /source
parentaf91e770f99da18ae97d6b601c706343cece11e9 (diff)
Fix incorrect behavior of operator% (#3470)
* Fix incorrect behavior of operator% Fixes #1059. This change fixes the incorrect translation of "operator%" from HLSL to SPIRV. The issue stems from the fact that the behavior of "operator%" in GLSL differs from that in HLSL. In HLSL it behaves as "remainder" where as it behaves as "modulus" in GLSL. We have been using SpvOpFMod for operator% when Slang compiles from HLSL to SPRIV, which is incorrect. This change switches it to SpvOpFRem. The tests are slightly modified to reveal any potential issues. * Change output type of test/compute/frem For testing the operator%, we are using "int" as the output type of the test, "test/compute/frem.slang". Since the operands are in float type, it is more preferable to have a float type as the resulting type. This can be done with an option, "-output-using-type". --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit-spirv.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index a600d4b10..46ce1d0b5 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -4398,7 +4398,7 @@ struct SPIRVEmitContext
opCode = isSigned ? SpvOpSRem : SpvOpUMod;
break;
case kIROp_FRem:
- opCode = SpvOpFMod;
+ opCode = SpvOpFRem;
break;
case kIROp_Less:
opCode = isFloatingPoint ? SpvOpFOrdLessThan