diff --git a/src/dxvk/dxvk_buffer.cpp b/src/dxvk/dxvk_buffer.cpp index 9940f358..c116eb55 100644 --- a/src/dxvk/dxvk_buffer.cpp +++ b/src/dxvk/dxvk_buffer.cpp @@ -47,13 +47,20 @@ namespace dxvk { VkMemoryPropertyFlags memoryType) : m_device (device), m_info (createInfo), - m_memFlags(memoryType) { - this->allocateResource(); + m_memFlags(memoryType), + m_resource(allocateResource()) { + } - void DxvkBuffer::allocateResource() { - m_resource = m_device->allocBufferResource(m_info, m_memFlags); + void DxvkBuffer::renameResource( + const Rc& resource) { + m_resource = resource; + } + + + Rc DxvkBuffer::allocateResource() { + return m_device->allocBufferResource(m_info, m_memFlags); } diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index 0fcaafa2..19a5159a 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -149,14 +149,22 @@ namespace dxvk { } /** - * \brief Allocates new backing resource + * \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] resource The new backing resource */ - void allocateResource(); + void renameResource( + const Rc& resource); + + /** + * \brief Allocates new backing resource + * \returns The new buffer + */ + Rc allocateResource(); private: diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 9be59b44..3155c414 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -354,7 +354,8 @@ namespace dxvk { void DxvkContext::invalidateBuffer(const Rc& buffer) { // Allocate new backing resource - buffer->allocateResource(); + buffer->renameResource( + buffer->allocateResource()); // We also need to update all bindings that the buffer // may be bound to either directly or through views.