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: InstanceThe instance.
adapter: AdapterThe adapter.
device: DeviceThe device.
queue: QueueThe queue.
Implementations§
Source§impl GpuContext
impl GpuContext
Sourcepub fn headless() -> Result<Self, RenderError>
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.
Sourcepub fn with_instance(
instance: Instance,
surface: Option<&Surface<'_>>,
) -> Result<Self, RenderError>
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.
Sourcepub async fn request(
instance: Instance,
surface: Option<&Surface<'_>>,
) -> Result<Self, RenderError>
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.
Sourcepub async fn from_adapter(
instance: Instance,
adapter: Adapter,
) -> Result<Self, RenderError>
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.