summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoaderManager.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2014-07-26 01:10:44 +0200
committerPierre Bourdon <delroth@gmail.com>2014-07-26 01:35:09 +0200
commit73f9a22e2ef8af906a116ad67f1054cc964ae3f0 (patch)
tree1dbe03370573168a47d0449df248408f47c747ed /Source/Core/VideoCommon/VertexLoaderManager.cpp
parent78c3a220600b6cbbd063693d89d423a985125408 (diff)
VertexLoader: Remove global state dependency on g_nativeVertexFmt
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index 16bb4689ac..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
@@ -122,10 +124,34 @@ 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;
+ 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);
}
@@ -134,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