Skip to main content

GpuContext

Struct GpuContext 

Source
pub struct GpuContext {
    pub instance: Instance,
    pub adapter: Adapter,
    pub device: Device,
    pub queue: Queue,
}
Expand description

A wgpu instance, adapter, device and queue.

Fields§

§instance: Instance

The instance.

§adapter: Adapter

The adapter.

§device: Device

The device.

§queue: Queue

The queue.

Implementations§

Source§

impl GpuContext

Source

pub fn headless() -> Result<Self, RenderError>

A context without a window, for offscreen rendering. Blocks until the adapter and device are ready (native only; use request on the web).

§Errors

RenderError::Backend if no adapter or device is available.

Source

pub fn with_instance( instance: Instance, surface: Option<&Surface<'_>>, ) -> Result<Self, RenderError>

Blocking request (native only: on the web the adapter and device are JS promises that only resolve after returning to the event loop).

§Errors

RenderError::Backend if no adapter or device is available.

Source

pub async fn request( instance: Instance, surface: Option<&Surface<'_>>, ) -> Result<Self, RenderError>

A context on instance whose adapter can present to surface (if given).

§Errors

RenderError::Backend if no adapter or device is available.

Source

pub async fn from_adapter( instance: Instance, adapter: Adapter, ) -> Result<Self, RenderError>

A context on an adapter obtained from instance.

Device limits, with the adapter’s texture sizes: the downlevel defaults (storage buffers, compute shaders) when the adapter supports compute shaders, otherwise the WebGL2 downlevel defaults. The built-in pipelines only use WebGL2-level features either way; the higher limits are for native plugins such as the order flow heatmap.

§Errors

RenderError::Backend if the device cannot be created.

Trait Implementations§

Source§

impl Debug for GpuContext

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,