Skip to content

Commit

Permalink
[dxvk] Sort buffer slices before returning them to the buffer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
doitsujin committed Nov 22, 2019
1 parent 596001c commit 1211bb5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dxvk/dxvk_buffer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "dxvk_buffer.h"
#include "dxvk_device.h"

#include <algorithm>

namespace dxvk {

DxvkBuffer::DxvkBuffer(
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1211bb5

Please sign in to comment.