Skip to main content

Device

Struct Device 

Source
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

Source

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.

Source

pub fn buffer_from(&self, bytes: &[u8]) -> Result<Buffer>

A buffer holding a copy of bytes.

Source§

impl Device

Source

pub fn command_buffer(&self) -> Result<CommandBuffer>

A new command buffer on this device’s queue.

Source§

impl Device

Source

pub fn system_default() -> Option<Device>

The system’s default Metal device, or None if there is none (for example in some virtual machines).

Source

pub fn shared() -> Option<&'static Device>

The process-wide default device, created on first use: one allocator, kernel cache and queue shared by everything that uses the GPU.

Source

pub fn memory(&self) -> MemoryStats

Memory use and limits of this device’s allocator.

Source

pub fn set_memory_limit(&self, bytes: usize) -> usize

Sets the memory limit (allocations beyond it fail) and returns the previous one.

Source

pub fn set_cache_limit(&self, bytes: usize) -> usize

Sets the cache limit, trimming the cache to it, and returns the previous one.

Source

pub fn clear_cache(&self)

Releases every cached buffer.

Source

pub fn reset_peak(&self)

Resets the peak to the current active memory.

Source

pub fn info(&self) -> &DeviceInfo

What this GPU is and can do.

Source

pub fn pipeline(&self, name: &str) -> Result<Pipeline>

The compute pipeline for the kernel name from nuvec’s kernel library, compiled on first use and cached.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.