namespace Brutal.VulkanApi.Abstractions;
///
/// Struct containing information about a memory allocation. Intentionally made similar to VMA's AllocationInfo
///
/// Allocator that sourced this allocation
/// Device memory handle
/// Size available in the memory allocation (might be more than requested)
/// Offset into the memory allocation
/// Memory type this allocation was made from
/// Custom handle, optionally used by allocator
public readonly record struct AllocationInfo(
IAllocator Allocator,
VkDeviceMemory Memory,
ByteSize AllocSize,
ByteSize AllocOffset,
int MemoryTypeIndex,
nint AllocHandle
)
{
///
/// Struct containing information about a memory allocation. Intentionally made similar to VMA's AllocationCreateInfo
///
/// Memory location preference can just leave as 'None'
/// Flags that must be set in a Memory Type chosen for an allocation
/// Flags that preferably should be set in a memory type chosen for an allocation
/// A floating-point value between 0 and 1, indicating the priority of the allocation relative to other memory allocations
/// For advanced use only. A pointer to an application-defined structure that can be used to pass custom data to the allocator
public record struct CreateInfo(
MemoryPreference Preference,
VkMemoryPropertyFlags RequiredProperties,
VkMemoryPropertyFlags PreferredProperties,
float Priority,
Ptr Next
)
{
///
/// Optional memory allocation flags. When set, the allocator chains a
/// in front of
/// (e.g. for buffers whose
/// device address will be queried).
///
public VkMemoryAllocateFlags AllocateFlags { get; set; }
}
}
///
/// Enum listing memory allocation preferences: whether to prefer GPU or CPU memory
///
public enum MemoryPreference : byte
{
None,
PreferGpu,
PreferCpu,
}