From 1211bb5e5f6655916c1704e0799b1ac835327f68 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 23 Nov 2019 00:32:05 +0100 Subject: [PATCH] [dxvk] Sort buffer slices before returning them to the buffer Buffer slices often get shuffled over time due to timing and thread synchronization, which makes it less and less likely for the dynamic uniform buffer binding optimization to be effective. Sorting the slices beforehand addresses the issue and may help CPU performance. --- src/dxvk/dxvk_buffer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dxvk/dxvk_buffer.cpp b/src/dxvk/dxvk_buffer.cpp index d3145518..17f4a53b 100644 --- a/src/dxvk/dxvk_buffer.cpp +++ b/src/dxvk/dxvk_buffer.cpp @@ -1,6 +1,8 @@ #include "dxvk_buffer.h" #include "dxvk_device.h" +#include + namespace dxvk { DxvkBuffer::DxvkBuffer( @@ -222,6 +224,11 @@ namespace dxvk { void DxvkBufferTracker::reset() { + std::sort(m_entries.begin(), m_entries.end(), + [] (const Entry& a, const Entry& b) { + return a.slice.handle < b.slice.handle; + }); + for (const auto& e : m_entries) e.buffer->freeSlice(e.slice);