From 10ccbfd68c3dc8ca5c874708868eb069f77928e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Oct 2023 12:24:59 +0200 Subject: [PATCH] Unify the clearing of variables after a draw call --- GPU/Common/DrawEngineCommon.h | 22 ++++++++++++++++++++++ GPU/D3D11/DrawEngineD3D11.cpp | 21 +-------------------- GPU/Directx9/DrawEngineDX9.cpp | 23 +---------------------- GPU/GLES/DrawEngineGLES.cpp | 24 +----------------------- GPU/Vulkan/DrawEngineVulkan.cpp | 19 +------------------ 5 files changed, 26 insertions(+), 83 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 3e9228bbfd..c2c781c6b3 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -195,6 +195,28 @@ protected: } } + inline void ResetAfterDrawInline() { + gpuStats.numFlushes++; + gpuStats.numDrawCalls += numDrawInds_; + gpuStats.numVertexDecodes += numDrawVerts_; + gpuStats.numVertsSubmitted += vertexCountInDrawCalls_; + + indexGen.Reset(); + decodedVerts_ = 0; + numDrawVerts_ = 0; + numDrawInds_ = 0; + vertexCountInDrawCalls_ = 0; + decodeIndsCounter_ = 0; + decodeVertsCounter_ = 0; + gstate_c.vertexFullAlpha = true; + + // Now seems as good a time as any to reset the min/max coords, which we may examine later. + gstate_c.vertBounds.minU = 512; + gstate_c.vertBounds.minV = 512; + gstate_c.vertBounds.maxU = 0; + gstate_c.vertBounds.maxV = 0; + } + uint32_t ComputeDrawcallsHash() const; bool useHWTransform_ = false; diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 1172e0ce29..f04385bb6f 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -725,27 +725,8 @@ rotateVBO: decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } - gpuStats.numFlushes++; - gpuStats.numDrawCalls += numDrawInds_; - gpuStats.numVertexDecodes += numDrawVerts_; - gpuStats.numVertsSubmitted += vertexCountInDrawCalls_; - - indexGen.Reset(); - decodedVerts_ = 0; - numDrawVerts_ = 0; - numDrawInds_ = 0; - vertexCountInDrawCalls_ = 0; - decodeVertsCounter_ = 0; - decodeIndsCounter_ = 0; - gstate_c.vertexFullAlpha = true; + ResetAfterDrawInline(); framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); - - // Now seems as good a time as any to reset the min/max coords, which we may examine later. - gstate_c.vertBounds.minU = 512; - gstate_c.vertBounds.minV = 512; - gstate_c.vertBounds.maxU = 0; - gstate_c.vertBounds.maxV = 0; - GPUDebug::NotifyDraw(); } diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 72f1988472..283ccd375e 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -666,29 +666,8 @@ rotateVBO: decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } - gpuStats.numFlushes++; - gpuStats.numDrawCalls += numDrawInds_; - gpuStats.numVertexDecodes += numDrawVerts_; - gpuStats.numVertsSubmitted += vertexCountInDrawCalls_; - - // TODO: The below should be shared. - - indexGen.Reset(); - decodedVerts_ = 0; - numDrawVerts_ = 0; - numDrawInds_ = 0; - vertexCountInDrawCalls_ = 0; - decodeVertsCounter_ = 0; - decodeIndsCounter_ = 0; - gstate_c.vertexFullAlpha = true; + ResetAfterDrawInline(); framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); - - // Now seems as good a time as any to reset the min/max coords, which we may examine later. - gstate_c.vertBounds.minU = 512; - gstate_c.vertBounds.minV = 512; - gstate_c.vertBounds.maxU = 0; - gstate_c.vertBounds.maxV = 0; - GPUDebug::NotifyDraw(); } diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index f48a9d80b3..7aefa970bc 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -473,30 +473,8 @@ void DrawEngineGLES::DoFlush() { } bail: - gpuStats.numFlushes++; - gpuStats.numDrawCalls += numDrawInds_; - gpuStats.numVertexDecodes += numDrawVerts_; - gpuStats.numVertsSubmitted += vertexCountInDrawCalls_; - - // TODO: When the next flush has the same vertex format, we can continue with the same offset in the vertex buffer, - // and start indexing from a higher value. This is very friendly to OpenGL (where we can't rely on baseindex if we - // wanted to avoid rebinding the vertex input every time). - indexGen.Reset(); - decodedVerts_ = 0; - numDrawVerts_ = 0; - numDrawInds_ = 0; - vertexCountInDrawCalls_ = 0; - decodeVertsCounter_ = 0; - decodeIndsCounter_ = 0; - gstate_c.vertexFullAlpha = true; + ResetAfterDrawInline(); framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); - - // Now seems as good a time as any to reset the min/max coords, which we may examine later. - gstate_c.vertBounds.minU = 512; - gstate_c.vertBounds.minV = 512; - gstate_c.vertBounds.maxU = 0; - gstate_c.vertBounds.maxV = 0; - GPUDebug::NotifyDraw(); } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index ed83c7f207..1f9a1f26dc 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -1014,27 +1014,10 @@ void DrawEngineVulkan::DoFlush() { decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } - gpuStats.numFlushes++; - gpuStats.numDrawCalls += numDrawInds_; - gpuStats.numVertexDecodes += numDrawVerts_; - gpuStats.numVertsSubmitted += vertexCountInDrawCalls_; + ResetAfterDrawInline(); - indexGen.Reset(); - decodedVerts_ = 0; - numDrawVerts_ = 0; - numDrawInds_ = 0; - vertexCountInDrawCalls_ = 0; - decodeIndsCounter_ = 0; - decodeVertsCounter_ = 0; - gstate_c.vertexFullAlpha = true; framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); - // Now seems as good a time as any to reset the min/max coords, which we may examine later. - gstate_c.vertBounds.minU = 512; - gstate_c.vertBounds.minV = 512; - gstate_c.vertBounds.maxU = 0; - gstate_c.vertBounds.maxV = 0; - GPUDebug::NotifyDraw(); }