pub struct GpuContext {
pub device: Device,
pub queue: Queue,
pub target_format: TextureFormat,
pub faults: FaultSink,
/* private fields */
}Expand description
GPU handles that a host passes to the engines, with the sink for errors no scope catches.
A clone is cheap, and shares the fault sink and the record of a lost device.
Fields§
§device: DeviceDevice every model builds on.
queue: QueueQueue the engine submits its work to.
target_format: TextureFormatColour format of the target a display pipeline renders into.
A model builds its display render pipeline once, at construction, and a pipeline is tied to its colour target format.
faults: FaultSinkSink for errors that nothing else caught. See GpuContext::new.
Implementations§
Source§impl GpuContext
impl GpuContext
Sourcepub fn new(
device: Device,
queue: Queue,
target_format: TextureFormat,
faults: FaultSink,
) -> Self
pub fn new( device: Device, queue: Queue, target_format: TextureFormat, faults: FaultSink, ) -> Self
Creates a context over device and queue, and takes over the device’s error handling. Left to wgpu, every
error is fatal.
Errors raised inside a fault::catching_on go to that scope. Everything else, including
egui’s own rendering on the same device, is stored in faults for the host to pick up. On the
web this is the only route. fault::catching_on pushes no scopes there.
A GPUInternalError still ends the web build. wgpu converts an error with
Error::from_js. Anything other than a GPUValidationError or a GPUOutOfMemoryError
panics there. A model provokes those two, and the handler reports them normally.
The context also records the loss of the device. Self::is_lost reports it.
Note that a second new on the same device takes over the error handler from the first context, and on native
targets the lost callback too. From then on only the newest context receives the device’s unscoped errors, and
on native targets its loss. In a browser every context on the device records the loss. A clone shares the fault
sink and the loss record with the context it came from.
The context carries no RuntimeInfo. A host that passes its context to a sweep attaches one with
.with_runtime_info(RuntimeInfo::collect(&adapter, &device)). Without it the sweep’s manifest records no
adapter.
Sourcepub fn with_runtime_info(self, info: RuntimeInfo) -> Self
pub fn with_runtime_info(self, info: RuntimeInfo) -> Self
Returns the context with info attached, as Self::runtime_info reads it back.
Sourcepub fn runtime_info(&self) -> Option<&RuntimeInfo>
pub fn runtime_info(&self) -> Option<&RuntimeInfo>
Facts about the host and the adapter, None when nothing attached them.
Trait Implementations§
Source§impl Clone for GpuContext
impl Clone for GpuContext
Auto Trait Implementations§
impl !RefUnwindSafe for GpuContext
impl !UnwindSafe for GpuContext
impl Freeze for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl UnsafeUnpin for GpuContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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