summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-util.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-23 12:14:21 -0700
committerGitHub <noreply@github.com>2024-04-23 12:14:21 -0700
commitf1de1817ca10e34ec6a844100f10f0de3340c9f2 (patch)
tree63e631a3c546107f450ab5153e630c5b4a0dc33a /source/slang/slang-ir-util.cpp
parent0d9206855888d694e0b8f91be4524b57293773d6 (diff)
Switch to direct-to-spirv backend as default. (#4002)
* Switch to direct-to-spirv backend as default. * Fix slang-test. * Fix. * Fix.
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
-rw-r--r--source/slang/slang-ir-util.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index eaf254190..f7a93dca6 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -1544,6 +1544,27 @@ void hoistInstOutOfASMBlocks(IRBlock* block)
}
}
+IRType* getSPIRVSampledElementType(IRInst* sampledType)
+{
+ auto sampledElementType = getVectorElementType((IRType*)sampledType);
+ if (sampledElementType->getOp() == kIROp_HalfType)
+ {
+ IRBuilder builder(sampledType);
+ sampledElementType = builder.getBasicType(BaseType::Float);
+ }
+ return sampledElementType;
+}
+
+IRType* replaceVectorElementType(IRType* originalVectorType, IRType* t)
+{
+ if (auto orignalVectorType = as<IRVectorType>(originalVectorType))
+ {
+ IRBuilder builder(originalVectorType);
+ return builder.getVectorType(t, orignalVectorType->getElementCount());
+ }
+ return t;
+}
+
IRParam* getParamAt(IRBlock* block, UIndex ii)
{
UIndex index = 0;