Skip to main content

GpuMemoryBackend

Trait GpuMemoryBackend 

Source
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§

Required Methods§

Source

fn allocate( &mut self, size: usize, memory_type: Self::MemoryType, ) -> Result<*mut c_void, Self::Error>

Allocate GPU memory

Source

fn free( &mut self, ptr: *mut c_void, memory_type: Self::MemoryType, ) -> Result<(), Self::Error>

Free GPU memory

Source

fn get_stats(&self) -> Self::Stats

Get memory statistics

Source

fn synchronize(&mut self) -> Result<(), Self::Error>

Synchronize all operations

Source

fn get_vendor(&self) -> GpuVendor

Get GPU vendor

Source

fn get_device_name(&self) -> &str

Get device name

Source

fn get_total_memory(&self) -> usize

Get total memory size

Implementors§