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-spirv.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 62819e6d5..321c547be 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -3426,6 +3426,27 @@ struct SPIRVEmitContext emitInst(parent, inst, SpvOpControlBarrier, executionScope, memoryScope, memorySemantics); } break; + case kIROp_Printf: + { + List operands; + operands.add(inst->getOperand(0)); + 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) + { + operands.add(makeStruct->getOperand(bb)); + } + } + } + ensureExtensionDeclaration(toSlice("SPV_KHR_non_semantic_info")); + result = emitInst(parent, inst, SpvOpExtInst, inst->getFullType(), kResultID, + getNonSemanticDebugPrintfExtInst(), SpvLiteralInteger::from32(1), operands.getArrayView()); + } + break; } if (result) emitDecorations(inst, getID(result)); -- cgit v1.2.3