#[non_exhaustive]pub enum Device {
WebGpu(Device),
Vulkan(Device),
Gl(Device),
}Expand description
A GPU that sessions on many maps and threads share: one backend’s device. Sessions on it keep working after the last handle drops, until they detach.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
WebGpu(Device)
A WebGPU device: the library’s, through wgpu, or the host’s
(Device::webgpu). In the browser, the browser’s
(Device::request_web_gpu).
Vulkan(Device)
A Vulkan GPU.
Gl(Device)
An OpenGL share group, or the one context that its sessions take turns in.
Implementations§
Source§impl Device
impl Device
Sourcepub fn new(options: DeviceOptions) -> Result<Device, Error>
pub fn new(options: DeviceOptions) -> Result<Device, Error>
The library’s device, on the platform’s native backend: Metal on
Apple’s platforms, and Vulkan elsewhere, then D3D12 on Windows, or
OpenGL where there is neither. WebGPU (wgpu) takes the place of a
native backend that isn’t there. A backend that can’t name the GPU
that options names is skipped: only Vulkan names one by UUID, and
only Vulkan and D3D12 by LUID. OpenGL lists one GPU, the one its
display renders on, at index 0.
So is OpenGL where it can’t render with options.gl_api.
Fails with ErrorKind::NotFound when
the options name no GPU, with
ErrorKind::Unsupported when no backend has a
GPU or in the browser, where a session renders on the page’s device,
and with ErrorKind::Native when the GPU
can’t create the device.
Sourcepub fn with_backend(
backend: BackendType,
options: DeviceOptions,
) -> Result<Device, Error>
pub fn with_backend( backend: BackendType, options: DeviceOptions, ) -> Result<Device, Error>
The library’s device on backend.
Fails as new does, and with
ErrorKind::Unsupported for a backend that
isn’t in this build or on this platform.
In the browser, only OpenGL’s: Device::WebGl. The browser makes
a WebGPU device asynchronously (Device::request_web_gpu).
Sourcepub fn borrowed_sync_kinds(
&self,
ring: &BorrowedRing,
) -> Result<(SyncKinds, SyncKinds), Error>
pub fn borrowed_sync_kinds( &self, ring: &BorrowedRing, ) -> Result<(SyncKinds, SyncKinds), Error>
The kinds of sync with which the host can wait for a frame of ring
on the device (the producer’s), and with which a session waits for
the host’s reads (the consumer’s).
Fails with ErrorKind::Unsupported when the
device can’t render into the ring: one of another backend, or one the
device lacks a feature for.
Sourcepub fn depth_stencil_formats(&self) -> DepthStencilFormats
pub fn depth_stencil_formats(&self) -> DepthStencilFormats
The formats of the depth textures that a borrowed ring takes on the device.
Sourcepub fn depth_export_kinds(&self) -> ExportKinds
pub fn depth_export_kinds(&self) -> ExportKinds
The kinds of export_kinds whose rings also
share each frame’s depth texture, when they keep depth: only
ExportKind::OpaqueFd, since an IOSurface, a dmabuf or an Android
hardware buffer holds no depth format. A ring of those keeps its depth
on the device.
Sourcepub fn export_kinds(&self) -> ExportKinds
pub fn export_kinds(&self) -> ExportKinds
The kinds of exported ring that sessions on the device share their images in: those that the device has exported an image of.
Sourcepub fn export_plan(
&self,
ring: &ExportedRing,
) -> Result<(ExportKind, SyncKinds, SyncKinds), Error>
pub fn export_plan( &self, ring: &ExportedRing, ) -> Result<(ExportKind, SyncKinds, SyncKinds), Error>
The kind that a session on the device shares ring’s images in, and
the kinds of sync with which the host can wait for a frame (the
producer’s) and a session for the host’s reads (the consumer’s).
Fails with ErrorKind::Unsupported when the
device exports none of the ring’s kinds.
Sourcepub fn export_sync_kinds(&self) -> (SyncKinds, SyncKinds)
pub fn export_sync_kinds(&self) -> (SyncKinds, SyncKinds)
The kinds of sync with which the host can wait for an exported ring’s frame (the producer’s) and a session for the host’s reads (the consumer’s), on a device that exports a ring.
Sourcepub fn for_exported_ring(ring: &ExportedRing) -> Result<Device, Error>
pub fn for_exported_ring(ring: &ExportedRing) -> Result<Device, Error>
The library’s device for ring: on the first of new’s
backends whose device exports one of the ring’s kinds.
Fails with ErrorKind::Unsupported when no
backend’s device does, and as new does.
Sourcepub fn presents_to_host_surfaces(&self) -> bool
pub fn presents_to_host_surfaces(&self) -> bool
Whether sessions on the device present to the host’s own surfaces:
a Vulkan device’s VkSurfaceKHRs, or the EGLSurfaces of an OpenGL
device that wraps the host’s context.
Sourcepub fn presents_to(&self, surface: SurfaceType) -> bool
pub fn presents_to(&self, surface: SurfaceType) -> bool
Whether sessions on the device present to the surfaces of
surface’s type: a Vulkan device’s instance needs the type’s surface
extension, which the loader may lack.
Sourcepub fn webgpu(
instance: Instance,
device: Device,
queue: Queue,
format: TextureFormat,
) -> Device
pub fn webgpu( instance: Instance, device: Device, queue: Queue, format: TextureFormat, ) -> Device
The host’s WebGPU device and queue, which instance made. The
session configures its surfaces with format, which each surface
must support.
Sourcepub fn backend(&self) -> BackendType
pub fn backend(&self) -> BackendType
The backend the device is of.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Device
impl !UnwindSafe for Device
impl Forget for Device
impl Freeze for Device
impl Move for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnsafeUnpin for Device
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.