9
9
#include " ../slang-record-replay/util/record-utility.h"
10
10
#include " slang-capability.h"
11
11
#include " slang-compiler.h"
12
+ #include " slang-internal.h"
12
13
#include " slang-repro.h"
13
14
14
15
// implementation of C interface
@@ -124,8 +125,9 @@ slang_createGlobalSession(SlangInt apiVersion, slang::IGlobalSession** outGlobal
124
125
return slang_createGlobalSession2 (&desc, outGlobalSession);
125
126
}
126
127
127
- SLANG_API SlangResult slang_createGlobalSession2 (
128
+ SLANG_API SlangResult slang_createGlobalSessionImpl (
128
129
const SlangGlobalSessionDesc* desc,
130
+ const Slang::GlobalSessionInternalDesc* internalDesc,
129
131
slang::IGlobalSession** outGlobalSession)
130
132
{
131
133
Slang::ComPtr<slang::IGlobalSession> globalSession;
@@ -151,24 +153,20 @@ SLANG_API SlangResult slang_createGlobalSession2(
151
153
{
152
154
Slang::String cacheFilename;
153
155
uint64_t dllTimestamp = 0 ;
154
- #define SLANG_PROFILE_CORE_MODULE_COMPILE 0
155
- #if SLANG_PROFILE_CORE_MODULE_COMPILE
156
- auto startTime = std::chrono::high_resolution_clock::now ();
157
- #else
158
- if (tryLoadBuiltinModuleFromCache (
156
+ SlangResult loadFromCacheResult = SLANG_FAIL;
157
+ if (!internalDesc->isBootstrap )
158
+ {
159
+ loadFromCacheResult = tryLoadBuiltinModuleFromCache (
159
160
globalSession,
160
161
slang::BuiltinModuleName::Core,
161
162
cacheFilename,
162
- dllTimestamp) != SLANG_OK)
163
- #endif
163
+ dllTimestamp);
164
+ }
165
+ if (loadFromCacheResult != SLANG_OK)
164
166
{
165
167
// Compile std lib from embeded source.
166
168
SLANG_RETURN_ON_FAIL (
167
169
globalSession->compileBuiltinModule (slang::BuiltinModuleName::Core, 0 ));
168
- #if SLANG_PROFILE_CORE_MODULE_COMPILE
169
- auto timeElapsed = std::chrono::high_resolution_clock::now () - startTime;
170
- printf (" core module compilation time: %.1fms\n " , timeElapsed.count () / 1000000.0 );
171
- #endif
172
170
// Store the compiled core module to cache file.
173
171
trySaveBuiltinModuleToCache (
174
172
globalSession,
@@ -182,18 +180,21 @@ SLANG_API SlangResult slang_createGlobalSession2(
182
180
{
183
181
Slang::String cacheFilename;
184
182
uint64_t dllTimestamp = 0 ;
185
- if (SLANG_SUCCEEDED (
186
- tryLoadBuiltinModuleFromDLL (globalSession, slang::BuiltinModuleName::GLSL)))
187
- {
188
- }
189
- else if (SLANG_SUCCEEDED (tryLoadBuiltinModuleFromCache (
190
- globalSession,
191
- slang::BuiltinModuleName::GLSL,
192
- cacheFilename,
193
- dllTimestamp)))
183
+ SlangResult loadFromCacheResult = SLANG_FAIL;
184
+ if (!internalDesc->isBootstrap )
194
185
{
186
+ loadFromCacheResult =
187
+ tryLoadBuiltinModuleFromDLL (globalSession, slang::BuiltinModuleName::GLSL);
188
+ if (SLANG_FAILED (loadFromCacheResult))
189
+ {
190
+ loadFromCacheResult = tryLoadBuiltinModuleFromCache (
191
+ globalSession,
192
+ slang::BuiltinModuleName::GLSL,
193
+ cacheFilename,
194
+ dllTimestamp);
195
+ }
195
196
}
196
- else
197
+ if ( SLANG_FAILED (loadFromCacheResult))
197
198
{
198
199
SLANG_RETURN_ON_FAIL (
199
200
globalSession->compileBuiltinModule (slang::BuiltinModuleName::GLSL, 0 ));
@@ -228,6 +229,14 @@ SLANG_API SlangResult slang_createGlobalSession2(
228
229
return SLANG_OK;
229
230
}
230
231
232
+ SLANG_API SlangResult slang_createGlobalSession2 (
233
+ const SlangGlobalSessionDesc* desc,
234
+ slang::IGlobalSession** outGlobalSession)
235
+ {
236
+ Slang::GlobalSessionInternalDesc internalDesc = {};
237
+ return slang_createGlobalSessionImpl (desc, &internalDesc, outGlobalSession);
238
+ }
239
+
231
240
SLANG_API void slang_shutdown ()
232
241
{
233
242
Slang::PerformanceProfiler::getProfiler ()->dispose ();
0 commit comments