pub struct Device { /* private fields */ }Expand description
A Metal GPU with its command queue, kernel library and pipeline cache. Cheap to clone.
Implementations§
Source§impl Device
impl Device
Sourcepub fn new_buffer(&self, len: usize) -> Result<Buffer>
pub fn new_buffer(&self, len: usize) -> Result<Buffer>
A buffer of len bytes from the caching allocator. Its contents are unspecified
(a reused buffer holds stale bytes); fails with GpuError::OutOfMemory beyond the
memory limit.
Sourcepub fn buffer_from(&self, bytes: &[u8]) -> Result<Buffer>
pub fn buffer_from(&self, bytes: &[u8]) -> Result<Buffer>
A buffer holding a copy of bytes.
Source§impl Device
impl Device
Sourcepub fn command_buffer(&self) -> Result<CommandBuffer>
pub fn command_buffer(&self) -> Result<CommandBuffer>
A new command buffer on this device’s queue.
Source§impl Device
impl Device
Sourcepub fn system_default() -> Option<Device>
pub fn system_default() -> Option<Device>
The system’s default Metal device, or None if there is none (for example in some
virtual machines).
The process-wide default device, created on first use: one allocator, kernel cache and queue shared by everything that uses the GPU.
Sourcepub fn memory(&self) -> MemoryStats
pub fn memory(&self) -> MemoryStats
Memory use and limits of this device’s allocator.
Sourcepub fn set_memory_limit(&self, bytes: usize) -> usize
pub fn set_memory_limit(&self, bytes: usize) -> usize
Sets the memory limit (allocations beyond it fail) and returns the previous one.
Sourcepub fn set_cache_limit(&self, bytes: usize) -> usize
pub fn set_cache_limit(&self, bytes: usize) -> usize
Sets the cache limit, trimming the cache to it, and returns the previous one.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Releases every cached buffer.
Sourcepub fn reset_peak(&self)
pub fn reset_peak(&self)
Resets the peak to the current active memory.
Sourcepub fn info(&self) -> &DeviceInfo
pub fn info(&self) -> &DeviceInfo
What this GPU is and can do.