From eca9386c0583d3fa1eccd37ce0e6014758ae1150 Mon Sep 17 00:00:00 2001 From: xebra Date: Mon, 1 Oct 2018 12:54:14 +0900 Subject: [PATCH] [spline/bezier]Reduce static buffers. Get rid of the spline buffer using half of the vertex buffer. --- GPU/Common/DrawEngineCommon.cpp | 2 -- GPU/Common/DrawEngineCommon.h | 4 ---- GPU/Common/SplineCommon.cpp | 12 ++++++------ GPU/D3D11/DrawEngineD3D11.cpp | 2 -- GPU/Directx9/DrawEngineDX9.cpp | 2 -- GPU/GLES/DrawEngineGLES.cpp | 2 -- GPU/Software/TransformUnit.cpp | 2 -- GPU/Vulkan/DrawEngineVulkan.cpp | 2 -- 8 files changed, 6 insertions(+), 22 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index abe7e7cf2d..60c250533a 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -34,7 +34,6 @@ enum { }; DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) { - quadIndices_ = new u16[6 * QUAD_INDICES_MAX]; decJitCache_ = new VertexDecoderJitCache(); transformed = (TransformedVertex *)AllocateMemoryPages(TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); transformedExpanded = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); @@ -43,7 +42,6 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) { DrawEngineCommon::~DrawEngineCommon() { FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE); FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE); - delete[] quadIndices_; delete decJitCache_; decoderMap_.Iterate([&](const uint32_t vtype, VertexDecoder *decoder) { delete decoder; diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 349b9ff958..353b3dd7d0 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -34,7 +34,6 @@ enum { VERTEX_BUFFER_MAX = 65536, DECODED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 64, DECODED_INDEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 16, - SPLINE_BUFFER_SIZE = VERTEX_BUFFER_MAX * 26, // At least, this buffer needs greater than 1679616 bytes for Mist Dragon morphing in FF4CC. }; // Avoiding the full include of TextureDecoder.h. @@ -170,9 +169,6 @@ protected: int decodedVerts_ = 0; GEPrimitiveType prevPrim_ = GE_PRIM_INVALID; - // Fixed index buffer for easy quad generation from spline/bezier - u16 *quadIndices_ = nullptr; - // Shader blending state bool fboTexNeedBind_ = false; bool fboTexBound_ = false; diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index ee4b26a6b9..a1f96fed32 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -528,8 +528,8 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx); OutputBuffers output; - output.vertices = (SimpleVertex *)splineBuffer; - output.indices = quadIndices_; + output.vertices = (SimpleVertex *)(decoded + DECODED_VERTEX_BUFFER_SIZE / 2); + output.indices = decIndex; output.count = 0; SplineSurface surface; @@ -543,7 +543,7 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi surface.num_patches_v = count_v - 3; surface.primType = prim_type; surface.patchFacing = patchFacing; - surface.Init(SPLINE_BUFFER_SIZE / vertexSize); + surface.Init(DECODED_VERTEX_BUFFER_SIZE / 2 / vertexSize); if (CanUseHardwareTessellation(prim_type)) { HardwareTessellation(output, surface, origVertType, points, tessDataTransfer); @@ -618,8 +618,8 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi points[idx] = simplified_control_points + (indices ? ConvertIndex(idx) : idx); OutputBuffers output; - output.vertices = (SimpleVertex *)splineBuffer; - output.indices = quadIndices_; + output.vertices = (SimpleVertex *)(decoded + DECODED_VERTEX_BUFFER_SIZE / 2); + output.indices = decIndex; output.count = 0; BezierSurface surface; @@ -631,7 +631,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi surface.num_patches_v = (count_v - 1) / 3; surface.primType = prim_type; surface.patchFacing = patchFacing; - surface.Init(SPLINE_BUFFER_SIZE / vertexSize); + surface.Init(DECODED_VERTEX_BUFFER_SIZE / 2 / vertexSize); if (CanUseHardwareTessellation(prim_type)) { HardwareTessellation(output, surface, origVertType, points, tessDataTransfer); diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 3a37cb63d1..e7752017dc 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -89,7 +89,6 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, // All this is a LOT of memory, need to see if we can cut down somehow. 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); - splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); indexGen.Setup(decIndex); @@ -104,7 +103,6 @@ DrawEngineD3D11::~DrawEngineD3D11() { DestroyDeviceObjects(); FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); - FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE); } void DrawEngineD3D11::InitDeviceObjects() { diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 3dec358faa..0f1c0b62d3 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -95,7 +95,6 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : vai_(256), vertexDeclMap // All this is a LOT of memory, need to see if we can cut down somehow. 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); - splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); indexGen.Setup(decIndex); @@ -115,7 +114,6 @@ DrawEngineDX9::~DrawEngineDX9() { DestroyDeviceObjects(); FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); - FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE); vertexDeclMap_.Iterate([&](const uint32_t &key, IDirect3DVertexDeclaration9 *decl) { if (decl) { decl->Release(); diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 937ab0bca8..a2bb108860 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -81,7 +81,6 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : vai_(256), draw_(draw) // All this is a LOT of memory, need to see if we can cut down somehow. 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); - splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); indexGen.Setup(decIndex); @@ -95,7 +94,6 @@ DrawEngineGLES::~DrawEngineGLES() { DestroyDeviceObjects(); FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); - FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE); delete tessDataTransferGLES; } diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 45fc87ccde..e72e9a85cb 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -42,13 +42,11 @@ 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); - splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); } SoftwareDrawEngine::~SoftwareDrawEngine() { FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); - FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE); } void SoftwareDrawEngine::DispatchFlush() { diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 407580e16f..654b8a1a41 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -89,7 +89,6 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan, Draw::DrawContext *dra // All this is a LOT of memory, need to see if we can cut down somehow. 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); - splineBuffer = (u8 *)AllocateMemoryPages(SPLINE_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); indexGen.Setup(decIndex); @@ -184,7 +183,6 @@ void DrawEngineVulkan::InitDeviceObjects() { DrawEngineVulkan::~DrawEngineVulkan() { FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); - FreeMemoryPages(splineBuffer, SPLINE_BUFFER_SIZE); DestroyDeviceObjects(); }