From 4064c89e8caa8e3902949957439b15404635e9d4 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 22 Sep 2024 12:32:43 +0200 Subject: [PATCH] [dxvk] Remove legacy buffer renaming interface --- src/dxvk/dxvk_buffer.h | 52 ++++++++++++++------------------------- src/dxvk/dxvk_context.cpp | 7 ------ src/dxvk/dxvk_context.h | 4 --- src/dxvk/dxvk_resource.h | 9 +------ 4 files changed, 19 insertions(+), 53 deletions(-) diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index 1a3fccaf1..3e597584d 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -289,20 +289,6 @@ namespace dxvk { return result; } - /** - * \brief Replaces backing resource - * - * Replaces the underlying buffer and implicitly marks - * any buffer views using this resource as dirty. Do - * not call this directly as this is called implicitly - * by the context's \c invalidateBuffer method. - * \param [in] slice The new backing resource - * \returns Previous buffer slice - */ - DxvkBufferSliceHandle rename(const DxvkBufferSliceHandle& slice) { - return std::exchange(m_physSlice, slice); - } - /** * \brief Transform feedback vertex stride * @@ -329,7 +315,7 @@ namespace dxvk { * \brief Allocates new buffer slice * \returns The new buffer slice */ - DxvkBufferSliceHandle allocSlice() { + DxvkBufferAllocation allocateSlice() { std::unique_lock freeLock(m_freeMutex); // If no slices are available, swap the two free lists. @@ -360,28 +346,26 @@ namespace dxvk { } // Take the first slice from the queue - DxvkBufferSliceHandle result = m_freeSlices.back(); + DxvkBufferAllocation result(m_freeSlices.back()); m_freeSlices.pop_back(); return result; } /** - * \brief Allocates a new buffer slice - * \returns New buffer slice - */ - DxvkBufferAllocation allocateSlice() { - return DxvkBufferAllocation(allocSlice()); - } - - /** - * \brief Replaces backing storage - * - * Implicitly invalidates all views created for the buffer. - * \param [in] slice New buffer slice - * \returns Previous buffer allocation for lifetime tracking. + * \brief Replaces backing resource + * + * Replaces the underlying buffer and implicitly marks + * any buffer views using this resource as dirty. Do + * not call this directly as this is called implicitly + * by the context's \c invalidateBuffer method. + * \param [in] slice The new backing resource + * \returns Previous buffer slice */ DxvkBufferAllocation assignSlice(DxvkBufferAllocation&& slice) { - return DxvkBufferAllocation(rename(slice.m_slice)); + DxvkBufferAllocation result(m_physSlice); + m_physSlice = slice.m_slice; + slice.m_slice = DxvkBufferSliceHandle(); + return result; } /** @@ -403,7 +387,7 @@ namespace dxvk { void freeSlice(const DxvkBufferSliceHandle& slice) { // Add slice to a separate free list to reduce lock contention. std::unique_lock swapLock(m_swapMutex); - m_nextSlices.push_back(slice); + m_nextSlices.emplace_back(slice); } /** @@ -438,11 +422,11 @@ namespace dxvk { VkDeviceSize m_maxAllocationSize = 0; std::vector m_buffers; - std::vector m_freeSlices; + std::vector m_freeSlices; alignas(CACHE_LINE_SIZE) sync::Spinlock m_swapMutex; - std::vector m_nextSlices; + std::vector m_nextSlices; void pushSlice(const DxvkBufferHandle& handle, uint32_t index) { DxvkBufferSliceHandle slice; @@ -450,7 +434,7 @@ namespace dxvk { slice.offset = handle.getBaseOffset() + m_physSliceStride * index; slice.length = m_physSliceLength; slice.mapPtr = handle.memory.mapPtr(m_physSliceStride * index); - m_freeSlices.push_back(slice); + m_freeSlices.emplace_back(slice); } DxvkBufferHandle allocBuffer( diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index d95303194..b60fa4205 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1865,13 +1865,6 @@ namespace dxvk { } - void DxvkContext::invalidateBuffer( - const Rc& buffer, - const DxvkBufferSliceHandle& slice) { - invalidateBuffer(buffer, DxvkBufferAllocation(slice)); - } - - void DxvkContext::resolveImage( const Rc& dstImage, const Rc& srcImage, diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 46b284d9f..e9ea8ce8a 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -964,10 +964,6 @@ namespace dxvk { void invalidateBuffer( const Rc& buffer, DxvkBufferAllocation&& slice); - - void invalidateBuffer( - const Rc& buffer, - const DxvkBufferSliceHandle& slice); /** * \brief Updates push constants diff --git a/src/dxvk/dxvk_resource.h b/src/dxvk/dxvk_resource.h index 185a2b565..7945a1b8f 100644 --- a/src/dxvk/dxvk_resource.h +++ b/src/dxvk/dxvk_resource.h @@ -1,17 +1,10 @@ #pragma once #include "dxvk_include.h" +#include "dxvk_memory.h" namespace dxvk { - enum class DxvkAccess : uint32_t { - Read = 0, - Write = 1, - None = 2, - }; - - using DxvkAccessFlags = Flags; - /** * \brief DXVK resource *