From b9df1e643bb93cb6016965d4efb36c18c5cabb35 Mon Sep 17 00:00:00 2001 From: lightningterror Date: Wed, 23 Jan 2019 12:23:21 +0100 Subject: [PATCH] gsdx-hw: Adjust/cleanup hw hacks variable calls. Use a function to check UserHacks for all variables in GSState.cpp instead of checking each variable individually. Get rid of UserHacks_HPO local variables in GSRendererOGL/DX and use the member variable m_userHacks_HPO instead, we don't need duplicates that do the same thing. Add ResetStates call at the beginning of GSRendererDX to match gl behavior. --- plugins/GSdx/GSState.cpp | 24 +++++++++++++------ .../GSdx/Renderers/DXCommon/GSRendererDX.cpp | 6 ++--- .../GSdx/Renderers/DXCommon/GSRendererDX.h | 2 -- .../GSdx/Renderers/OpenGL/GSRendererOGL.cpp | 16 +++++-------- plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h | 1 - 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 29c87d5831..e4e69c0f44 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -47,13 +47,24 @@ GSState::GSState() { // m_nativeres seems to be a hack. Unfortunately it impacts draw call number which make debug painful in the replayer. // Let's keep it disabled to ease debug. - m_nativeres = theApp.GetConfigI("upscale_multiplier") == 1 || GLLoader::in_replayer; - m_mipmap = theApp.GetConfigI("mipmap"); - m_NTSC_Saturation = theApp.GetConfigB("NTSC_Saturation"); - m_userhacks_skipdraw = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_SkipDraw") : 0; - m_userhacks_skipdraw_offset = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_SkipDraw_Offset") : 0; - m_userhacks_auto_flush = theApp.GetConfigB("UserHacks") ? theApp.GetConfigB("UserHacks_AutoFlush") : 0; + m_nativeres = theApp.GetConfigI("upscale_multiplier") == 1 || GLLoader::in_replayer; + m_mipmap = theApp.GetConfigI("mipmap"); + m_NTSC_Saturation = theApp.GetConfigB("NTSC_Saturation"); m_clut_load_before_draw = theApp.GetConfigB("clut_load_before_draw"); + if (theApp.GetConfigB("UserHacks")) + { + m_userhacks_auto_flush = theApp.GetConfigB("UserHacks_AutoFlush"); + m_userhacks_skipdraw = theApp.GetConfigI("UserHacks_SkipDraw"); + m_userhacks_skipdraw_offset = theApp.GetConfigI("UserHacks_SkipDraw_Offset"); + UserHacks_WildHack = theApp.GetConfigI("UserHacks_WildHack"); + } + else + { + m_userhacks_auto_flush = false; + m_userhacks_skipdraw = 0; + m_userhacks_skipdraw_offset = 0; + UserHacks_WildHack = 0; + } s_n = 0; s_dump = theApp.GetConfigB("dump"); @@ -79,7 +90,6 @@ GSState::GSState() //s_saven = 0; //s_savel = 0; - UserHacks_WildHack = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_WildHack") : 0; m_crc_hack_level = theApp.GetConfigT("crc_hack_level"); if (m_crc_hack_level == CRCHackLevel::Automatic) m_crc_hack_level = GSUtil::GetRecommendedCRCHackLevel(theApp.GetCurrentRendererType()); diff --git a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp index 18f4081aba..5071798c79 100644 --- a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp +++ b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp @@ -31,14 +31,14 @@ GSRendererDX::GSRendererDX(GSTextureCache* tc, const GSVector2& pixelcenter) { UserHacks_AlphaHack = theApp.GetConfigB("UserHacks_AlphaHack"); UserHacks_AlphaStencil = theApp.GetConfigB("UserHacks_AlphaStencil"); - UserHacks_HPO = theApp.GetConfigI("UserHacks_HalfPixelOffset"); } else { UserHacks_AlphaHack = false; UserHacks_AlphaStencil = false; - UserHacks_HPO = 0; } + + ResetStates(); } GSRendererDX::~GSRendererDX() @@ -804,7 +804,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc //The resulting shifted output aligns better with common blending / corona / blurring effects, //but introduces a few bad pixels on the edges. - if (rt && rt->LikelyOffset && UserHacks_HPO == 1) + if (rt && rt->LikelyOffset && m_userHacks_HPO == 1) { // DX9 has pixelcenter set to 0.0, so give it some value here diff --git a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.h b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.h index 439b870e06..d5e30b1b4b 100644 --- a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.h +++ b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.h @@ -41,8 +41,6 @@ protected: virtual void DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex); virtual void SetupIA(const float& sx, const float& sy) = 0; - int UserHacks_HPO; - GSDeviceDX* dev; GSDeviceDX::VSSelector m_vs_sel; diff --git a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp index 35100bdbbe..a58012537c 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp +++ b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp @@ -26,21 +26,17 @@ GSRendererOGL::GSRendererOGL() : GSRendererHW(new GSTextureCacheOGL(this)) { - m_sw_blending = theApp.GetConfigI("accurate_blending_unit"); + m_sw_blending = theApp.GetConfigI("accurate_blending_unit"); + if (theApp.GetConfigB("UserHacks")) + UserHacks_tri_filter = static_cast(theApp.GetConfigI("UserHacks_TriFilter")); + else + UserHacks_tri_filter = TriFiltering::None; // Hope nothing requires too many draw calls. m_drawlist.reserve(2048); - UserHacks_HPO = theApp.GetConfigI("UserHacks_HalfPixelOffset"); - UserHacks_tri_filter = static_cast(theApp.GetConfigI("UserHacks_TriFilter")); - m_prim_overlap = PRIM_OVERLAP_UNKNOW; ResetStates(); - - if (!theApp.GetConfigB("UserHacks")) { - UserHacks_HPO = 0; - UserHacks_tri_filter = TriFiltering::None; - } } bool GSRendererOGL::CreateDevice(GSDevice* dev) @@ -1225,7 +1221,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour //The resulting shifted output aligns better with common blending / corona / blurring effects, //but introduces a few bad pixels on the edges. - if (rt && rt->LikelyOffset && UserHacks_HPO == 1) + if (rt && rt->LikelyOffset && m_userHacks_HPO == 1) { ox2 *= rt->OffsetHack_modx; oy2 *= rt->OffsetHack_mody; diff --git a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h index d74d35caa7..ea505cf7b4 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h +++ b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h @@ -53,7 +53,6 @@ class GSRendererOGL final : public GSRendererHW PRIM_OVERLAP m_prim_overlap; std::vector m_drawlist; - int UserHacks_HPO; TriFiltering UserHacks_tri_filter; GSDeviceOGL::VSConstantBuffer vs_cb;