From 12e891ed9ac934adbcc4160da6a05938cc38b529 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 17 Oct 2024 22:22:34 -0700 Subject: Cleanup definition of `printf`. (#5330) * Cleanup definition of `printf`. * Fix. * Fix spirv generation. * Fix. * enhance test. --- source/slang/slang-emit-glsl.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/slang/slang-emit-glsl.cpp') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 7f8bc14b4..3ba967e20 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -2146,6 +2146,27 @@ bool GLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu m_writer->emit("endInvocationInterlockARB()"); return true; } + case kIROp_Printf: + { + m_glslExtensionTracker->requireExtension(toSlice("GL_EXT_debug_printf")); + m_writer->emit("debugPrintfEXT("); + emitOperand(inst->getOperand(0), getInfo(EmitOp::General)); + if (inst->getOperandCount() == 2) + { + auto operand = inst->getOperand(1); + if (auto makeStruct = as(operand)) + { + // Flatten the tuple resulting from the variadic pack. + for (UInt bb = 0; bb < makeStruct->getOperandCount(); ++bb) + { + m_writer->emit(", "); + emitOperand(makeStruct->getOperand(bb), getInfo(EmitOp::General)); + } + } + } + m_writer->emit(")"); + return true; + } default: break; } -- cgit v1.2.3