From a18d624bcbde3da98c2d6f761b2c8a8e233b55eb Mon Sep 17 00:00:00 2001 From: willkuer Date: Mon, 5 Dec 2016 22:55:53 +0100 Subject: [PATCH] gsdx: Add an automatic CRC hack level If a user switches renderer they also have to remember to change the CRC hack level for the best user experience with the selected renderer. This commit adds a new automatic CRC level that autoselects the recommended CRC level for the selected renderer, so that a user doesn't have to make the change manually. coauthor: turtleli --- plugins/GSdx/GS.cpp | 4 ---- plugins/GSdx/GS.h | 3 ++- plugins/GSdx/GSHwHack.cpp | 9 +++++---- plugins/GSdx/GSSetting.cpp | 8 ++++++-- plugins/GSdx/GSSettingsDlg.cpp | 14 ++------------ plugins/GSdx/GSState.cpp | 6 ++++-- plugins/GSdx/GSTextureCache.cpp | 5 ++++- plugins/GSdx/GSUtil.cpp | 5 +++++ plugins/GSdx/GSUtil.h | 1 + plugins/GSdx/GSdx.cpp | 15 +++++++++------ 10 files changed, 38 insertions(+), 32 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 35d320579a..e64a0ff7a2 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -216,11 +216,7 @@ static int _GSopen(void** dsp, const char* title, GSRendererType renderer, int t renderer = static_cast(theApp.GetConfigI("Renderer")); #ifdef _WIN32 if (renderer == GSRendererType::Default) - { renderer = GSUtil::GetBestRenderer(); - if (renderer == GSRendererType::OGL_HW) - theApp.SetConfig("crc_hack_level", static_cast(CRCHackLevel::Partial)); - } #endif } diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 57f393bff3..eeeb8fcab2 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -1432,8 +1432,9 @@ enum class TriFiltering : uint8 Forced, }; -enum class CRCHackLevel : uint8 +enum class CRCHackLevel : int8 { + Automatic = -1, None, Minimum, Partial, diff --git a/plugins/GSdx/GSHwHack.cpp b/plugins/GSdx/GSHwHack.cpp index 5238a1e09a..3256ee60ea 100644 --- a/plugins/GSdx/GSHwHack.cpp +++ b/plugins/GSdx/GSHwHack.cpp @@ -23,11 +23,12 @@ #include "GSState.h" #include "GSdx.h" -CRCHackLevel s_crc_hack_level = CRCHackLevel::Full; +static CRCHackLevel s_crc_hack_level = CRCHackLevel::Full; // hacks #define Aggresive (s_crc_hack_level >= CRCHackLevel::Aggressive) -#define Dx_only (s_crc_hack_level >= CRCHackLevel::Full) +#define Dx_only (s_crc_hack_level >= CRCHackLevel::Full) +#define Dx_and_OGL (s_crc_hack_level >= CRCHackLevel::Partial) CRC::Region g_crc_region = CRC::NoRegion; @@ -2419,11 +2420,11 @@ void GSState::SetupCrcHack() { GetSkipCount lut[CRC::TitleCount]; - s_crc_hack_level = static_cast(theApp.GetConfigI("crc_hack_level")); + s_crc_hack_level = m_crc_hack_level; memset(lut, 0, sizeof(lut)); - if (s_crc_hack_level > CRCHackLevel::Minimum) { + if (Dx_and_OGL) { lut[CRC::AceCombat4] = GSC_AceCombat4; lut[CRC::BlackHawkDown] = GSC_BlackHawkDown; lut[CRC::BleachBladeBattlers] = GSC_BleachBladeBattlers; diff --git a/plugins/GSdx/GSSetting.cpp b/plugins/GSdx/GSSetting.cpp index 0a43926867..a632ad50c5 100644 --- a/plugins/GSdx/GSSetting.cpp +++ b/plugins/GSdx/GSSetting.cpp @@ -46,10 +46,14 @@ const char* dialog_message(int ID, bool* updateText) { #endif case IDC_CRC_LEVEL: return "Control the number of Auto-CRC hacks applied to games.\n\n" + "Automatic:\nAutomatically sets the recommended CRC hack level based on the selected renderer.\n" + "This is the recommended setting.\n" + "Partial will be selected for OpenGL.\nFull will be selected for Direct3D.\n\n" "None:\nRemove nearly all CRC hacks (debug only).\n\n" "Minimum:\nEnable a couple of CRC hacks (23).\n\n" - "Partial:\nEnable most of the CRC hacks.\nRecommended OpenGL setting (Accurate/depth options may be required).\n\n" - "Full:\nEnable all CRC hacks.\nRecommended Direct3D setting.\n\n" + "Partial:\nEnable most of the CRC hacks.\n" + "For an optimal experience with OpenGL, Blending Unit Accuracy/Depth Emulation may need to be enabled.\n\n" + "Full:\nEnable all CRC hacks.\n\n" "Aggressive:\nUse more aggressive CRC hacks. Only affects a few games, removing some effects which might make the image sharper/clearer.\n" "Affected games: FFX, FFX2, FFXII, GOW2, ICO, SoTC, SSX3, SMT3, SMTDDS1, SMTDDS2.\n" "Works as a speedhack for: Steambot Chronicles."; diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 7a767fc5b5..9c11bf6a12 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -334,19 +334,9 @@ void GSSettingsDlg::UpdateRenderers() } else { - GSRendererType ini_renderer = GSRendererType(theApp.GetConfigI("Renderer")); - - if (ini_renderer == GSRendererType::Undefined) - { + renderer_setting = GSRendererType(theApp.GetConfigI("Renderer")); + if (renderer_setting == GSRendererType::Undefined) renderer_setting = GSUtil::GetBestRenderer(); - - if(renderer_setting == GSRendererType::OGL_HW) - theApp.SetConfig("crc_hack_level", static_cast(CRCHackLevel::Partial)); - } - else - { - renderer_setting = ini_renderer; - } } GSRendererType renderer_sel = GSRendererType::Default; diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index f336e6b384..f322139d64 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -22,7 +22,7 @@ #include "stdafx.h" #include "GSState.h" #include "GSdx.h" - +#include "GSUtil.h" //#define Offset_ST // Fixes Persona3 mini map alignment which is off even in software rendering @@ -78,7 +78,9 @@ GSState::GSState() //s_savel = 0; UserHacks_WildHack = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_WildHack") : 0; - m_crc_hack_level = static_cast(theApp.GetConfigI("crc_hack_level")); + m_crc_hack_level = theApp.GetConfigT("crc_hack_level"); + if (m_crc_hack_level == CRCHackLevel::Automatic) + m_crc_hack_level = GSUtil::GetRecommendedCRCHackLevel(theApp.GetCurrentRendererType()); memset(&m_v, 0, sizeof(m_v)); memset(&m_vertex, 0, sizeof(m_vertex)); diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 42770f344a..c6dbb1d96c 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "GSTextureCache.h" +#include "GSUtil.h" bool s_IS_OPENGL = false; bool GSTextureCache::m_disable_partial_invalidation = false; @@ -51,7 +52,9 @@ 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 = static_cast(theApp.GetConfigI("crc_hack_level")); + m_crc_hack_level = theApp.GetConfigT("crc_hack_level"); + if (m_crc_hack_level == CRCHackLevel::Automatic) + m_crc_hack_level = GSUtil::GetRecommendedCRCHackLevel(theApp.GetCurrentRendererType()); // In theory 4MB is enough but 9MB is safer for overflow (8MB // isn't enough in custom resolution) diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp index 6cb090e0ab..409b167fea 100644 --- a/plugins/GSdx/GSUtil.cpp +++ b/plugins/GSdx/GSUtil.cpp @@ -241,6 +241,11 @@ bool GSUtil::CheckSSE() return status; } +CRCHackLevel GSUtil::GetRecommendedCRCHackLevel(GSRendererType type) +{ + return type == GSRendererType::OGL_HW ? CRCHackLevel::Partial : CRCHackLevel::Full; +} + #define OCL_PROGRAM_VERSION 3 #ifdef ENABLE_OPENCL diff --git a/plugins/GSdx/GSUtil.h b/plugins/GSdx/GSUtil.h index 2676a5ca61..81b469c1c0 100644 --- a/plugins/GSdx/GSUtil.h +++ b/plugins/GSdx/GSUtil.h @@ -50,6 +50,7 @@ public: static bool HasCompatibleBits(uint32 spsm, uint32 dpsm); static bool CheckSSE(); + static CRCHackLevel GetRecommendedCRCHackLevel(GSRendererType type); #ifdef ENABLE_OPENCL static void GetDeviceDescs(list& dl); diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 47fe853fa4..dbe79019d6 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -229,11 +229,14 @@ void GSdxApp::Init() m_gs_hw_mipmapping.push_back(GSSetting(1, "Basic", "Fast")); m_gs_hw_mipmapping.push_back(GSSetting(2, "Full", "Slow")); - m_gs_crc_level.push_back(GSSetting(0 , "None", "Debug")); - m_gs_crc_level.push_back(GSSetting(1 , "Minimum", "Debug")); - m_gs_crc_level.push_back(GSSetting(2 , "Partial", "OpenGL Recommended")); - m_gs_crc_level.push_back(GSSetting(3 , "Full", "Direct3D Recommended")); - m_gs_crc_level.push_back(GSSetting(4 , "Aggressive", "")); + m_gs_crc_level = { + GSSetting(CRCHackLevel::Automatic, "Automatic", "Default"), + GSSetting(CRCHackLevel::None , "None", "Debug"), + GSSetting(CRCHackLevel::Minimum, "Minimum", "Debug"), + GSSetting(CRCHackLevel::Partial, "Partial", "OpenGL Recommended"), + GSSetting(CRCHackLevel::Full, "Full", "Direct3D Recommended"), + GSSetting(CRCHackLevel::Aggressive, "Aggressive", ""), + }; m_gs_acc_blend_level.push_back(GSSetting(0, "None", "Fastest")); m_gs_acc_blend_level.push_back(GSSetting(1, "Basic", "Recommended low-end PC")); @@ -303,7 +306,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"] = to_string(static_cast(CRCHackLevel::Full)); + m_default_configuration["crc_hack_level"] = std::to_string(static_cast(CRCHackLevel::Automatic)); m_default_configuration["CrcHacksExclusions"] = ""; m_default_configuration["debug_glsl_shader"] = "0"; m_default_configuration["debug_opengl"] = "0";