diff --git a/src/dxvk/dxvk_buffer.cpp b/src/dxvk/dxvk_buffer.cpp index 32419265d..8a978337f 100644 --- a/src/dxvk/dxvk_buffer.cpp +++ b/src/dxvk/dxvk_buffer.cpp @@ -21,28 +21,19 @@ namespace dxvk { } - DxvkPhysicalBufferSlice DxvkBuffer::rename(const DxvkPhysicalBufferSlice& slice) { - DxvkPhysicalBufferSlice prevSlice = std::move(m_physSlice); - - m_physSlice = slice; - m_revision += 1; - return prevSlice; - } - - DxvkPhysicalBufferSlice DxvkBuffer::allocPhysicalSlice() { - std::unique_lock freeLock(m_freeMutex); + std::unique_lock freeLock(m_freeMutex); // If no slices are available, swap the two free lists. if (m_freeSlices.size() == 0) { - std::unique_lock swapLock(m_swapMutex); + std::unique_lock swapLock(m_swapMutex); std::swap(m_freeSlices, m_nextSlices); } // If there are still no slices available, create a new // physical buffer and add all slices to the free list. if (m_freeSlices.size() == 0) { - std::unique_lock swapLock(m_swapMutex); + std::unique_lock swapLock(m_swapMutex); m_physBuffer = this->allocPhysicalBuffer(m_physSliceCount); for (uint32_t i = 0; i < m_physSliceCount; i++) { @@ -63,7 +54,7 @@ namespace dxvk { void DxvkBuffer::freePhysicalSlice(const DxvkPhysicalBufferSlice& slice) { // Add slice to a separate free list to reduce lock contention. - std::unique_lock swapLock(m_swapMutex); + std::unique_lock swapLock(m_swapMutex); // Discard slices allocated from other physical buffers. // This may make descriptor set binding more efficient. diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index e41a40dc0..ad7dfe68e 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -111,8 +111,12 @@ namespace dxvk { * \param [in] slice The new backing resource * \returns Previous buffer slice */ - DxvkPhysicalBufferSlice rename( - const DxvkPhysicalBufferSlice& slice); + DxvkPhysicalBufferSlice rename(const DxvkPhysicalBufferSlice& slice) { + DxvkPhysicalBufferSlice prevSlice = std::move(m_physSlice); + m_physSlice = slice; + m_revision += 1; + return prevSlice; + } /** * \brief Allocates new physical resource @@ -140,8 +144,8 @@ namespace dxvk { DxvkPhysicalBufferSlice m_physSlice; uint32_t m_revision = 0; - std::mutex m_freeMutex; - std::mutex m_swapMutex; + sync::Spinlock m_freeMutex; + sync::Spinlock m_swapMutex; std::vector m_freeSlices; std::vector m_nextSlices;