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

[dxvk] Introduce DxvkBufferSliceHandle

This struct is meant to replace DxvkPhysicalBufferSlice in the long
run, in a way that doesn't require extra reference counting.
This commit is contained in:
Philip Rebohle 2019-01-09 14:23:04 +01:00
parent 2f1f8ba0a4
commit bbb7728b58
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -7,6 +7,21 @@
namespace dxvk { namespace dxvk {
/**
* \brief Buffer slice info
*
* Stores the Vulkan buffer handle, offset
* and length of the slice, and a pointer
* to the mapped region..
*/
struct DxvkBufferSliceHandle {
VkBuffer handle;
VkDeviceSize offset;
VkDeviceSize length;
void* mapPtr;
};
/** /**
* \brief Virtual buffer resource * \brief Virtual buffer resource
* *
@ -70,12 +85,40 @@ namespace dxvk {
return m_physSlice.resource()->isInUse(); return m_physSlice.resource()->isInUse();
} }
/**
* \brief Retrieves slice handle
* \returns Buffer slice handle
*/
DxvkBufferSliceHandle getSliceHandle() const {
DxvkBufferSliceHandle result;
result.handle = m_physSlice.handle();
result.offset = m_physSlice.offset();
result.length = m_physSlice.length();
result.mapPtr = m_physSlice.mapPtr(0);
return result;
}
/**
* \brief Retrieves sub slice handle
*
* \param [in] offset Offset into buffer
* \param [in] length Sub slice length
* \returns Buffer slice handle
*/
DxvkBufferSliceHandle getSliceHandle(VkDeviceSize offset, VkDeviceSize length) const {
DxvkBufferSliceHandle result;
result.handle = m_physSlice.handle();
result.offset = m_physSlice.offset() + offset;
result.length = length;
result.mapPtr = m_physSlice.mapPtr(offset);
return result;
}
/** /**
* \brief Retrieves descriptor info * \brief Retrieves descriptor info
* *
* \param [in] offset Buffer slice offset * \param [in] offset Buffer slice offset
* \param [in] length Buffer slice length * \param [in] length Buffer slice length
* \param [in] keepOffset \c false to zero offset
* \returns Buffer slice descriptor * \returns Buffer slice descriptor
*/ */
DxvkDescriptorInfo getDescriptor(VkDeviceSize offset, VkDeviceSize length) const { DxvkDescriptorInfo getDescriptor(VkDeviceSize offset, VkDeviceSize length) const {
@ -287,6 +330,31 @@ namespace dxvk {
return m_buffer != nullptr; return m_buffer != nullptr;
} }
/**
* \brief Retrieves buffer slice handle
*
* Returns the buffer handle and offset
* \returns Buffer slice handle
*/
DxvkBufferSliceHandle getSliceHandle() const {
return m_buffer != nullptr
? m_buffer->getSliceHandle(m_offset, m_length)
: DxvkBufferSliceHandle();
}
/**
* \brief Retrieves sub slice handle
*
* \param [in] offset Offset into buffer
* \param [in] length Sub slice length
* \returns Buffer slice handle
*/
DxvkBufferSliceHandle getSliceHandle(VkDeviceSize offset, VkDeviceSize length) const {
return m_buffer != nullptr
? m_buffer->getSliceHandle(m_offset + offset, length)
: DxvkBufferSliceHandle();
}
/** /**
* \brief Physical slice * \brief Physical slice
* *
@ -441,6 +509,16 @@ namespace dxvk {
return m_physView->bufferResource(); return m_physView->bufferResource();
} }
/**
* \brief Retrieves buffer slice handle
* \returns Buffer slice handle
*/
DxvkBufferSliceHandle getSliceHandle() const {
return m_buffer->getSliceHandle(
m_info.rangeOffset,
m_info.rangeLength);
}
/** /**
* \brief Underlying buffer slice * \brief Underlying buffer slice
* \returns Slice backing the view * \returns Slice backing the view