From f0131c2e09faba0d65fa5b7360898e514e3636f5 Mon Sep 17 00:00:00 2001 From: comex Date: Wed, 27 Aug 2014 13:26:06 -0400 Subject: Mechanical changes to move most CP state to a struct rather than separate globals. The next commit will add a separate copy of the struct and the ability for LoadCPReg to work on it. --- Source/Core/VideoCommon/CPMemory.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/CPMemory.cpp') diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp index 752063065b..22bc95c57d 100644 --- a/Source/Core/VideoCommon/CPMemory.cpp +++ b/Source/Core/VideoCommon/CPMemory.cpp @@ -2,17 +2,22 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "VideoCommon/CPMemory.h" // CP state u8 *cached_arraybases[16]; -// STATE_TO_SAVE -u32 arraybases[16]; -u32 arraystrides[16]; -TMatrixIndexA MatrixIndexA; -TMatrixIndexB MatrixIndexB; -TVtxDesc g_VtxDesc; -// Most games only use the first VtxAttr and simply reconfigure it all the time as needed. -VAT g_VtxAttr[8]; +CPState g_main_cp_state; + +void DoCPState(PointerWrap& p) +{ + p.DoArray(g_main_cp_state.array_bases, 16); + p.DoArray(g_main_cp_state.array_strides, 16); + p.Do(g_main_cp_state.matrix_index_a); + p.Do(g_main_cp_state.matrix_index_b); + p.Do(g_main_cp_state.vtx_desc.Hex); + p.DoArray(g_main_cp_state.vtx_attr, 8); + p.DoMarker("CP Memory"); +} -- cgit v1.2.3 From e86ddacb18affaef2d773b0c86fdf57f93d594c4 Mon Sep 17 00:00:00 2001 From: comex Date: Wed, 27 Aug 2014 13:38:00 -0400 Subject: Changes to allow LoadCPReg to work in a preprocess mode which affects a separate state. This state will be used to calculate sizes for skipping over commands on a separate thread. An alternative to having these state variables would be to have the preprocessor stash "state as we go" somewhere, but I think that would be much uglier. GetVertexSize now takes an extra argument to determine which state to use, as does FifoCommandRunnable, which calls it. While I'm modifying FifoCommandRunnable, I also change it to take a buffer and size as parameters rather than using g_pVideoData, which will also be necessary later. I also get rid of an unused overload. --- Source/Core/VideoCommon/CPMemory.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Source/Core/VideoCommon/CPMemory.cpp') diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp index 22bc95c57d..739a3e66e3 100644 --- a/Source/Core/VideoCommon/CPMemory.cpp +++ b/Source/Core/VideoCommon/CPMemory.cpp @@ -10,9 +10,12 @@ u8 *cached_arraybases[16]; CPState g_main_cp_state; +CPState g_preprocess_cp_state; void DoCPState(PointerWrap& p) { + // We don't save g_preprocess_cp_state separately because the GPU should be + // synced around state save/load. p.DoArray(g_main_cp_state.array_bases, 16); p.DoArray(g_main_cp_state.array_strides, 16); p.Do(g_main_cp_state.matrix_index_a); @@ -20,4 +23,11 @@ void DoCPState(PointerWrap& p) p.Do(g_main_cp_state.vtx_desc.Hex); p.DoArray(g_main_cp_state.vtx_attr, 8); p.DoMarker("CP Memory"); + if (p.mode == PointerWrap::MODE_READ) + CopyPreprocessCPStateFromMain(); +} + +void CopyPreprocessCPStateFromMain() +{ + memcpy(&g_preprocess_cp_state, &g_main_cp_state, sizeof(CPState)); } -- cgit v1.2.3