mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-02 22:29:16 +01:00
[dxvk] Added proper documentation for staging buffers
This commit is contained in:
parent
5f0e94138e
commit
3de427439b
@ -66,8 +66,10 @@ namespace dxvk {
|
|||||||
void DxvkDevice::recycleStagingBuffer(const Rc<DxvkStagingBuffer>& buffer) {
|
void DxvkDevice::recycleStagingBuffer(const Rc<DxvkStagingBuffer>& buffer) {
|
||||||
// Drop staging buffers that are bigger than the
|
// Drop staging buffers that are bigger than the
|
||||||
// standard ones to save memory, recycle the rest
|
// standard ones to save memory, recycle the rest
|
||||||
if (buffer->size() == DefaultStagingBufferSize)
|
if (buffer->size() == DefaultStagingBufferSize) {
|
||||||
m_recycledStagingBuffers.returnObject(buffer);
|
m_recycledStagingBuffers.returnObject(buffer);
|
||||||
|
buffer->reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,6 +141,12 @@ namespace dxvk {
|
|||||||
return m_info;
|
return m_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Size of a mipmap level
|
||||||
|
*
|
||||||
|
* \param [in] level Mip level
|
||||||
|
* \returns Size of that level
|
||||||
|
*/
|
||||||
VkExtent3D mipLevelExtent(uint32_t level) const {
|
VkExtent3D mipLevelExtent(uint32_t level) const {
|
||||||
VkExtent3D size = m_info.extent;
|
VkExtent3D size = m_info.extent;
|
||||||
size.width = std::max(1u, size.width >> level);
|
size.width = std::max(1u, size.width >> level);
|
||||||
|
@ -6,6 +6,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
class DxvkDevice;
|
class DxvkDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Staging buffer slice
|
||||||
|
*
|
||||||
|
* Provides the application with a
|
||||||
|
* pointer to the mapped buffer.
|
||||||
|
*/
|
||||||
struct DxvkStagingBufferSlice {
|
struct DxvkStagingBufferSlice {
|
||||||
VkBuffer buffer = VK_NULL_HANDLE;
|
VkBuffer buffer = VK_NULL_HANDLE;
|
||||||
VkDeviceSize offset = 0;
|
VkDeviceSize offset = 0;
|
||||||
@ -13,23 +19,53 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Staging uffer
|
||||||
|
*
|
||||||
|
* A mapped buffer that can be used for fast data
|
||||||
|
* transfer operations from the host to the GPU.
|
||||||
|
* Implements a linear sub-allocator for staging
|
||||||
|
* buffer slices.
|
||||||
|
*/
|
||||||
class DxvkStagingBuffer : public RcObject {
|
class DxvkStagingBuffer : public RcObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DxvkStagingBuffer(
|
DxvkStagingBuffer(
|
||||||
const Rc<DxvkBuffer>& buffer);
|
const Rc<DxvkBuffer>& buffer);
|
||||||
|
|
||||||
~DxvkStagingBuffer();
|
~DxvkStagingBuffer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Buffer size, in bytes
|
||||||
|
* \returns Buffer size, in bytes
|
||||||
|
*/
|
||||||
VkDeviceSize size() const;
|
VkDeviceSize size() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Number of bytes still available
|
||||||
|
* \returns Number of bytes still available
|
||||||
|
*/
|
||||||
VkDeviceSize freeBytes() const;
|
VkDeviceSize freeBytes() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Allocates a staging buffer slice
|
||||||
|
*
|
||||||
|
* This may fail if the amount of data requested is
|
||||||
|
* larger than the amount of data still available.
|
||||||
|
* \param [in] size Requested allocation size
|
||||||
|
* \param [out] slice Allocated staging buffer slice
|
||||||
|
* \returns \c true on success, \c false on failure
|
||||||
|
*/
|
||||||
bool alloc(
|
bool alloc(
|
||||||
VkDeviceSize size,
|
VkDeviceSize size,
|
||||||
DxvkStagingBufferSlice& slice);
|
DxvkStagingBufferSlice& slice);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Resets staging buffer
|
||||||
|
*
|
||||||
|
* Resets the allocator and thus frees
|
||||||
|
* all slices allocated from the buffer.
|
||||||
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -42,6 +78,12 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Staging buffer allocator
|
||||||
|
*
|
||||||
|
* Convenient allocator for staging buffer slices
|
||||||
|
* which creates new staging buffers on demand.
|
||||||
|
*/
|
||||||
class DxvkStagingAlloc {
|
class DxvkStagingAlloc {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -49,9 +91,24 @@ namespace dxvk {
|
|||||||
DxvkStagingAlloc(DxvkDevice* device);
|
DxvkStagingAlloc(DxvkDevice* device);
|
||||||
~DxvkStagingAlloc();
|
~DxvkStagingAlloc();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Allocates a staging buffer slice
|
||||||
|
*
|
||||||
|
* This \e may create a new staging buffer
|
||||||
|
* if needed. This method should not fail.
|
||||||
|
* \param [in] size Required amount of memory
|
||||||
|
* \returns Allocated staging buffer slice
|
||||||
|
*/
|
||||||
DxvkStagingBufferSlice alloc(
|
DxvkStagingBufferSlice alloc(
|
||||||
VkDeviceSize size);
|
VkDeviceSize size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Resets staging buffer allocator
|
||||||
|
*
|
||||||
|
* Returns all buffers to the device so that
|
||||||
|
* they can be recycled. Buffers must not be
|
||||||
|
* in use when this is called.
|
||||||
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user