From 6c33b73cdd8cddb1fb83cedce9dd46c76a3802d8 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 8 Mar 2022 18:14:12 +1000 Subject: [PATCH] GS: Make TC offset changable without recreating --- pcsx2-qt/Settings/GraphicsSettingsWidget.ui | 12 +++++++++-- pcsx2/GS/GS.cpp | 15 ++------------ pcsx2/GS/GSState.cpp | 13 +++++++++--- pcsx2/GS/GSState.h | 3 ++- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 22 ++++++++++++++------- pcsx2/GS/Renderers/HW/GSRendererHW.h | 3 +++ 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui index 7bc6122a15..dc93d35939 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui @@ -809,7 +809,11 @@ - + + + 1000 + + @@ -819,7 +823,11 @@ - + + + 1000 + + diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 909c0e8be0..f02fd6c36c 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -767,9 +767,6 @@ void GSUpdateConfig(const Pcsx2Config::GSOptions& new_config) GSConfig.SWExtraThreads != old_config.SWExtraThreads || GSConfig.SWExtraThreadsHeight != old_config.SWExtraThreadsHeight || - GSConfig.UserHacks_TCOffsetX != old_config.UserHacks_TCOffsetX || - GSConfig.UserHacks_TCOffsetY != old_config.UserHacks_TCOffsetY || - GSConfig.ShadeBoost_Brightness != old_config.ShadeBoost_Brightness || GSConfig.ShadeBoost_Contrast != old_config.ShadeBoost_Contrast || GSConfig.ShadeBoost_Saturation != old_config.ShadeBoost_Saturation || @@ -793,16 +790,8 @@ void GSUpdateConfig(const Pcsx2Config::GSOptions& new_config) s_gs->SetGameCRC(s_gs->GetGameCRC(), s_gs->GetGameCRCOptions()); } - if ( - GSConfig.AutoFlushSW != old_config.AutoFlushSW || - GSConfig.UserHacks_AutoFlush != old_config.UserHacks_AutoFlush || - GSConfig.UserHacks_WildHack != old_config.UserHacks_WildHack) - { - s_gs->ResetHandlers(); - } - - if (GSConfig.Mipmap != old_config.Mipmap || GSConfig.HWMipmap != old_config.HWMipmap) - s_gs->UpdateMipmapEnabled(); + // renderer-specific options (e.g. auto flush, TC offset) + s_gs->UpdateSettings(old_config); // reload texture cache when trilinear filtering or TC options change if ( diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index ae73a26aaa..6972843415 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -132,7 +132,6 @@ GSState::GSState() Reset(); ResetHandlers(); - UpdateMipmapEnabled(); } GSState::~GSState() @@ -315,9 +314,17 @@ void GSState::ResetHandlers() m_fpGIFRegHandlers[GIF_A_D_REG_LABEL] = &GSState::GIFRegHandlerNull; } -void GSState::UpdateMipmapEnabled() +void GSState::UpdateSettings(const Pcsx2Config::GSOptions& old_config) { - m_mipmap = GSConfig.UseHardwareRenderer() ? (GSConfig.HWMipmap >= HWMipmapLevel::Basic) : GSConfig.Mipmap; + m_mipmap = GSConfig.Mipmap; + + if ( + GSConfig.AutoFlushSW != old_config.AutoFlushSW || + GSConfig.UserHacks_AutoFlush != old_config.UserHacks_AutoFlush || + GSConfig.UserHacks_WildHack != old_config.UserHacks_WildHack) + { + ResetHandlers(); + } } bool GSState::isinterlaced() diff --git a/pcsx2/GS/GSState.h b/pcsx2/GS/GSState.h index 7dcbf7deca..c0a948f8e6 100644 --- a/pcsx2/GS/GSState.h +++ b/pcsx2/GS/GSState.h @@ -260,7 +260,6 @@ public: virtual ~GSState(); void ResetHandlers(); - void UpdateMipmapEnabled(); int GetFramebufferHeight(); void SaturateOutputSize(GSVector4i& r); @@ -274,6 +273,8 @@ public: float GetTvRefreshRate(); virtual void Reset(); + virtual void UpdateSettings(const Pcsx2Config::GSOptions& old_config); + void Flush(); void FlushPrim(); void FlushWrite(); diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 1e87956785..2c7bae085d 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -35,13 +35,7 @@ GSRendererHW::GSRendererHW() , m_lod(GSVector2i(0, 0)) { m_mipmap = (GSConfig.HWMipmap >= HWMipmapLevel::Basic); - - if (GSConfig.UserHacks) - { - m_userhacks_tcoffset_x = GSConfig.UserHacks_TCOffsetX / -1000.0f; - m_userhacks_tcoffset_y = GSConfig.UserHacks_TCOffsetY / -1000.0f; - m_userhacks_tcoffset = m_userhacks_tcoffset_x < 0.0f || m_userhacks_tcoffset_y < 0.0f; - } + SetTCOffset(); if (!GSConfig.UpscaleMultiplier) // Custom Resolution { @@ -158,6 +152,13 @@ void GSRendererHW::CustomResolutionScaling() printf("Frame buffer size set to %dx%d (%dx%d)\n", scissored_buffer_size.x, scissored_buffer_size.y, m_width, m_height); } +void GSRendererHW::SetTCOffset() +{ + m_userhacks_tcoffset_x = std::max(GSConfig.UserHacks_TCOffsetX, 0) / -1000.0f; + m_userhacks_tcoffset_y = std::max(GSConfig.UserHacks_TCOffsetY, 0) / -1000.0f; + m_userhacks_tcoffset = m_userhacks_tcoffset_x < 0.0f || m_userhacks_tcoffset_y < 0.0f; +} + GSRendererHW::~GSRendererHW() { delete m_tc; @@ -215,6 +216,13 @@ void GSRendererHW::Reset() GSRenderer::Reset(); } +void GSRendererHW::UpdateSettings(const Pcsx2Config::GSOptions& old_config) +{ + GSRenderer::UpdateSettings(old_config); + m_mipmap = (GSConfig.HWMipmap >= HWMipmapLevel::Basic); + SetTCOffset(); +} + void GSRendererHW::VSync(u32 field, bool registers_written) { if (m_reset) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.h b/pcsx2/GS/Renderers/HW/GSRendererHW.h index 7dd7c103e0..6964d1ec59 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.h +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.h @@ -141,6 +141,8 @@ protected: virtual void DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) = 0; + void SetTCOffset(); + bool m_userhacks_tcoffset; float m_userhacks_tcoffset_x; float m_userhacks_tcoffset_y; @@ -175,6 +177,7 @@ public: GSVector2i GetTargetSize(); void Reset() override; + void UpdateSettings(const Pcsx2Config::GSOptions& old_config) override; void VSync(u32 field, bool registers_written) override; GSTexture* GetOutput(int i, int& y_offset) override;