From 8d4b659b4d95fb72f4c483f6327acd60b44268bc Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 5 Mar 2024 11:18:14 -0800 Subject: [SPIRV] Fix DebugLine generated from source with #line directive. (#3678) --- source/slang/slang-emit-spirv.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (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 dd417e38f..e37d09af7 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -1599,10 +1599,20 @@ struct SPIRVEmitContext case kIROp_DebugSource: { ensureExtensionDeclaration(UnownedStringSlice("SPV_KHR_non_semantic_info")); - // SPIRV does not allow string lits longer than 65535, so we need to split the source string - // in OpDebugSourceContinued instructions. auto debugSource = as(inst); auto sourceStr = as(debugSource->getSource())->getStringSlice(); + // If source content is empty, skip the content operand. + if (sourceStr.getLength() == 0) + { + return emitOpDebugSource( + getSection(SpvLogicalSectionID::ConstantsAndTypes), + inst, + inst->getFullType(), + getNonSemanticDebugInfoExtInst(), + debugSource->getFileName()); + } + // SPIRV does not allow string lits longer than 65535, so we need to split the source string + // in OpDebugSourceContinued instructions. auto sourceStrHead = sourceStr.getLength() > 65535 ? sourceStr.head(65535) : sourceStr; auto spvStrHead = emitInst( getSection(SpvLogicalSectionID::DebugStringsAndSource), -- cgit v1.2.3