pub(crate) struct Gpu {
pub(crate) instance: Instance,
pub(crate) adapter: Adapter,
pub(crate) device: Device,
pub(crate) queue: Queue,
pub(crate) capabilities: DeviceCapabilities,
}Expand description
The GPU context a scene draws with, requested asynchronously.
Everything here is a Send + Sync wgpu handle, so the request can run off
the event loop’s thread and the context can cross back to it. The scene
itself cannot cross: its ECS world is single-threaded, so it is built on
the main thread once this arrives.
The context and its device outlive a suspension: rebuilding them would drop every pipeline, buffer and texture the scene holds, for a change the platform only makes to the native window.
Fields§
§instance: Instance§adapter: Adapter§device: Device§queue: Queue§capabilities: DeviceCapabilitiesWhat the device can do beyond the WebGPU baseline, captured while the adapter is still here to report it.
wgpu::Device exposes its limits and features but not the downlevel
flags, and the adapter is not kept once the device exists, so this is
read once and carried; see DeviceCapabilities.
Implementations§
Source§impl Gpu
impl Gpu
Sourcepub(crate) async fn request(
instance: Instance,
surface: Surface<'static>,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub(crate) async fn request( instance: Instance, surface: Surface<'static>, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Request the adapter and device that can present to surface.
surface is a probe: it exists only so the adapter is required to be
able to present to the window, and is dropped again before the device
is requested. The context deliberately ends up owning no surface,
because a surface is tied to the native window it was created from —
Android replaces that window across a suspension — while the adapter
and device are not. Whoever presents builds one for the window it has
at that moment.
Async because both requests resolve on the browser’s task queue on the web; blocking on them there would hang the page.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Gpu
impl !UnwindSafe for Gpu
impl Forget for Gpu
impl Freeze for Gpu
impl Send for Gpu
impl Sync for Gpu
impl Unpin for Gpu
impl UnsafeUnpin for Gpu
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> Component for Twhere
T: 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 more