24 Buffer(
Device& device, VkDeviceSize instanceSize, uint32_t instanceCount, VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize minOffsetAlignment = 1);
40 VkResult
map(VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0);
56 void writeToBuffer(
const void* data, VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0)
const;
68 VkResult
flush(VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0)
const;
78 [[nodiscard]] VkDescriptorBufferInfo
descriptorInfo(
const VkDeviceSize size = VK_WHOLE_SIZE,
const VkDeviceSize offset = 0)
const {
return VkDescriptorBufferInfo{
m_buffer, offset, size, }; }
91 [[nodiscard]] VkResult
invalidate(VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0)
const;
149 static VkDeviceSize
getAlignment(
const VkDeviceSize instanceSize,
const VkDeviceSize minOffsetAlignment) {
return (minOffsetAlignment > 0) ? (instanceSize + minOffsetAlignment - 1) & ~(minOffsetAlignment - 1) : instanceSize; }
This file contains the Device class.
VkBuffer getBuffer() const
void unmap()
Unmap a mapped memory range.
Buffer & operator=(Buffer &&)=delete
void * getMappedMemory() const
VkDeviceSize m_bufferSize
VkDeviceSize getBufferSize() const
VkResult map(VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
Map a memory range of this buffer.
VkResult flush(VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0) const
Flush a memory range of the buffer to make it visible to the device.
VkDeviceSize m_alignmentSize
Buffer & operator=(const Buffer &)=delete
VkResult invalidateIndex(const VkDeviceSize index) const
Invalidate a memory range of the buffer to make it visible to the host.
VkMemoryPropertyFlags getMemoryPropertyFlags() const
VkResult invalidate(VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0) const
Invalidate a memory range of the buffer to make it visible to the host.
VkDeviceSize getAlignmentSize() const
VkDescriptorBufferInfo descriptorInfoForIndex(const VkDeviceSize index) const
Create a buffer info descriptor.
uint32_t getInstanceCount() const
static VkDeviceSize getAlignment(const VkDeviceSize instanceSize, const VkDeviceSize minOffsetAlignment)
Returns the minimum instance size required to be compatible with devices minOffsetAlignment.
Buffer(Device &device, VkDeviceSize instanceSize, uint32_t instanceCount, VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize minOffsetAlignment=1)
Buffer(const Buffer &)=delete
VkDescriptorBufferInfo descriptorInfo(const VkDeviceSize size=VK_WHOLE_SIZE, const VkDeviceSize offset=0) const
Create a buffer info descriptor.
VkResult flushIndex(const VkDeviceSize index) const
Flush the memory range at index * alignmentSize of the buffer to make it visible to the device.
VkMemoryPropertyFlags m_memoryPropertyFlags
void writeToBuffer(const void *data, VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0) const
Copies the specified data to the mapped buffer.
VkDeviceSize m_instanceSize
VkBufferUsageFlags getUsageFlags() const
void writeToIndex(const void *data, const VkDeviceSize index) const
Copies "instanceSize" bytes of data to the mapped buffer at an offset of index * alignmentSize.
VkDeviceSize getInstanceSize() const
VkBufferUsageFlags m_usageFlags
VkPhysicalDeviceProperties getProperties() const