diff options
| author | jarcherNV <jarcher@nvidia.com> | 2025-06-06 14:30:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 14:30:06 -0700 |
| commit | 0d16228ae22fa2e1a00e62dc099eea08da7717fe (patch) | |
| tree | 067573914132892dc1336dcdea2c8b595f24f871 /source/compiler-core/slang-artifact-impl.cpp | |
| parent | 649d533727b31b28397ffb3a530e655ac3861547 (diff) | |
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.
Diffstat (limited to 'source/compiler-core/slang-artifact-impl.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-impl.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
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<IArtifactPostEmitMetadata>(this); + if (!metadata) + return SLANG_E_NOT_AVAILABLE; + + *outMetadata = static_cast<slang::IMetadata*>(metadata); + (*outMetadata)->addRef(); + return SLANG_OK; +} + SlangResult Artifact::getOrCreateRepresentation( const Guid& typeGuid, ArtifactKeep keep, |
