summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorjarcherNV <jarcher@nvidia.com>2025-06-06 14:30:06 -0700
committerGitHub <noreply@github.com>2025-06-06 14:30:06 -0700
commit0d16228ae22fa2e1a00e62dc099eea08da7717fe (patch)
tree067573914132892dc1336dcdea2c8b595f24f871 /source/slang/slang.cpp
parent649d533727b31b28397ffb3a530e655ac3861547 (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/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp57
1 files changed, 51 insertions, 6 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index d8879c690..d66e86b2d 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -5499,12 +5499,16 @@ SLANG_NO_THROW void SLANG_MCALL ComponentType::getEntryPointHash(
buildHash(builder);
// Add the name and name override for the specified entry point to the hash.
- auto entryPointName = getEntryPoint(entryPointIndex)->getName()->text;
- builder.append(entryPointName);
- auto entryPointMangledName = getEntryPointMangledName(entryPointIndex);
- builder.append(entryPointMangledName);
- auto entryPointNameOverride = getEntryPointNameOverride(entryPointIndex);
- builder.append(entryPointNameOverride);
+ auto entryPoint = getEntryPoint(entryPointIndex);
+ if (entryPoint)
+ {
+ auto entryPointName = entryPoint->getName()->text;
+ builder.append(entryPointName);
+ auto entryPointMangledName = getEntryPointMangledName(entryPointIndex);
+ builder.append(entryPointMangledName);
+ auto entryPointNameOverride = getEntryPointNameOverride(entryPointIndex);
+ builder.append(entryPointNameOverride);
+ }
auto hash = builder.finalize().toBlob();
*outHash = hash.detach();
@@ -5567,6 +5571,33 @@ SLANG_NO_THROW SlangResult SLANG_MCALL ComponentType::getEntryPointMetadata(
return SLANG_OK;
}
+SLANG_NO_THROW SlangResult SLANG_MCALL ComponentType::getEntryPointCompileResult(
+ SlangInt entryPointIndex,
+ Int targetIndex,
+ slang::ICompileResult** outCompileResult,
+ slang::IBlob** outDiagnostics)
+{
+ auto linkage = getLinkage();
+ if (targetIndex < 0 || targetIndex >= linkage->targets.getCount())
+ return SLANG_E_INVALID_ARG;
+ auto target = linkage->targets[targetIndex];
+
+ auto targetProgram = getTargetProgram(target);
+
+ DiagnosticSink sink(linkage->getSourceManager(), Lexer::sourceLocationLexer);
+ applySettingsToDiagnosticSink(&sink, &sink, linkage->m_optionSet);
+ applySettingsToDiagnosticSink(&sink, &sink, m_optionSet);
+
+ IArtifact* artifact = targetProgram->getOrCreateEntryPointResult(entryPointIndex, &sink);
+ sink.getBlobIfNeeded(outDiagnostics);
+ if (artifact == nullptr)
+ return SLANG_E_NOT_AVAILABLE;
+
+ *outCompileResult = static_cast<slang::ICompileResult*>(artifact);
+ (*outCompileResult)->addRef();
+ return SLANG_OK;
+}
+
RefPtr<ComponentType> ComponentType::specialize(
SpecializationArg const* inSpecializationArgs,
SlangInt specializationArgCount,
@@ -5902,6 +5933,20 @@ SLANG_NO_THROW SlangResult SLANG_MCALL ComponentType::getTargetMetadata(
return SLANG_OK;
}
+SLANG_NO_THROW SlangResult SLANG_MCALL ComponentType::getTargetCompileResult(
+ Int targetIndex,
+ slang::ICompileResult** outCompileResult,
+ slang::IBlob** outDiagnostics)
+{
+ IArtifact* artifact = getTargetArtifact(targetIndex, outDiagnostics);
+ if (artifact == nullptr)
+ return SLANG_E_NOT_AVAILABLE;
+
+ *outCompileResult = static_cast<slang::ICompileResult*>(artifact);
+ //(*outCompileResult)->addRef(); // TODO: Needed if using a ComPtr.
+ return SLANG_OK;
+}
+
//
// CompositeComponentType
//