From c66004bbb25bb62ad4cc30a1984eaa98ffb81406 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 6 Oct 2016 19:08:21 +0200 Subject: [PATCH] gsdx: hidden option to better support dual context clut Option is on by default. Just a safety net in case of regression Fix clut issue on virtua fighter (SW) and harley davidson (SW/HW). --- plugins/GSdx/GSState.cpp | 10 ++++++++++ plugins/GSdx/GSState.h | 1 + plugins/GSdx/GSdx.cpp | 1 + 3 files changed, 12 insertions(+) diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 9d68ad0c02..685e88d53a 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -50,6 +50,7 @@ GSState::GSState() m_NTSC_Saturation = theApp.GetConfigB("NTSC_Saturation"); m_userhacks_skipdraw = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_SkipDraw") : 0; m_userhacks_auto_flush = theApp.GetConfigB("UserHacks") ? theApp.GetConfigB("UserHacks_AutoFlush") : 0; + m_clut_load_before_draw = theApp.GetConfigB("clut_load_before_draw"); s_n = 0; s_dump = theApp.GetConfigB("dump"); @@ -1512,6 +1513,15 @@ void GSState::FlushPrim() { GL_REG("FlushPrim ctxt %d", PRIM->CTXT); + // Some games (Harley Davidson/Virtua Fighter) do dirty trick with multiple contexts cluts + // In doubt, always reload the clut before a draw. + // Note: perf impact is likely slow enough as WriteTest will likely be false. + if (m_clut_load_before_draw) { + if (m_mem.m_clut.WriteTest(m_context->TEX0, m_env.TEXCLUT)) { + m_mem.m_clut.Write(m_context->TEX0, m_env.TEXCLUT); + } + } + GSVertex buff[2]; s_n++; diff --git a/plugins/GSdx/GSState.h b/plugins/GSdx/GSState.h index 0cebd8195e..ac8b949a4a 100644 --- a/plugins/GSdx/GSState.h +++ b/plugins/GSdx/GSState.h @@ -136,6 +136,7 @@ class GSState : public GSAlignedClass<32> void (*m_irq)(); bool m_path3hack; bool m_init_read_fifo_supported; + bool m_clut_load_before_draw; struct GSTransferBuffer { diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 7515170b61..b0fdd98469 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -284,6 +284,7 @@ void GSdxApp::Init() m_default_configuration["capture_threads"] = "4"; m_default_configuration["CaptureHeight"] = "480"; m_default_configuration["CaptureWidth"] = "640"; + m_default_configuration["clut_load_before_draw"] = "1"; m_default_configuration["crc_hack_level"] = "3"; m_default_configuration["CrcHacksExclusions"] = ""; m_default_configuration["debug_glsl_shader"] = "0";