summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoaderManager.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2021-03-07 00:21:11 -0500
committerGitHub <noreply@github.com>2021-03-07 00:21:11 -0500
commit089250fde65c2e225681c0ef6917d28fa187e8de (patch)
treebcbb6db025c6003bd681e0028f0bc3b7b223bd07 /Source/Core/VideoCommon/VertexLoaderManager.cpp
parent5f7d935b0a40f5cece7341927bd92b6a8d5debbe (diff)
parentdf81210e96c6603d3aeb6c76f51b030d06cd06ac (diff)
Merge pull request #9497 from Pokechu22/better-fifo-analyzer
Graphics refactoring + add names and descriptions in FIFO analyzer
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp108
1 files changed, 65 insertions, 43 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index bcbf64d3d4..fdb63679f5 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -15,9 +15,11 @@
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
+#include "Common/Logging/Log.h"
#include "Core/HW/Memmap.h"
#include "VideoCommon/BPMemory.h"
+#include "VideoCommon/CPMemory.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/DataReader.h"
#include "VideoCommon/IndexGenerator.h"
@@ -75,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;
@@ -276,7 +293,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
// if cull mode is CULL_ALL, tell VertexManager to skip triangles and quads.
// They still need to go through vertex loading, because we need to calculate a zfreeze refrence
// slope.
- bool cullall = (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5);
+ bool cullall = (bpmem.genMode.cullmode == CullMode::All && primitive < 5);
DataReader dst = g_vertex_manager->PrepareForAdditionalData(
primitive, count, loader->m_native_vtx_decl.stride, cullall);
@@ -302,79 +319,84 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess)
{
bool update_global_state = !is_preprocess;
CPState* state = is_preprocess ? &g_preprocess_cp_state : &g_main_cp_state;
- switch (sub_cmd & 0xF0)
+ switch (sub_cmd & CP_COMMAND_MASK)
{
- case 0x30:
+ case MATINDEX_A:
if (update_global_state)
VertexShaderManager::SetTexMatrixChangedA(value);
break;
- case 0x40:
+ case MATINDEX_B:
if (update_global_state)
VertexShaderManager::SetTexMatrixChangedB(value);
break;
- case 0x50:
- state->vtx_desc.Hex &= ~0x1FFFF; // keep the Upper bits
- state->vtx_desc.Hex |= value;
- state->attr_dirty = BitSet32::AllTrue(8);
+ case VCD_LO:
+ state->vtx_desc.low.Hex = value;
+ state->attr_dirty = BitSet32::AllTrue(CP_NUM_VAT_REG);
state->bases_dirty = true;
break;
- case 0x60:
- state->vtx_desc.Hex &= 0x1FFFF; // keep the lower 17Bits
- state->vtx_desc.Hex |= (u64)value << 17;
- state->attr_dirty = BitSet32::AllTrue(8);
+ case VCD_HI:
+ state->vtx_desc.high.Hex = value;
+ state->attr_dirty = BitSet32::AllTrue(CP_NUM_VAT_REG);
state->bases_dirty = true;
break;
- case 0x70:
- ASSERT((sub_cmd & 0x0F) < 8);
- state->vtx_attr[sub_cmd & 7].g0.Hex = value;
- state->attr_dirty[sub_cmd & 7] = true;
+ case CP_VAT_REG_A:
+ if ((sub_cmd - CP_VAT_REG_A) >= CP_NUM_VAT_REG)
+ WARN_LOG_FMT(VIDEO, "CP_VAT_REG_A: Invalid VAT {}", sub_cmd - CP_VAT_REG_A);
+ state->vtx_attr[sub_cmd & CP_VAT_MASK].g0.Hex = value;
+ state->attr_dirty[sub_cmd & CP_VAT_MASK] = true;
break;
- case 0x80:
- ASSERT((sub_cmd & 0x0F) < 8);
- state->vtx_attr[sub_cmd & 7].g1.Hex = value;
- state->attr_dirty[sub_cmd & 7] = true;
+ case CP_VAT_REG_B:
+ if ((sub_cmd - CP_VAT_REG_B) >= CP_NUM_VAT_REG)
+ WARN_LOG_FMT(VIDEO, "CP_VAT_REG_B: Invalid VAT {}", sub_cmd - CP_VAT_REG_B);
+ state->vtx_attr[sub_cmd & CP_VAT_MASK].g1.Hex = value;
+ state->attr_dirty[sub_cmd & CP_VAT_MASK] = true;
break;
- case 0x90:
- ASSERT((sub_cmd & 0x0F) < 8);
- state->vtx_attr[sub_cmd & 7].g2.Hex = value;
- state->attr_dirty[sub_cmd & 7] = true;
+ case CP_VAT_REG_C:
+ if ((sub_cmd - CP_VAT_REG_C) >= CP_NUM_VAT_REG)
+ WARN_LOG_FMT(VIDEO, "CP_VAT_REG_C: Invalid VAT {}", sub_cmd - CP_VAT_REG_C);
+ state->vtx_attr[sub_cmd & CP_VAT_MASK].g2.Hex = value;
+ state->attr_dirty[sub_cmd & CP_VAT_MASK] = true;
break;
// Pointers to vertex arrays in GC RAM
- case 0xA0:
- state->array_bases[sub_cmd & 0xF] = value & CommandProcessor::GetPhysicalAddressMask();
+ case ARRAY_BASE:
+ state->array_bases[sub_cmd & CP_ARRAY_MASK] =
+ value & CommandProcessor::GetPhysicalAddressMask();
state->bases_dirty = true;
break;
- case 0xB0:
- state->array_strides[sub_cmd & 0xF] = value & 0xFF;
+ case ARRAY_STRIDE:
+ state->array_strides[sub_cmd & CP_ARRAY_MASK] = value & 0xFF;
break;
+
+ default:
+ WARN_LOG_FMT(VIDEO, "Unknown CP register {:02x} set to {:08x}", sub_cmd, value);
}
}
void FillCPMemoryArray(u32* memory)
{
- memory[0x30] = g_main_cp_state.matrix_index_a.Hex;
- memory[0x40] = g_main_cp_state.matrix_index_b.Hex;
- memory[0x50] = (u32)g_main_cp_state.vtx_desc.Hex;
- memory[0x60] = (u32)(g_main_cp_state.vtx_desc.Hex >> 17);
+ 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] = g_main_cp_state.vtx_desc.low.Hex;
+ memory[VCD_HI] = g_main_cp_state.vtx_desc.high.Hex;
- for (int i = 0; i < 8; ++i)
+ for (int i = 0; i < CP_NUM_VAT_REG; ++i)
{
- memory[0x70 + i] = g_main_cp_state.vtx_attr[i].g0.Hex;
- memory[0x80 + i] = g_main_cp_state.vtx_attr[i].g1.Hex;
- memory[0x90 + i] = g_main_cp_state.vtx_attr[i].g2.Hex;
+ memory[CP_VAT_REG_A + i] = g_main_cp_state.vtx_attr[i].g0.Hex;
+ memory[CP_VAT_REG_B + i] = g_main_cp_state.vtx_attr[i].g1.Hex;
+ memory[CP_VAT_REG_C + i] = g_main_cp_state.vtx_attr[i].g2.Hex;
}
- for (int i = 0; i < 16; ++i)
+ for (int i = 0; i < CP_NUM_ARRAYS; ++i)
{
- memory[0xA0 + i] = g_main_cp_state.array_bases[i];
- memory[0xB0 + i] = g_main_cp_state.array_strides[i];
+ memory[ARRAY_BASE + i] = g_main_cp_state.array_bases[i];
+ memory[ARRAY_STRIDE + i] = g_main_cp_state.array_strides[i];
}
}