VideoCommon: Move VertexLoaderManager logic out of CPState

This commit is contained in:
Pokechu22
2021-05-13 16:05:31 -07:00
parent e4605fa399
commit d039b1bc0d
7 changed files with 54 additions and 31 deletions

View File

@ -58,9 +58,9 @@ std::array<VertexLoaderBase*, CP_NUM_VAT_REG> g_preprocess_vertex_loaders;
void Init()
{
MarkAllDirty();
for (auto& map_entry : g_main_cp_state.vertex_loaders)
for (auto& map_entry : g_main_vertex_loaders)
map_entry = nullptr;
for (auto& map_entry : g_preprocess_cp_state.vertex_loaders)
for (auto& map_entry : g_preprocess_vertex_loaders)
map_entry = nullptr;
SETSTAT(g_stats.num_vertex_loaders, 0);
}
@ -75,7 +75,7 @@ void Clear()
void UpdateVertexArrayPointers()
{
// Anything to update?
if (!g_main_cp_state.bases_dirty)
if (!g_bases_dirty)
return;
// Some games such as Burnout 2 can put invalid addresses into
@ -106,7 +106,7 @@ void UpdateVertexArrayPointers()
Memory::GetPointer(g_main_cp_state.array_bases[CPArray::TexCoord0 + i]);
}
g_main_cp_state.bases_dirty = false;
g_bases_dirty = false;
}
namespace
@ -121,8 +121,8 @@ struct entry
void MarkAllDirty()
{
g_main_cp_state.attr_dirty = BitSet32::AllTrue(8);
g_preprocess_cp_state.attr_dirty = BitSet32::AllTrue(8);
g_main_vat_dirty = BitSet8::AllTrue(8);
g_preprocess_vat_dirty = BitSet8::AllTrue(8);
}
NativeVertexFormat* GetOrCreateMatchingFormat(const PortableVertexDeclaration& decl)
@ -197,10 +197,12 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl)
static VertexLoaderBase* RefreshLoader(int vtx_attr_group, bool preprocess = false)
{
CPState* state = preprocess ? &g_preprocess_cp_state : &g_main_cp_state;
state->last_id = vtx_attr_group;
BitSet8& attr_dirty = preprocess ? g_preprocess_vat_dirty : g_main_vat_dirty;
auto& vertex_loaders = preprocess ? g_main_vertex_loaders : g_preprocess_vertex_loaders;
g_current_vat = vtx_attr_group;
VertexLoaderBase* loader;
if (state->attr_dirty[vtx_attr_group])
if (attr_dirty[vtx_attr_group])
{
// We are not allowed to create a native vertex format on preprocessing as this is on the wrong
// thread
@ -230,12 +232,12 @@ static VertexLoaderBase* RefreshLoader(int vtx_attr_group, bool preprocess = fal
native = g_renderer->CreateNativeVertexFormat(format);
loader->m_native_vertex_format = native.get();
}
state->vertex_loaders[vtx_attr_group] = loader;
state->attr_dirty[vtx_attr_group] = false;
vertex_loaders[vtx_attr_group] = loader;
attr_dirty[vtx_attr_group] = false;
}
else
{
loader = state->vertex_loaders[vtx_attr_group];
loader = vertex_loaders[vtx_attr_group];
}
// Lookup pointers for any vertex arrays.