summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-emit-hlsl.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 1cb9b769f..59d40d3a1 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -1252,23 +1252,30 @@ void HLSLSourceEmitter::emitSimpleValueImpl(IRInst* inst)
{
case IRConstant::FloatKind::Nan:
{
- m_writer->emit("(0.0 / 0.0)");
+ m_writer->emit("(0.0f / 0.0f)");
return;
}
case IRConstant::FloatKind::PositiveInfinity:
{
- m_writer->emit("(1.0 / 0.0)");
+ m_writer->emit("(1.0f / 0.0f)");
return;
}
case IRConstant::FloatKind::NegativeInfinity:
{
- m_writer->emit("(-1.0 / 0.0)");
+ m_writer->emit("(-1.0f / 0.0f)");
return;
}
default:
- break;
+ {
+ m_writer->emit(constantInst->value.floatVal);
+ // Add 'f' suffix for 32-bit float literals to ensure DXC treats them as float
+ if (constantInst->getDataType()->getOp() == kIROp_FloatType)
+ {
+ m_writer->emit("f");
+ }
+ return;
+ }
}
- break;
}
default: