From 02d92210adb3369d4c3d7bb06660ca0cde0a2add Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 1 Aug 2019 21:30:27 +0200 Subject: [PATCH] [dxvk] Avoid redundant descriptor set updates when binding buffers (v2) We need to check not just the buffer object but also the length of the bound buffer range, since this information will be written into the descriptor and cannot be changed via dynamic offsets. Fixes: f501ebc ('[dxvk] Avoid redundant descriptor set updates when binding buffers') --- src/dxvk/dxvk_context.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 96d29375d..3f012a77c 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -148,12 +148,24 @@ namespace dxvk { void DxvkContext::bindResourceBuffer( uint32_t slot, const DxvkBufferSlice& buffer) { - m_rc[slot].bufferSlice = buffer; - m_rcTracked.clr(slot); + bool needsUpdate = !m_rc[slot].bufferSlice.matchesBuffer(buffer); - m_flags.set( - DxvkContextFlag::CpDirtyResources, - DxvkContextFlag::GpDirtyResources); + if (likely(needsUpdate)) + m_rcTracked.clr(slot); + else + needsUpdate = m_rc[slot].bufferSlice.length() != buffer.length(); + + if (likely(needsUpdate)) { + m_flags.set( + DxvkContextFlag::CpDirtyResources, + DxvkContextFlag::GpDirtyResources); + } else { + m_flags.set( + DxvkContextFlag::CpDirtyDescriptorOffsets, + DxvkContextFlag::GpDirtyDescriptorOffsets); + } + + m_rc[slot].bufferSlice = buffer; }