summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-hlsl.cpp
diff options
context:
space:
mode:
authorQubaef <52603374+Qubaef@users.noreply.github.com>2022-09-16 06:55:54 +0200
committerGitHub <noreply@github.com>2022-09-15 21:55:54 -0700
commit53db0e9e126cb26ffb505e1bf02cc64f00cc9855 (patch)
treeeb2b3adb828e154bfd1b7c6084e8e496b21a555e /source/slang/slang-emit-hlsl.cpp
parenta5d3bec25d70f23da1e79cd7773981ff34593611 (diff)
Add support for GL_EXT_debug_printf extension to slang (#2399)
Diffstat (limited to 'source/slang/slang-emit-hlsl.cpp')
-rw-r--r--source/slang/slang-emit-hlsl.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 20fcc5bed..2ffcd6c10 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -539,19 +539,21 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
}
case kIROp_StringLit:
{
- IRStringLit* lit = cast<IRStringLit>(inst);
- UnownedStringSlice slice = lit->getStringSlice();
- m_writer->emit(int32_t(getStableHashCode32(slice.begin(), slice.getLength())));
+ const auto handler = StringEscapeUtil::getHandler(StringEscapeUtil::Style::Slang);
+
+ StringBuilder buf;
+ const UnownedStringSlice slice = as<IRStringLit>(inst)->getStringSlice();
+ StringEscapeUtil::appendQuoted(handler, slice, buf);
+
+ m_writer->emit(buf);
+
return true;
}
case kIROp_GetStringHash:
{
- // On GLSL target, the `String` type is just an `int`
- // that is the hash of the string, so we can emit
- // the first operand to `getStringHash` directly.
- //
- EmitOpInfo outerPrec = inOuterPrec;
- emitOperand(inst->getOperand(0), outerPrec);
+ const UnownedStringSlice slice = as<IRStringLit>(inst->getOperand(0))->getStringSlice();
+ m_writer->emit(static_cast<int32_t>(getStableHashCode32(slice.begin(), slice.getLength())));
+
return true;
}
case kIROp_ByteAddressBufferLoad: