1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 16:24:12 +01:00

[dxvk] Separated buffer renaming from allocation

This commit is contained in:
Philip Rebohle 2017-12-20 02:58:36 +01:00
parent 70e5314cc6
commit f68655feff
3 changed files with 23 additions and 7 deletions

View File

@ -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<DxvkBufferResource>& resource) {
m_resource = resource;
}
Rc<DxvkBufferResource> DxvkBuffer::allocateResource() {
return m_device->allocBufferResource(m_info, m_memFlags);
}

View File

@ -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<DxvkBufferResource>& resource);
/**
* \brief Allocates new backing resource
* \returns The new buffer
*/
Rc<DxvkBufferResource> allocateResource();
private:

View File

@ -354,7 +354,8 @@ namespace dxvk {
void DxvkContext::invalidateBuffer(const Rc<DxvkBuffer>& 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.