1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 04:24:11 +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

@ -6,6 +6,21 @@
#include "dxvk_buffer_res.h"
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
@ -70,12 +85,40 @@ namespace dxvk {
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
*
* \param [in] offset Buffer slice offset
* \param [in] length Buffer slice length
* \param [in] keepOffset \c false to zero offset
* \returns Buffer slice descriptor
*/
DxvkDescriptorInfo getDescriptor(VkDeviceSize offset, VkDeviceSize length) const {
@ -287,6 +330,31 @@ namespace dxvk {
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
*
@ -440,6 +508,16 @@ namespace dxvk {
Rc<DxvkResource> bufferResource() const {
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