From fc39f042ae2bc7704c8fa59853e82d3407d0c6fb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 22 Sep 2022 00:08:38 -0700 Subject: [PATCH] softgpu: Avoid unnecessary flushing for curves. We don't need to flush all drawing between curves in softgpu, let them queue up. --- GPU/Common/DrawEngineCommon.h | 2 ++ GPU/Common/SplineCommon.cpp | 3 ++- GPU/GPUCommon.cpp | 6 ++++-- GPU/Software/TransformUnit.cpp | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 40c397649b16..8fc0382a29ca 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -147,6 +147,8 @@ class DrawEngineCommon { bool useHWTransform_ = false; bool useHWTessellation_ = false; + // Used to prevent unnecessary flushing in softgpu. + bool flushOnParams_ = true; // Vertex collector buffers u8 *decoded = nullptr; diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index d3f864a4d461..b2358f401b30 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -577,7 +577,8 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic if (output.count) DispatchSubmitPrim(output.vertices, output.indices, PatchPrimToPrim(surface.primType), output.count, vertTypeID, gstate.getCullMode(), &generatedBytesRead); - DispatchFlush(); + if (flushOnParams_) + DispatchFlush(); if (origVertType & GE_VTYPE_TC_MASK) { gstate_c.uv = prevUVScale; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 3d64bdb1ab00..a5fd84e6968f 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1942,7 +1942,8 @@ void GPUCommon::Execute_Bezier(u32 op, u32 diff) { } // Can't flush after setting gstate_c.submitType below since it'll be a mess - it must be done already. - drawEngineCommon_->DispatchFlush(); + if (flushOnParams_) + drawEngineCommon_->DispatchFlush(); Spline::BezierSurface surface; surface.tess_u = gstate.getPatchDivisionU(); @@ -2014,7 +2015,8 @@ void GPUCommon::Execute_Spline(u32 op, u32 diff) { } // Can't flush after setting gstate_c.submitType below since it'll be a mess - it must be done already. - drawEngineCommon_->DispatchFlush(); + if (flushOnParams_) + drawEngineCommon_->DispatchFlush(); Spline::SplineSurface surface; surface.tess_u = gstate.getPatchDivisionU(); diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index c1471f71727f..660e7a82e16e 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -54,6 +54,7 @@ SoftwareDrawEngine::SoftwareDrawEngine() { // All this is a LOT of memory, need to see if we can cut down somehow. Used for splines. decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); + flushOnParams_ = false; } SoftwareDrawEngine::~SoftwareDrawEngine() {