summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-hlsl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-09-09 11:39:04 -0700
committerGitHub <noreply@github.com>2021-09-09 11:39:04 -0700
commit28adf8917e53953dbfebd746410a427a55eed814 (patch)
treeb575bcdcc7860d64065e538d3fbf1d0466803aa3 /source/slang/slang-emit-hlsl.cpp
parentcc075b76ee25876135584d31ec650776fcb69166 (diff)
`reinterpret` and 16-bit value packing. (#1933)
* `reinterpret` and 16-bit value packing. * Update `half-texture` cross-compile test reference result. * Revert inadvertent reformatting of slang-ir-inst-defs.h Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-hlsl.cpp')
-rw-r--r--source/slang/slang-emit-hlsl.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 3921cbbac..2fda8ab99 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -479,7 +479,9 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
emitType(inst->getDataType());
m_writer->emit(")");
break;
-
+ case BaseType::Half:
+ m_writer->emit("f16tof32");
+ break;
case BaseType::Float:
// Note: at present HLSL only supports
// reinterpreting integer bits as a `float`.
@@ -511,11 +513,18 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
case BaseType::UInt:
case BaseType::Int:
break;
-
+ case BaseType::UInt16:
+ case BaseType::Int16:
+ break;
case BaseType::Float:
m_writer->emit("asuint(");
closeCount++;
break;
+
+ case BaseType::Half:
+ m_writer->emit("f32tof16(");
+ closeCount++;
+ break;
}
emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
@@ -750,20 +759,32 @@ void HLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
case kIROp_VoidType:
case kIROp_BoolType:
case kIROp_Int8Type:
- case kIROp_Int16Type:
case kIROp_IntType:
case kIROp_Int64Type:
case kIROp_UInt8Type:
- case kIROp_UInt16Type:
case kIROp_UIntType:
case kIROp_UInt64Type:
case kIROp_FloatType:
case kIROp_DoubleType:
- case kIROp_HalfType:
{
m_writer->emit(getDefaultBuiltinTypeName(type->getOp()));
return;
}
+ case kIROp_Int16Type:
+ {
+ m_writer->emit("min16int");
+ return;
+ }
+ case kIROp_UInt16Type:
+ {
+ m_writer->emit("min16uint");
+ return;
+ }
+ case kIROp_HalfType:
+ {
+ m_writer->emit("min16float");
+ return;
+ }
case kIROp_StructType:
m_writer->emit(getName(type));
return;