Skip to main content

GpuContext

Struct GpuContext 

Source
pub struct GpuContext { /* private fields */ }
Expand description

An initialised GPU device and queue.

Construct via GpuContext::try_init. Returns None if no compatible adapter is available (headless CI, no GPU hardware, feature disabled).

The _private field is always present (unconditionally) so that external code cannot construct a GpuContext with struct-literal syntax even when the gpu feature is disabled (which would otherwise leave an empty struct that can be trivially constructed).

Implementations§

Source§

impl GpuContext

Source

pub fn try_init() -> Option<Self>

Try to initialise a GPU context.

Returns None when:

  • The gpu feature is not enabled.
  • No compatible wgpu adapter exists on the current host.
  • The device-request step fails (e.g. out-of-resources).
Source

pub fn enumerate_devices() -> Vec<GpuDeviceInfo>

Enumerate available GPU adapters and return info about each.

Source

pub fn try_init_with_name(name_pattern: &str) -> Option<Self>

Try to initialise with a specific adapter selected by name substring match (case-insensitive).

Source

pub fn try_init_with_index(index: usize) -> Option<Self>

Try to initialise with a specific adapter by index.

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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.