diff options
| author | aidanfnv <aidanf@nvidia.com> | 2025-10-06 17:29:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-07 00:29:05 +0000 |
| commit | 9f9d28c1f496132dc71b80252b0eeddfa28cc8bc (patch) | |
| tree | 7205df36d863c77b49936b6e043192db99cb657d | |
| parent | e23b5fa997c9032ee21d58da8c7023fc16795286 (diff) | |
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.
| -rw-r--r-- | docs/user-guide/10-link-time-specialization.md | 10 |
1 files 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<slang::IEntryPoint> computeEntryPoint; SLANG_RETURN_ON_FAIL( - module->findEntryPointByName(entryPointName, computeEntryPoint.writeRef())); + mainModule->findEntryPointByName(entryPointName, computeEntryPoint.writeRef())); std::vector<slang::IComponentType*> componentTypes; componentTypes.push_back(mainModule); @@ -113,7 +113,7 @@ composedProgram->link(linkedProgram.writeRef(), diagnosticsBlob.writeRef()); // Get compiled code. ComPtr<slang::IBlob> compiledCode; -linkedProgram->getEntryPointCode(0, 0, compiledCode.writeRef(), diagnosticBlob.writeRef()); +linkedProgram->getEntryPointCode(0, 0, compiledCode.writeRef(), diagnosticsBlob.writeRef()); ``` |
