@@ -374,6 +374,7 @@ static std::unique_ptr<RenderCommandSemaphore> g_renderSemaphores[NUM_FRAMES];
374374static uint32_t g_backBufferIndex;
375375static std::unique_ptr<GuestSurface> g_backBufferHolder;
376376static GuestSurface* g_backBuffer;
377+ static std::vector<std::pair<GuestSurface*, uint32_t >> g_surfaceCache;
377378
378379static std::unique_ptr<RenderTexture> g_intermediaryBackBufferTexture;
379380static uint32_t g_intermediaryBackBufferTextureWidth;
@@ -3199,6 +3200,8 @@ void Video::Present()
31993200 be<uint32_t > usage;
32003201 };
32013202
3203+ g_surfaceCache.clear ();
3204+
32023205 auto pFormatConfig = (GraphicsFormatConfig*)(g_memory.base + 0x82B7BD20 );
32033206
32043207 // Kill Auto Surfaces
@@ -3305,8 +3308,9 @@ void Video::Present()
33053308 surfaceParams = (params.r10 & 2 ) == 0 ? &pMyGraphicDevice->m_SurfaceParamA : &pMyGraphicDevice->m_SurfaceParamC ;
33063309 }
33073310
3308- auto gSurface = CreateSurface (params.width , params.height , pFormatConfig[params.r8 ].SurfaceFormat , 0 , surfaceParams);
3309- GuestToHostFunction<void >(sub_82592E98, surface.second .get (), gSurface , params.width , params.height );
3311+ // Until cache system is gone for good
3312+ // auto gSurface = CreateSurface(params.width, params.height, pFormatConfig[params.r8].SurfaceFormat, 0, surfaceParams);
3313+ // GuestToHostFunction<void>(sub_82592E98, surface.second.get(), gSurface, params.width, params.height);
33103314 }
33113315
33123316 printf (" ----------------------------[Textures]-----------------------------------\n " );
@@ -3380,6 +3384,21 @@ void Video::Present()
33803384 pRenderTargetContainer->m_mspPostEffect .clear ();
33813385 pRenderTargetContainer->m_mspPostEffectAfter .clear ();
33823386
3387+
3388+
3389+ if (auto it = pResourceManager->m_mResource [pTextureManager->m_MgrIndex ].find (" radermap" );
3390+ it != pResourceManager->m_mResource [pTextureManager->m_MgrIndex ].end ())
3391+ {
3392+ if (auto pPopup = pApp->GetGame ()->m_lrPopulScreenTask .m_pElement )
3393+ {
3394+ auto pHUDRaderMap = pPopup->GetHUDPopupScreen <Sonicteam::HUDRaderMap>();
3395+ pHUDRaderMap->m_pMainTexture .reset ();
3396+ pHUDRaderMap->m_pMaskTexture .reset ();
3397+ }
3398+ }
3399+
3400+
3401+
33833402 // framebuffer_tile should properly reference framebuffer0's GuestTexture
33843403 // PROPER FIX OPTIONS:
33853404 // 1. Allocate new texture to the same pointer instead of this workaround
@@ -3396,8 +3415,25 @@ void Video::Present()
33963415
33973416 // Refresh Lua Render
33983417 // 0x82B814F8 (stdx::string) gCurrentRenderScript
3418+
33993419 GuestToHostFunction<void >(sub_8260DF88, pDocState, 0x82B814F8 , 1 );
3420+ auto SetResource = [&](auto * spTextureTo, const char * name) {
3421+ if (auto it = pResourceManager->m_mResource [pTextureManager->m_MgrIndex ].find (name);
3422+ it != pResourceManager->m_mResource [pTextureManager->m_MgrIndex ].end ()) {
3423+ *spTextureTo = static_cast <Sonicteam::MyTexture*>(it->second .get ());
3424+ }
3425+ };
34003426
3427+ if (pResourceManager->m_mResource [pTextureManager->m_MgrIndex ].find (" radermap" ) != pResourceManager->m_mResource [pTextureManager->m_MgrIndex ].end ())
3428+ {
3429+ if (auto pPopup = pApp->GetGame ()->m_lrPopulScreenTask .m_pElement ) {
3430+ auto pHUDRaderMap = pPopup->GetHUDPopupScreen <Sonicteam::HUDRaderMap>();
3431+ SetResource (&pHUDRaderMap->m_pMainTexture , " radermap" );
3432+ SetResource (&pHUDRaderMap->m_pMaskTexture , " radermap_mask" );
3433+ }
3434+ }
3435+
3436+
34013437 // TODO: Fix particle not updating position or disappearing after Lua refresh
34023438 }
34033439
@@ -3714,7 +3750,6 @@ static GuestBuffer* CreateIndexBuffer(uint32_t length, uint32_t, uint32_t format
37143750 return buffer;
37153751}
37163752
3717- static std::vector<std::pair<GuestSurface*, uint32_t >> g_surfaceCache;
37183753
37193754// TODO: Singleplayer (possibly) uses the same memory location in EDRAM for HDR and FB0 surfaces,
37203755// so we just remember who was created first and use that instead of creating a new one.
0 commit comments