diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2023-01-26 23:15:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-26 23:15:23 +0100 |
| commit | 9c9310bf44f0a7b0ad1de2e643f32ec00a553e0e (patch) | |
| tree | 613159524f59f9cabe66791dfa42856026e33ad8 /Source/Core/VideoCommon/VertexLoaderManager.cpp | |
| parent | 09a8d9591db06ebdbe5abdd3166c76982856fc55 (diff) | |
| parent | 7413be148705866efebd504ef7356377dce81274 (diff) | |
Merge pull request #11208 from TellowKrinkle/CPUCull
Cull vertices on the CPU
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderManager.cpp | 29 |
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); |
