From c27cae2f106d220f1deb2f061f5020bd4a4f6352 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 5 Oct 2024 01:17:29 +0200 Subject: [PATCH] [d3d11] Improve per-context staging buffer handling In D3D11, the staging buffer is only used for UpdateSubresource, which isn't always used much. Reducing the size and freeing the buffer after every submission avoids situations where system memory chunks are kept alive by a single unused 4MB allocation. --- src/d3d11/d3d11_context.h | 4 +++- src/d3d11/d3d11_context_imm.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 4d018cb1..a0e79004 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -72,7 +72,9 @@ namespace dxvk { template friend class D3D11DeviceContextExt; template friend class D3D11UserDefinedAnnotation; - constexpr static VkDeviceSize StagingBufferSize = 4ull << 20; + // Use a local staging buffer to handle tiny uploads, most + // of the time we're fine with hitting the global allocator + constexpr static VkDeviceSize StagingBufferSize = 256ull << 10; public: D3D11CommonContext( diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 08f992b5..0d3a0156 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -992,6 +992,10 @@ namespace dxvk { // Vulkan queue submission is performed. if (synchronizeSubmission) m_device->waitForSubmission(&m_submitStatus); + + // Free local staging buffer so that we don't + // end up with a persistent allocation + ResetStagingBuffer(); } }