From b8814ef00f41c05e90ce21982f2e5a0e22024b9c Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sun, 26 Jan 2025 21:21:29 -0500 Subject: [PATCH] GFXPC refactor --- .../resolution-editor/ResolutionEditor.cpp | 17 +++++++++-------- soh/soh/OTRGlobals.cpp | 15 +++++++-------- soh/soh/framebuffer_effects.c | 5 ++--- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index c15f04364..a2242ac08 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -60,6 +60,7 @@ void AdvancedResolutionSettingsWindow::InitElement() { } void AdvancedResolutionSettingsWindow::DrawElement() { + GfxPc* gfxPc = GfxPc::GetInstance(); // Initialise update flags. bool update[3]; for (uint8_t i = 0; i < sizeof(update); i++) @@ -71,13 +72,13 @@ void AdvancedResolutionSettingsWindow::DrawElement() { short integerScale_maximumBounds = 1; // can change when window is resized // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. - if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > - ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + if (((float)gfxPc->mGameWindowViewport.width / gfxPc->mGameWindowViewport.height) > + ((float)gfxPc->mCurDimensions.width / gfxPc->mCurDimensions.height)) { // Scale to window height - integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + integerScale_maximumBounds = gfxPc->mGameWindowViewport.height / gfxPc->mCurDimensions.height; } else { // Scale to window width - integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + integerScale_maximumBounds = gfxPc->mGameWindowViewport.width / gfxPc->mCurDimensions.width; } // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. @@ -161,9 +162,9 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } } // Resolution visualiser - ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, - gfx_current_game_window_viewport.height); - ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + ImGui::Text("Viewport dimensions: %d x %d", gfxPc->mGameWindowViewport.width, + gfxPc->mGameWindowViewport.height); + ImGui::Text("Internal resolution: %d x %d", gfxPc->mCurDimensions.width, gfxPc->mCurDimensions.height); UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); if (disabled_everything) { // Hide aspect ratio controls. @@ -203,7 +204,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { } else if (showHorizontalResField) { // Show calculated aspect ratio if (item_aspectRatio) { UIWidgets::Spacer(2); - const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height; + const float resolvedAspectRatio = (float)gfxPc->mCurDimensions.width / gfxPc->mCurDimensions.height; ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio); } else { UIWidgets::Spacer(enhancementSpacerHeight); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6d5430d69..d46440a7b 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1439,7 +1439,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { if (prevAltAssets != curAltAssets) { prevAltAssets = curAltAssets; Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets); - gfx_texture_cache_clear(); + GfxPc::GetInstance()->TextureCacheClear(); SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); } @@ -1790,7 +1790,7 @@ extern "C" void OTRControllerCallback(uint8_t rumble) { } extern "C" float OTRGetAspectRatio() { - return gfx_current_dimensions.aspect_ratio; + return GfxPc::GetInstance()->mCurDimensions.aspect_ratio; } extern "C" float OTRGetDimensionFromLeftEdge(float v) { @@ -1803,12 +1803,12 @@ extern "C" float OTRGetDimensionFromRightEdge(float v) { // Gets the width of the current render target area extern "C" uint32_t OTRGetGameRenderWidth() { - return gfx_current_dimensions.width; + return GfxPc::GetInstance()->mCurDimensions.width; } // Gets the height of the current render target area extern "C" uint32_t OTRGetGameRenderHeight() { - return gfx_current_dimensions.height; + return GfxPc::GetInstance()->mCurDimensions.height; } f32 floorf(f32 x);// RANDOTODO False positive error "allowing all exceptions is incompatible with previous function" @@ -2373,11 +2373,11 @@ extern "C" void EntranceTracker_SetLastEntranceOverride(s16 entranceIndex) { } extern "C" void Gfx_RegisterBlendedTexture(const char* name, u8* mask, u8* replacement) { - gfx_register_blended_texture(name, mask, replacement); + GfxPc::GetInstance()->RegisterBlendedTexture(name, mask, replacement); } extern "C" void Gfx_UnregisterBlendedTexture(const char* name) { - gfx_unregister_blended_texture(name); + GfxPc::GetInstance()->UnregisterBlendedTexture(name); } extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) { @@ -2390,8 +2390,7 @@ extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) { if (ResourceMgr_OTRSigCheck(imgName)) { texAddr = (const uint8_t*)ResourceMgr_GetResourceDataByNameHandlingMQ(imgName); } - - gfx_texture_cache_delete(texAddr); + GfxPc::GetInstance()->TextureCacheDelete(texAddr); } void SoH_ProcessDroppedFiles(std::string filePath) { diff --git a/soh/soh/framebuffer_effects.c b/soh/soh/framebuffer_effects.c index 0eba6b25b..53f544884 100644 --- a/soh/soh/framebuffer_effects.c +++ b/soh/soh/framebuffer_effects.c @@ -2,8 +2,7 @@ #include "global.h" #include "OTRGlobals.h" -int gfx_create_framebuffer(uint32_t width, uint32_t height, uint32_t native_width, uint32_t native_height, - uint8_t resize); +int gfx_create_framebuffer(uint32_t width, uint32_t height, uint32_t native_width, uint32_t native_height,uint8_t resize); s32 gPauseFrameBuffer = -1; s32 gBlurFrameBuffer = -1; @@ -16,7 +15,7 @@ s32 gN64ResFrameBuffer = -1; void FB_CreateFramebuffers(void) { if (gPauseFrameBuffer == -1) { - gPauseFrameBuffer = gfx_create_framebuffer(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, true); + gPauseFrameBuffer =gfx_create_framebuffer(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, true); } if (gBlurFrameBuffer == -1) {