From 0d16228ae22fa2e1a00e62dc099eea08da7717fe Mon Sep 17 00:00:00 2001 From: jarcherNV Date: Fri, 6 Jun 2025 14:30:06 -0700 Subject: Add command line option for separate debug info (#7178) * Add command line option for separate debug info Add command line arg -separate-debug-info which, if provided, produces both a .spv and a .dbg.spv file. The .dbg.spv file contains full debug info and the .spv file has all debug info stripped out. Also add a DebugBuildIdentifier instruction to store a unique hash in both the output files, so they can be more easily matched together. A matching API is provided to allow using the Slang API to retrieve a base and debug SPIRV as well as the debug build identifier string. --- source/compiler-core/slang-artifact-impl.cpp | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source/compiler-core/slang-artifact-impl.cpp') diff --git a/source/compiler-core/slang-artifact-impl.cpp b/source/compiler-core/slang-artifact-impl.cpp index 31c01f1de..1aed32cea 100644 --- a/source/compiler-core/slang-artifact-impl.cpp +++ b/source/compiler-core/slang-artifact-impl.cpp @@ -170,6 +170,48 @@ void Artifact::removeAt(ContainedKind kind, Index i) } } +uint32_t Artifact::getItemCount() +{ + // Ignore the metadata when counting items, and the base artifact is item 0. + uint32_t count = 1; + for (auto artifact : m_associated) + if (artifact->getDesc().payload != ArtifactPayload::Metadata && + artifact->getDesc().payload != ArtifactPayload::PostEmitMetadata) + count++; + return count; +} + +SlangResult Artifact::getItemData(uint32_t index, slang::IBlob** outblob) +{ + // Item 0 is the base artifact, otherwise iterate and ignore the metadata. + if (index == 0) + return loadBlob(ArtifactKeep::Yes, outblob); + + uint32_t count = 1; + for (auto artifact : m_associated) + { + if (artifact->getDesc().payload == ArtifactPayload::Metadata || + artifact->getDesc().payload == ArtifactPayload::PostEmitMetadata) + continue; + if (count == index) + return artifact->loadBlob(ArtifactKeep::Yes, outblob); + count++; + } + return SLANG_FAIL; +} + +SlangResult Artifact::getMetadata(slang::IMetadata** outMetadata) +{ + // Find and return the associated metadata artifact. + auto metadata = findAssociatedRepresentation(this); + if (!metadata) + return SLANG_E_NOT_AVAILABLE; + + *outMetadata = static_cast(metadata); + (*outMetadata)->addRef(); + return SLANG_OK; +} + SlangResult Artifact::getOrCreateRepresentation( const Guid& typeGuid, ArtifactKeep keep, -- cgit v1.2.3