pub struct Device { /* private fields */ }Expand description
A WebGPU device that renderers on any thread share: the library’s, or the host’s. Clones share it.
Implementations§
Source§impl Device
impl Device
Sourcepub fn new(adapter_index: Option<usize>) -> Result<Device, Error>
pub fn new(adapter_index: Option<usize>) -> Result<Device, Error>
The library’s device, on the adapter at adapter_index in
wgpu::Instance::enumerate_adapters order, or on the
high-performance adapter when None. It logs the adapter it is on,
and its uncaptured errors.
Fails with ErrorKind::NotFound when there is
no adapter at adapter_index, with
ErrorKind::Unsupported when there is no
adapter at all, and with ErrorKind::Native
when the adapter can’t create the device.
Sourcepub fn from_wgpu(
instance: Option<Instance>,
device: Device,
queue: Queue,
surface_format: Option<TextureFormat>,
) -> Device
pub fn from_wgpu( instance: Option<Instance>, device: Device, queue: Queue, surface_format: Option<TextureFormat>, ) -> Device
The host’s device and queue. Window surfaces need the instance that
made the device. A surface on it is configured with the format that
its options name, or else with surface_format, which it must
support. The host keeps the device’s uncaptured-error and device-lost
handlers.
pub fn device(&self) -> &Device
pub fn queue(&self) -> &Queue
pub fn instance(&self) -> Option<&Instance>
Sourcepub fn lost(&self) -> Option<&str>
pub fn lost(&self) -> Option<&str>
Why the device was lost, once the library’s device is: a browser loses it when the GPU process resets or can’t present. The host’s device keeps its own device-lost callback, and reports nothing here.
Sourcepub fn adapter_info(&self) -> AdapterInfo
pub fn adapter_info(&self) -> AdapterInfo
The adapter the device is on (name, backend, driver).