diff options
| author | Yong He <yonghe@outlook.com> | 2025-03-24 17:01:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-24 17:01:55 -0700 |
| commit | c54bc9ebff0691c397885363e0da7a122e3e407d (patch) | |
| tree | f29681f8aa35b5b01e169a35a77cdd81317a8330 /source/slang/slang-api.cpp | |
| parent | 0d7d6468dfcabb759ec40921e5da3a8598f1c770 (diff) | |
Don't load cached builtin module in slang-bootstrap. (#6667)
* Don't load cached builtin module in slang-bootstrap.
* Fixes.
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-api.cpp')
| -rw-r--r-- | source/slang/slang-api.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp index 701f49355..9b7b605a2 100644 --- a/source/slang/slang-api.cpp +++ b/source/slang/slang-api.cpp @@ -9,6 +9,7 @@ #include "../slang-record-replay/util/record-utility.h" #include "slang-capability.h" #include "slang-compiler.h" +#include "slang-internal.h" #include "slang-repro.h" // implementation of C interface @@ -124,8 +125,9 @@ slang_createGlobalSession(SlangInt apiVersion, slang::IGlobalSession** outGlobal return slang_createGlobalSession2(&desc, outGlobalSession); } -SLANG_API SlangResult slang_createGlobalSession2( +SLANG_API SlangResult slang_createGlobalSessionImpl( const SlangGlobalSessionDesc* desc, + const Slang::GlobalSessionInternalDesc* internalDesc, slang::IGlobalSession** outGlobalSession) { Slang::ComPtr<slang::IGlobalSession> globalSession; @@ -151,24 +153,20 @@ SLANG_API SlangResult slang_createGlobalSession2( { Slang::String cacheFilename; uint64_t dllTimestamp = 0; -#define SLANG_PROFILE_CORE_MODULE_COMPILE 0 -#if SLANG_PROFILE_CORE_MODULE_COMPILE - auto startTime = std::chrono::high_resolution_clock::now(); -#else - if (tryLoadBuiltinModuleFromCache( + SlangResult loadFromCacheResult = SLANG_FAIL; + if (!internalDesc->isBootstrap) + { + loadFromCacheResult = tryLoadBuiltinModuleFromCache( globalSession, slang::BuiltinModuleName::Core, cacheFilename, - dllTimestamp) != SLANG_OK) -#endif + dllTimestamp); + } + if (loadFromCacheResult != SLANG_OK) { // Compile std lib from embeded source. SLANG_RETURN_ON_FAIL( globalSession->compileBuiltinModule(slang::BuiltinModuleName::Core, 0)); -#if SLANG_PROFILE_CORE_MODULE_COMPILE - auto timeElapsed = std::chrono::high_resolution_clock::now() - startTime; - printf("core module compilation time: %.1fms\n", timeElapsed.count() / 1000000.0); -#endif // Store the compiled core module to cache file. trySaveBuiltinModuleToCache( globalSession, @@ -182,18 +180,21 @@ SLANG_API SlangResult slang_createGlobalSession2( { Slang::String cacheFilename; uint64_t dllTimestamp = 0; - if (SLANG_SUCCEEDED( - tryLoadBuiltinModuleFromDLL(globalSession, slang::BuiltinModuleName::GLSL))) - { - } - else if (SLANG_SUCCEEDED(tryLoadBuiltinModuleFromCache( - globalSession, - slang::BuiltinModuleName::GLSL, - cacheFilename, - dllTimestamp))) + SlangResult loadFromCacheResult = SLANG_FAIL; + if (!internalDesc->isBootstrap) { + loadFromCacheResult = + tryLoadBuiltinModuleFromDLL(globalSession, slang::BuiltinModuleName::GLSL); + if (SLANG_FAILED(loadFromCacheResult)) + { + loadFromCacheResult = tryLoadBuiltinModuleFromCache( + globalSession, + slang::BuiltinModuleName::GLSL, + cacheFilename, + dllTimestamp); + } } - else + if (SLANG_FAILED(loadFromCacheResult)) { SLANG_RETURN_ON_FAIL( globalSession->compileBuiltinModule(slang::BuiltinModuleName::GLSL, 0)); @@ -228,6 +229,14 @@ SLANG_API SlangResult slang_createGlobalSession2( return SLANG_OK; } +SLANG_API SlangResult slang_createGlobalSession2( + const SlangGlobalSessionDesc* desc, + slang::IGlobalSession** outGlobalSession) +{ + Slang::GlobalSessionInternalDesc internalDesc = {}; + return slang_createGlobalSessionImpl(desc, &internalDesc, outGlobalSession); +} + SLANG_API void slang_shutdown() { Slang::PerformanceProfiler::getProfiler()->dispose(); |
