Create and use CPArray enum class
This commit is contained in:
1 parent
3aaeb2b9ef
commit
1914087998
22 files changed
+171
-126
No files matched your search
@@ -190,11 +190,11 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode)
|
||||
{
|
||||
s_DrawingObject = false;
|
||||
|
||||
int array = 0xc + (cmd - static_cast<u8>(Opcode::GX_LOAD_INDX_A)) / 8;
|
||||
CPArray array = static_cast<CPArray>(0xc + (cmd - static_cast<u8>(Opcode::GX_LOAD_INDX_A)) / 8);
|
||||
u32 value = ReadFifo32(data);
|
||||
|
||||
if (mode == DecodeMode::Record)
|
||||
FifoRecordAnalyzer::ProcessLoadIndexedXf(value, array);
|
||||
FifoRecordAnalyzer::ProcessLoadIndexedXf(array, value);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -238,8 +238,8 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode)
|
||||
{
|
||||
for (size_t i = 0; i < offsets.size(); ++i)
|
||||
{
|
||||
FifoRecordAnalyzer::WriteVertexArray(static_cast<int>(i), data + offsets[i], vertexSize,
|
||||
numVertices);
|
||||
FifoRecordAnalyzer::WriteVertexArray(static_cast<CPArray>(i), data + offsets[i],
|
||||
vertexSize, numVertices);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,11 +284,11 @@ void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem)
|
||||
break;
|
||||
|
||||
case ARRAY_BASE:
|
||||
cpMem.arrayBases[subCmd & CP_ARRAY_MASK] = value;
|
||||
cpMem.arrayBases[static_cast<CPArray>(subCmd & CP_ARRAY_MASK)] = value;
|
||||
break;
|
||||
|
||||
case ARRAY_STRIDE:
|
||||
cpMem.arrayStrides[subCmd & CP_ARRAY_MASK] = value & 0xFF;
|
||||
cpMem.arrayStrides[static_cast<CPArray>(subCmd & CP_ARRAY_MASK)] = value & 0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <array>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/EnumMap.h"
|
||||
|
||||
#include "VideoCommon/CPMemory.h"
|
||||
|
||||
namespace FifoAnalyzer
|
||||
@@ -22,8 +24,8 @@ struct CPMemory
|
||||
{
|
||||
TVtxDesc vtxDesc;
|
||||
std::array<VAT, CP_NUM_VAT_REG> vtxAttr;
|
||||
std::array<u32, CP_NUM_ARRAYS> arrayBases{};
|
||||
std::array<u32, CP_NUM_ARRAYS> arrayStrides{};
|
||||
Common::EnumMap<u32, CPArray::XF_D> arrayBases{};
|
||||
Common::EnumMap<u32, CPArray::XF_D> arrayStrides{};
|
||||
};
|
||||
|
||||
void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem);
|
||||
|
||||
@@ -30,7 +30,7 @@ void FifoRecordAnalyzer::Initialize(const u32* cpMem)
|
||||
std::copy(strides_start, strides_end, s_CpMem.arrayStrides.begin());
|
||||
}
|
||||
|
||||
void FifoRecordAnalyzer::ProcessLoadIndexedXf(u32 val, int array)
|
||||
void FifoRecordAnalyzer::ProcessLoadIndexedXf(CPArray array, u32 val)
|
||||
{
|
||||
int index = val >> 16;
|
||||
int size = ((val >> 12) & 0xF) + 1;
|
||||
@@ -40,19 +40,19 @@ void FifoRecordAnalyzer::ProcessLoadIndexedXf(u32 val, int array)
|
||||
FifoRecorder::GetInstance().UseMemory(address, size * 4, MemoryUpdate::XF_DATA);
|
||||
}
|
||||
|
||||
void FifoRecordAnalyzer::WriteVertexArray(int arrayIndex, const u8* vertexData, int vertexSize,
|
||||
void FifoRecordAnalyzer::WriteVertexArray(CPArray arrayIndex, const u8* vertexData, int vertexSize,
|
||||
int numVertices)
|
||||
{
|
||||
// Skip if not indexed array
|
||||
VertexComponentFormat arrayType;
|
||||
if (arrayIndex == ARRAY_POSITION)
|
||||
if (arrayIndex == CPArray::Position)
|
||||
arrayType = s_CpMem.vtxDesc.low.Position;
|
||||
else if (arrayIndex == ARRAY_NORMAL)
|
||||
else if (arrayIndex == CPArray::Normal)
|
||||
arrayType = s_CpMem.vtxDesc.low.Normal;
|
||||
else if (arrayIndex >= ARRAY_COLOR0 && arrayIndex < ARRAY_COLOR0 + NUM_COLOR_ARRAYS)
|
||||
arrayType = s_CpMem.vtxDesc.low.Color[arrayIndex - ARRAY_COLOR0];
|
||||
else if (arrayIndex >= ARRAY_TEXCOORD0 && arrayIndex < ARRAY_TEXCOORD0 + NUM_TEXCOORD_ARRAYS)
|
||||
arrayType = s_CpMem.vtxDesc.high.TexCoord[arrayIndex - ARRAY_TEXCOORD0];
|
||||
else if (arrayIndex >= CPArray::Color0 && arrayIndex <= CPArray::Color1)
|
||||
arrayType = s_CpMem.vtxDesc.low.Color[u8(arrayIndex) - u8(CPArray::Color0)];
|
||||
else if (arrayIndex >= CPArray::TexCoord0 && arrayIndex <= CPArray::TexCoord7)
|
||||
arrayType = s_CpMem.vtxDesc.high.TexCoord[u8(arrayIndex) - u8(CPArray::TexCoord0)];
|
||||
else
|
||||
{
|
||||
PanicAlertFmt("Invalid arrayIndex {}", arrayIndex);
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
enum class CPArray : u8;
|
||||
|
||||
namespace FifoRecordAnalyzer
|
||||
{
|
||||
// Must call this before analyzing Fifo commands with FifoAnalyzer::AnalyzeCommand()
|
||||
void Initialize(const u32* cpMem);
|
||||
|
||||
void ProcessLoadIndexedXf(u32 val, int array);
|
||||
void WriteVertexArray(int arrayIndex, const u8* vertexData, int vertexSize, int numVertices);
|
||||
void ProcessLoadIndexedXf(CPArray array, u32 val);
|
||||
void WriteVertexArray(CPArray arrayIndex, const u8* vertexData, int vertexSize, int numVertices);
|
||||
} // namespace FifoRecordAnalyzer
|
||||
Reference in new issue
Block a user