summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-05 11:18:14 -0800
committerGitHub <noreply@github.com>2024-03-05 11:18:14 -0800
commit8d4b659b4d95fb72f4c483f6327acd60b44268bc (patch)
tree834583cc393987472036b9d3b3e740bc25f908f3 /source/slang/slang-emit-spirv.cpp
parentbb017e6aa8ddbfac6b9a78a66f4706964fbeaff4 (diff)
[SPIRV] Fix DebugLine generated from source with #line directive. (#3678)
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp14
1 files changed, 12 insertions, 2 deletions
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<IRDebugSource>(inst);
auto sourceStr = as<IRStringLit>(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),