summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexManagerBase.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2023-01-26 23:15:23 +0100
committerGitHub <noreply@github.com>2023-01-26 23:15:23 +0100
commit9c9310bf44f0a7b0ad1de2e643f32ec00a553e0e (patch)
tree613159524f59f9cabe66791dfa42856026e33ad8 /Source/Core/VideoCommon/VertexManagerBase.cpp
parent09a8d9591db06ebdbe5abdd3166c76982856fc55 (diff)
parent7413be148705866efebd504ef7356377dce81274 (diff)
Merge pull request #11208 from TellowKrinkle/CPUCull
Cull vertices on the CPU
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 85e2b48556..1ccfebad0c 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -104,6 +104,7 @@ VertexManagerBase::~VertexManagerBase() = default;
bool VertexManagerBase::Initialize()
{
m_index_generator.Init();
+ m_cpu_cull.Init();
return true;
}
@@ -117,6 +118,13 @@ void VertexManagerBase::AddIndices(OpcodeDecoder::Primitive primitive, u32 num_v
m_index_generator.AddIndices(primitive, num_vertices);
}
+bool VertexManagerBase::AreAllVerticesCulled(VertexLoaderBase* loader,
+ OpcodeDecoder::Primitive primitive, const u8* src,
+ u32 count)
+{
+ return m_cpu_cull.AreAllVerticesCulled(loader, primitive, src, count);
+}
+
DataReader VertexManagerBase::PrepareForAdditionalData(OpcodeDecoder::Primitive primitive,
u32 count, u32 stride, bool cullall)
{
@@ -187,6 +195,16 @@ DataReader VertexManagerBase::PrepareForAdditionalData(OpcodeDecoder::Primitive
return DataReader(m_cur_buffer_pointer, m_end_buffer_pointer);
}
+DataReader VertexManagerBase::DisableCullAll(u32 stride)
+{
+ if (m_cull_all)
+ {
+ m_cull_all = false;
+ ResetBuffer(stride);
+ }
+ return DataReader(m_cur_buffer_pointer, m_end_buffer_pointer);
+}
+
void VertexManagerBase::FlushData(u32 count, u32 stride)
{
m_cur_buffer_pointer += count * stride;
@@ -548,6 +566,8 @@ void VertexManagerBase::Flush()
// Now the vertices can be flushed to the GPU. Everything following the CommitBuffer() call
// must be careful to not upload any utility vertices, as the binding will be lost otherwise.
const u32 num_indices = m_index_generator.GetIndexLen();
+ if (num_indices == 0)
+ return;
u32 base_vertex, base_index;
CommitBuffer(m_index_generator.GetNumVerts(),
VertexLoaderManager::GetCurrentVertexFormat()->GetVertexStride(), num_indices,