diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 267c099253..967ba19061 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -23,6 +23,7 @@ #include "GPU/Common/DrawEngineCommon.h" #include "GPU/Common/SplineCommon.h" #include "GPU/Common/VertexDecoderCommon.h" +#include "GPU/Common/TextureDecoder.h" // for ReliableHash #include "GPU/ge_constants.h" #include "GPU/GPUState.h" diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 616633d489..26bdbee733 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -67,6 +67,9 @@ protected: // Preprocessing for spline/bezier u32 NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, int lowerBound, int upperBound, u32 vertType); + // Utility for vertex caching + u32 ComputeMiniHash(); + // Vertex decoding void DecodeVertsStep(u8 *dest, int &i, int &decodedVerts); diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 55becaa89a..7cd890b270 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -357,50 +357,6 @@ void DrawEngineD3D11::DecodeVerts() { } } -inline u32 ComputeMiniHashRange(const void *ptr, size_t sz) { - // Switch to u32 units. - const u32 *p = (const u32 *)ptr; - sz >>= 2; - - if (sz > 100) { - size_t step = sz / 4; - u32 hash = 0; - for (size_t i = 0; i < sz; i += step) { - hash += DoReliableHash32(p + i, 100, 0x3A44B9C4); - } - return hash; - } else { - return p[0] + p[sz - 1]; - } -} - -u32 DrawEngineD3D11::ComputeMiniHash() { - u32 fullhash = 0; - const int vertexSize = dec_->GetDecVtxFmt().stride; - const int indexSize = IndexSize(dec_->VertexType()); - - int step; - if (numDrawCalls < 3) { - step = 1; - } else if (numDrawCalls < 8) { - step = 4; - } else { - step = numDrawCalls / 8; - } - for (int i = 0; i < numDrawCalls; i += step) { - const DeferredDrawCall &dc = drawCalls[i]; - if (!dc.inds) { - fullhash += ComputeMiniHashRange(dc.verts, vertexSize * dc.vertexCount); - } else { - int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound; - fullhash += ComputeMiniHashRange((const u8 *)dc.verts + vertexSize * indexLowerBound, vertexSize * (indexUpperBound - indexLowerBound)); - fullhash += ComputeMiniHashRange(dc.inds, indexSize * dc.vertexCount); - } - } - - return fullhash; -} - void DrawEngineD3D11::MarkUnreliable(VertexArrayInfoD3D11 *vai) { vai->status = VertexArrayInfoD3D11::VAI_UNRELIABLE; if (vai->vbo) { diff --git a/GPU/D3D11/DrawEngineD3D11.h b/GPU/D3D11/DrawEngineD3D11.h index 86e0cb6c65..f76bf1e17e 100644 --- a/GPU/D3D11/DrawEngineD3D11.h +++ b/GPU/D3D11/DrawEngineD3D11.h @@ -168,7 +168,6 @@ private: ID3D11InputLayout *SetupDecFmtForDraw(D3D11VertexShader *vshader, const DecVtxFormat &decFmt, u32 pspFmt); - u32 ComputeMiniHash(); ReliableHashType ComputeHash(); // Reads deferred vertex data. void MarkUnreliable(VertexArrayInfoD3D11 *vai); diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 0177066cb8..4d80f7416f 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -32,7 +32,6 @@ #include "GPU/GPUState.h" #include "GPU/ge_constants.h" -#include "GPU/Common/TextureDecoder.h" #include "GPU/Common/SplineCommon.h" #include "GPU/Common/TransformCommon.h" #include "GPU/Common/VertexDecoderCommon.h" @@ -337,50 +336,6 @@ void DrawEngineDX9::DecodeVerts() { } } -inline u32 ComputeMiniHashRange(const void *ptr, size_t sz) { - // Switch to u32 units. - const u32 *p = (const u32 *)ptr; - sz >>= 2; - - if (sz > 100) { - size_t step = sz / 4; - u32 hash = 0; - for (size_t i = 0; i < sz; i += step) { - hash += DoReliableHash32(p + i, 100, 0x3A44B9C4); - } - return hash; - } else { - return p[0] + p[sz - 1]; - } -} - -u32 DrawEngineDX9::ComputeMiniHash() { - u32 fullhash = 0; - const int vertexSize = dec_->GetDecVtxFmt().stride; - const int indexSize = IndexSize(dec_->VertexType()); - - int step; - if (numDrawCalls < 3) { - step = 1; - } else if (numDrawCalls < 8) { - step = 4; - } else { - step = numDrawCalls / 8; - } - for (int i = 0; i < numDrawCalls; i += step) { - const DeferredDrawCall &dc = drawCalls[i]; - if (!dc.inds) { - fullhash += ComputeMiniHashRange(dc.verts, vertexSize * dc.vertexCount); - } else { - int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound; - fullhash += ComputeMiniHashRange((const u8 *)dc.verts + vertexSize * indexLowerBound, vertexSize * (indexUpperBound - indexLowerBound)); - fullhash += ComputeMiniHashRange(dc.inds, indexSize * dc.vertexCount); - } - } - - return fullhash; -} - void DrawEngineDX9::MarkUnreliable(VertexArrayInfoDX9 *vai) { vai->status = VertexArrayInfoDX9::VAI_UNRELIABLE; if (vai->vbo) { diff --git a/GPU/Directx9/DrawEngineDX9.h b/GPU/Directx9/DrawEngineDX9.h index f3895b5e29..fa15b2869f 100644 --- a/GPU/Directx9/DrawEngineDX9.h +++ b/GPU/Directx9/DrawEngineDX9.h @@ -162,7 +162,6 @@ private: IDirect3DVertexDeclaration9 *SetupDecFmtForDraw(VSShader *vshader, const DecVtxFormat &decFmt, u32 pspFmt); - u32 ComputeMiniHash(); ReliableHashType ComputeHash(); // Reads deferred vertex data. void MarkUnreliable(VertexArrayInfoDX9 *vai); diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index bbf209cfb5..db09ea8b89 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -351,50 +351,6 @@ void DrawEngineGLES::DecodeVerts() { } } -inline u32 ComputeMiniHashRange(const void *ptr, size_t sz) { - // Switch to u32 units. - const u32 *p = (const u32 *)ptr; - sz >>= 2; - - if (sz > 100) { - size_t step = sz / 4; - u32 hash = 0; - for (size_t i = 0; i < sz; i += step) { - hash += DoReliableHash32(p + i, 100, 0x3A44B9C4); - } - return hash; - } else { - return p[0] + p[sz - 1]; - } -} - -u32 DrawEngineGLES::ComputeMiniHash() { - u32 fullhash = 0; - const int vertexSize = dec_->GetDecVtxFmt().stride; - const int indexSize = IndexSize(dec_->VertexType()); - - int step; - if (numDrawCalls < 3) { - step = 1; - } else if (numDrawCalls < 8) { - step = 4; - } else { - step = numDrawCalls / 8; - } - for (int i = 0; i < numDrawCalls; i += step) { - const DeferredDrawCall &dc = drawCalls[i]; - if (!dc.inds) { - fullhash += ComputeMiniHashRange(dc.verts, vertexSize * dc.vertexCount); - } else { - int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound; - fullhash += ComputeMiniHashRange((const u8 *)dc.verts + vertexSize * indexLowerBound, vertexSize * (indexUpperBound - indexLowerBound)); - fullhash += ComputeMiniHashRange(dc.inds, indexSize * dc.vertexCount); - } - } - - return fullhash; -} - void DrawEngineGLES::MarkUnreliable(VertexArrayInfo *vai) { vai->status = VertexArrayInfo::VAI_UNRELIABLE; if (vai->vbo) { diff --git a/GPU/GLES/DrawEngineGLES.h b/GPU/GLES/DrawEngineGLES.h index e8b2906185..5e68b1b325 100644 --- a/GPU/GLES/DrawEngineGLES.h +++ b/GPU/GLES/DrawEngineGLES.h @@ -174,7 +174,6 @@ private: void FreeBuffer(GLuint buf); void FreeVertexArray(VertexArrayInfo *vai); - u32 ComputeMiniHash(); ReliableHashType ComputeHash(); // Reads deferred vertex data. void MarkUnreliable(VertexArrayInfo *vai); diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 27615414e1..4b51ba8897 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -443,23 +443,6 @@ void DrawEngineVulkan::DecodeVerts(VulkanPushBuffer *push, uint32_t *bindOffset, } } -inline u32 ComputeMiniHashRange(const void *ptr, size_t sz) { - // Switch to u32 units. - const u32 *p = (const u32 *)ptr; - sz >>= 2; - - if (sz > 100) { - size_t step = sz / 4; - u32 hash = 0; - for (size_t i = 0; i < sz; i += step) { - hash += DoReliableHash32(p + i, 100, 0x3A44B9C4); - } - return hash; - } else { - return p[0] + p[sz - 1]; - } -} - VkDescriptorSet DrawEngineVulkan::GetDescriptorSet(VkImageView imageView, VkSampler sampler, VkBuffer base, VkBuffer light, VkBuffer bone) { DescriptorSetKey key; key.imageView_ = imageView;