|
Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
|
Wraps allocation and lifetime functionality of a VkBuffer. More...
#include <foray_managedbuffer.hpp>
Classes | |
| struct | CreateInfo |
| Combines all structs used for initialization. More... | |
Public Member Functions | |
| ManagedBuffer () | |
| void | Create (Context *context, const CreateInfo &createInfo) |
| Creates the buffer based on createInfo. | |
| 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, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT. If data is set, also maps writes and unmaps. | |
| 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 usecases. | |
| virtual void | Destroy () override |
| Destroy the resource. | |
| virtual bool | Exists () const override |
| Return true, if the managed resource is allocated. | |
| void | WriteDataDeviceLocal (const void *data, VkDeviceSize size, VkDeviceSize offset=0) |
| Employ a staging buffer to upload data. | |
| 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. | |
| void | MapAndWrite (const void *data, size_t size=0) |
| Attempts to map buffer, write data, unmap. | |
| virtual | ~ManagedBuffer () |
| FORAY_GETTER_V (Buffer) | |
| FORAY_GETTER_V (IsMapped) | |
| FORAY_GETTER_V (Allocation) | |
| FORAY_GETTER_CR (AllocationInfo) | |
| FORAY_GETTER_V (Name) | |
| FORAY_GETTER_V (Size) | |
| FORAY_GETTER_V (Alignment) | |
| VkDeviceAddress | GetDeviceAddress () const |
| Gets the buffers device address. | |
| virtual void | SetName (std::string_view name) override |
| Sets the buffers name. Decorates VkBuffer, VmaAllocation and VulkanResource base class. | |
| VkDescriptorBufferInfo | GetVkDescriptorBufferInfo () const |
| Fills VkDescriptorBufferInfo object with zero offset and full buffer size. | |
| void | FillVkDescriptorBufferInfo (VkDescriptorBufferInfo &bufferInfo) const |
| Same as GetVkDescriptorBufferInfo, but writing to an existing object. | |
Public Member Functions inherited from foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_BUFFER > | |
| VulkanResource () | |
| VulkanResource (std::string_view name) | |
| virtual std::string_view | GetTypeName () const |
| Returns <OBJECT_TYPE> stringified. | |
Public Member Functions inherited from foray::core::ManagedResource | |
| ManagedResource () | |
| Default constructor registers the resource. | |
| ManagedResource (std::string_view name) | |
| Registers the resource and sets its name. | |
| virtual | ~ManagedResource () |
| Unregisters the resource. | |
| std::string_view | GetName () const |
| Return a custom name for the object. | |
| std::string | Print () const |
| Print name and type in one string. | |
Public Member Functions inherited from foray::NoMoveDefaults | |
| NoMoveDefaults ()=default | |
| NoMoveDefaults (const NoMoveDefaults &other)=delete | |
| NoMoveDefaults (NoMoveDefaults &&other)=default | |
| NoMoveDefaults & | operator= (const NoMoveDefaults &other)=delete |
Protected Member Functions | |
| void | UpdateDebugNames () |
Protected Member Functions inherited from foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_BUFFER > | |
| virtual void | SetObjectName (core::Context *context, const void *handle, std::string_view name, bool updateResourceName=true) |
| Set the object name. Sets both ManagedResource::mName aswell as vulkan debug object name. | |
Protected Attributes | |
| Context * | mContext {} |
| VkBuffer | mBuffer {} |
| VmaAllocation | mAllocation {} |
| VmaAllocationInfo | mAllocationInfo {} |
| VkDeviceSize | mSize = {} |
| VkDeviceSize | mAlignment = {} |
| bool | mIsMapped = false |
Protected Attributes inherited from foray::core::ManagedResource | |
| std::string | mName |
| This objects custom name. | |
Additional Inherited Members | |
Static Public Member Functions inherited from foray::core::ManagedResource | |
| static void | sPrintAllocatedResources (bool printAsWarning) |
| Print a list of all registered existing resources. | |
| static const std::unordered_set< ManagedResource * > * | GetTotalAllocatedResources () |
Wraps allocation and lifetime functionality of a VkBuffer.
|
inline |
|
inlinevirtual |
| void foray::core::ManagedBuffer::Create | ( | Context * | context, |
| const CreateInfo & | createInfo | ||
| ) |
Creates the buffer based on createInfo.
| context | Requires Allocator, Device, DispatchTable (CommandPool for certain shorthands) |
| void foray::core::ManagedBuffer::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 usecases.
| context | Requires Allocator, Device, DispatchTable |
| void foray::core::ManagedBuffer::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, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT. If data is set, also maps writes and unmaps.
| context | Requires Allocator, Device, DispatchTable |
|
overridevirtual |
Destroy the resource.
Implements foray::core::ManagedResource.
|
inlineoverridevirtual |
Return true, if the managed resource is allocated.
Example: Vulkan object stored could be nullptr or instantiated
Implements foray::core::ManagedResource.
| void foray::core::ManagedBuffer::FillVkDescriptorBufferInfo | ( | VkDescriptorBufferInfo & | bufferInfo | ) | const |
Same as GetVkDescriptorBufferInfo, but writing to an existing object.
| foray::core::ManagedBuffer::FORAY_GETTER_CR | ( | AllocationInfo | ) |
| foray::core::ManagedBuffer::FORAY_GETTER_V | ( | Alignment | ) |
| foray::core::ManagedBuffer::FORAY_GETTER_V | ( | Allocation | ) |
| foray::core::ManagedBuffer::FORAY_GETTER_V | ( | Buffer | ) |
| foray::core::ManagedBuffer::FORAY_GETTER_V | ( | IsMapped | ) |
| foray::core::ManagedBuffer::FORAY_GETTER_V | ( | Name | ) |
| foray::core::ManagedBuffer::FORAY_GETTER_V | ( | Size | ) |
| VkDeviceAddress foray::core::ManagedBuffer::GetDeviceAddress | ( | ) | const |
Gets the buffers device address.
|
inline |
Fills VkDescriptorBufferInfo object with zero offset and full buffer size.
| void foray::core::ManagedBuffer::Map | ( | void *& | data | ) |
Maps the buffer to memory address data.
| void foray::core::ManagedBuffer::MapAndWrite | ( | const void * | data, |
| size_t | size = 0 |
||
| ) |
Attempts to map buffer, write data, unmap.
| size | Amount to write. If zero, writes equal to the entire size of the buffer |
|
overridevirtual |
Sets the buffers name. Decorates VkBuffer, VmaAllocation and VulkanResource base class.
Reimplemented from foray::core::ManagedResource.
| void foray::core::ManagedBuffer::Unmap | ( | ) |
Unmaps the buffer.
|
protected |
| void foray::core::ManagedBuffer::WriteDataDeviceLocal | ( | const void * | data, |
| VkDeviceSize | size, | ||
| VkDeviceSize | offset = 0 |
||
| ) |
Employ a staging buffer to upload data.
| data | data |
| size | size |
| offset | write offset into buffer |
| void foray::core::ManagedBuffer::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.
| cmdBuffer | Single use command buffer. Must be completely reset, function will automatically begin, write, submit and resynchronize. |
| data | data |
| size | size |
| offset | write offset into buffer |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |