summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir.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.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.cpp')
-rw-r--r--source/slang/slang-ir.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 7cdc8ecfa..4ea3755f8 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -3773,7 +3773,12 @@ namespace Slang
return nullptr;
}
- static int _getTypeStyleId(IRType* type)
+ enum class TypeCastStyle
+ {
+ Unknown = -1,
+ Int, Float, Bool, Ptr, Void
+ };
+ static TypeCastStyle _getTypeStyleId(IRType* type)
{
if (auto vectorType = as<IRVectorType>(type))
{
@@ -3787,22 +3792,24 @@ namespace Slang
switch (style)
{
case kIROp_IntType:
- return 0;
+ return TypeCastStyle::Int;
case kIROp_FloatType:
- return 1;
+ case kIROp_HalfType:
+ case kIROp_DoubleType:
+ return TypeCastStyle::Float;
case kIROp_BoolType:
- return 2;
+ return TypeCastStyle::Bool;
case kIROp_PtrType:
case kIROp_InOutType:
case kIROp_OutType:
case kIROp_RawPointerType:
case kIROp_RefType:
case kIROp_ConstRefType:
- return 3;
+ return TypeCastStyle::Ptr;
case kIROp_VoidType:
- return 4;
+ return TypeCastStyle::Void;
default:
- return -1;
+ return TypeCastStyle::Unknown;
}
}
@@ -3814,14 +3821,14 @@ namespace Slang
auto toStyle = _getTypeStyleId(type);
auto fromStyle = _getTypeStyleId(value->getDataType());
- if (fromStyle == kIROp_VoidType)
+ if (fromStyle == TypeCastStyle::Void)
{
// We shouldn't be casting from void to other types.
SLANG_UNREACHABLE("cast from void type");
}
- SLANG_RELEASE_ASSERT(toStyle != -1);
- SLANG_RELEASE_ASSERT(fromStyle != -1);
+ SLANG_RELEASE_ASSERT(toStyle != TypeCastStyle::Unknown);
+ SLANG_RELEASE_ASSERT(fromStyle != TypeCastStyle::Unknown);
struct OpSeq
{
@@ -3845,7 +3852,7 @@ namespace Slang
/* From Ptr */ {kIROp_CastPtrToInt, {kIROp_CastPtrToInt, kIROp_CastIntToFloat}, kIROp_CastPtrToBool, kIROp_BitCast, kIROp_CastToVoid},
};
- auto op = opMap[fromStyle][toStyle];
+ auto op = opMap[(int)fromStyle][(int)toStyle];
if (op.op0 == kIROp_Nop)
return value;
auto t = type;
@@ -5896,6 +5903,18 @@ namespace Slang
);
return i;
}
+ IRSPIRVAsmOperand* IRBuilder::emitSPIRVAsmOperandConvertTexel(IRInst* inst)
+ {
+ SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent()));
+ auto i = createInst<IRSPIRVAsmOperand>(
+ this,
+ kIROp_SPIRVAsmOperandConvertTexel,
+ inst->getFullType(),
+ inst
+ );
+ addInst(i);
+ return i;
+ }
IRSPIRVAsmOperand* IRBuilder::emitSPIRVAsmOperandRayPayloadFromLocation(IRInst* inst)
{
SLANG_ASSERT(as<IRSPIRVAsm>(m_insertLoc.getParent()));