Skip to content

Commit

Permalink
OpcodeDecoding: Get vertex size from the loader
Browse files Browse the repository at this point in the history
  • Loading branch information
K0bin committed Sep 18, 2022
1 parent d113f9a commit 907b5d7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Source/Core/Core/FifoPlayer/FifoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class FifoPlaybackAnalyzer : public OpcodeDecoder::Callback

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;
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/FifoPlayer/FifoRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class FifoRecorder::FifoRecordAnalyzer : public OpcodeDecoder::Callback

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,
Expand Down
19 changes: 17 additions & 2 deletions Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,19 @@ class DetailCallback : public OpcodeDecoder::Callback
text = QStringLiteral("Unknown opcode %1").arg(opcode, 2, 16);
}

OPCODE_CALLBACK(void OnCommand(const u8* data, u32 size)) {}
OPCODE_CALLBACK(void OnCommand(const u8* data, u32 size))
{
}

OPCODE_CALLBACK(CPState& GetCPState()) { return m_cpmem; }
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;
Expand Down Expand Up @@ -731,6 +741,11 @@ class DescriptionCallback : public OpcodeDecoder::Callback

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;
};
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/VideoCommon/OpcodeDecoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ class RunCallback final : public Callback
return g_main_cp_state;
}

OPCODE_CALLBACK(u32 GetVertexSize(u8 vat))
{
VertexLoaderBase* loader = VertexLoaderManager::RefreshLoader<is_preprocess>(vat);
return loader->m_vertex_size;
}

u32 m_cycles = 0;
bool m_in_display_list = false;
};
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/VideoCommon/OpcodeDecoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class Callback

// 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
};

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 907b5d7

Please sign in to comment.