From 186b0f105cbd91193725a0f82d9077aa4ea10c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 5 Jun 2023 09:40:08 +0200 Subject: [PATCH] Simplify the vertex cache ID handling --- GPU/Common/DrawEngineCommon.cpp | 9 --------- GPU/Common/DrawEngineCommon.h | 1 - GPU/D3D11/DrawEngineD3D11.cpp | 8 ++++---- GPU/Directx9/DrawEngineDX9.cpp | 8 ++++---- GPU/GLES/DrawEngineGLES.cpp | 2 -- GPU/Vulkan/DrawEngineVulkan.cpp | 9 +++++---- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 234d2af223..554dd72bb3 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -821,15 +821,6 @@ void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti if ((vertexCount < 2 && prim > 0) || (vertexCount < 3 && prim > GE_PRIM_LINE_STRIP && prim != GE_PRIM_RECTANGLES)) return; - if (g_Config.bVertexCache) { - u32 dhash = dcid_; - dhash = __rotl(dhash ^ (u32)(uintptr_t)verts, 13); - dhash = __rotl(dhash ^ (u32)(uintptr_t)inds, 19); - dhash = __rotl(dhash ^ (u32)vertTypeID, 7); - dhash = __rotl(dhash ^ (u32)vertexCount, 11); - dcid_ = lowbias32_r(dhash ^ (u32)prim); - } - DeferredDrawCall &dc = drawCalls_[numDrawCalls_]; dc.verts = verts; dc.inds = inds; diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index c9b51ff020..0798c454b5 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -218,7 +218,6 @@ protected: int decimationCounter_ = 0; int decodeCounter_ = 0; - u32 dcid_ = 0; // Vertex collector state IndexGenerator indexGen; diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index aab67928bd..119607d76d 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -363,12 +363,13 @@ void DrawEngineD3D11::DoFlush() { useCache = false; if (useCache) { - u32 id = dcid_ ^ gstate.getUVGenMode(); // This can have an effect on which UV decoder we need to use! And hence what the decoded data will look like. See #9263 + // getUVGenMode can have an effect on which UV decoder we need to use! And hence what the decoded data will look like. See #9263 + u32 dcid = (u32)XXH3_64bits(&drawCalls_, sizeof(DeferredDrawCall) * numDrawCalls_) ^ gstate.getUVGenMode(); - VertexArrayInfoD3D11 *vai = vai_.Get(id); + VertexArrayInfoD3D11 *vai = vai_.Get(dcid); if (!vai) { vai = new VertexArrayInfoD3D11(); - vai_.Insert(id, vai); + vai_.Insert(dcid, vai); } switch (vai->status) { @@ -724,7 +725,6 @@ rotateVBO: numDrawCalls_ = 0; vertexCountInDrawCalls_ = 0; decodeCounter_ = 0; - dcid_ = 0; gstate_c.vertexFullAlpha = true; framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index b098898d21..95767740a4 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -345,11 +345,12 @@ void DrawEngineDX9::DoFlush() { useCache = false; if (useCache) { - u32 id = dcid_ ^ gstate.getUVGenMode(); // This can have an effect on which UV decoder we need to use! And hence what the decoded data will look like. See #9263 - VertexArrayInfoDX9 *vai = vai_.Get(id); + // getUVGenMode can have an effect on which UV decoder we need to use! And hence what the decoded data will look like. See #9263 + u32 dcid = (u32)XXH3_64bits(&drawCalls_, sizeof(DeferredDrawCall) * numDrawCalls_) ^ gstate.getUVGenMode(); + VertexArrayInfoDX9 *vai = vai_.Get(dcid); if (!vai) { vai = new VertexArrayInfoDX9(); - vai_.Insert(id, vai); + vai_.Insert(dcid, vai); } switch (vai->status) { @@ -666,7 +667,6 @@ rotateVBO: numDrawCalls_ = 0; vertexCountInDrawCalls_ = 0; decodeCounter_ = 0; - dcid_ = 0; gstate_c.vertexFullAlpha = true; framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 1f55ad16d3..e77728eb08 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -248,7 +248,6 @@ void DrawEngineGLES::DoFlush() { numDrawCalls_ = 0; vertexCountInDrawCalls_ = 0; decodeCounter_ = 0; - dcid_ = 0; return; } @@ -483,7 +482,6 @@ bail: numDrawCalls_ = 0; vertexCountInDrawCalls_ = 0; decodeCounter_ = 0; - dcid_ = 0; gstate_c.vertexFullAlpha = true; framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 62bf89de8d..8676ba9e87 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -597,12 +597,14 @@ void DrawEngineVulkan::DoFlush() { } if (useCache) { + // getUVGenMode can have an effect on which UV decoder we need to use! And hence what the decoded data will look like. See #9263 + u32 dcid = (u32)XXH3_64bits(&drawCalls_, sizeof(DeferredDrawCall) * numDrawCalls_) ^ gstate.getUVGenMode(); + PROFILE_THIS_SCOPE("vcache"); - u32 id = dcid_ ^ gstate.getUVGenMode(); // This can have an effect on which UV decoder we need to use! And hence what the decoded data will look like. See #9263 - VertexArrayInfoVulkan *vai = vai_.Get(id); + VertexArrayInfoVulkan *vai = vai_.Get(dcid); if (!vai) { vai = new VertexArrayInfoVulkan(); - vai_.Insert(id, vai); + vai_.Insert(dcid, vai); } switch (vai->status) { @@ -1011,7 +1013,6 @@ void DrawEngineVulkan::DoFlush() { numDrawCalls_ = 0; vertexCountInDrawCalls_ = 0; decodeCounter_ = 0; - dcid_ = 0; gstate_c.vertexFullAlpha = true; framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);