Convert vertex loader position cache to std::array
This commit is contained in:
parent
f722bdf7f1
commit
97d0ff58c8
|
@ -23,7 +23,7 @@ static void PosMtx_ReadDirect_UByte(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
u32 posmtx = DataRead<u8>() & 0x3f;
|
u32 posmtx = DataRead<u8>() & 0x3f;
|
||||||
if (loader->m_counter < 3)
|
if (loader->m_counter < 3)
|
||||||
VertexLoaderManager::position_matrix_index[loader->m_counter + 1] = posmtx;
|
VertexLoaderManager::position_matrix_index_cache[loader->m_counter + 1] = posmtx;
|
||||||
DataWrite<u32>(posmtx);
|
DataWrite<u32>(posmtx);
|
||||||
PRIM_LOG("posmtx: {}, ", posmtx);
|
PRIM_LOG("posmtx: {}, ", posmtx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,10 +211,11 @@ int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentForm
|
||||||
{
|
{
|
||||||
CMP(count_reg, 3);
|
CMP(count_reg, 3);
|
||||||
FixupBranch dont_store = B(CC_GT);
|
FixupBranch dont_store = B(CC_GT);
|
||||||
MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_cache);
|
MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_cache.data());
|
||||||
ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch2_reg), EncodeRegTo64(count_reg),
|
ADD(EncodeRegTo64(scratch1_reg), EncodeRegTo64(scratch2_reg), EncodeRegTo64(count_reg),
|
||||||
ArithOption(EncodeRegTo64(count_reg), ShiftType::LSL, 4));
|
ArithOption(EncodeRegTo64(count_reg), ShiftType::LSL, 4));
|
||||||
m_float_emit.STUR(write_size, coords, EncodeRegTo64(scratch1_reg), -16);
|
m_float_emit.STUR(write_size, coords, EncodeRegTo64(scratch1_reg),
|
||||||
|
-int(sizeof(decltype(VertexLoaderManager::position_cache[0]))));
|
||||||
SetJumpTarget(dont_store);
|
SetJumpTarget(dont_store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +423,7 @@ void VertexLoaderARM64::GenerateVertexLoader()
|
||||||
// Z-Freeze
|
// Z-Freeze
|
||||||
CMP(count_reg, 3);
|
CMP(count_reg, 3);
|
||||||
FixupBranch dont_store = B(CC_GT);
|
FixupBranch dont_store = B(CC_GT);
|
||||||
MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index);
|
MOVP2R(EncodeRegTo64(scratch2_reg), VertexLoaderManager::position_matrix_index_cache.data());
|
||||||
STR(scratch1_reg, EncodeRegTo64(scratch2_reg), ArithOption(count_reg, true));
|
STR(scratch1_reg, EncodeRegTo64(scratch2_reg), ArithOption(count_reg, true));
|
||||||
SetJumpTarget(dont_store);
|
SetJumpTarget(dont_store);
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
|
|
||||||
namespace VertexLoaderManager
|
namespace VertexLoaderManager
|
||||||
{
|
{
|
||||||
float position_cache[3][4];
|
// Used by zfreeze
|
||||||
|
std::array<std::array<float, 4>, 3> position_cache;
|
||||||
// The counter added to the address of the array is 1, 2, or 3, but never zero.
|
// The counter added to the address of the array is 1, 2, or 3, but never zero.
|
||||||
// So only index 1 - 3 are used.
|
// So only index 1 - 3 are used.
|
||||||
u32 position_matrix_index[4];
|
std::array<u32, 4> position_matrix_index_cache;
|
||||||
|
|
||||||
static NativeVertexFormatMap s_native_vertex_map;
|
static NativeVertexFormatMap s_native_vertex_map;
|
||||||
static NativeVertexFormat* s_current_vtx_fmt;
|
static NativeVertexFormat* s_current_vtx_fmt;
|
||||||
|
|
|
@ -53,8 +53,8 @@ void UpdateVertexArrayPointers();
|
||||||
|
|
||||||
// Position cache for zfreeze (3 vertices, 4 floats each to allow SIMD overwrite).
|
// Position cache for zfreeze (3 vertices, 4 floats each to allow SIMD overwrite).
|
||||||
// These arrays are in reverse order.
|
// These arrays are in reverse order.
|
||||||
extern float position_cache[3][4];
|
extern std::array<std::array<float, 4>, 3> position_cache;
|
||||||
extern u32 position_matrix_index[4];
|
extern std::array<u32, 4> position_matrix_index_cache;
|
||||||
|
|
||||||
// VB_HAS_X. Bitmask telling what vertex components are present.
|
// VB_HAS_X. Bitmask telling what vertex components are present.
|
||||||
extern u32 g_current_components;
|
extern u32 g_current_components;
|
||||||
|
|
|
@ -119,8 +119,9 @@ int VertexLoaderX64::ReadVertex(OpArg data, VertexComponentFormat attribute, Com
|
||||||
{
|
{
|
||||||
CMP(32, R(count_reg), Imm8(3));
|
CMP(32, R(count_reg), Imm8(3));
|
||||||
FixupBranch dont_store = J_CC(CC_A);
|
FixupBranch dont_store = J_CC(CC_A);
|
||||||
LEA(32, scratch3, MScaled(count_reg, SCALE_4, -4));
|
LEA(32, scratch3,
|
||||||
MOVUPS(MPIC(VertexLoaderManager::position_cache, scratch3, SCALE_4), coords);
|
MScaled(count_reg, SCALE_4, -int(VertexLoaderManager::position_cache[0].size())));
|
||||||
|
MOVUPS(MPIC(VertexLoaderManager::position_cache.data(), scratch3, SCALE_4), coords);
|
||||||
SetJumpTarget(dont_store);
|
SetJumpTarget(dont_store);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -408,7 +409,8 @@ void VertexLoaderX64::GenerateVertexLoader()
|
||||||
// zfreeze
|
// zfreeze
|
||||||
CMP(32, R(count_reg), Imm8(3));
|
CMP(32, R(count_reg), Imm8(3));
|
||||||
FixupBranch dont_store = J_CC(CC_A);
|
FixupBranch dont_store = J_CC(CC_A);
|
||||||
MOV(32, MPIC(VertexLoaderManager::position_matrix_index, count_reg, SCALE_4), R(scratch1));
|
MOV(32, MPIC(VertexLoaderManager::position_matrix_index_cache.data(), count_reg, SCALE_4),
|
||||||
|
R(scratch1));
|
||||||
SetJumpTarget(dont_store);
|
SetJumpTarget(dont_store);
|
||||||
|
|
||||||
m_native_vtx_decl.posmtx.components = 4;
|
m_native_vtx_decl.posmtx.components = 4;
|
||||||
|
|
|
@ -558,7 +558,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format)
|
||||||
{
|
{
|
||||||
// If this vertex format has per-vertex position matrix IDs, look it up.
|
// If this vertex format has per-vertex position matrix IDs, look it up.
|
||||||
if (vert_decl.posmtx.enable)
|
if (vert_decl.posmtx.enable)
|
||||||
mtxIdx = VertexLoaderManager::position_matrix_index[3 - i];
|
mtxIdx = VertexLoaderManager::position_matrix_index_cache[3 - i];
|
||||||
|
|
||||||
if (vert_decl.position.components == 2)
|
if (vert_decl.position.components == 2)
|
||||||
VertexLoaderManager::position_cache[2 - i][2] = 0;
|
VertexLoaderManager::position_cache[2 - i][2] = 0;
|
||||||
|
|
Loading…
Reference in New Issue