From 9c8fab83a53c43e345566c35f87c16fe7b815e01 Mon Sep 17 00:00:00 2001 From: jarcherNV Date: Thu, 12 Jun 2025 19:14:49 -0700 Subject: Fix API changes from separate debugging support (#7397) Recent separate debugging support added two new functions which broke backwards compatibility. This change restores the old API and moves the new functions to an IComponentType2 interface which can be used if separate debug files are needed. --- source/slang/slang.cpp | 84 ++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 41 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index daebddeae..6ee50251a 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -5322,6 +5322,8 @@ ISlangUnknown* ComponentType::getInterface(Guid const& guid) } if (guid == IModulePrecompileService_Experimental::getTypeGuid()) return static_cast(this); + if (guid == IComponentType2::getTypeGuid()) + return static_cast(this); return nullptr; } @@ -5568,33 +5570,6 @@ 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(artifact); - (*outCompileResult)->addRef(); - return SLANG_OK; -} - RefPtr ComponentType::specialize( SpecializationArg const* inSpecializationArgs, SlangInt specializationArgCount, @@ -5737,6 +5712,47 @@ SLANG_NO_THROW SlangResult SLANG_MCALL ComponentType::linkWithOptions( 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(artifact); + (*outCompileResult)->addRef(); + 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(artifact); + (*outCompileResult)->addRef(); + return SLANG_OK; +} + /// Visitor used by `ComponentType::enumerateModules` struct EnumerateModulesVisitor : ComponentTypeVisitor { @@ -5930,20 +5946,6 @@ 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(artifact); - //(*outCompileResult)->addRef(); // TODO: Needed if using a ComPtr. - return SLANG_OK; -} - // // CompositeComponentType // -- cgit v1.2.3