namespace Brutal.VulkanApi.Abstractions; /// /// Allocation information for a partition of a buffer allocation (portion of a larger buffer) /// /// Buffer partitioner that created this partition /// Information about this allocation within the buffer /// Offset within owning buffer where this partition starts /// Size of this partition public readonly record struct BufferPartitionInfo( IBufferPartitioner? Partitioner, BufferAllocationInfo BufferInfo, ByteSize PartitionOffset, ByteSize PartitionSize ) : IMappable, IBindBuffer { public record struct CreateInfo(ByteSize Size); /// /// Reference to the parent Vulkan buffer /// public VkBuffer VkBuffer => BufferInfo.VkBuffer; /// /// Offset within the parent buffer where this partition starts /// public ByteSize BindOffset => BufferInfo.BufferOffset + PartitionOffset; /// /// Offset within the owning device memory allocation where this partition starts /// public ByteSize MemoryOffset => BufferInfo.AllocationInfo.AllocOffset + BindOffset; /// /// If true, this partition is a full buffer allocation /// public bool IsFullPartition => Partitioner is null; /// /// Convenience function to create a partition info object for a full buffer allocation /// /// BufferAllocationInfo object /// BufferAllocationInfo as BufferPartitionInfo, with the 'partition' covering the entire buffer public static BufferPartitionInfo FullPartition(BufferAllocationInfo bufferAllocationInfo) { return new BufferPartitionInfo( Partitioner: null, BufferInfo: bufferAllocationInfo, PartitionSize: bufferAllocationInfo.BufferSize, PartitionOffset: ByteSize.Zero ); } AllocationInfo IMappable.AllocationInfo => BufferInfo.AllocationInfo; ByteSize IMappable.MapSize => PartitionSize; ByteSize IMappable.MapOffset => PartitionOffset; }