Skip to main content

Ctx

Struct Ctx 

Source
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: DeviceTier

The 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: Device

The device every resource in a test is created on.

§queue: Queue

The queue a test’s writes and submissions go through.

§capabilities: DeviceCapabilities

What 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

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more