summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-02-07 18:27:23 -0800
committerGitHub <noreply@github.com>2025-02-07 18:27:23 -0800
commit57b09a8986668626c37055e431fa0ac6449d7214 (patch)
tree8a96d7ea01a150d22ba47818655239b21d4ac25e /source/slang/slang-ir.cpp
parent79aebc18d54db3f0be8bd6529c0d79f4d8d4fc58 (diff)
Use and() and or() functions for logical-AND and OR (#6310)
* Use and() and or() functions for logical-AND and OR With this commit, Slang will emit function calls to `and()` and `or()` for the logical-AND and logical-OR when the operands are non-scalar and the target profile is SM6.0 and above. This is required change from SM6.0. For WGSL, there is no operator overloadings of `&&` and `||` when the operands are non-scalar. Unlike HLSL, WGSL also don't have `and()` nor `or()`. Alternatively, we can use `select()`.
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 6cf7a1786..07e8b2742 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -6020,6 +6020,20 @@ IRInst* IRBuilder::emitShl(IRType* type, IRInst* left, IRInst* right)
return inst;
}
+IRInst* IRBuilder::emitAnd(IRType* type, IRInst* left, IRInst* right)
+{
+ auto inst = createInst<IRInst>(this, kIROp_And, type, left, right);
+ addInst(inst);
+ return inst;
+}
+
+IRInst* IRBuilder::emitOr(IRType* type, IRInst* left, IRInst* right)
+{
+ auto inst = createInst<IRInst>(this, kIROp_Or, type, left, right);
+ addInst(inst);
+ return inst;
+}
+
IRInst* IRBuilder::emitGetNativePtr(IRInst* value)
{
auto valueType = value->getDataType();