mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Create memory::Buffer
& Implement StagingBuffer
as derivative
A `Buffer` class was created to hold any generic Vulkan buffer object with `span` semantics, `StagingBuffer` was implemented atop it as a wrapper for `Buffer` that inherits from `FenceCycleDependency` and can be used as such.
This commit is contained in:
@ -11,29 +11,36 @@ namespace skyline::gpu::memory {
|
||||
* @brief A view into a CPU mapping of a Vulkan buffer
|
||||
* @note The mapping **should not** be used after the lifetime of the object has ended
|
||||
*/
|
||||
struct StagingBuffer : public span<u8>, public FenceCycleDependency {
|
||||
struct Buffer : public span<u8> {
|
||||
VmaAllocator vmaAllocator;
|
||||
VmaAllocation vmaAllocation;
|
||||
vk::Buffer vkBuffer;
|
||||
|
||||
constexpr StagingBuffer(u8 *pointer, size_t size, VmaAllocator vmaAllocator, vk::Buffer vkBuffer, VmaAllocation vmaAllocation)
|
||||
constexpr Buffer(u8 *pointer, size_t size, VmaAllocator vmaAllocator, vk::Buffer vkBuffer, VmaAllocation vmaAllocation)
|
||||
: vmaAllocator(vmaAllocator),
|
||||
vkBuffer(vkBuffer),
|
||||
vmaAllocation(vmaAllocation),
|
||||
span(pointer, size) {}
|
||||
|
||||
StagingBuffer(const StagingBuffer &) = delete;
|
||||
Buffer(const Buffer &) = delete;
|
||||
|
||||
constexpr StagingBuffer(StagingBuffer &&other)
|
||||
constexpr Buffer(Buffer &&other)
|
||||
: vmaAllocator(std::exchange(other.vmaAllocator, nullptr)),
|
||||
vmaAllocation(std::exchange(other.vmaAllocation, nullptr)),
|
||||
vkBuffer(std::exchange(other.vkBuffer, {})) {}
|
||||
|
||||
StagingBuffer &operator=(const StagingBuffer &) = delete;
|
||||
Buffer &operator=(const Buffer &) = delete;
|
||||
|
||||
StagingBuffer &operator=(StagingBuffer &&) = default;
|
||||
Buffer &operator=(Buffer &&) = default;
|
||||
|
||||
~StagingBuffer();
|
||||
~Buffer();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A Buffer that can be independently attached to a fence cycle
|
||||
*/
|
||||
class StagingBuffer : public Buffer, public FenceCycleDependency {
|
||||
using Buffer::Buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -99,6 +106,11 @@ namespace skyline::gpu::memory {
|
||||
*/
|
||||
std::shared_ptr<StagingBuffer> AllocateStagingBuffer(vk::DeviceSize size);
|
||||
|
||||
/**
|
||||
* @brief Creates a buffer with a CPU mapping and all usage flags
|
||||
*/
|
||||
Buffer AllocateBuffer(vk::DeviceSize size);
|
||||
|
||||
/**
|
||||
* @brief Creates an image which is allocated and deallocated using RAII
|
||||
*/
|
||||
|
Reference in New Issue
Block a user