diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-10-25 10:14:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-25 10:14:22 -0700 |
| commit | 4bad669bbc5ec3ff77321f083c59cde87eb10229 (patch) | |
| tree | bf0abc916692cf34e804469bba400f2b04172472 | |
| parent | ef40d3044cf75ec3d7b24a43257fa744b45274f9 (diff) | |
Replace stdlib on Slang API with CoreModule (#5405)
This is a breaking change in a way that the Slang API function names are changed. All of them are commented as "experimental" and we wouldn't provide a back-ward compatibility for them.
Following functions are renamed:
compileStdLib() -> compileCoreModule()
loadStdLib() -> loadCoreModule()
saveStdLib() -> saveCoreModule()
slang_createGlobalSessionWithoutStdLib() -> slang_createGlobalSessionWithoutCoreModule()
slang_getEmbeddedStdLib() -> slang_getEmbeddedCoreModule()
hasDeferredStdLib() -> hasDeferredCoreModule()
Following command-line arguments are renamed:
"-load-stdlib" -> "-load-core-module"
"-save-stdlib" -> "-save-core-module"
"-save-stdlib-bin-source" -> "-save-core-module-bin-source"
"-compile-stdlib" -> "-compile-core-module"
29 files changed, 170 insertions, 168 deletions
diff --git a/docs/build_reference.ps1 b/docs/build_reference.ps1 index ebf745244..0aa424771 100644 --- a/docs/build_reference.ps1 +++ b/docs/build_reference.ps1 @@ -33,7 +33,7 @@ Remove-Item -Path ".\stdlib-reference\attributes" -Recurse -Force git describe --tags | Out-File -FilePath ".\stdlib-reference\_includes\version.inc" -Encoding ASCII cd stdlib-reference -& ../../build/Release/bin/slangc -compile-stdlib -doc +& ../../build/Release/bin/slangc -compile-core-module -doc Move-Item -Path ".\toc.html" -Destination ".\_includes\stdlib-reference-toc.html" -Force git config user.email "bot@shader-slang.com" git config user.name "Stdlib Reference Bot" @@ -49,4 +49,4 @@ cd ../ # Copy-Item -Path .\stdlib-reference\global-decls -Destination D:\git_repo\stdlib-reference\global-decls -Recurse -Force # Copy-Item -Path .\stdlib-reference\interfaces -Destination D:\git_repo\stdlib-reference\interfaces -Recurse -Force # Copy-Item -Path .\stdlib-reference\types -Destination D:\git_repo\stdlib-reference\types -Recurse -Force -# Copy-Item -Path .\stdlib-reference\_includes\stdlib-reference-toc.html -Destination D:\git_repo\stdlib-reference\_includes\stdlib-reference-toc.html -Force
\ No newline at end of file +# Copy-Item -Path .\stdlib-reference\_includes\stdlib-reference-toc.html -Destination D:\git_repo\stdlib-reference\_includes\stdlib-reference-toc.html -Force diff --git a/docs/doc-system.md b/docs/doc-system.md index 56635e4ed..1eb55f817 100644 --- a/docs/doc-system.md +++ b/docs/doc-system.md @@ -88,7 +88,7 @@ Currently the only documentation style supported is a single file 'markdown' out It is possible to generate documentation for Slangs internal `stdlib`. This can be achieved with `slangc` via ``` -slangc -doc -compile-stdlib +slangc -doc -compile-core-module ``` The documentation will be written to a file `stdlib-doc.md`. diff --git a/docs/stdlib-docgen.md b/docs/stdlib-docgen.md index df9317de9..0be3af548 100644 --- a/docs/stdlib-docgen.md +++ b/docs/stdlib-docgen.md @@ -19,7 +19,7 @@ rm -rf ./global-decls rm -rf ./attributes # generate updated pages -slangc -compile-stdlib -doc +slangc -compile-core-module -doc # optional: move generated toc.html to `_includes` mv toc.html ./_includes/stdlib-reference-toc.html @@ -96,7 +96,7 @@ as with `@remarks`. - Include examples if needed in the examples section. - Provide a see also section with links to related declarations. -After updating comments, build `slangc`, and run `slangc -compile-stdlib -doc` in `stdlib-reference` diretory to update the markdown files for preview. +After updating comments, build `slangc`, and run `slangc -compile-core-module -doc` in `stdlib-reference` diretory to update the markdown files for preview. Your PR only needs to include changes to *.meta.slang files. Once your PR is merged, slang CI will run `slangc` and push the updated markdown files to the `stdlib-reference` repo. @@ -111,4 +111,4 @@ C++'s visiblity modifiers: they apply to everything after it. To preview github pages locally, you need to follow instructions on setting up Jekyll: https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll -You will need to use Jekyll to create a Gem file before serving it.
\ No newline at end of file +You will need to use Jekyll to create a Gem file before serving it. diff --git a/include/slang.h b/include/slang.h index 624b66342..c466cd3b6 100644 --- a/include/slang.h +++ b/include/slang.h @@ -947,13 +947,13 @@ extern "C" // Internal ArchiveType, - CompileStdLib, + CompileCoreModule, Doc, IrCompression, - LoadStdLib, + LoadCoreModule, ReferenceModule, - SaveStdLib, - SaveStdLibBinSource, + SaveCoreModule, + SaveCoreModuleBinSource, TrackLiveness, LoopInversion, // bool, enable loop inversion optimization @@ -3307,10 +3307,10 @@ namespace slang }; - typedef uint32_t CompileStdLibFlags; - struct CompileStdLibFlag + typedef uint32_t CompileCoreModuleFlags; + struct CompileCoreModuleFlag { - enum Enum : CompileStdLibFlags + enum Enum : CompileCoreModuleFlags { WriteDocumentation = 0x1, }; @@ -3482,27 +3482,27 @@ namespace slang virtual SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport( SlangPassThrough passThrough) = 0; - /** Compile from (embedded source) the StdLib on the session. - Will return a failure if there is already a StdLib available + /** Compile from (embedded source) the core module on the session. + Will return a failure if there is already a core module available NOTE! API is experimental and not ready for production code @param flags to control compilation */ - virtual SLANG_NO_THROW SlangResult SLANG_MCALL compileStdLib(CompileStdLibFlags flags) = 0; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL compileCoreModule(CompileCoreModuleFlags flags) = 0; - /** Load the StdLib. Currently loads modules from the file system. - @param stdLib Start address of the serialized stdlib - @param stdLibSizeInBytes The size in bytes of the serialized stdlib + /** Load the core module. Currently loads modules from the file system. + @param coreModule Start address of the serialized core module + @param coreModuleSizeInBytes The size in bytes of the serialized core module NOTE! API is experimental and not ready for production code */ - virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) = 0; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) = 0; - /** Save the StdLib modules to the file system - @param archiveType The type of archive used to hold the stdlib - @param outBlob The serialized blob containing the standard library + /** Save the core module to the file system + @param archiveType The type of archive used to hold the core module + @param outBlob The serialized blob containing the core module NOTE! API is experimental and not ready for production code */ - virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) = 0; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) = 0; /** Look up the internal ID of a capability by its `name`. @@ -4232,7 +4232,7 @@ namespace slang // using. #define SLANG_API_VERSION 0 -/* Create a global session, with built in StdLib. +/* Create a global session, with the built-in core module. @param apiVersion Pass in SLANG_API_VERSION @param outGlobalSession (out)The created global session. @@ -4241,22 +4241,24 @@ SLANG_EXTERN_C SLANG_API SlangResult slang_createGlobalSession( SlangInt apiVersion, slang::IGlobalSession** outGlobalSession); -/* Create a global session, but do not set up the stdlib. The stdlib can -then be loaded via loadStdLib or compileStdLib +/* Create a global session, but do not set up the core module. The core module can +then be loaded via loadCoreModule or compileCoreModule @param apiVersion Pass in SLANG_API_VERSION -@param outGlobalSession (out)The created global session that doesn't have a StdLib setup. +@param outGlobalSession (out)The created global session that doesn't have a core module setup. NOTE! API is experimental and not ready for production code */ -SLANG_EXTERN_C SLANG_API SlangResult slang_createGlobalSessionWithoutStdLib( +SLANG_EXTERN_C SLANG_API SlangResult slang_createGlobalSessionWithoutCoreModule( SlangInt apiVersion, slang::IGlobalSession** outGlobalSession); -/* Returns a blob that contains the serialized stdlib. -Returns nullptr if there isn't an embedded stdlib. +/* Returns a blob that contains the serialized core module. +Returns nullptr if there isn't an embedded core module. + +NOTE! API is experimental and not ready for production code */ -SLANG_API ISlangBlob* slang_getEmbeddedStdLib(); +SLANG_API ISlangBlob* slang_getEmbeddedCoreModule(); /* Cleanup all global allocations used by Slang, to prevent memory leak detectors from diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp index 9a0ebe4f1..d362d7043 100644 --- a/source/core/slang-test-tool-util.cpp +++ b/source/core/slang-test-tool-util.cpp @@ -37,12 +37,12 @@ namespace Slang } } -/* static */bool TestToolUtil::hasDeferredStdLib(Index argc, const char*const* argv) +/* static */bool TestToolUtil::hasDeferredCoreModule(Index argc, const char*const* argv) { for (Index i = 0; i < argc; ++i) { UnownedStringSlice option(argv[i]); - if (option == "-load-stdlib" || option == "-compile-stdlib") + if (option == "-load-core-module" || option == "-compile-core-module") { return true; } diff --git a/source/core/slang-test-tool-util.h b/source/core/slang-test-tool-util.h index 03f3b768e..967dc0fa8 100644 --- a/source/core/slang-test-tool-util.h +++ b/source/core/slang-test-tool-util.h @@ -64,8 +64,8 @@ struct TestToolUtil /// Sets the default preludes on the session based on the executable path static SlangResult setSessionDefaultPreludeFromExePath(const char* exePath, slang::IGlobalSession* session); - /// Returns true if the StdLib should not be initialized immediately (eg when doing a -load-stdlib). - static bool hasDeferredStdLib(Index numArgs, const char*const* args); + /// Returns true if the core module should not be initialized immediately (eg when doing a -load-core-module). + static bool hasDeferredCoreModule(Index numArgs, const char*const* args); static SlangResult getDllDirectoryPath(const char* exePath, String& outDllDirectoryPath); }; diff --git a/source/slang-record-replay/record/slang-global-session.cpp b/source/slang-record-replay/record/slang-global-session.cpp index 012900f5c..06bbed553 100644 --- a/source/slang-record-replay/record/slang-global-session.cpp +++ b/source/slang-record-replay/record/slang-global-session.cpp @@ -306,48 +306,48 @@ namespace SlangRecord return res; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileStdLib(slang::CompileStdLibFlags flags) + SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileCoreModule(slang::CompileCoreModuleFlags flags) { slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); ParameterRecorder* recorder {}; { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_compileStdLib, m_globalSessionHandle); + recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_compileCoreModule, m_globalSessionHandle); recorder->recordEnumValue(flags); m_recordManager->endMethodRecord(); } - SlangResult res = m_actualGlobalSession->compileStdLib(flags); + SlangResult res = m_actualGlobalSession->compileCoreModule(flags); return res; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) + SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) { slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); ParameterRecorder* recorder {}; { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_loadStdLib, m_globalSessionHandle); - recorder->recordPointer(stdLib, false, stdLibSizeInBytes); + recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_loadCoreModule, m_globalSessionHandle); + recorder->recordPointer(coreModule, false, coreModuleSizeInBytes); m_recordManager->endMethodRecord(); } - SlangResult res = m_actualGlobalSession->loadStdLib(stdLib, stdLibSizeInBytes); + SlangResult res = m_actualGlobalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); return res; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) + SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) { slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); ParameterRecorder* recorder {}; { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_saveStdLib, m_globalSessionHandle); + recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_saveCoreModule, m_globalSessionHandle); recorder->recordEnumValue(archiveType); recorder = m_recordManager->endMethodRecord(); } - SlangResult res = m_actualGlobalSession->saveStdLib(archiveType, outBlob); + SlangResult res = m_actualGlobalSession->saveCoreModule(archiveType, outBlob); { recorder->recordAddress(*outBlob); diff --git a/source/slang-record-replay/record/slang-global-session.h b/source/slang-record-replay/record/slang-global-session.h index 25504ff02..284185cb4 100644 --- a/source/slang-record-replay/record/slang-global-session.h +++ b/source/slang-record-replay/record/slang-global-session.h @@ -42,9 +42,9 @@ namespace SlangRecord SLANG_NO_THROW SlangResult SLANG_MCALL checkCompileTargetSupport(SlangCompileTarget target) override; SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport(SlangPassThrough passThrough) override; - SLANG_NO_THROW SlangResult SLANG_MCALL compileStdLib(slang::CompileStdLibFlags flags) override; - SLANG_NO_THROW SlangResult SLANG_MCALL loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) override; - SLANG_NO_THROW SlangResult SLANG_MCALL saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) override; + SLANG_NO_THROW SlangResult SLANG_MCALL compileCoreModule(slang::CompileCoreModuleFlags flags) override; + SLANG_NO_THROW SlangResult SLANG_MCALL loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) override; + SLANG_NO_THROW SlangResult SLANG_MCALL saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) override; SLANG_NO_THROW SlangCapabilityID SLANG_MCALL findCapability(char const* name) override; diff --git a/source/slang-record-replay/replay/decoder-consumer.h b/source/slang-record-replay/replay/decoder-consumer.h index aa3883cc0..d1039d867 100644 --- a/source/slang-record-replay/replay/decoder-consumer.h +++ b/source/slang-record-replay/replay/decoder-consumer.h @@ -30,9 +30,9 @@ namespace SlangRecord virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) = 0; virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) = 0; virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) = 0; - virtual void IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) = 0; - virtual void IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) = 0; - virtual void IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) = 0; + virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) = 0; + virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) = 0; + virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) = 0; virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) = 0; virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) = 0; virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) = 0; diff --git a/source/slang-record-replay/replay/json-consumer.cpp b/source/slang-record-replay/replay/json-consumer.cpp index 27b2830d6..21fd45807 100644 --- a/source/slang-record-replay/replay/json-consumer.cpp +++ b/source/slang-record-replay/replay/json-consumer.cpp @@ -787,17 +787,17 @@ namespace SlangRecord } - void JsonConsumer::IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) + void JsonConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) { SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileStdLib"); + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileCoreModule"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "flags", CompileStdLibFlagsToString(flags)); + _writePairNoComma(builder, indent, "flags", CompileCoreModuleFlagsToString(flags)); } } @@ -806,19 +806,19 @@ namespace SlangRecord } - void JsonConsumer::IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) + void JsonConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) { SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; - _writeString(builder, indent, "IGlobalSession::loadStdLib: {\n"); + _writeString(builder, indent, "IGlobalSession::loadCoreModule: {\n"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadStdLib"); + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadCoreModule"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "stdLib-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "stdLibSizeInBytes", (uint32_t)stdLibSizeInBytes); + _writePair(builder, indent, "coreModule-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma(builder, indent, "coreModuleSizeInBytes", (uint32_t)coreModuleSizeInBytes); } } @@ -826,14 +826,14 @@ namespace SlangRecord m_fileStream.flush(); } - void JsonConsumer::IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) + void JsonConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) { SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveStdLib"); + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveCoreModule"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); _writePair(builder, indent, "archiveType", SlangArchiveTypeToString(archiveType)); diff --git a/source/slang-record-replay/replay/json-consumer.h b/source/slang-record-replay/replay/json-consumer.h index d0529aab4..a7eaf1ec2 100644 --- a/source/slang-record-replay/replay/json-consumer.h +++ b/source/slang-record-replay/replay/json-consumer.h @@ -77,9 +77,9 @@ namespace SlangRecord virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId); virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target); virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough); - virtual void IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags); - virtual void IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes); - virtual void IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId); + virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags); + virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes); + virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId); virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name); virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler); virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target); diff --git a/source/slang-record-replay/replay/replay-consumer.cpp b/source/slang-record-replay/replay/replay-consumer.cpp index dd457c5d0..3ef2ae97d 100644 --- a/source/slang-record-replay/replay/replay-consumer.cpp +++ b/source/slang-record-replay/replay/replay-consumer.cpp @@ -466,42 +466,42 @@ namespace SlangRecord } - void ReplayConsumer::IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) + void ReplayConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) { InputObjectSanityCheck(objectId); slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->compileStdLib(flags); + SlangResult res = globalSession->compileCoreModule(flags); if (SLANG_FAILED(res)) { - slangRecordLog(LogLevel::Error, "IGlobalSession::compileStdLib fails, ret: 0x%X, this: 0x%X\n", res, objectId); + slangRecordLog(LogLevel::Error, "IGlobalSession::compileCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); } } - void ReplayConsumer::IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) + void ReplayConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) { InputObjectSanityCheck(objectId); slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->loadStdLib(stdLib, stdLibSizeInBytes); + SlangResult res = globalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); if (SLANG_FAILED(res)) { - slangRecordLog(LogLevel::Error, "IGlobalSession::loadStdLib fails, ret: 0x%X, this: 0x%X\n", res, objectId); + slangRecordLog(LogLevel::Error, "IGlobalSession::loadCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); } } - void ReplayConsumer::IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) + void ReplayConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) { InputObjectSanityCheck(objectId); OutputObjectSanityCheck(outBlobId); slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); ISlangBlob* outBlob {}; - SlangResult res = globalSession->saveStdLib(archiveType, &outBlob); + SlangResult res = globalSession->saveCoreModule(archiveType, &outBlob); if (outBlob && SLANG_SUCCEEDED(res)) { @@ -509,7 +509,7 @@ namespace SlangRecord } else { - slangRecordLog(LogLevel::Error, "IGlobalSession::saveStdLib fails, ret: 0x%X, this: 0x%X\n", res, objectId); + slangRecordLog(LogLevel::Error, "IGlobalSession::saveCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); } } diff --git a/source/slang-record-replay/replay/replay-consumer.h b/source/slang-record-replay/replay/replay-consumer.h index b7620af0d..8a0260c82 100644 --- a/source/slang-record-replay/replay/replay-consumer.h +++ b/source/slang-record-replay/replay/replay-consumer.h @@ -76,9 +76,9 @@ namespace SlangRecord virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) override; virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) override; virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) override; - virtual void IGlobalSession_compileStdLib(ObjectID objectId, slang::CompileStdLibFlags flags) override; - virtual void IGlobalSession_loadStdLib(ObjectID objectId, const void* stdLib, size_t stdLibSizeInBytes) override; - virtual void IGlobalSession_saveStdLib(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) override; + virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) override; + virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) override; + virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) override; virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) override; virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) override; virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) override; diff --git a/source/slang-record-replay/replay/slang-decoder.cpp b/source/slang-record-replay/replay/slang-decoder.cpp index 30d182729..6eb4ac8f5 100644 --- a/source/slang-record-replay/replay/slang-decoder.cpp +++ b/source/slang-record-replay/replay/slang-decoder.cpp @@ -91,14 +91,14 @@ namespace SlangRecord case ApiCallId::IGlobalSession_checkPassThroughSupport: IGlobalSession_checkPassThroughSupport(objectId, parameterBlock); break; - case ApiCallId::IGlobalSession_compileStdLib: - IGlobalSession_compileStdLib(objectId, parameterBlock); + case ApiCallId::IGlobalSession_compileCoreModule: + IGlobalSession_compileCoreModule(objectId, parameterBlock); break; - case ApiCallId::IGlobalSession_loadStdLib: - IGlobalSession_loadStdLib(objectId, parameterBlock); + case ApiCallId::IGlobalSession_loadCoreModule: + IGlobalSession_loadCoreModule(objectId, parameterBlock); break; - case ApiCallId::IGlobalSession_saveStdLib: - IGlobalSession_saveStdLib(objectId, parameterBlock); + case ApiCallId::IGlobalSession_saveCoreModule: + IGlobalSession_saveCoreModule(objectId, parameterBlock); break; case ApiCallId::IGlobalSession_findCapability: IGlobalSession_findCapability(objectId, parameterBlock); @@ -619,29 +619,29 @@ namespace SlangRecord slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); } - void SlangDecoder::IGlobalSession_compileStdLib(ObjectID objectId, ParameterBlock const& parameterBlock) + void SlangDecoder::IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) { - slang::CompileStdLibFlags flags {}; + slang::CompileCoreModuleFlags flags {}; ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, flags); for (auto consumer: m_consumers) { - consumer->IGlobalSession_compileStdLib(objectId, flags); + consumer->IGlobalSession_compileCoreModule(objectId, flags); } } - void SlangDecoder::IGlobalSession_loadStdLib(ObjectID objectId, ParameterBlock const& parameterBlock) + void SlangDecoder::IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) { - PointerDecoder<void*> stdLib; - ParameterDecoder::decodePointer(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, stdLib); + PointerDecoder<void*> coreModule; + ParameterDecoder::decodePointer(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, coreModule); for (auto consumer: m_consumers) { - consumer->IGlobalSession_loadStdLib(objectId, stdLib.getPointer(), stdLib.getDataSize()); + consumer->IGlobalSession_loadCoreModule(objectId, coreModule.getPointer(), coreModule.getDataSize()); } } - void SlangDecoder::IGlobalSession_saveStdLib(ObjectID objectId, ParameterBlock const& parameterBlock) + void SlangDecoder::IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) { SlangArchiveType archiveType {}; ObjectID outBlobId = 0; @@ -650,7 +650,7 @@ namespace SlangRecord for (auto consumer: m_consumers) { - consumer->IGlobalSession_saveStdLib(objectId, archiveType, outBlobId); + consumer->IGlobalSession_saveCoreModule(objectId, archiveType, outBlobId); } } diff --git a/source/slang-record-replay/replay/slang-decoder.h b/source/slang-record-replay/replay/slang-decoder.h index 78c3128ba..03af6d842 100644 --- a/source/slang-record-replay/replay/slang-decoder.h +++ b/source/slang-record-replay/replay/slang-decoder.h @@ -57,9 +57,9 @@ namespace SlangRecord void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_checkPassThroughSupport(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_compileStdLib(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_loadStdLib(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_saveStdLib(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_findCapability(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock); void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock); diff --git a/source/slang-record-replay/util/emum-to-string.h b/source/slang-record-replay/util/emum-to-string.h index 8c140cf3d..3b275399c 100644 --- a/source/slang-record-replay/util/emum-to-string.h +++ b/source/slang-record-replay/util/emum-to-string.h @@ -215,13 +215,13 @@ namespace SlangRecord CASE(ValidateUniformity); CASE(AllowGLSL); CASE(ArchiveType); - CASE(CompileStdLib); + CASE(CompileCoreModule); CASE(Doc); CASE(IrCompression); - CASE(LoadStdLib); + CASE(LoadCoreModule); CASE(ReferenceModule); - CASE(SaveStdLib); - CASE(SaveStdLibBinSource); + CASE(SaveCoreModule); + CASE(SaveCoreModuleBinSource); CASE(TrackLiveness); CASE(LoopInversion); CASE(CountOfParsableOptions); @@ -332,15 +332,15 @@ namespace SlangRecord } } - static Slang::String CompileStdLibFlagsToString(const slang::CompileStdLibFlags flags) + static Slang::String CompileCoreModuleFlagsToString(const slang::CompileCoreModuleFlags flags) { using namespace slang; switch(flags) { - case CompileStdLibFlag::WriteDocumentation: return "WriteDocumentation"; + case CompileCoreModuleFlag::WriteDocumentation: return "WriteDocumentation"; default: Slang::StringBuilder str; - str << "Unknown CompileStdLibFlags: " << static_cast<uint32_t>(flags); + str << "Unknown CompileCoreModuleFlags: " << static_cast<uint32_t>(flags); return str.toString(); } } diff --git a/source/slang-record-replay/util/record-format.h b/source/slang-record-replay/util/record-format.h index 1a32dbbd6..7c53044d6 100644 --- a/source/slang-record-replay/util/record-format.h +++ b/source/slang-record-replay/util/record-format.h @@ -78,9 +78,9 @@ namespace SlangRecord IGlobalSession_getSharedLibraryLoader = makeApiCallId(Class_IGlobalSession, 0x000E), IGlobalSession_checkCompileTargetSupport = makeApiCallId(Class_IGlobalSession, 0x000F), IGlobalSession_checkPassThroughSupport = makeApiCallId(Class_IGlobalSession, 0x0010), - IGlobalSession_compileStdLib = makeApiCallId(Class_IGlobalSession, 0x0011), - IGlobalSession_loadStdLib = makeApiCallId(Class_IGlobalSession, 0x0012), - IGlobalSession_saveStdLib = makeApiCallId(Class_IGlobalSession, 0x0013), + IGlobalSession_compileCoreModule = makeApiCallId(Class_IGlobalSession, 0x0011), + IGlobalSession_loadCoreModule = makeApiCallId(Class_IGlobalSession, 0x0012), + IGlobalSession_saveCoreModule = makeApiCallId(Class_IGlobalSession, 0x0013), IGlobalSession_findCapability = makeApiCallId(Class_IGlobalSession, 0x0014), IGlobalSession_setDownstreamCompilerForTransition = makeApiCallId(Class_IGlobalSession, 0x0015), IGlobalSession_getDownstreamCompilerForTransition = makeApiCallId(Class_IGlobalSession, 0x0016), diff --git a/source/slang-stdlib/CMakeLists.txt b/source/slang-stdlib/CMakeLists.txt index a6d646cf3..e7fed354a 100644 --- a/source/slang-stdlib/CMakeLists.txt +++ b/source/slang-stdlib/CMakeLists.txt @@ -19,7 +19,7 @@ set(stdlib_generated_header add_custom_command( OUTPUT ${stdlib_generated_header} COMMAND - slang-bootstrap -archive-type riff-lz4 -save-stdlib-bin-source + slang-bootstrap -archive-type riff-lz4 -save-core-module-bin-source ${stdlib_generated_header} DEPENDS slang-bootstrap VERBATIM diff --git a/source/slang-stdlib/slang-embedded-stdlib.cpp b/source/slang-stdlib/slang-embedded-stdlib.cpp index 87107fa50..83e4a8c70 100644 --- a/source/slang-stdlib/slang-embedded-stdlib.cpp +++ b/source/slang-stdlib/slang-embedded-stdlib.cpp @@ -4,21 +4,21 @@ #ifdef SLANG_EMBED_STDLIB -static const uint8_t g_stdLib[] = +static const uint8_t g_coreModule[] = { # include "slang-stdlib-generated.h" }; -static Slang::StaticBlob g_stdLibBlob((const void*)g_stdLib, sizeof(g_stdLib)); +static Slang::StaticBlob g_coreModuleBlob((const void*)g_coreModule, sizeof(g_coreModule)); -SLANG_API ISlangBlob* slang_getEmbeddedStdLib() +SLANG_API ISlangBlob* slang_getEmbeddedCoreModule() { - return &g_stdLibBlob; + return &g_coreModuleBlob; } #else -SLANG_API ISlangBlob* slang_getEmbeddedStdLib() +SLANG_API ISlangBlob* slang_getEmbeddedCoreModule() { return nullptr; } diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp index ccecc74e1..feaca559e 100644 --- a/source/slang/slang-api.cpp +++ b/source/slang/slang-api.cpp @@ -51,7 +51,7 @@ SlangResult tryLoadStdLibFromCache( auto cacheTimestamp = *(uint64_t*)(cacheData.getData()); if (cacheTimestamp != currentLibTimestamp) return SLANG_FAIL; - SLANG_RETURN_ON_FAIL(globalSession->loadStdLib( + SLANG_RETURN_ON_FAIL(globalSession->loadCoreModule( (uint8_t*)cacheData.getData() + sizeof(uint64_t), cacheData.getSizeInBytes() - sizeof(uint64_t))); return SLANG_OK; @@ -66,7 +66,7 @@ SlangResult trySaveStdLibToCache( { Slang::ComPtr<ISlangBlob> stdLibBlobPtr; SLANG_RETURN_ON_FAIL( - globalSession->saveStdLib(SLANG_ARCHIVE_TYPE_RIFF_LZ4, stdLibBlobPtr.writeRef())); + globalSession->saveCoreModule(SLANG_ARCHIVE_TYPE_RIFF_LZ4, stdLibBlobPtr.writeRef())); Slang::FileStream fileStream; SLANG_RETURN_ON_FAIL(fileStream.init(cacheFilename, Slang::FileMode::Create)); @@ -89,13 +89,13 @@ SLANG_API SlangResult slang_createGlobalSession( Slang::_debugGetIRAllocCounter() = 0x80000000; #endif - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(apiVersion, globalSession.writeRef())); + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(apiVersion, globalSession.writeRef())); // If we have the embedded stdlib, load from that, else compile it - ISlangBlob* stdLibBlob = slang_getEmbeddedStdLib(); + ISlangBlob* stdLibBlob = slang_getEmbeddedCoreModule(); if (stdLibBlob) { - SLANG_RETURN_ON_FAIL(globalSession->loadStdLib(stdLibBlob->getBufferPointer(), stdLibBlob->getBufferSize())); + SLANG_RETURN_ON_FAIL(globalSession->loadCoreModule(stdLibBlob->getBufferPointer(), stdLibBlob->getBufferSize())); } else { @@ -109,7 +109,7 @@ SLANG_API SlangResult slang_createGlobalSession( #endif { // Compile std lib from embeded source. - SLANG_RETURN_ON_FAIL(globalSession->compileStdLib(0)); + SLANG_RETURN_ON_FAIL(globalSession->compileCoreModule(0)); #if SLANG_PROFILE_STDLIB_COMPILE auto timeElapsed = std::chrono::high_resolution_clock::now() - startTime; printf("stdlib compilation time: %.1fms\n", timeElapsed.count() / 1000000.0); @@ -148,7 +148,7 @@ SLANG_API void slang_shutdown() Slang::freeCapabilityDefs(); } -SLANG_API SlangResult slang_createGlobalSessionWithoutStdLib( +SLANG_API SlangResult slang_createGlobalSessionWithoutCoreModule( SlangInt apiVersion, slang::IGlobalSession** outGlobalSession) { diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index c1251488b..71c751ff2 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -3275,9 +3275,9 @@ namespace Slang SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport(SlangPassThrough passThrough) override; void writeStdlibDoc(String config); - SLANG_NO_THROW SlangResult SLANG_MCALL compileStdLib(slang::CompileStdLibFlags flags) override; - SLANG_NO_THROW SlangResult SLANG_MCALL loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) override; - SLANG_NO_THROW SlangResult SLANG_MCALL saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) override; + SLANG_NO_THROW SlangResult SLANG_MCALL compileCoreModule(slang::CompileCoreModuleFlags flags) override; + SLANG_NO_THROW SlangResult SLANG_MCALL loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) override; + SLANG_NO_THROW SlangResult SLANG_MCALL saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) override; SLANG_NO_THROW SlangCapabilityID SLANG_MCALL findCapability(char const* name) override; diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 43f98872d..4875627f5 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -543,18 +543,18 @@ void initCommandOptions(CommandOptions& options) const Option internalOpts[] = { - { OptionKind::ArchiveType, "-archive-type", "-archive-type <archive-type>", "Set the archive type for -save-stdlib. Default is zip." }, - { OptionKind::CompileStdLib, "-compile-stdlib", nullptr, + { OptionKind::ArchiveType, "-archive-type", "-archive-type <archive-type>", "Set the archive type for -save-core-module. Default is zip." }, + { OptionKind::CompileCoreModule, "-compile-core-module", nullptr, "Compile the StdLib from embedded sources. " "Will return a failure if there is already a StdLib available."}, - { OptionKind::Doc, "-doc", nullptr, "Write documentation for -compile-stdlib" }, + { OptionKind::Doc, "-doc", nullptr, "Write documentation for -compile-core-module" }, { OptionKind::IrCompression,"-ir-compression", "-ir-compression <type>", "Set compression for IR and AST outputs.\n" "Accepted compression types: none, lite"}, - { OptionKind::LoadStdLib, "-load-stdlib", "-load-stdlib <filename>", "Load the StdLib from file." }, + { OptionKind::LoadCoreModule, "-load-core-module", "-load-core-module <filename>", "Load the core module from file." }, { OptionKind::ReferenceModule, "-r", "-r <name>", "reference module <name>" }, - { OptionKind::SaveStdLib, "-save-stdlib", "-save-stdlib <filename>", "Save the StdLib modules to an archive file." }, - { OptionKind::SaveStdLibBinSource, "-save-stdlib-bin-source","-save-stdlib-bin-source <filename>", "Same as -save-stdlib but output " + { OptionKind::SaveCoreModule, "-save-core-module", "-save-core-module <filename>", "Save the core module to an archive file." }, + { OptionKind::SaveCoreModuleBinSource, "-save-core-module-bin-source","-save-core-module-bin-source <filename>", "Same as -save-core-module but output " "the data as a C array.\n"}, { OptionKind::TrackLiveness, "-track-liveness", nullptr, "Enable liveness tracking. Places SLANG_LIVE_START, and SLANG_LIVE_END in output source to indicate value liveness." }, { OptionKind::LoopInversion, "-loop-inversion", nullptr, "Enable loop inversion in the code-gen optimization. Default is off" }, @@ -798,7 +798,7 @@ struct OptionsParser bool m_hasLoadedRepro = false; bool m_compileStdLib = false; - slang::CompileStdLibFlags m_compileStdLibFlags; + slang::CompileCoreModuleFlags m_compileStdLibFlags; SlangArchiveType m_archiveType = SLANG_ARCHIVE_TYPE_RIFF_LZ4; @@ -1747,7 +1747,7 @@ SlangResult OptionsParser::_parse( case OptionKind::NoCodeGen: linkage->m_optionSet.set(OptionKind::SkipCodeGen, true); break; break; - case OptionKind::LoadStdLib: + case OptionKind::LoadCoreModule: { CommandLineArg fileName; SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName)); @@ -1755,38 +1755,38 @@ SlangResult OptionsParser::_parse( // Load the file ScopedAllocation contents; SLANG_RETURN_ON_FAIL(File::readAllBytes(fileName.value, contents)); - SLANG_RETURN_ON_FAIL(m_session->loadStdLib(contents.getData(), contents.getSizeInBytes())); + SLANG_RETURN_ON_FAIL(m_session->loadCoreModule(contents.getData(), contents.getSizeInBytes())); // Ensure that the linkage's AST builder is up-to-date. linkage->getASTBuilder()->m_cachedNodes = asInternal(m_session)->getGlobalASTBuilder()->m_cachedNodes; break; } - case OptionKind::CompileStdLib: m_compileStdLib = true; break; + case OptionKind::CompileCoreModule: m_compileStdLib = true; break; case OptionKind::ArchiveType: { SLANG_RETURN_ON_FAIL(_expectValue(m_archiveType)); break; } - case OptionKind::SaveStdLib: + case OptionKind::SaveCoreModule: { CommandLineArg fileName; SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName)); ComPtr<ISlangBlob> blob; - SLANG_RETURN_ON_FAIL(m_session->saveStdLib(m_archiveType, blob.writeRef())); + SLANG_RETURN_ON_FAIL(m_session->saveCoreModule(m_archiveType, blob.writeRef())); SLANG_RETURN_ON_FAIL(File::writeAllBytes(fileName.value, blob->getBufferPointer(), blob->getBufferSize())); break; } - case OptionKind::SaveStdLibBinSource: + case OptionKind::SaveCoreModuleBinSource: { CommandLineArg fileName; SLANG_RETURN_ON_FAIL(m_reader.expectArg(fileName)); ComPtr<ISlangBlob> blob; - SLANG_RETURN_ON_FAIL(m_session->saveStdLib(m_archiveType, blob.writeRef())); + SLANG_RETURN_ON_FAIL(m_session->saveCoreModule(m_archiveType, blob.writeRef())); StringBuilder builder; StringWriter writer(&builder, 0); @@ -1811,7 +1811,7 @@ SlangResult OptionsParser::_parse( case OptionKind::Doc: { // If compiling stdlib is enabled, will write out documentation - m_compileStdLibFlags |= slang::CompileStdLibFlag::WriteDocumentation; + m_compileStdLibFlags |= slang::CompileCoreModuleFlag::WriteDocumentation; // Enable writing out documentation on the req linkage->m_optionSet.set(CompilerOptionName::Doc, true); @@ -2380,7 +2380,7 @@ SlangResult OptionsParser::_parse( if (m_compileStdLib) { - SLANG_RETURN_ON_FAIL(m_session->compileStdLib(m_compileStdLibFlags)); + SLANG_RETURN_ON_FAIL(m_session->compileCoreModule(m_compileStdLibFlags)); } // TODO(JS): This is a restriction because of how setting of state works for load repro diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 93fb2c203..b77a3efc8 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -342,7 +342,7 @@ void Session::writeStdlibDoc(String config) } } -SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags) +SlangResult Session::compileCoreModule(slang::CompileCoreModuleFlags compileFlags) { SLANG_AST_BUILDER_RAII(m_builtinLinkage->getASTBuilder()); @@ -369,7 +369,7 @@ SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags) auto stdLibSrcBlob = StringBlob::moveCreate(stdLibSrcBuilder.produceString()); addBuiltinSource(coreLanguageScope, "core", stdLibSrcBlob); - if (compileFlags & slang::CompileStdLibFlag::WriteDocumentation) + if (compileFlags & slang::CompileCoreModuleFlag::WriteDocumentation) { // Load config file first. String configText; @@ -393,7 +393,7 @@ SlangResult Session::compileStdLib(slang::CompileStdLibFlags compileFlags) return SLANG_OK; } -SlangResult Session::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) +SlangResult Session::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) { SLANG_PROFILE; @@ -407,7 +407,7 @@ SlangResult Session::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) // Make a file system to read it from ComPtr<ISlangFileSystemExt> fileSystem; - SLANG_RETURN_ON_FAIL(loadArchiveFileSystem(stdLib, stdLibSizeInBytes, fileSystem)); + SLANG_RETURN_ON_FAIL(loadArchiveFileSystem(coreModule, coreModuleSizeInBytes, fileSystem)); // Let's try loading serialized modules and adding them SLANG_RETURN_ON_FAIL(_readBuiltinModule(fileSystem, coreLanguageScope, "core")); @@ -416,7 +416,7 @@ SlangResult Session::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) return SLANG_OK; } -SlangResult Session::saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) +SlangResult Session::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) { if (m_builtinLinkage->mapNameToLoadedModules.getCount() == 0) { diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp index c7cca428b..75e68ce58 100644 --- a/source/slangc/main.cpp +++ b/source/slangc/main.cpp @@ -83,12 +83,12 @@ SLANG_TEST_TOOL_API SlangResult innerMain(StdWriters* stdWriters, slang::IGlobal // Assume we will used the shared session ComPtr<slang::IGlobalSession> session(sharedSession); - // The sharedSession always has a pre-loaded stdlib, is sharedSession is not nullptr. - // This differed test checks if the command line has an option to setup the stdlib. - // If so we *don't* use the sharedSession, and create a new stdlib-less session just for this compilation. - if (TestToolUtil::hasDeferredStdLib(Index(argc - 1), argv + 1)) + // The sharedSession always has a pre-loaded core module, is sharedSession is not nullptr. + // This differed test checks if the command line has an option to setup the core module. + // If so we *don't* use the sharedSession, and create a new session without the core module just for this compilation. + if (TestToolUtil::hasDeferredCoreModule(Index(argc - 1), argv + 1)) { - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef())); + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(SLANG_API_VERSION, session.writeRef())); } else if (!session) { diff --git a/tests/serialization/std-lib-serialize.slang b/tests/serialization/std-lib-serialize.slang index eef99c8f8..e63a1220e 100644 --- a/tests/serialization/std-lib-serialize.slang +++ b/tests/serialization/std-lib-serialize.slang @@ -1,5 +1,5 @@ -//TEST:COMPILE: -save-stdlib slang-std-lib.zip -//TEST:COMPARE_COMPUTE: -compile-arg -load-stdlib -compile-arg slang-std-lib.zip -shaderobj +//TEST:COMPILE: -save-core-module slang-core-module.zip +//TEST:COMPARE_COMPUTE: -compile-arg -load-core-module -compile-arg slang-core-module.zip -shaderobj struct A { @@ -29,4 +29,4 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) float inVal = float(tid); float outVal = test(inVal); outputBuffer[tid] = outVal; -}
\ No newline at end of file +} diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 218125748..7d8f3a8aa 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -1397,12 +1397,12 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe // Assume we will used the shared session ComPtr<slang::IGlobalSession> session(sharedSession); - // The sharedSession always has a pre-loaded stdlib. - // This differed test checks if the command line has an option to setup the stdlib. - // If so we *don't* use the sharedSession, and create a new stdlib-less session just for this compilation. - if (TestToolUtil::hasDeferredStdLib(Index(inArgc - 1), inArgv + 1)) + // The sharedSession always has a pre-loaded core module. + // This differed test checks if the command line has an option to setup the core module. + // If so we *don't* use the sharedSession, and create a new session without the core module just for this compilation. + if (TestToolUtil::hasDeferredCoreModule(Index(inArgc - 1), inArgv + 1)) { - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef())); + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(SLANG_API_VERSION, session.writeRef())); } SlangResult res = SLANG_FAIL; diff --git a/tools/slang-test/slangc-tool.cpp b/tools/slang-test/slangc-tool.cpp index 159e6faf2..ff44c0db6 100644 --- a/tools/slang-test/slangc-tool.cpp +++ b/tools/slang-test/slangc-tool.cpp @@ -14,12 +14,12 @@ SlangResult SlangCTool::innerMain(StdWriters* stdWriters, slang::IGlobalSession* // Assume we will used the shared session ComPtr<slang::IGlobalSession> session(sharedSession); - // The sharedSession always has a pre-loaded stdlib. - // This differed test checks if the command line has an option to setup the stdlib. - // If so we *don't* use the sharedSession, and create a new stdlib-less session just for this compilation. - if (TestToolUtil::hasDeferredStdLib(Index(argc - 1), argv + 1)) + // The sharedSession always has a pre-loaded core module. + // This differed test checks if the command line has an option to setup the core module. + // If so we *don't* use the sharedSession, and create a new session without the core module just for this compilation. + if (TestToolUtil::hasDeferredCoreModule(Index(argc - 1), argv + 1)) { - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef())); + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(SLANG_API_VERSION, session.writeRef())); } ComPtr<slang::ICompileRequest> compileRequest; diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index a472248eb..6d45809ac 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -158,13 +158,13 @@ public: /// Timeout time for communication over connection. /// NOTE! If the timeout is hit, the connection will be destroyed, and then recreated. - /// For tests that compile the stdlib, if that takes this time, the stdlib will be + /// To test it, compile the core module, if it takes too much time, the core module will be /// repeatedly compiled and each time fail. /// NOTE! This timeout may be altered in the ctor for a specific target, the initializatoin /// value is just the default. /// - /// TODO(JS): We could split the stdlib compilation from other actions, and have timeout specific for - /// that. To do this we could have a 'compileStdLib' RPC method. + /// TODO(JS): We could split the core module compilation from other actions, and have timeout specific for + /// that. To do this we could have a 'compileCoreModule' RPC method. /// /// Current default is 60 seconds. Slang::Int connectionTimeOutInMs = 60 * 1000; diff --git a/tools/test-server/test-server-main.cpp b/tools/test-server/test-server-main.cpp index bfc96af9a..fab84b9f5 100644 --- a/tools/test-server/test-server-main.cpp +++ b/tools/test-server/test-server-main.cpp @@ -105,12 +105,12 @@ SlangResult innerMain(StdWriters* stdWriters, slang::IGlobalSession* sharedSessi // Assume we will used the shared session ComPtr<slang::IGlobalSession> session(sharedSession); - // The sharedSession always has a pre-loaded stdlib. - // This differed test checks if the command line has an option to setup the stdlib. - // If so we *don't* use the sharedSession, and create a new stdlib-less session just for this compilation. - if (TestToolUtil::hasDeferredStdLib(Index(argc - 1), argv + 1)) + // The sharedSession always has a pre-loaded core module. + // This differed test checks if the command line has an option to setup the core module. + // If so we *don't* use the sharedSession, and create a new session without the core module just for this compilation. + if (TestToolUtil::hasDeferredCoreModule(Index(argc - 1), argv + 1)) { - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef())); + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutCoreModule(SLANG_API_VERSION, session.writeRef())); } ComPtr<slang::ICompileRequest> compileRequest; |
