From 2db74e7f21cdad4abc7f5148ffcdd9e801093b42 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Sat, 17 Sep 2022 14:19:13 +0200 Subject: [PATCH] OpcodeDecoding: Get vertex size from the loader --- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 5 +++++ Source/Core/Core/FifoPlayer/FifoRecorder.cpp | 5 +++++ Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 10 ++++++++++ Source/Core/VideoCommon/OpcodeDecoding.cpp | 6 ++++++ Source/Core/VideoCommon/OpcodeDecoding.h | 5 +++-- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index b93fcf980a..e6a3a6e224 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -55,6 +55,11 @@ public: OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; } + OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) + { + return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]); + } + bool m_start_of_primitives = false; bool m_end_of_primitives = false; bool m_efb_copy = false; diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index a47877ef4f..4464615495 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -45,6 +45,11 @@ public: OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; } + OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) + { + return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]); + } + private: void ProcessVertexComponent(CPArray array_index, VertexComponentFormat array_type, u32 component_offset, u32 vertex_size, u16 num_vertices, diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index d593a7419d..bcf0276a02 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -316,6 +316,11 @@ public: OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; } + OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) + { + return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]); + } + QString text; CPState m_cpmem; }; @@ -731,6 +736,11 @@ public: OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; } + OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) + { + return VertexLoaderBase::GetVertexSize(GetCPState().vtx_desc, GetCPState().vtx_attr[vat]); + } + QString text; CPState m_cpmem; }; diff --git a/Source/Core/VideoCommon/OpcodeDecoding.cpp b/Source/Core/VideoCommon/OpcodeDecoding.cpp index c8f2f2c53a..bc19a1c2de 100644 --- a/Source/Core/VideoCommon/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/OpcodeDecoding.cpp @@ -228,6 +228,12 @@ public: return g_main_cp_state; } + OPCODE_CALLBACK(u32 GetVertexSize(u8 vat)) + { + VertexLoaderBase* loader = VertexLoaderManager::RefreshLoader(vat); + return loader->m_vertex_size; + } + u32 m_cycles = 0; bool m_in_display_list = false; }; diff --git a/Source/Core/VideoCommon/OpcodeDecoding.h b/Source/Core/VideoCommon/OpcodeDecoding.h index 1badf63196..2035f5c733 100644 --- a/Source/Core/VideoCommon/OpcodeDecoding.h +++ b/Source/Core/VideoCommon/OpcodeDecoding.h @@ -110,6 +110,8 @@ public: // Get the current CP state. Needed for vertex decoding; will also be mutated for CP commands. virtual CPState& GetCPState() = 0; + + virtual u32 GetVertexSize(u8 vat) = 0; #endif }; @@ -229,8 +231,7 @@ static DOLPHIN_FORCE_INLINE u32 RunCommand(const u8* data, u32 available, T& cal (cmdbyte & OpcodeDecoder::GX_PRIMITIVE_MASK) >> OpcodeDecoder::GX_PRIMITIVE_SHIFT); const u8 vat = cmdbyte & OpcodeDecoder::GX_VAT_MASK; - const u32 vertex_size = VertexLoaderBase::GetVertexSize(callback.GetCPState().vtx_desc, - callback.GetCPState().vtx_attr[vat]); + const u32 vertex_size = callback.GetVertexSize(vat); const u16 num_vertices = Common::swap16(&data[1]); if (available < 3 + num_vertices * vertex_size)