From 7df69829732745d98b843d37d68a65920d1d883b Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 30 May 2015 03:58:27 +1200 Subject: [PATCH] Add a dirty flag for arraybases. Only loop through and call getPointers when something has actually changed. Worth about 2-4% speedup un SMG over the previous commit. --- Source/Core/VideoBackends/Software/CPMemLoader.cpp | 3 +++ Source/Core/VideoCommon/CPMemory.cpp | 3 +++ Source/Core/VideoCommon/CPMemory.h | 1 + Source/Core/VideoCommon/VertexLoaderManager.cpp | 9 +++++++++ 4 files changed, 16 insertions(+) diff --git a/Source/Core/VideoBackends/Software/CPMemLoader.cpp b/Source/Core/VideoBackends/Software/CPMemLoader.cpp index d1ebe6cc87..c33cd2dd0e 100644 --- a/Source/Core/VideoBackends/Software/CPMemLoader.cpp +++ b/Source/Core/VideoBackends/Software/CPMemLoader.cpp @@ -23,11 +23,13 @@ void SWLoadCPReg(u32 sub_cmd, u32 value) case 0x50: g_main_cp_state.vtx_desc.Hex &= ~0x1FFFF; // keep the Upper bits g_main_cp_state.vtx_desc.Hex |= value; + g_main_cp_state.bases_dirty = true; break; case 0x60: g_main_cp_state.vtx_desc.Hex &= 0x1FFFF; // keep the lower 17Bits g_main_cp_state.vtx_desc.Hex |= (u64)value << 17; + g_main_cp_state.bases_dirty = true; break; case 0x70: @@ -48,6 +50,7 @@ void SWLoadCPReg(u32 sub_cmd, u32 value) // Pointers to vertex arrays in GC RAM case 0xA0: g_main_cp_state.array_bases[sub_cmd & 0xF] = value; + g_main_cp_state.bases_dirty = true; break; case 0xB0: diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp index 55904f5684..5fc7bbe98d 100644 --- a/Source/Core/VideoCommon/CPMemory.cpp +++ b/Source/Core/VideoCommon/CPMemory.cpp @@ -22,7 +22,10 @@ void DoCPState(PointerWrap& p) p.DoArray(g_main_cp_state.vtx_attr, 8); p.DoMarker("CP Memory"); if (p.mode == PointerWrap::MODE_READ) + { CopyPreprocessCPStateFromMain(); + g_main_cp_state.bases_dirty = true; + } } void CopyPreprocessCPStateFromMain() diff --git a/Source/Core/VideoCommon/CPMemory.h b/Source/Core/VideoCommon/CPMemory.h index 47b1e169ab..491f818305 100644 --- a/Source/Core/VideoCommon/CPMemory.h +++ b/Source/Core/VideoCommon/CPMemory.h @@ -255,6 +255,7 @@ struct CPState final // Attributes that actually belong to VertexLoaderManager: BitSet32 attr_dirty; + bool bases_dirty; VertexLoaderBase* vertex_loaders[8]; }; diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index 4ebb07788b..dbb421991c 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -56,6 +56,10 @@ void Shutdown() void UpdateVertexArrayPointers() { + // Anything to update? + if (!g_main_cp_state.bases_dirty) + return; + // Some games such as Burnout 2 can put invalid addresses into // the array base registers. (see issue 8591) // But the vertex arrays with invalid addresses aren't actually enabled. @@ -67,6 +71,8 @@ void UpdateVertexArrayPointers() if (g_main_cp_state.vtx_desc.GetVertexArrayStatus(i) >= 0x2) cached_arraybases[i] = Memory::GetPointer(g_main_cp_state.array_bases[i]); } + + g_main_cp_state.bases_dirty = false; } namespace @@ -224,12 +230,14 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess) state->vtx_desc.Hex &= ~0x1FFFF; // keep the Upper bits state->vtx_desc.Hex |= value; state->attr_dirty = BitSet32::AllTrue(8); + state->bases_dirty = true; break; case 0x60: state->vtx_desc.Hex &= 0x1FFFF; // keep the lower 17Bits state->vtx_desc.Hex |= (u64)value << 17; state->attr_dirty = BitSet32::AllTrue(8); + state->bases_dirty = true; break; case 0x70: @@ -253,6 +261,7 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess) // Pointers to vertex arrays in GC RAM case 0xA0: state->array_bases[sub_cmd & 0xF] = value; + state->bases_dirty = true; break; case 0xB0: