Buffer

Represents a Vulkan buffer object.

Properties

BufferSize

(ulong) : Gets the size of the buffer.

InstanceCount

(uint) : Gets the number of instances of the buffer.

InstanceSize

(ulong) { get; set }: Gets or sets the size of each instance in the buffer.

AlignmentSize

(ulong) : Gets the alignment size for the buffer.

UsageFlags

(BufferUsageFlags) : Gets the usage flags for the buffer.

MemoryPropertyFlags

(MemoryPropertyFlags) : Gets the memory property flags for the buffer.

VkBuffer

(Silk.NET.Vulkan.Buffer): Buffer

Public Methods

Map

public Result Map(ulong size = Vk.WholeSize, ulong offset = 0)

Maps a memory range of this buffer.

Parameters:

  • size (ulong): The size of the memory range to map. (Default: Vk.WholeSize)
  • offset (ulong): The byte offset from the beginning. (Default: 0)

Returns: Result

  • The result of the buffer mapping call.

UnMap

public void UnMap()

Unmaps a previously mapped memory range.

ReadFromBuffer

public T ReadFromBuffer()

Reads data from the mapped buffer into a specified type.

Returns: T

  • The data read from the buffer.

WriteToBuffer

public void WriteToBuffer(T[] data, ulong size = Vk.WholeSize, ulong offset = 0)

Copies the specified data to the mapped buffer. Default value writes whole buffer range

Parameters:

  • data (T[]): Pointer to the data to copy.
  • size (ulong): Size of the data to copy. Pass VK_WHOLE_SIZE to flush the complete buffer range. (Default: Vk.WholeSize)
  • offset (ulong): Byte offset from beginning of mapped region. (Default: 0)

WriteToBuffer

public void WriteToBuffer(T data, ulong size = Vk.WholeSize, ulong offset = 0)

Writes data to the mapped buffer.

Parameters:

  • data (T): The data to write.
  • size (ulong): The size of the data to copy. (Default: Vk.WholeSize)
  • offset (ulong): The byte offset from the beginning of the mapped region. (Default: 0)

WriteBytesToBuffer

public void WriteBytesToBuffer(byte[] data)

Writes bytes to the mapped buffer.

Parameters:

  • data (byte[]): The byte data to write.

WriteToIndex

public void WriteToIndex(T[] data, int index)

Writes data from the given array to the Vulkan buffer, starting at the specified index.

Parameters:

  • data (T[]): The source array containing the data to be written.
  • index (int): The index in the target buffer where writing should begin.

Flush

public Result Flush(ulong size = Vk.WholeSize, ulong offset = 0)

Flush a memory range of the buffer to make it visible to the device.

Parameters:

  • size (ulong): (Optional) Size of the memory range to flush. Pass VK_WHOLE_SIZE to flush the complete buffer range. (Default: Vk.WholeSize)
  • offset (ulong): (Optional) Byte offset from the beginning. (Default: 0)

Returns: Result

  • VkResult of the flush call. Remarks: Only required for non-coherent memory.

Invalidate

public Result Invalidate(ulong size = Vk.WholeSize, ulong offset = 0)

Invalidate a memory range of the buffer to make it visible to the host.

Parameters:

  • size (ulong): (Optional) Size of the memory range to invalidate. Pass VK_WHOLE_SIZE to invalidate the complete buffer range. (Default: Vk.WholeSize)
  • offset (ulong): (Optional) Byte offset from the beginning. (Default: 0)

Returns: Result

  • VkResult of the invalidate call. Remarks: Only required for non-coherent memory.

DescriptorInfo

public DescriptorBufferInfo DescriptorInfo(ulong size = Vk.WholeSize, ulong offset = 0)

Create a buffer info descriptor.

Parameters:

  • size (ulong): (Optional) Size of the memory range of the descriptor. (Default: Vk.WholeSize)
  • offset (ulong): (Optional) Byte offset from the beginning. (Default: 0)

Returns: DescriptorBufferInfo

  • VkDescriptorBufferInfo of specified offset and range.

FlushIndex

public Result FlushIndex(int index)

Flush the memory range at index * alignmentSize of the buffer to make it visible to the device.

Parameters:

  • index (int): Used in offset calculation.

Returns: Result

  • VkResult of the flush call.

DescriptorInfoForIndex

public DescriptorBufferInfo DescriptorInfoForIndex(int index)

Create a buffer info descriptor.

Parameters:

  • index (int): Specifies the region given by index * alignmentSize.

Returns: DescriptorBufferInfo

  • VkDescriptorBufferInfo for the instance at index.

InvalidateIndex

public Result InvalidateIndex(int index)

Invalidate a memory range of the buffer to make it visible to the host.

Parameters:

  • index (int): Specifies the region to invalidate: index * alignmentSize.

Returns: Result

  • VkResult of the invalidate call. Remarks: Only required for non-coherent memory.

Dispose

public void Dispose()

Disposes of the buffer and associated resources.