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
impl NullInstance
Sourcepub fn new(caps: DeviceCaps) -> Self
pub fn new(caps: DeviceCaps) -> Self
A null instance reporting one adapter with caps.
Sourcepub fn with_geometry_preference(self, path: GeometryPath) -> Self
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.
Sourcepub fn gpu_driven() -> Self
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.
Sourcepub fn portable() -> Self
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.
Sourcepub fn with_present_feedback(self) -> Self
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.
Sourcepub fn with_adapters(self, count: u32) -> Self
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.
Sourcepub fn with_recorder(self, recorder: Recorder) -> Self
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.
Trait Implementations§
Source§impl Clone for NullInstance
impl Clone for NullInstance
Source§impl Debug for NullInstance
impl Debug for NullInstance
Source§impl Instance for NullInstance
impl Instance for NullInstance
Source§fn backend(&self) -> BackendKind
fn backend(&self) -> BackendKind
Source§fn adapters(&self) -> Vec<AdapterInfo>
fn adapters(&self) -> Vec<AdapterInfo>
Source§unsafe fn create_surface(
&self,
target: &SurfaceTarget,
) -> Result<SurfaceHandle, HalError>
unsafe fn create_surface( &self, target: &SurfaceTarget, ) -> Result<SurfaceHandle, HalError>
Source§fn destroy_surface(&self, surface: SurfaceHandle)
fn destroy_surface(&self, surface: SurfaceHandle)
surface’s handle. A swapchain already on it goes on
working. Read moreSource§fn surface_caps(
&self,
surface: SurfaceHandle,
adapter: AdapterId,
) -> Result<SurfaceCaps, HalError>
fn surface_caps( &self, surface: SurfaceHandle, adapter: AdapterId, ) -> Result<SurfaceCaps, HalError>
Source§fn request_device(
&self,
desc: &DeviceDesc<'_>,
) -> Result<Box<dyn PendingDevice>, HalError>
fn request_device( &self, desc: &DeviceDesc<'_>, ) -> Result<Box<dyn PendingDevice>, HalError>
PendingDevice::poll. Read more