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
impl GpuContext
Sourcepub fn try_init() -> Option<Self>
pub fn try_init() -> Option<Self>
Try to initialise a GPU context.
Returns None when:
- The
gpufeature is not enabled. - No compatible wgpu adapter exists on the current host.
- The device-request step fails (e.g. out-of-resources).
Sourcepub fn enumerate_devices() -> Vec<GpuDeviceInfo>
pub fn enumerate_devices() -> Vec<GpuDeviceInfo>
Enumerate available GPU adapters and return info about each.
Sourcepub fn try_init_with_name(name_pattern: &str) -> Option<Self>
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).
Sourcepub fn try_init_with_index(index: usize) -> Option<Self>
pub fn try_init_with_index(index: usize) -> Option<Self>
Try to initialise with a specific adapter by index.
Auto Trait Implementations§
impl Freeze for GpuContext
impl RefUnwindSafe for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl UnsafeUnpin for GpuContext
impl UnwindSafe for GpuContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more