pub trait GpuMemoryBackend {
type Error: Error + Send + Sync + 'static;
type MemoryType: Clone + PartialEq;
type Stats: Clone;
// Required methods
fn allocate(
&mut self,
size: usize,
memory_type: Self::MemoryType,
) -> Result<*mut c_void, Self::Error>;
fn free(
&mut self,
ptr: *mut c_void,
memory_type: Self::MemoryType,
) -> Result<(), Self::Error>;
fn get_stats(&self) -> Self::Stats;
fn synchronize(&mut self) -> Result<(), Self::Error>;
fn get_vendor(&self) -> GpuVendor;
fn get_device_name(&self) -> &str;
fn get_total_memory(&self) -> usize;
}Expand description
Unified memory backend trait for all GPU vendors
Required Associated Types§
type Error: Error + Send + Sync + 'static
type MemoryType: Clone + PartialEq
type Stats: Clone
Required Methods§
Sourcefn allocate(
&mut self,
size: usize,
memory_type: Self::MemoryType,
) -> Result<*mut c_void, Self::Error>
fn allocate( &mut self, size: usize, memory_type: Self::MemoryType, ) -> Result<*mut c_void, Self::Error>
Allocate GPU memory
Sourcefn free(
&mut self,
ptr: *mut c_void,
memory_type: Self::MemoryType,
) -> Result<(), Self::Error>
fn free( &mut self, ptr: *mut c_void, memory_type: Self::MemoryType, ) -> Result<(), Self::Error>
Free GPU memory
Sourcefn synchronize(&mut self) -> Result<(), Self::Error>
fn synchronize(&mut self) -> Result<(), Self::Error>
Synchronize all operations
Sourcefn get_vendor(&self) -> GpuVendor
fn get_vendor(&self) -> GpuVendor
Get GPU vendor
Sourcefn get_device_name(&self) -> &str
fn get_device_name(&self) -> &str
Get device name
Sourcefn get_total_memory(&self) -> usize
fn get_total_memory(&self) -> usize
Get total memory size