From 9f9d28c1f496132dc71b80252b0eeddfa28cc8bc Mon Sep 17 00:00:00 2001 From: aidanfnv Date: Mon, 6 Oct 2025 17:29:05 -0700 Subject: Use loadModuleFromSourceString in specialization example snippet (#8616) Fixes #8221 This modifies the code snippet used to demonstrate link-time specialization to use the public `loadModuleFromSourceString` API instead of the internal `UnownedRawBlob::create`. It also corrects a couple variable names in the snippet as well. --- docs/user-guide/10-link-time-specialization.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/user-guide/10-link-time-specialization.md b/docs/user-guide/10-link-time-specialization.md index e5bc97930..bda8692a8 100644 --- a/docs/user-guide/10-link-time-specialization.md +++ b/docs/user-guide/10-link-time-specialization.md @@ -84,16 +84,16 @@ slang::IModule* mainModule = slangSession->loadModule("main.slang", diagnosticsB // Load the specialization constant module from string. const char* sampleCountSrc = R"(export static const int kSampleCount = 2;)"; -auto sampleCountModuleSrcBlob = UnownedRawBlob::create(sampleCountSrc, strlen(sampleCountSrc)); -slang::IModule* sampleCountModule = slangSession->loadModuleFromSource( +slang::IModule* sampleCountModule = slangSession->loadModuleFromSourceString( "sample-count", // module name "sample-count.slang", // synthetic module path - sampleCountModuleSrcBlob); // module source content + sampleCountSrc, // module source content + diagnosticsBlob.writeRef()); // Compose the modules and entry points. ComPtr computeEntryPoint; SLANG_RETURN_ON_FAIL( - module->findEntryPointByName(entryPointName, computeEntryPoint.writeRef())); + mainModule->findEntryPointByName(entryPointName, computeEntryPoint.writeRef())); std::vector componentTypes; componentTypes.push_back(mainModule); @@ -113,7 +113,7 @@ composedProgram->link(linkedProgram.writeRef(), diagnosticsBlob.writeRef()); // Get compiled code. ComPtr compiledCode; -linkedProgram->getEntryPointCode(0, 0, compiledCode.writeRef(), diagnosticBlob.writeRef()); +linkedProgram->getEntryPointCode(0, 0, compiledCode.writeRef(), diagnosticsBlob.writeRef()); ``` -- cgit v1.2.3