summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoaderManager.cpp
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2015-01-02 21:05:36 +0100
committerdegasus <wickmarkus@web.de>2015-01-03 21:50:51 +0100
commit110d4940705b7e53bad9e098ce693c06958a884d (patch)
treee1ecc94fc871398de9a0e91d9e4488b4b8293735 /Source/Core/VideoCommon/VertexLoaderManager.cpp
parentacebd7fe4cb4f99d4e5ea880f27506fae85f95fd (diff)
VideoCommon: fix deterministic dual core
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index 0ab87b323d..b95e286c1e 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -93,23 +93,32 @@ void MarkAllDirty()
g_preprocess_cp_state.attr_dirty = BitSet32::AllTrue(8);
}
-static VertexLoaderBase* RefreshLoader(int vtx_attr_group, CPState* state)
+static VertexLoaderBase* RefreshLoader(int vtx_attr_group, bool preprocess = false)
{
+ CPState* state = preprocess ? &g_preprocess_cp_state : &g_main_cp_state;
+
VertexLoaderBase* loader;
if (state->attr_dirty[vtx_attr_group])
{
+ // We are not allowed to create a native vertex format on preprocessing as this is on the wrong thread
+ bool check_for_native_format = !preprocess;
+
VertexLoaderUID uid(state->vtx_desc, state->vtx_attr[vtx_attr_group]);
std::lock_guard<std::mutex> lk(s_vertex_loader_map_lock);
VertexLoaderMap::iterator iter = s_vertex_loader_map.find(uid);
if (iter != s_vertex_loader_map.end())
{
loader = iter->second.get();
+ check_for_native_format &= !loader->m_native_vertex_format;
}
else
{
loader = VertexLoaderBase::CreateVertexLoader(state->vtx_desc, state->vtx_attr[vtx_attr_group]);
s_vertex_loader_map[uid] = std::unique_ptr<VertexLoaderBase>(loader);
-
+ INCSTAT(stats.numVertexLoaders);
+ }
+ if (check_for_native_format)
+ {
// search for a cached native vertex format
const PortableVertexDeclaration& format = loader->m_native_vtx_decl;
auto& native = s_native_vertex_map[format];
@@ -121,8 +130,6 @@ static VertexLoaderBase* RefreshLoader(int vtx_attr_group, CPState* state)
native->m_components = loader->m_native_components;
}
loader->m_native_vertex_format = native.get();
-
- INCSTAT(stats.numVertexLoaders);
}
state->vertex_loaders[vtx_attr_group] = loader;
state->attr_dirty[vtx_attr_group] = false;
@@ -137,9 +144,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
if (!count)
return 0;
- CPState* state = &g_main_cp_state;
-
- VertexLoaderBase* loader = RefreshLoader(vtx_attr_group, state);
+ VertexLoaderBase* loader = RefreshLoader(vtx_attr_group);
int size = count * loader->m_VertexSize;
if ((int)src.size() < size)
@@ -172,7 +177,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
int GetVertexSize(int vtx_attr_group, bool preprocess)
{
- return RefreshLoader(vtx_attr_group, preprocess ? &g_preprocess_cp_state : &g_main_cp_state)->m_VertexSize;
+ return RefreshLoader(vtx_attr_group, preprocess)->m_VertexSize;
}
NativeVertexFormat* GetCurrentVertexFormat()