2#include "../foray_vma.hpp"
3#include "../foray_vulkan.hpp"
29 CreateInfo(VkBufferUsageFlags usage, VkDeviceSize size, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags flags = {}, std::string_view name =
"");
43 void Create(
Context* context, VkBufferUsageFlags usage, VkDeviceSize size, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags flags = {}, std::string_view name =
"");
62 void Map(
void*& data);
90 virtual void SetName(std::string_view name)
override;
Extension of the commandbuffer wrapper for temporary host synchronized command buffer execution.
Definition foray_commandbuffer.hpp:41
Wraps allocation and lifetime functionality of a VkBuffer.
Definition foray_managedbuffer.hpp:12
void MapAndWrite(const void *data, size_t size=0)
Attempts to map buffer, write data, unmap.
virtual void Destroy() override
Destroy the resource.
FORAY_GETTER_CR(AllocationInfo)
ManagedBuffer()
Definition foray_managedbuffer.hpp:33
VmaAllocation mAllocation
Definition foray_managedbuffer.hpp:100
VkDeviceSize mSize
Definition foray_managedbuffer.hpp:102
VkDescriptorBufferInfo GetVkDescriptorBufferInfo() const
Fills VkDescriptorBufferInfo object with zero offset and full buffer size.
Definition foray_managedbuffer.hpp:93
void Create(Context *context, VkBufferUsageFlags usage, VkDeviceSize size, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags flags={}, std::string_view name="")
Simplified version of Create that omits the use of a create info but should be sufficient for many us...
void Create(Context *context, const CreateInfo &createInfo)
Creates the buffer based on createInfo.
void WriteDataDeviceLocal(const void *data, VkDeviceSize size, VkDeviceSize offset=0)
Employ a staging buffer to upload data.
void FillVkDescriptorBufferInfo(VkDescriptorBufferInfo &bufferInfo) const
Same as GetVkDescriptorBufferInfo, but writing to an existing object.
VkDeviceAddress GetDeviceAddress() const
Gets the buffers device address.
void WriteDataDeviceLocal(HostSyncCommandBuffer &cmdBuffer, const void *data, VkDeviceSize size, VkDeviceSize offset=0)
Create staging buffer, copy data to it, copy data to device buffer, destroy staging buffer.
void Map(void *&data)
Maps the buffer to memory address data.
void Unmap()
Unmaps the buffer.
VkDeviceSize mAlignment
Definition foray_managedbuffer.hpp:103
virtual ~ManagedBuffer()
Definition foray_managedbuffer.hpp:70
VkBuffer mBuffer
Definition foray_managedbuffer.hpp:99
void CreateForStaging(Context *context, VkDeviceSize size, const void *data=nullptr, std::string_view bufferName={})
Creates the buffer with VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_AUTO_PREFER_HOST,...
VmaAllocationInfo mAllocationInfo
Definition foray_managedbuffer.hpp:101
virtual void SetName(std::string_view name) override
Sets the buffers name. Decorates VkBuffer, VmaAllocation and VulkanResource base class.
bool mIsMapped
Definition foray_managedbuffer.hpp:104
Context * mContext
Definition foray_managedbuffer.hpp:98
FORAY_GETTER_V(Allocation)
virtual bool Exists() const override
Return true, if the managed resource is allocated.
Definition foray_managedbuffer.hpp:47
FORAY_GETTER_V(Alignment)
ManagedResource variant which automates GetTypeName() overloading by returning a stringified version ...
Definition foray_managedresource.hpp:59
Definition foray_commandbuffer.hpp:6
Non owning context object.
Definition foray_context.hpp:16
Combines all structs used for initialization.
Definition foray_managedbuffer.hpp:16
VmaAllocationCreateInfo AllocationCreateInfo
Allocation create info used to configure Vma.
Definition foray_managedbuffer.hpp:20
std::string Name
Debug name assigned to both VmaAllocation and VkBuffer vulkan object.
Definition foray_managedbuffer.hpp:24
CreateInfo(VkBufferUsageFlags usage, VkDeviceSize size, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags flags={}, std::string_view name="")
Shorthand for most commonly used fields.
VkBufferCreateInfo BufferCreateInfo
Buffer Create info used to configure Vulkan buffer create.
Definition foray_managedbuffer.hpp:18
VkDeviceSize Alignment
If non zero, Vma's aligned buffer allocate function is invoked.
Definition foray_managedbuffer.hpp:22
CreateInfo()
Default constructor (initializes .sType field and nulls everything else)