2#include <vk_mem_alloc.h>
44 other.device_ = VK_NULL_HANDLE;
45 other.physicalDevice_ = VK_NULL_HANDLE;
46 other.allocator_ = VK_NULL_HANDLE;
47 other.buffer = VK_NULL_HANDLE;
48 other.allocation_ = VK_NULL_HANDLE;
50 other.mappedMemory =
nullptr;
51 other.isHostCoherent_ =
false;
52 other.isPersistentlyMapped_ =
false;
77 other.device_ = VK_NULL_HANDLE;
78 other.physicalDevice_ = VK_NULL_HANDLE;
79 other.allocator_ = VK_NULL_HANDLE;
80 other.buffer = VK_NULL_HANDLE;
81 other.allocation_ = VK_NULL_HANDLE;
83 other.mappedMemory = VK_NULL_HANDLE;
84 other.isHostCoherent_ =
false;
85 other.isPersistentlyMapped_ =
false;
103 Buffer(VkDevice device, VkPhysicalDevice physicalDevice);
129 void create(
size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties);
161 void flush(VkDeviceSize mappedOffset = 0, VkDeviceSize mappedSize = VK_WHOLE_SIZE);
190 bool ensureSize(
size_t requiredSize, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties);
Wrapper for texture data.
The application context is the core class which stores the basic openxr and vulkan objects.
void * getMappedMemory() const
void flush(VkDeviceSize mappedOffset=0, VkDeviceSize mappedSize=VK_WHOLE_SIZE)
Flushes a mapped memory range to the GPU to make CPU writes visible.
Buffer(VkDevice device, VkPhysicalDevice physicalDevice)
Construct with direct Vulkan handles (decoupled from ApplicationContext)
VmaAllocator allocator_
Borrowed reference to VMA allocator.
void unmap()
Unmaps the memory if it is mapped.
Buffer & operator=(Buffer &&other) noexcept
VkDeviceSize getBufferSize() const
void uploadDataAtOffset(const void *data, VkDeviceSize dataSize, VkDeviceSize offset)
Helper function to map, copy data at an offset and unmap the buffer.
void setDebugName(const std::string &name)
Sets the name shown in vulkan validation layer.
VmaAllocation allocation_
VMA allocation handle.
void create(size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties)
Creates a buffer with a certain size, usage flags and memory properties.
Buffer(Buffer &&other) noexcept
bool isMapped() const
Checks whether the buffer is already mapped to a memory range.
std::string getDebugName() const
Buffer(Engine::Core::ApplicationContext *context)
Construct from ApplicationContext (for engine code)
Buffer()
Default constructor - uses EngineManager singleton to get Vulkan handles.
void uploadData(const void *data, VkDeviceSize dataSize)
Helper function to map, copy the data and unmap the buffer. Best used for infrequent updates.
bool isHostCoherent_
True if buffer uses HOST_COHERENT memory (no flush needed)
VkBuffer getBuffer() const
void destroy()
Destroys all vulkan resources of the buffer.
void * map()
Maps the buffer to be writable by the cpu. The mapped memory range is also stored in the object.
void overrideSize(VkDeviceSize newSize)
Overrides the size of a buffer in case the VulkanBuffer is created in place.
VkDeviceAddress getDeviceAddress() const
VkPhysicalDevice physicalDevice_
VkDeviceMemory getBufferMemory() const
Gets the underlying VkDeviceMemory handle (for backward compatibility)
bool ensureSize(size_t requiredSize, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties)
Ensures the buffer has at least the required size, recreating if necessary.
bool isPersistentlyMapped_
Core audio subsystem owning the miniaudio engine and managing playback.