Skip to main content

NullInstance

Struct NullInstance 

Source
pub struct NullInstance { /* private fields */ }
Expand description

A no-op, recording Instance.

Share its Recorder with NullInstance::with_recorder to inspect the stream after running a frame entirely through dyn traits.

Implementations§

Source§

impl NullInstance

Source

pub fn new(caps: DeviceCaps) -> Self

A null instance reporting one adapter with caps.

Source

pub fn with_geometry_preference(self, path: GeometryPath) -> Self

Prefers a supported geometry tail while retaining the capability ceiling. If a device request omits that tail’s feature, uses its granted ceiling.

§Panics

Panics if this instance’s capabilities cannot run path.

Source

pub fn gpu_driven() -> Self

A full desktop device: everything in Features::GPU_DRIVEN — bindless, buffer device address, draw_indirect_count, multi-draw, compute, timeline semaphores — plus push constants, timestamps, the other query kinds and a draw index.

Features::DRAW_INDEX is outside the default request, like Features::POLYGON_MODE_LINE: a device opened with DeviceDesc::for_adapter is not granted it, and a test that wants a renderer drawing a range of buckets per call asks for it by name.

Not mesh shaders and not ray tracing: those are separate selector axes, and a preset that held every flag would leave GeometryPath::MeshShader as the only answer any test could get.

Source

pub fn portable() -> Self

The floor every backend clears, shaped like WebGPU: compute only.

No descriptor indexing, no buffer device address, no draw_indirect_count, no multi-draw, no push constants, no timeline semaphores, and — the shape that matters most — an implicit swapchain acquire, so AcquiredFrame comes back with no semaphores at all. Every selector lands on its lowest value here. Renderer code that works against both presets works against crcbl-vk and crcbl-webgpu.

Source

pub fn with_present_feedback(self) -> Self

This instance’s adapter, plus Features::PRESENT_FEEDBACK.

Neither preset advertises it and neither should: there is no display under this backend, so an adapter that claimed by default to observe presents would be telling every test that opened one something untrue. But the capability is the switch on the seam’s two answers for Device::wait_until_presented — without it the wait must return Ok at once, with it the wait may lapse — so a caller’s timed-out-wait path needs a device that claims it, and until this existed such a device had to be assembled from DeviceCaps by hand in each test that wanted one.

Claiming it is only half of what makes a wait lapse: nothing here is slow, so the timeout itself comes from Recorder::report_present_wait_timeouts. And this is the adapter’s capability, so a device still gets it only by asking, as it would from a real backend.

Source

pub fn with_adapters(self, count: u32) -> Self

Reports count adapters instead of one, all with this instance’s caps, each named with its index once there is more than one to tell apart.

The switch on the seam’s adapter selection loop, which needs more than one adapter before it is a loop at all. crcbl/src/engine.rs’s start_device walks the list asking each adapter for SurfaceCaps and takes the first that answers, because crates/crcbl/tests/windowed_e2e.rs found a discrete RADV GPU that enumerates first under Xvfb and cannot present to the window at all while the software rasteriser behind it can. With one adapter that walk has one outcome, so neither “the first refused and the second served” nor “every one refused” could be driven from any backend here.

Reporting more than one is only half of it: nothing here makes an adapter refuse, so the refusal comes from Recorder::refuse_surface_on. The adapters are otherwise identical — same caps, same DeviceType::Cpu — because this backend has one set of capabilities and an adapter here claiming to be a discrete GPU would be telling every test that opened one something untrue.

count may be 0, which is a real state a real instance reaches — a machine with no GPU, a browser with no WebGPU — and the one the engine answers with “no adapter” before it walks anything.

Source

pub fn with_recorder(self, recorder: Recorder) -> Self

Uses recorder instead of this instance’s own, so a caller can keep a handle on the stream after the instance is boxed as dyn Instance.

Source

pub fn recorder(&self) -> Recorder

A clone of this instance’s recorder.

Trait Implementations§

Source§

impl Clone for NullInstance

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NullInstance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Instance for NullInstance

Source§

fn backend(&self) -> BackendKind

Which backend this is. For logs and bug reports — never for behaviour.
Source§

fn adapters(&self) -> Vec<AdapterInfo>

Every adapter this backend can see, with its capabilities already filled in so selection logic never has to open a device to reject one.
Source§

unsafe fn create_surface( &self, target: &SurfaceTarget, ) -> Result<SurfaceHandle, HalError>

Creates a presentation surface from a shell’s native window handles. Read more
Source§

fn destroy_surface(&self, surface: SurfaceHandle)

Invalidates surface’s handle. A swapchain already on it goes on working. Read more
Source§

fn surface_caps( &self, surface: SurfaceHandle, adapter: AdapterId, ) -> Result<SurfaceCaps, HalError>

What surface supports on adapter. Read more
Source§

fn request_device( &self, desc: &DeviceDesc<'_>, ) -> Result<Box<dyn PendingDevice>, HalError>

Starts opening a device. The device itself arrives from PendingDevice::poll. Read more
Source§

fn create_device( &self, desc: &DeviceDesc<'_>, ) -> Result<Box<dyn Device>, HalError>

Opens a device, blocking until it is ready. Read more

Auto Trait Implementations§

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.