@@ -178,6 +178,43 @@ uint32 LatteShaderCache_getPipelineCacheExtraVersion(uint64 titleId)
178
178
return extraVersion;
179
179
}
180
180
181
+ void LatteShaderCache_drawBackgroundImage (ImTextureID texture, int width, int height)
182
+ {
183
+ // clear framebuffers and clean up
184
+ const auto kPopupFlags =
185
+ ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings |
186
+ ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize;
187
+ auto & io = ImGui::GetIO ();
188
+ ImGui::SetNextWindowPos ({0 , 0 }, ImGuiCond_Always);
189
+ ImGui::SetNextWindowSize (io.DisplaySize , ImGuiCond_Always);
190
+ ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 );
191
+ ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, {0 , 0 });
192
+ if (ImGui::Begin (" Background texture" , nullptr , kPopupFlags ))
193
+ {
194
+ if (texture)
195
+ {
196
+ float imageDisplayWidth = io.DisplaySize .x ;
197
+ float imageDisplayHeight = height * imageDisplayWidth / width;
198
+
199
+ float paddingLeftAndRight = 0 .0f ;
200
+ float paddingTopAndBottom = (io.DisplaySize .y - imageDisplayHeight) / 2 .0f ;
201
+ if (imageDisplayHeight > io.DisplaySize .y )
202
+ {
203
+ imageDisplayHeight = io.DisplaySize .y ;
204
+ imageDisplayWidth = width * imageDisplayHeight / height;
205
+ paddingLeftAndRight = (io.DisplaySize .x - imageDisplayWidth) / 2 .0f ;
206
+ paddingTopAndBottom = 0 .0f ;
207
+ }
208
+
209
+ ImGui::GetWindowDrawList ()->AddImage (texture, ImVec2 (paddingLeftAndRight, paddingTopAndBottom),
210
+ ImVec2 (io.DisplaySize .x - paddingLeftAndRight,
211
+ io.DisplaySize .y - paddingTopAndBottom), {0 , 1 }, {1 , 0 });
212
+ }
213
+ }
214
+ ImGui::End ();
215
+ ImGui::PopStyleVar (2 );
216
+ }
217
+
181
218
void LatteShaderCache_load ()
182
219
{
183
220
shaderCacheScreenStats.compiledShaderCount = 0 ;
@@ -231,48 +268,36 @@ void LatteShaderCache_load()
231
268
g_shaderCacheLoaderState.loadedShaderFiles = 0 ;
232
269
233
270
// get game background loading image
234
- TGAFILE TVfile{};
235
- g_shaderCacheLoaderState.textureTVId = nullptr ;
236
-
237
- std::string tvTexPath = fmt::format (" {}/meta/bootTvTex.tga" , CafeSystem::GetMlcStoragePath (CafeSystem::GetForegroundTitleId ()));
238
- sint32 statusTV;
239
- auto fscfile = fsc_open (tvTexPath.c_str (), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &statusTV);
240
- if (fscfile)
271
+ auto loadBackgroundTexture = [](bool isTV, ImTextureID& out)
241
272
{
242
- uint32 size = fsc_getFileSize (fscfile);
243
- if (size > 0 )
244
- {
245
- std::vector<uint8> tmpData (size);
246
- fsc_readFile (fscfile, tmpData.data (), size);
247
- const bool backgroundLoaded = LoadTGAFile (tmpData, &TVfile);
273
+ TGAFILE file{};
274
+ out = nullptr ;
248
275
249
- if (backgroundLoaded)
250
- g_shaderCacheLoaderState.textureTVId = g_renderer->GenerateTexture (TVfile.imageData , { TVfile.imageWidth , TVfile.imageHeight });
251
- }
276
+ std::string fileName = isTV ? " bootTvTex.tga" : " bootDRCTex.tga" ;
252
277
253
- fsc_close (fscfile);
254
- }
255
- // get game background loading image for DRC
256
- TGAFILE DRCfile{};
257
- g_shaderCacheLoaderState.textureDRCId = nullptr ;
258
-
259
- std::string drcTexPath = fmt::format (" {}/meta/bootDRCTex.tga" , CafeSystem::GetMlcStoragePath (CafeSystem::GetForegroundTitleId ()));
260
- sint32 statusDRC;
261
- auto fscfile2 = fsc_open (drcTexPath.c_str (), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &statusDRC);
262
- if (fscfile2)
263
- {
264
- uint32 size = fsc_getFileSize (fscfile2);
265
- if (size > 0 )
278
+ std::string texPath = fmt::format (" {}/meta/{}" , CafeSystem::GetMlcStoragePath (CafeSystem::GetForegroundTitleId ()), fileName);
279
+ sint32 status;
280
+ auto fscfile = fsc_open (texPath.c_str (), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &status);
281
+ if (fscfile)
266
282
{
267
- std::vector<uint8> tmpData (size);
268
- fsc_readFile (fscfile2, tmpData.data (), size);
269
- const bool backgroundLoaded = LoadTGAFile (tmpData, &DRCfile);
283
+ uint32 size = fsc_getFileSize (fscfile);
284
+ if (size > 0 )
285
+ {
286
+ std::vector<uint8> tmpData (size);
287
+ fsc_readFile (fscfile, tmpData.data (), size);
288
+ const bool backgroundLoaded = LoadTGAFile (tmpData, &file);
270
289
271
- if (backgroundLoaded)
272
- g_shaderCacheLoaderState.textureDRCId = g_renderer->GenerateTexture (DRCfile.imageData , { DRCfile.imageWidth , DRCfile.imageHeight });
290
+ if (backgroundLoaded)
291
+ out = g_renderer->GenerateTexture (file.imageData , { file.imageWidth , file.imageHeight });
292
+ }
293
+
294
+ fsc_close (fscfile);
273
295
}
274
- fsc_close (fscfile2);
275
- }
296
+ };
297
+
298
+ loadBackgroundTexture (true , g_shaderCacheLoaderState.textureTVId );
299
+ loadBackgroundTexture (false , g_shaderCacheLoaderState.textureDRCId );
300
+
276
301
sint32 numLoadedShaders = 0 ;
277
302
uint32 loadIndex = 0 ;
278
303
@@ -319,79 +344,22 @@ void LatteShaderCache_load()
319
344
if (g_renderer->GetType () == RendererAPI::Vulkan)
320
345
LatteShaderCache_loadVulkanPipelineCache (cacheTitleId);
321
346
322
- // clear framebuffers and clean up
323
- auto & io = ImGui::GetIO ();
324
- const auto kPopupFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize;
325
- for (int i = 0 ; i < 2 ; ++i)
326
- {
327
- g_renderer->BeginFrame (true );
328
- if (g_renderer->ImguiBegin (true ))
329
- {
330
- ImGui::SetNextWindowPos ({ 0 ,0 }, ImGuiCond_Always);
331
- ImGui::SetNextWindowSize (io.DisplaySize , ImGuiCond_Always);
332
- ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 );
333
- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, { 0 ,0 });
334
- if (ImGui::Begin (" Background texture" , nullptr , kPopupFlags ))
335
- {
336
- if (g_shaderCacheLoaderState.textureTVId )
337
- {
338
- float imageDisplayWidth = io.DisplaySize .x ;
339
- float imageDisplayHeight = 720 * imageDisplayWidth / 1280 ;
340
-
341
- float paddingLeftAndRight = 0 .0f ;
342
- float paddingTopAndBottom = (io.DisplaySize .y - imageDisplayHeight)/2 .0f ;
343
- if (imageDisplayHeight > io.DisplaySize .y )
344
- {
345
- imageDisplayHeight = io.DisplaySize .y ;
346
- imageDisplayWidth = 1280 * imageDisplayHeight / 720 ;
347
- paddingLeftAndRight = (io.DisplaySize .x - imageDisplayWidth)/2 .0f ;
348
- paddingTopAndBottom = 0 .0f ;
349
- }
350
-
351
- ImGui::GetWindowDrawList ()->AddImage (g_shaderCacheLoaderState.textureTVId , ImVec2 (paddingLeftAndRight, paddingTopAndBottom), ImVec2 (io.DisplaySize .x -paddingLeftAndRight, io.DisplaySize .y -paddingTopAndBottom), { 0 ,1 }, { 1 ,0 });
352
- }
353
- }
354
- ImGui::End ();
355
- ImGui::PopStyleVar (2 );
356
- g_renderer->ImguiEnd ();
357
- }
358
347
359
- g_renderer->BeginFrame (false );
360
- if (g_renderer->ImguiBegin (false ))
361
- {
362
- ImGui::SetNextWindowPos ({ 0 ,0 }, ImGuiCond_Always);
363
- ImGui::SetNextWindowSize (io.DisplaySize , ImGuiCond_Always);
364
- ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 );
365
- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, { 0 ,0 });
366
-
367
- if (ImGui::Begin (" Background texture2" , nullptr , kPopupFlags ))
368
- {
369
- if (g_shaderCacheLoaderState.textureDRCId )
370
- {
371
- float imageDisplayWidth = io.DisplaySize .x ;
372
- float imageDisplayHeight = 480 * imageDisplayWidth / 854 ;
373
-
374
- float paddingLeftAndRight = 0 .0f ;
375
- float paddingTopAndBottom = (io.DisplaySize .y - imageDisplayHeight)/2 .0f ;
376
- if (imageDisplayHeight > io.DisplaySize .y )
377
- {
378
- imageDisplayHeight = io.DisplaySize .y ;
379
- imageDisplayWidth = 854 * imageDisplayHeight / 480 ;
380
- paddingLeftAndRight = (io.DisplaySize .x - imageDisplayWidth)/2 .0f ;
381
- paddingTopAndBottom = 0 .0f ;
382
- }
383
-
384
- ImGui::GetWindowDrawList ()->AddImage (g_shaderCacheLoaderState.textureDRCId , ImVec2 (paddingLeftAndRight, paddingTopAndBottom), ImVec2 (io.DisplaySize .x -paddingLeftAndRight, io.DisplaySize .y -paddingTopAndBottom), { 0 ,1 }, { 1 ,0 });
385
- }
386
- }
387
- ImGui::End ();
388
- ImGui::PopStyleVar (2 );
389
- g_renderer->ImguiEnd ();
390
- }
391
-
392
- g_renderer->SwapBuffers (true , true );
348
+ g_renderer->BeginFrame (true );
349
+ if (g_renderer->ImguiBegin (true ))
350
+ {
351
+ LatteShaderCache_drawBackgroundImage (g_shaderCacheLoaderState.textureTVId , 1280 , 720 );
352
+ g_renderer->ImguiEnd ();
353
+ }
354
+ g_renderer->BeginFrame (false );
355
+ if (g_renderer->ImguiBegin (false ))
356
+ {
357
+ LatteShaderCache_drawBackgroundImage (g_shaderCacheLoaderState.textureDRCId , 854 , 480 );
358
+ g_renderer->ImguiEnd ();
393
359
}
394
360
361
+ g_renderer->SwapBuffers (true , true );
362
+
395
363
if (g_shaderCacheLoaderState.textureTVId )
396
364
g_renderer->DeleteTexture (g_shaderCacheLoaderState.textureTVId );
397
365
if (g_shaderCacheLoaderState.textureDRCId )
@@ -427,35 +395,11 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
427
395
g_renderer->BeginFrame (true );
428
396
if (g_renderer->ImguiBegin (true ))
429
397
{
398
+ // render background texture
399
+ LatteShaderCache_drawBackgroundImage (g_shaderCacheLoaderState.textureTVId , 1280 , 720 );
400
+
430
401
const auto progress_font = ImGui_GetFont (window_size.y / 32 .0f ); // = 24 by default
431
402
const auto shader_count_font = ImGui_GetFont (window_size.y / 48 .0f ); // = 16
432
- // render background texture
433
- if (g_shaderCacheLoaderState.textureTVId )
434
- {
435
- ImGui::SetNextWindowPos ({ 0 , 0 }, ImGuiCond_Always);
436
- ImGui::SetNextWindowSize (io.DisplaySize , ImGuiCond_Always);
437
- ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 );
438
- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, { 0 , 0 });
439
- if (ImGui::Begin (" Background texture" , nullptr , kPopupFlags | ImGuiWindowFlags_NoBringToFrontOnFocus))
440
- {
441
- float imageDisplayWidth = io.DisplaySize .x ;
442
- float imageDisplayHeight = 720 * imageDisplayWidth / 1280 ;
443
-
444
- float paddingLeftAndRight = 0 .0f ;
445
- float paddingTopAndBottom = (io.DisplaySize .y - imageDisplayHeight) / 2 .0f ;
446
- if (imageDisplayHeight > io.DisplaySize .y )
447
- {
448
- imageDisplayHeight = io.DisplaySize .y ;
449
- imageDisplayWidth = 1280 * imageDisplayHeight / 720 ;
450
- paddingLeftAndRight = (io.DisplaySize .x - imageDisplayWidth) / 2 .0f ;
451
- paddingTopAndBottom = 0 .0f ;
452
- }
453
-
454
- ImGui::GetWindowDrawList ()->AddImage (g_shaderCacheLoaderState.textureTVId , ImVec2 (paddingLeftAndRight, paddingTopAndBottom), ImVec2 (io.DisplaySize .x -paddingLeftAndRight, io.DisplaySize .y -paddingTopAndBottom), { 0 ,1 }, { 1 ,0 });
455
- }
456
- ImGui::End ();
457
- ImGui::PopStyleVar (2 );
458
- }
459
403
460
404
ImVec2 position = { window_size.x / 2 .0f , window_size.y / 2 .0f };
461
405
ImVec2 pivot = { 0 .5f , 0 .5f };
@@ -541,31 +485,7 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
541
485
g_renderer->BeginFrame (false );
542
486
if (g_renderer->ImguiBegin (false ))
543
487
{
544
- ImGui::SetNextWindowPos ({ 0 ,0 }, ImGuiCond_Always);
545
- ImGui::SetNextWindowSize (io.DisplaySize , ImGuiCond_Always);
546
- ImGui::PushStyleVar (ImGuiStyleVar_WindowBorderSize, 0 );
547
- ImGui::PushStyleVar (ImGuiStyleVar_WindowPadding, { 0 ,0 });
548
- if (ImGui::Begin (" Background texture2" , nullptr , kPopupFlags ))
549
- {
550
- if (g_shaderCacheLoaderState.textureDRCId )
551
- {
552
- float imageDisplayWidth = io.DisplaySize .x ;
553
- float imageDisplayHeight = 480 * imageDisplayWidth / 854 ;
554
-
555
- float paddingLeftAndRight = 0 .0f ;
556
- float paddingTopAndBottom = (io.DisplaySize .y - imageDisplayHeight)/2 .0f ;
557
- if (imageDisplayHeight > io.DisplaySize .y )
558
- {
559
- imageDisplayHeight = io.DisplaySize .y ;
560
- imageDisplayWidth = 854 * imageDisplayHeight / 480 ;
561
- paddingLeftAndRight = (io.DisplaySize .x - imageDisplayWidth)/2 .0f ;
562
- paddingTopAndBottom = 0 .0f ;
563
- }
564
- ImGui::GetWindowDrawList ()->AddImage (g_shaderCacheLoaderState.textureDRCId , ImVec2 (paddingLeftAndRight, paddingTopAndBottom), ImVec2 (io.DisplaySize .x -paddingLeftAndRight, io.DisplaySize .y -paddingTopAndBottom), { 0 ,1 }, { 1 ,0 });
565
- }
566
- }
567
- ImGui::End ();
568
- ImGui::PopStyleVar (2 );
488
+ LatteShaderCache_drawBackgroundImage (g_shaderCacheLoaderState.textureDRCId , 854 , 480 );
569
489
g_renderer->ImguiEnd ();
570
490
}
571
491
0 commit comments