summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoaderManager.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-02-08 15:22:10 -0800
committerPokechu22 <Pokechu022@gmail.com>2021-03-06 19:27:08 -0800
commitf749fcfa9f42cda679ff7f4288c8418d2b56b08d (patch)
tree5bcc8c255eae974638c20f1a4e76a22fcaee69e4 /Source/Core/VideoCommon/VertexLoaderManager.cpp
parentc27efb3f1fefa49db7962532865fbbe483f248f1 (diff)
Convert CPMemory to BitField and enum class
Additionally, VCacheEnhance has been added to UVAT_group1. According to YAGCD, this field is always 1. TVtxDesc also now has separate low and high fields whose hex values correspond with the proper registers, instead of having one 33-bit value. This change was made in a way that should be backwards-compatible.
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index 93322de512..4dcc211178 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -77,11 +77,26 @@ void UpdateVertexArrayPointers()
// But the vertex arrays with invalid addresses aren't actually enabled.
// Note: Only array bases 0 through 11 are used by the Vertex loaders.
// 12 through 15 are used for loading data into xfmem.
- for (int i = 0; i < 12; i++)
+ // We also only update the array base if the vertex description states we are going to use it.
+ if (IsIndexed(g_main_cp_state.vtx_desc.low.Position))
+ cached_arraybases[ARRAY_POSITION] =
+ Memory::GetPointer(g_main_cp_state.array_bases[ARRAY_POSITION]);
+
+ if (IsIndexed(g_main_cp_state.vtx_desc.low.Normal))
+ cached_arraybases[ARRAY_NORMAL] = Memory::GetPointer(g_main_cp_state.array_bases[ARRAY_NORMAL]);
+
+ for (size_t i = 0; i < g_main_cp_state.vtx_desc.low.Color.Size(); i++)
+ {
+ if (IsIndexed(g_main_cp_state.vtx_desc.low.Color[i]))
+ cached_arraybases[ARRAY_COLOR + i] =
+ Memory::GetPointer(g_main_cp_state.array_bases[ARRAY_COLOR + i]);
+ }
+
+ for (size_t i = 0; i < g_main_cp_state.vtx_desc.high.TexCoord.Size(); i++)
{
- // Only update the array base if the vertex description states we are going to use it.
- if (g_main_cp_state.vtx_desc.GetVertexArrayStatus(i) & MASK_INDEXED)
- cached_arraybases[i] = Memory::GetPointer(g_main_cp_state.array_bases[i]);
+ if (IsIndexed(g_main_cp_state.vtx_desc.high.TexCoord[i]))
+ cached_arraybases[ARRAY_TEXCOORD0 + i] =
+ Memory::GetPointer(g_main_cp_state.array_bases[ARRAY_TEXCOORD0 + i]);
}
g_main_cp_state.bases_dirty = false;
@@ -317,15 +332,13 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess)
break;
case VCD_LO:
- state->vtx_desc.Hex &= ~0x1FFFF; // keep the Upper bits
- state->vtx_desc.Hex |= value;
+ state->vtx_desc.low.Hex = value;
state->attr_dirty = BitSet32::AllTrue(CP_NUM_VAT_REG);
state->bases_dirty = true;
break;
case VCD_HI:
- state->vtx_desc.Hex &= 0x1FFFF; // keep the lower 17Bits
- state->vtx_desc.Hex |= (u64)value << 17;
+ state->vtx_desc.high.Hex = value;
state->attr_dirty = BitSet32::AllTrue(CP_NUM_VAT_REG);
state->bases_dirty = true;
break;
@@ -371,8 +384,8 @@ void FillCPMemoryArray(u32* memory)
{
memory[MATINDEX_A] = g_main_cp_state.matrix_index_a.Hex;
memory[MATINDEX_B] = g_main_cp_state.matrix_index_b.Hex;
- memory[VCD_LO] = (u32)g_main_cp_state.vtx_desc.Hex;
- memory[VCD_HI] = (u32)(g_main_cp_state.vtx_desc.Hex >> 17);
+ memory[VCD_LO] = g_main_cp_state.vtx_desc.low.Hex;
+ memory[VCD_HI] = g_main_cp_state.vtx_desc.high.Hex;
for (int i = 0; i < CP_NUM_VAT_REG; ++i)
{