summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2022-04-13 16:12:53 -0700
committerPokechu22 <Pokechu022@gmail.com>2022-04-22 16:54:38 -0700
commit97d0ff58c8dbe374a1b87e1a72f1f245ed27ed96 (patch)
tree70031f58df4bfbfc6222257bebaf3bced14cf24e /Source/Core
parentf722bdf7f1ab5913d035f257ff82865a686b08d6 (diff)
Convert vertex loader position cache to std::array
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/VertexLoader.cpp2
-rw-r--r--Source/Core/VideoCommon/VertexLoaderARM64.cpp7
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp6
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.h4
-rw-r--r--Source/Core/VideoCommon/VertexLoaderX64.cpp8
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp2
6 files changed, 16 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp
index b01ac961b9..c703c96508 100644
--- a/Source/Core/VideoCommon/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/VertexLoader.cpp
@@ -23,7 +23,7 @@ static void PosMtx_ReadDirect_UByte(VertexLoader* loader)
{
u32 posmtx = DataRead<u8>() & 0x3f;
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);
PRIM_LOG("posmtx: {}, ", posmtx);
}
diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp
index 7c47f153a6..a191dbb2c8 100644
--- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp
@@ -211,10 +211,11 @@ int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentForm
{
CMP(count_reg, 3);
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),
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);
}
@@ -422,7 +423,7 @@ void VertexLoaderARM64::GenerateVertexLoader()
// Z-Freeze
CMP(count_reg, 3);
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));
SetJumpTarget(dont_store);
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index b0922e5a6e..e2881a8e3d 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -31,11 +31,11 @@
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.
// 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 NativeVertexFormat* s_current_vtx_fmt;
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.h b/Source/Core/VideoCommon/VertexLoaderManager.h
index d6bda13c00..2ba724d75d 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.h
+++ b/Source/Core/VideoCommon/VertexLoaderManager.h
@@ -53,8 +53,8 @@ void UpdateVertexArrayPointers();
// Position cache for zfreeze (3 vertices, 4 floats each to allow SIMD overwrite).
// These arrays are in reverse order.
-extern float position_cache[3][4];
-extern u32 position_matrix_index[4];
+extern std::array<std::array<float, 4>, 3> position_cache;
+extern std::array<u32, 4> position_matrix_index_cache;
// VB_HAS_X. Bitmask telling what vertex components are present.
extern u32 g_current_components;
diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp
index 734fa0819c..91889c83d9 100644
--- a/Source/Core/VideoCommon/VertexLoaderX64.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp
@@ -119,8 +119,9 @@ int VertexLoaderX64::ReadVertex(OpArg data, VertexComponentFormat attribute, Com
{
CMP(32, R(count_reg), Imm8(3));
FixupBranch dont_store = J_CC(CC_A);
- LEA(32, scratch3, MScaled(count_reg, SCALE_4, -4));
- MOVUPS(MPIC(VertexLoaderManager::position_cache, scratch3, SCALE_4), coords);
+ LEA(32, scratch3,
+ MScaled(count_reg, SCALE_4, -int(VertexLoaderManager::position_cache[0].size())));
+ MOVUPS(MPIC(VertexLoaderManager::position_cache.data(), scratch3, SCALE_4), coords);
SetJumpTarget(dont_store);
}
};
@@ -408,7 +409,8 @@ void VertexLoaderX64::GenerateVertexLoader()
// zfreeze
CMP(32, R(count_reg), Imm8(3));
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);
m_native_vtx_decl.posmtx.components = 4;
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 5fa85b2761..4ffebaadf3 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -558,7 +558,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format)
{
// If this vertex format has per-vertex position matrix IDs, look it up.
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)
VertexLoaderManager::position_cache[2 - i][2] = 0;