summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-util.cpp
diff options
context:
space:
mode:
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;