From ff89619b09e7db4a87da1739cc02e054099e5828 Mon Sep 17 00:00:00 2001 From: Akash Date: Mon, 13 Feb 2017 16:46:27 +0530 Subject: [PATCH] GSdx: Add an Enumeration for CRC Hack level --- plugins/GSdx/GS.h | 9 +++++++++ plugins/GSdx/GSHwHack.cpp | 10 +++++----- plugins/GSdx/GSRendererDX.cpp | 2 +- plugins/GSdx/GSState.cpp | 5 ++--- plugins/GSdx/GSState.h | 2 +- plugins/GSdx/GSTextureCache.cpp | 4 ++-- plugins/GSdx/GSTextureCache.h | 2 +- plugins/GSdx/GSdx.cpp | 2 +- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 7e3385d837..eba2a0ac6a 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -1425,3 +1425,12 @@ enum class Filtering : uint8 Trilinear_Bilinear_Forced, Trilinear_Always }; + +enum class CRCHackLevel : uint8 +{ + None, + Minimum, + Partial, + Full, + Aggressive +}; diff --git a/plugins/GSdx/GSHwHack.cpp b/plugins/GSdx/GSHwHack.cpp index e3b57c182a..5238a1e09a 100644 --- a/plugins/GSdx/GSHwHack.cpp +++ b/plugins/GSdx/GSHwHack.cpp @@ -23,11 +23,11 @@ #include "GSState.h" #include "GSdx.h" -int s_crc_hack_level = 3; +CRCHackLevel s_crc_hack_level = CRCHackLevel::Full; // hacks -#define Aggresive (s_crc_hack_level > 3) -#define Dx_only (s_crc_hack_level > 2) +#define Aggresive (s_crc_hack_level >= CRCHackLevel::Aggressive) +#define Dx_only (s_crc_hack_level >= CRCHackLevel::Full) CRC::Region g_crc_region = CRC::NoRegion; @@ -2419,11 +2419,11 @@ void GSState::SetupCrcHack() { GetSkipCount lut[CRC::TitleCount]; - s_crc_hack_level = theApp.GetConfigI("crc_hack_level"); + s_crc_hack_level = static_cast(theApp.GetConfigI("crc_hack_level")); memset(lut, 0, sizeof(lut)); - if (s_crc_hack_level > 1) { + if (s_crc_hack_level > CRCHackLevel::Minimum) { lut[CRC::AceCombat4] = GSC_AceCombat4; lut[CRC::BlackHawkDown] = GSC_BlackHawkDown; lut[CRC::BleachBladeBattlers] = GSC_BleachBladeBattlers; diff --git a/plugins/GSdx/GSRendererDX.cpp b/plugins/GSdx/GSRendererDX.cpp index 76ed169c69..f14a132182 100644 --- a/plugins/GSdx/GSRendererDX.cpp +++ b/plugins/GSdx/GSRendererDX.cpp @@ -299,7 +299,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc // Gregory: code is not yet ready so let's only enable it when // CRC is below the FULL level - if (m_texture_shuffle && (m_crc_hack_level < 3)) { + if (m_texture_shuffle && (m_crc_hack_level < CRCHackLevel::Full)) { ps_sel.shuffle = 1; ps_sel.fmt = 0; diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 14befa55ee..77858d0b84 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -23,7 +23,6 @@ #include "GSState.h" #include "GSdx.h" -extern int g_crc_hack_level; //#define Offset_ST // Fixes Persona3 mini map alignment which is off even in software rendering @@ -79,7 +78,7 @@ GSState::GSState() //s_savel = 0; UserHacks_WildHack = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_WildHack") : 0; - m_crc_hack_level = theApp.GetConfigI("crc_hack_level"); + m_crc_hack_level = static_cast(theApp.GetConfigI("crc_hack_level")); memset(&m_v, 0, sizeof(m_v)); memset(&m_vertex, 0, sizeof(m_vertex)); @@ -2519,7 +2518,7 @@ void GSState::SetGameCRC(uint32 crc, int options) { m_crc = crc; m_options = options; - m_game = CRC::Lookup(m_crc_hack_level ? crc : 0); + m_game = CRC::Lookup(m_crc_hack_level != CRCHackLevel::None ? crc : 0); SetupCrcHack(); // Until we find a solution that work for all games. diff --git a/plugins/GSdx/GSState.h b/plugins/GSdx/GSState.h index eca27e2d50..9de8a2890f 100644 --- a/plugins/GSdx/GSState.h +++ b/plugins/GSdx/GSState.h @@ -160,7 +160,7 @@ protected: int UserHacks_WildHack; bool isPackedUV_HackFlag; - int m_crc_hack_level; + CRCHackLevel m_crc_hack_level; GetSkipCount m_gsc; int m_skip; int m_userhacks_skipdraw; diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 1c6405e376..9b836f0ac0 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -51,7 +51,7 @@ GSTextureCache::GSTextureCache(GSRenderer* r) m_paltex = theApp.GetConfigB("paltex"); m_can_convert_depth &= s_IS_OPENGL; // only supported by openGL so far - m_crc_hack_level = theApp.GetConfigI("crc_hack_level"); + m_crc_hack_level = static_cast(theApp.GetConfigI("crc_hack_level")); // In theory 4MB is enough but 9MB is safer for overflow (8MB // isn't enough in custom resolution) @@ -281,7 +281,7 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con // Gregory: to avoid a massive slow down for nothing, let's only enable // this code when CRC is below the FULL level - if (m_crc_hack_level < 3) + if (m_crc_hack_level < CRCHackLevel::Full) Read(t, t->m_valid); else dst = t; diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index a1547542b3..7ba4e0a77e 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -129,7 +129,7 @@ protected: bool m_preload_frame; uint8* m_temp; bool m_can_convert_depth; - int m_crc_hack_level; + CRCHackLevel m_crc_hack_level; static bool m_disable_partial_invalidation; bool m_texture_inside_rt; static bool m_wrap_gs_mem; diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 2e922463dc..69b4252f6a 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -294,7 +294,7 @@ void GSdxApp::Init() m_default_configuration["CaptureHeight"] = "480"; m_default_configuration["CaptureWidth"] = "640"; m_default_configuration["clut_load_before_draw"] = "0"; - m_default_configuration["crc_hack_level"] = "3"; + m_default_configuration["crc_hack_level"] = to_string(static_cast(CRCHackLevel::Full)); m_default_configuration["CrcHacksExclusions"] = ""; m_default_configuration["debug_glsl_shader"] = "0"; m_default_configuration["debug_opengl"] = "0";