From f521c2002e6b664944c6c39bab767dca1802887a Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Fri, 4 Oct 2024 10:20:57 -0400 Subject: Add interfaces for retrieving separate linkable downstream binaries (#5128) * Implement separate downstream library interface Create a new com interface to house the methods for precompiling slang modules to target code. Add methods to count dependent modules and scrape them for downstream target binaries such that the downstream target binaries are linkabe outside of slang, e.g. via spirv-link or dxc. Fixes #5147 * Rename to _Experimental Clearly identify this as an interface subject to change. --- tools/gfx-unit-test/precompiled-module-2.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/gfx-unit-test/precompiled-module-2.cpp b/tools/gfx-unit-test/precompiled-module-2.cpp index e8ceb6f45..f997b2a7b 100644 --- a/tools/gfx-unit-test/precompiled-module-2.cpp +++ b/tools/gfx-unit-test/precompiled-module-2.cpp @@ -29,9 +29,12 @@ namespace gfx_test auto globalSession = slangSession->getGlobalSession(); globalSession->createSession(sessionDesc, slangSession.writeRef()); - Slang::ComPtr diagnosticsBlob; - slang::IModule* module = slangSession->loadModule(shaderModuleName, diagnosticsBlob.writeRef()); - diagnoseIfNeeded(diagnosticsBlob); + slang::IModule* module; + { + Slang::ComPtr diagnosticsBlob; + module = slangSession->loadModule(shaderModuleName, diagnosticsBlob.writeRef()); + diagnoseIfNeeded(diagnosticsBlob); + } if (!module) return SLANG_FAIL; @@ -49,7 +52,14 @@ namespace gfx_test default: return SLANG_FAIL; } - module->precompileForTarget(target, diagnosticsBlob.writeRef()); + + ComPtr precompileService; + if (module->queryInterface(slang::SLANG_UUID_IModulePrecompileService_Experimental, (void**)precompileService.writeRef()) == SLANG_OK) + { + Slang::ComPtr diagnosticsBlob; + precompileService->precompileForTarget(target, diagnosticsBlob.writeRef()); + diagnoseIfNeeded(diagnosticsBlob); + } } // Write loaded modules to memory file system. -- cgit v1.2.3