summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoaderManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index 4d0597ba88..9bee673db4 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -30,6 +30,7 @@
#include "VideoCommon/VertexLoaderBase.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VertexShaderManager.h"
+#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/XFMemory.h"
namespace VertexLoaderManager
@@ -366,17 +367,33 @@ int RunVertices(int vtx_attr_group, OpcodeDecoder::Primitive primitive, int coun
vertex_shader_manager.SetVertexFormat(loader->m_native_components,
loader->m_native_vertex_format->GetVertexDeclaration());
+ // CPUCull's performance increase comes from encoding fewer GPU commands, not sending less data
+ // Therefore it's only useful to check if culling could remove a flush
+ const bool can_cpu_cull = g_ActiveConfig.bCPUCull &&
+ primitive < OpcodeDecoder::Primitive::GX_DRAW_LINES &&
+ !g_vertex_manager->HasSendableVertices();
+
// 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 == CullMode::All &&
- primitive < OpcodeDecoder::Primitive::GX_DRAW_LINES);
+ // They still need to go through vertex loading, because we need to calculate a zfreeze
+ // reference slope.
+ const bool cullall = (bpmem.genMode.cullmode == CullMode::All &&
+ primitive < OpcodeDecoder::Primitive::GX_DRAW_LINES);
- DataReader dst = g_vertex_manager->PrepareForAdditionalData(
- primitive, count, loader->m_native_vtx_decl.stride, cullall);
+ const int stride = loader->m_native_vtx_decl.stride;
+ DataReader dst = g_vertex_manager->PrepareForAdditionalData(primitive, count, stride,
+ cullall || can_cpu_cull);
count = loader->RunVertices(src, dst.GetPointer(), count);
+ if (can_cpu_cull && !cullall)
+ {
+ if (!g_vertex_manager->AreAllVerticesCulled(loader, primitive, dst.GetPointer(), count))
+ {
+ DataReader new_dst = g_vertex_manager->DisableCullAll(stride);
+ memmove(new_dst.GetPointer(), dst.GetPointer(), count * stride);
+ }
+ }
+
g_vertex_manager->AddIndices(primitive, count);
g_vertex_manager->FlushData(count, loader->m_native_vtx_decl.stride);