pub struct Ctx {
pub tier: DeviceTier,
pub device: Device,
pub queue: Queue,
pub capabilities: DeviceCapabilities,
}Expand description
A ready-to-use GPU context.
Fields§
§tier: DeviceTierThe tier the device was requested at.
Kept beside the device because a device reports what it was given, not what was asked for: a WebGL2-shaped device on a desktop adapter has the adapter’s features and limits as lowered by the tier, which is only readable as a description when the tier is part of it.
device: DeviceThe device every resource in a test is created on.
queue: QueueThe queue a test’s writes and submissions go through.
capabilities: DeviceCapabilitiesWhat the device can do beyond the WebGPU baseline.
A DeviceCapabilities rather than the adapter it was read from: the
adapter is dropped once the device exists, and the renderer needs the
capabilities, not the adapter.
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub async fn headless() -> Ctx
pub async fn headless() -> Ctx
Create a headless GPU context with the default adapter.
UNLIT3D_DEVICE_TIER narrows the device; see Ctx::headless_for.
Asynchronous because wgpu’s adapter and device requests are: on the web
they wrap promises that only settle in a later task, and a browser has
no second thread to block on. A synchronous caller drives this through
block_on.
Sourcepub async fn headless_for(tier: DeviceTier) -> Ctx
pub async fn headless_for(tier: DeviceTier) -> Ctx
Create a headless GPU context restricted to tier.
The tier’s limits are requested from the adapter and its capabilities
are recorded beside the device, so a test can exercise the paths a
WebGL2 browser takes — no storage buffers, no base_vertex — on
hardware that has both. The adapter’s own limits and capabilities are
what DeviceTier::Native asks for; the WebGPU baseline’s, which is
what Ctx::headless uses, are what DeviceTier::WebGpu asks for.
Nothing is presented: the context is headless on the web too, where the canvas exists only because a browser will not hand out an adapter without one.
Auto Trait Implementations§
impl !RefUnwindSafe for Ctx
impl !UnwindSafe for Ctx
impl Forget for Ctx
impl Freeze for Ctx
impl Send for Ctx
impl Sync for Ctx
impl Unpin for Ctx
impl UnsafeUnpin for Ctx
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
§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