use std::ffi::c_void;
use std::ptr::NonNull;
use anyhow::Result;
use ash::vk::*;
pub trait Allocation: Send + Sync {
unsafe fn memory(&self) -> DeviceMemory;
fn offset(&self) -> u64;
fn size(&self) -> u64;
fn mapped_ptr(&self) -> Option<NonNull<c_void>>;
}
pub trait MemoryLocation: Clone + Send + Sync {
fn gpu_only() -> Self;
fn cpu_to_gpu() -> Self;
fn gpu_to_cpu() -> Self;
}
pub trait AllocationCreateInfo {
type MemoryLocation: MemoryLocation;
fn new(
name: Option<&'static str>,
requirements: MemoryRequirements,
location: Self::MemoryLocation,
linear: bool,
) -> Self;
}
pub trait Allocator: Clone + Send + Sync {
type Allocation: Allocation;
type AllocationCreateInfo: AllocationCreateInfo;
fn allocate(&self, desc: Self::AllocationCreateInfo) -> Result<Self::Allocation>;
fn free(&self, allocation: Self::Allocation) -> Result<()>;
}