diff options
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderManager.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index dd1196a48e..d5e74a0e11 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -12,11 +12,13 @@ #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexLoader.h" #include "VideoCommon/VertexLoaderManager.h" +#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexShaderManager.h" #include "VideoCommon/VideoCommon.h" static int s_attr_dirty; // bitfield +static NativeVertexFormat* s_current_vtx_fmt; static VertexLoader *g_VertexLoaders[8]; namespace std @@ -104,8 +106,7 @@ static VertexLoader* RefreshLoader(int vtx_attr_group) { if ((s_attr_dirty >> vtx_attr_group) & 1) { - VertexLoaderUID uid; - uid.InitFromCurrentState(vtx_attr_group); + VertexLoaderUID uid(g_VtxDesc, g_VtxAttr[vtx_attr_group]); VertexLoaderMap::iterator iter = g_VertexLoaderMap.find(uid); if (iter != g_VertexLoaderMap.end()) { @@ -123,11 +124,35 @@ static VertexLoader* RefreshLoader(int vtx_attr_group) return g_VertexLoaders[vtx_attr_group]; } +static NativeVertexFormat* GetNativeVertexFormat(const PortableVertexDeclaration& format, + u32 components) +{ + auto& native = s_native_vertex_map[format]; + if (!native) + { + auto raw_pointer = g_vertex_manager->CreateNativeVertexFormat(); + native = std::unique_ptr<NativeVertexFormat>(raw_pointer); + native->Initialize(format); + native->m_components = components; + } + return native.get(); +} + void RunVertices(int vtx_attr_group, int primitive, int count) { if (!count) return; - RefreshLoader(vtx_attr_group)->RunVertices(vtx_attr_group, primitive, count); + VertexLoader* loader = RefreshLoader(vtx_attr_group); + + // If the native vertex format changed, force a flush. + NativeVertexFormat* required_vtx_fmt = GetNativeVertexFormat( + loader->GetNativeVertexDeclaration(), + loader->GetNativeComponents()); + if (required_vtx_fmt != s_current_vtx_fmt) + VertexManager::Flush(); + s_current_vtx_fmt = required_vtx_fmt; + + RefreshLoader(vtx_attr_group)->RunVertices(g_VtxAttr[vtx_attr_group], primitive, count); } int GetVertexSize(int vtx_attr_group) @@ -135,17 +160,9 @@ int GetVertexSize(int vtx_attr_group) return RefreshLoader(vtx_attr_group)->GetVertexSize(); } -NativeVertexFormat* GetNativeVertexFormat(const PortableVertexDeclaration& format, u32 components) +NativeVertexFormat* GetCurrentVertexFormat() { - auto& native = s_native_vertex_map[format]; - if (!native) - { - auto raw_pointer = g_vertex_manager->CreateNativeVertexFormat(); - native = std::unique_ptr<NativeVertexFormat>(raw_pointer); - native->m_components = components; - native->Initialize(format); - } - return native.get(); + return s_current_vtx_fmt; } } // namespace |
