diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 59083f5352..45353bcbc8 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -41,9 +41,13 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) { } 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); + 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); } DrawEngineCommon::~DrawEngineCommon() { + FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); + FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE); FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE); delete decJitCache_; diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index df5eeb0284..9426074cd1 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -88,9 +88,6 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, // Allocate nicely aligned memory. Maybe graphics drivers will // appreciate it. // 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); - indexGen.Setup(decIndex); InitDeviceObjects(); @@ -102,8 +99,6 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, DrawEngineD3D11::~DrawEngineD3D11() { DestroyDeviceObjects(); - FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); - FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); } void DrawEngineD3D11::InitDeviceObjects() { diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index ce59de44aa..0043250fe2 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -91,11 +91,6 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : draw_(draw), vai_(256), decOptions_.expand8BitNormalsToFloat = true; decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL; - // Allocate nicely aligned memory. Maybe graphics drivers will - // appreciate it. - // 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); indexGen.Setup(decIndex); @@ -113,8 +108,6 @@ DrawEngineDX9::~DrawEngineDX9() { } DestroyDeviceObjects(); - FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); - FreeMemoryPages(decIndex, DECODED_INDEX_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 80618e1fda..193b8ab67f 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -67,12 +67,6 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : inputLayoutMap_(16), d decOptions_.expandAllWeightsToFloat = false; decOptions_.expand8BitNormalsToFloat = false; - // Allocate nicely aligned memory. Maybe graphics drivers will - // appreciate it. - // 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); - indexGen.Setup(decIndex); InitDeviceObjects(); @@ -83,8 +77,6 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : inputLayoutMap_(16), d DrawEngineGLES::~DrawEngineGLES() { DestroyDeviceObjects(); - FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); - FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); delete tessDataTransferGLES; } diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index da8469779a..b7afe1851a 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -41,14 +41,14 @@ #define TRANSFORM_BUF_SIZE (65536 * 48) TransformUnit::TransformUnit() { - decoded_ = (u8 *)AllocateMemoryPages(TRANSFORM_BUF_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); + decoded_ = (u8 *)AllocateAlignedMemory(TRANSFORM_BUF_SIZE, 16); if (!decoded_) return; binner_ = new BinManager(); } TransformUnit::~TransformUnit() { - FreeMemoryPages(decoded_, TRANSFORM_BUF_SIZE); + FreeAlignedMemory(decoded_); delete binner_; } @@ -57,16 +57,10 @@ bool TransformUnit::IsStarted() { } 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() { - FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); - FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); -} +SoftwareDrawEngine::~SoftwareDrawEngine() {} void SoftwareDrawEngine::NotifyConfigChanged() { DrawEngineCommon::NotifyConfigChanged(); diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 39c72b27a7..0e72dab087 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -75,11 +75,6 @@ DrawEngineVulkan::DrawEngineVulkan(Draw::DrawContext *draw) decOptions_.alignOutputToWord = true; #endif - // Allocate nicely aligned memory. Maybe graphics drivers will appreciate it. - // 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); - indexGen.Setup(decIndex); } @@ -214,9 +209,6 @@ void DrawEngineVulkan::InitDeviceObjects() { } DrawEngineVulkan::~DrawEngineVulkan() { - FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE); - FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); - DestroyDeviceObjects(); }