From 775154166207d8517dc7eb113c7fe7d3ccfc25c7 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 26 Oct 2019 14:20:04 +0200 Subject: [PATCH] [dxvk] Don't lock swap lock if not necessary The swap lock only protects the 'next' free list, which is not accessed at all when creating a new buffer. --- src/dxvk/dxvk_buffer.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index 70bea16eb..75cce046d 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -236,15 +236,14 @@ namespace dxvk { std::unique_lock freeLock(m_freeMutex); // If no slices are available, swap the two free lists. - if (unlikely(m_freeSlices.size() == 0)) { + if (unlikely(m_freeSlices.empty())) { std::unique_lock swapLock(m_swapMutex); std::swap(m_freeSlices, m_nextSlices); } // If there are still no slices available, create a new // backing buffer and add all slices to the free list. - if (unlikely(m_freeSlices.size() == 0)) { - std::unique_lock swapLock(m_swapMutex); + if (unlikely(m_freeSlices.empty())) { DxvkBufferHandle handle = allocBuffer(m_physSliceCount); DxvkBufferSliceHandle slice;