Skip to main content

ForwardRenderer

Struct ForwardRenderer 

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

Everything the forward frame owns, created once.

Implementations§

Source§

impl ForwardRenderer

Source

pub fn replace_page( &mut self, device: &dyn Device, queue: QueueHandle, kind: PageKind, page: &PageDesc<'_>, ) -> Result<(), HalError>

Replaces kind’s material page with page’s layers of that kind, in force from each frame slot’s next begin_frame.

Texture hot reload’s device half: an edited texture is re-decoded, its page rebuilt on the host, and handed here. The whole page goes up into a new image, because a copy into the image a frame in flight samples is a frame that reads some texels old and some new — and each slot’s groups move onto it at that slot’s own frame, the replaced image living until the last slot has left it. page’s extent for kind may differ from the one in force; its layer count may not, because every material row names a layer by number and those numbers have to go on meaning the same textures.

page’s other kinds are not read beyond the length check every layer gets. A kind the renderer was built with no layers of has nothing to replace, and replacing it with none is accepted and creates nothing.

A startup-path upload, as with_scene’s is: crate::texture records its own barriers and waits for the device to go idle, which is legal here because it runs between frames, outside any graph, and blocks until the copy has landed — so no frame can bind an image whose upload has not finished. See this crate’s docs on the one rule.

§Errors

HalError::InvalidDescriptor for a layer of the wrong length (the check with_scene makes) or a layer count that is not the one in force, and HalError from the upload. Either way the renderer is unchanged: the page in force stays in force.

Source§

impl ForwardRenderer

§Views

docs/plan/29-fp-rendering.md’s second camera: a view draws the scene this renderer already holds, through a camera of its own, into a target of its own — and shares every pool, page, probe and shadow map with the primary camera rather than building them again.

Source

pub fn create_view( &mut self, device: &dyn Device, queue: QueueHandle, desc: &ViewDesc, ) -> Result<ViewId, HalError>

Builds a view of this renderer’s scene and hands back its id.

What a view costs is one camera’s share of the frame and nothing else: its own cull and draw-argument buffers (sized by the instance capacity, like the primary camera’s), its frame blocks, its light clustering and the per-frame blocks of every screen-space pass. Geometry, materials, pages, probes and the shadow atlas are the scene’s, and a view reads them where they already are.

A view draws nothing until a frame begins it — see begin_view and add_passes_with_views.

§Errors

HalError::InvalidDescriptor when MAX_VIEWS views already exist, or for a ViewBackground::Transparent view whose effects name one of ViewBackground::REFUSED_ON_TRANSPARENT — a filter that would blend its coverage edges with the empty background, see that variant. And whatever the device refuses while building one — in which case nothing of the view is left behind.

Source

pub fn destroy_view(&mut self, device: &dyn Device, view: ViewId)

Releases view and hands its id back.

Every instance is drawn in the view the id names next: the bit this view hid instances with is cleared from every record, so a view created later under the same id starts from ViewMask::ALL rather than from what a view it never was had hidden.

Like destroy, the caller’s to call once no frame in flight still names the view’s buffers and groups.

§Panics

If view is ViewId::PRIMARY, which lives as long as the renderer, or names no view this renderer built.

Source

pub fn begin_view( &mut self, device: &dyn Device, view: ViewId, camera: &Camera, extent: (u32, u32), ) -> Result<(), HalError>

Writes view’s blocks for this frame, drawn through camera into a target of extent.

After begin_frame, in the same frame, which is what rotated the instance ring, skinned what moves and fitted the shadow maps: a view writes into the slot that call chose, lit by the sun it was handed and shadowed through the maps the primary camera’s frame draws — unless its ViewDesc::lighting fixes a light of its own. A view begun and then not named in add_passes_with_views records nothing.

§Errors

HalError if one of the view’s blocks could not be written.

§Panics

If view is ViewId::PRIMARY — its blocks are begin_frame’s — or names no view this renderer built, or if no frame has begun.

Source

pub fn set_instance_views(&mut self, handle: InstanceHandle, views: ViewMask)

Sets the views handle is drawn in. Every instance starts in ViewMask::ALL.

A camera’s cull and nothing else: a view the instance is hidden from rejects it before testing a bound, and every shadow map still draws it — so a weapon hidden from a scope’s view goes on casting the shadow the primary camera sees.

Not a move: the record’s transform history is left as it is, so a visibility change does not report motion. A stale handle is ignored, on set_instance’s terms.

Source

pub fn instance_views(&self, handle: InstanceHandle) -> Option<ViewMask>

The views handle is drawn in, or None for a stale handle.

Source

pub fn view_draws(&self, view: ViewId) -> &DrawGen

view’s draw generator — draws for a view other than the primary camera.

§Panics

If view names no view this renderer built.

Source§

impl ForwardRenderer

Source

pub const LOD_ERROR_BUDGET: f32 = LOD_ERROR_BUDGET

The budget this renderer selects under unless set_lod_error_budget says otherwise, and the ratio the hold budget sits at below whichever one is in force.

Public because a test that drives a camera across a level boundary has to know where the boundary is, and where it is depends on both numbers — re-deriving either in the test would be a second copy to drift.

Source

pub const LOD_HOLD_RATIO: f32 = LOD_HOLD_RATIO

Source

pub const MAX_PASSES: u32

The most passes add_passes adds to one frame.

DrawGen::MAX_PASSES per cull — the camera’s, and one per shadow cull beside it — plus LightGrid::MAX_PASSES for the froxel grid and the passes that draw. A ceiling, not a count: a frame whose shadow slots are not all filled runs fewer culls, which is what makes a free tile free.

Derived rather than written down, because a number written down is one that stops matching the frame the day a pass is added — which is exactly how the samples’ hand-picked 8 came to time the first eight passes of a fourteen-pass frame. A caller sizing PassTimers wants MAX_TIMED_PASSES, which adds this to what the overlay renderers record.

Source

pub const BASE_COLOR_PAGE_LABEL: &'static str = "base-colour-page"

What add_passes names the base-colour page in the graph.

RenderGraph::import_image keeps the label of whichever import ran first, so a caller importing the page too passes this rather than a string of its own — otherwise every barrier record and dump line would name the page differently depending on which subsystem got there first.

Source

pub const NORMAL_PAGE_LABEL: &'static str = "normal-page"

What add_passes names the normal page in the graph, on BASE_COLOR_PAGE_LABEL’s terms.

Source

pub const MRO_PAGE_LABEL: &'static str = "metallic-roughness-occlusion-page"

What add_passes names the metallic-roughness-occlusion page in the graph, on BASE_COLOR_PAGE_LABEL’s terms.

Source

pub const EMISSIVE_PAGE_LABEL: &'static str = "emissive-page"

What add_passes names the emissive page in the graph, on BASE_COLOR_PAGE_LABEL’s terms.

Source

pub fn new( device: &dyn Device, queue: QueueHandle, target_format: Format, ) -> Result<Self, HalError>

Builds both pipelines and makes scene::demo resident.

ForwardRenderer::with_scene with the engine’s own description, and nothing else — so the frame this draws is the one the golden suite has always compared, and every existing caller is untouched.

target_format must be the format the tonemap pass will render into — dynamic rendering checks pipeline and attachment formats against each other at pass-begin time, not at creation.

§Errors

HalError, on ForwardRenderer::with_scene’s terms.

Source

pub fn with_scene( device: &dyn Device, queue: QueueHandle, target_format: Format, scene: &SceneDesc<'_>, ) -> Result<Self, HalError>

Builds both pipelines and makes scene resident.

Everything in the description is created here and never grows: the geometry pools, the cluster pool, the material table, the page, the instance array and the bucket table are all sized and filled once. See crate::scene for why that split is where the seam is, and for the four places a description’s order decides what the frame looks like.

target_format must be the format the tonemap pass will render into — dynamic rendering checks pipeline and attachment formats against each other at pass-begin time, not at creation.

§No description is too small

One mesh and one material row is a scene, and so is scene::demo’s four and three. Nothing on this type names a description entry by position any more — the five set_* demo wrappers that did are gone, and ForwardRenderer::add_instance takes the mesh and the row a caller wrote its own description in.

§Errors

HalError::InvalidDescriptor if the description cannot be made resident as written: a page layer that is not its kind’s extent’s worth of RGBA8, a page kind holding layers at no extent, a material row naming a layer that kind’s page has not got, a DAG carrying a vertex array for anything but each of its levels, a cluster array with a read outside itself in it (see MeshClusters::check), or more vertices, indices, mesh table entries or material rows than SceneDesc::capacities reserves — that last naming the pool, the capacity and what the description needs, because the answer to it is to raise the number. Every one of those is settled before the first device object exists, so a refusal leaks nothing.

HalError otherwise, from any seam call — including the geometry a pool refuses for itself, such as vertex bytes that are not a whole number of vertices. A backend that cannot build a pipeline says so here rather than drawing nothing later, and a failure part-way through releases everything already created, so a caller that retries or exits leaves nothing behind.

Source

pub fn with_scene_serviced( device: &dyn Device, queue: QueueHandle, target_format: Format, scene: &SceneDesc<'_>, service: &mut dyn FnMut(), ) -> Result<Self, HalError>

ForwardRenderer::with_scene, calling service between the steps of the build so the thread running it can keep its window alive.

§What it is for: a build on the thread that owns the window

The build needs the device, so it runs on whichever thread holds it — for a game that is the loop thread, which also owns the window, and a desktop marks a window hung when its thread takes no message for a few seconds (see crcbl_shell::Shell::keep_alive). A game passes &mut || shell.keep_alive() here and the window keeps answering for the whole build.

§Where it is called

Where the time is, which was measured rather than guessed. With a cold driver shader cache — a player’s first launch, or the first after a driver update — pipeline creation is most of the build. Measured in 2026-09 on an RX 7900 XTX, release, building one glTF scene: 2.2 to 2.4 s on Vulkan and 1.9 to 2.2 s on D3D12 cold against 0.25 s warm, while the mesh and page uploads took about 0.1 s either way. So service runs after every mesh upload (each level of a DAG), after every page layer’s mip chain and each page’s upload, after each of the camera’s post-processing subsystems, before every mesh-pass and grass pipeline, and between the build’s other phases.

The longest gap left is one pipeline, and a pipeline cannot be split: on that scene, cold, it was the forward pass’s colour pipeline at 0.31 s on Vulkan and 0.36 s on D3D12, where the build without calls had been one gap of 2 s. Warm, the longest was about 0.04 s. A machine eight times slower under contention still calls back inside the five seconds Windows allows.

service sees nothing of the build and cannot touch the renderer or the scene. Whatever reaches the window meanwhile — input, a resize, a close request — is the caller’s to keep for later, as crcbl_shell::Shell::keep_alive does.

§Errors

ForwardRenderer::with_scene’s, on its terms: a failure part-way through releases everything already created.

Source

pub fn with_scene_on_path( device: &dyn Device, queue: QueueHandle, target_format: Format, scene: &SceneDesc<'_>, geometry_path: GeometryPath, ) -> Result<Self, HalError>

Builds exactly the requested geometry tail, independently of the device’s performance preference. Capabilities remain available to other callers.

§Errors

Returns HalError::UnsupportedFeatures before creating device objects when the requested tail lacks its required feature. Other failures follow Self::with_scene’s rollback contract.

Source

pub fn begin_frame( &mut self, device: &dyn Device, camera: &Camera, light: &DirectionalLight, extent: (u32, u32), ) -> Result<(), HalError>

Rotates to the next frame’s uniform buffer and instance buffer, writes this frame’s camera and light into the first, and uploads whatever changed into the second.

Must be called once per frame, before ForwardRenderer::add_passes. Separate from add_passes because the write happens on the CPU and the passes are recorded on the GPU timeline: fusing them would hide the ring rotation inside a function whose name says nothing about it.

It moves nothing. Every object’s transform is the caller’s, written through ForwardRenderer::set_instance whenever it changes, so the transfer this records is InstancePool::begin_frame’s delta and a frame in which nothing moved uploads no instance bytes at all. The sandbox’s spinning cube is one 80-byte write a frame because the sandbox spins it; a still scene is free.

It also writes this frame’s cull parameters — the camera’s frustum, extracted from the very same view-projection the uniform block carries, so the pass that decides what is on screen and the pass that draws it cannot be looking at two different cameras — and zeroes the counters the two compute passes only ever add to. See crate::draw_gen on why those zeroes come from the host.

§Errors

HalError if the uniform buffer, the instance buffer or any of the draw-generation buffers could not be written.

Source

pub fn begin_skinned_frame( &mut self, device: &dyn Device, skinning: &mut Skinning, ranges: &[SkinRange<'_>], camera: &Camera, light: &DirectionalLight, extent: (u32, u32), ) -> Result<(), SkinningError>

begin_frame for a frame that skins: the same call with the skinning plan folded into it.

It does four things in the one order that is correct, which is why it is a call and not a note in someone’s docs:

  1. rotates the instance ring, so the frame slot exists;
  2. hands that slot and ranges to skinning, which validates them, uploads the palettes and moves the ping-pong — the only place the parity ever moves;
  3. points every object placed by add_skinned_instance at the half of its region the parity now names;
  4. uploads the instance delta, so those bases are the ones this frame draws.

Do those three and four in the other order and the objects carry the previous frame’s half — a character posed one frame late, every frame, with nothing to report it. A caller never sees a parity or a table id, and so cannot get that wrong.

Build ranges with SkinnedMesh::skin_range, one per reserved region this frame animates. A frame with no skinned object still calls this with an empty slice — see Skinning::begin_frame, whose slot would otherwise re-dispatch whichever frame last used it.

add_skinned_passes is the other half, and the one that orders the dispatch before the draws.

§Errors

Whatever Skinning::begin_frame refuses — a joint index past its palette, a binding count that is not the region’s vertex count, more than the pass was built for — and SkinningError::Hal for anything the seam refused, this renderer’s own uniform and instance writes included.

§Panics

If skinning was not built with at least FRAMES_IN_FLIGHT frames: its rings are indexed by this renderer’s frame slot, and Skinning::begin_frame refuses a slot it has no buffers for.

Source

pub fn add_instance( &mut self, desc: &InstanceDesc, ) -> Result<InstanceHandle, InstancePoolError>

Puts an object in the scene and returns the handle that names it.

An instance in the pool is an object in the scene: the frame records a fixed number of draws and the cull pass decides which instances they walk, so adding one costs a slot in an array and not a command. It is drawn from the next ForwardRenderer::begin_frame, which is what uploads it.

§The index it lands at is not decoration

draw_gen.slang keys topic 25’s hysteresis state by the instance’s array index, at instance_index * group_stride, and mesh_cluster.slang’s amplification stage reads the same address. So the record of which of a DAG’s groups an object had expanded belongs to the slot, not to the object — and a slot that remove_instance freed is handed to the next add_instance, which inherits it. What that costs is one frame selected against a history that is not this object’s, and the next frame’s own judgement replaces it; it is never a wrong picture, because every group is judged afresh whatever the state said.

That inheritance is inert while the scene holds one instance of a DAG mesh, which is every frame the engine has drawn so far — one instance’s run has no previous occupant, and a flat mesh’s MeshLevels record names no groups at all, so nothing indexes the state for it. It stops being inert the moment an application places a second.

§A DAG mesh needs a device that can choose a level

One device shape cannot draw a Geometry::Dag mesh: a mesh stage with no amplification stage in front of it emits every cluster of the bucket, which for a DAG is every level at once — several overlapping copies of one surface. This does not refuse it, because it has no vocabulary for that refusal; a caller placing a DAG asks ForwardRenderer::selects_levels first, and places it only where that says yes. A flat mesh is unaffected on every path.

§Errors

InstancePoolError::PoolFull when the instance pool is full. It never grows — Capacities::instances is what a caller sizes it with.

§Panics

If InstanceDesc::mesh or InstanceDesc::material is past the end of the description this renderer was built from. Both are indices a caller wrote against a description it holds, so an out-of-range one is a mistake in the calling code rather than a condition the frame can be in — and the alternative is an object silently drawn as some other mesh, in some other colour.

Source

pub fn set_instance(&mut self, handle: InstanceHandle, desc: &InstanceDesc)

Rewrites the object handle names — its mesh, its material and its transform, all three.

A stale handle — one ForwardRenderer::remove_instance retired — writes nothing, rather than overwriting whatever took its slot.

Takes effect at the next ForwardRenderer::begin_frame, which uploads the element and nothing else: an object that did not move costs no transfer at all.

§Panics

On ForwardRenderer::add_instance’s terms, for the same reason.

Source

pub fn set_instance_casts_shadow(&mut self, handle: InstanceHandle, casts: bool)

Sets whether handle casts a shadow. Every instance starts casting.

Every shadow map and nothing else: an instance that casts none is rejected by the cull of the sun’s cascades and of every shadowed light, on every geometry path, so it lands in no tile of the atlas — and in no reflective shadow map, which draws those same culls’ survivors, so it bounces no light into the probes either. Every camera still draws it, and it still receives the shadows the rest of the scene casts.

What a model drawn for an icon wants, placed where the scene’s sun can see it: see ViewBackground::Transparent and set_instance_views.

A change redraws every shadow map whose cull the instance could be kept by, because it is a write InstancePool::take_written names. Not a move, on set_instance_views’ terms, and a stale handle is ignored.

Source

pub fn instance_casts_shadow(&self, handle: InstanceHandle) -> Option<bool>

Whether handle casts a shadow, or None for a stale handle.

Source

pub fn remove_instance(&mut self, handle: InstanceHandle)

Takes the object handle names back out of the scene, freeing its slot.

A removal is a cleared live bit, not a skipped draw, because the frame no longer records a draw per object: cull.slang asks whether an instance is live before it reads anything else, so removing an object and culling it off screen take the same path out of the frame. An instance left in the pool would be drawn wherever its transform put it.

A stale handle removes nothing. Takes effect at the next ForwardRenderer::begin_frame, on ForwardRenderer::set_instance’s terms.

Source

pub fn capture_probe_visibility( &mut self, device: &dyn Device, queue: QueueHandle, ) -> Result<(), HalError>

Captures a visibility map for every probe, from the static geometry standing in the scene right now.

The probe visibility rung: each probe records how far away the nearest surface is in every direction, and mesh.slang’s probe_irradiance then weighs each of a fragment’s eight probes by whether it can see that fragment — so a probe on the far side of a wall contributes nothing and a room stops lighting the room next door. This crate’s own probe_capture module is the pass, probe_visibility is the geometry it draws, and crcbl_shaders::probe_visibility is the format.

§Call it once, after the scene’s walls are placed

A description carries no instances — SceneDesc is meshes, materials, a page and the probe rows, and the objects arrive afterwards through ForwardRenderer::add_instance — so there is nothing for a capture inside ForwardRenderer::with_scene to be about. This is the call that has the room in it, and an application makes it once its static geometry is placed.

A caller that never makes it draws exactly the frame this renderer drew before the maps existed: every group names the one-texel placeholder, which no surface is further away than, and every probe keeps all of its weight.

It is a capture of geometry and not a bake of light. Nothing about the lights is recorded, every one of them still moves, and the rows the probes carry are untouched.

§What it sees, and what it does not

Every instance live in the pool when it is called, at the transform it then has, rasterised from its mesh’s level-0 triangles into six 90° faces per probe. Objects that move afterwards keep the occlusion they had here, which is the accepted limit this technique has everywhere it is used — a probe volume is about the walls. Recapturing after a wall moves is this call again.

The device must be idle. The previous capture’s image is released here, and a frame in flight may still be reading it.

§Errors

HalError from the capture. The previous maps are kept on the failing path, so a renderer that has captured once and then failed goes on drawing with what it had.

Source

pub fn follow_probe_volume( &mut self, device: &dyn Device, queue: QueueHandle, point: [f32; 3], ) -> Result<u32, HalError>

Re-centres the irradiance clipmap on point by whole probe steps, and captures the probes the step exposed.

The irradiance probes’ scrolling: each level moves a whole number of its own probe spacings towards point, so the probes that stay inside it stand exactly where they stood and go on being addressed at the rows they already had — and only the slabs the step brought in are captured. Answers how many rows that was, which is zero for the ordinary frame: the point has to travel half a probe spacing before the nearest whole step changes at all.

ProbeVolume::follow is the rule and exposed beside it is the invalidation; this is the two of them plus the device work they imply — the visibility maps of the exposed rows, and the position table the reflective-shadow-map gather reads.

§A volume authored to cover its whole world does not move

The steps are the ones that centre a level on point, and a caller whose volume is already the world it is in wants none of them — so a caller passes the point it wants the centre at rather than the camera outright when the two differ. apps/lantern and apps/shard are that case and their own modules say so.

§A step stalls, and a frame that does not step costs a comparison

The recapture is ForwardRenderer::capture_probe_visibility’s pass over fewer rows, and it waits on Device::wait_idle exactly as that one does — so a step drains the device before it rewrites anything and leaves it drained. That is a stall, and it is why the probe records price a step separately from a frame. A call that steps nothing returns before the wait, so the ordinary frame pays a rounding per level and per axis and nothing else.

It may therefore be called from a frame loop, but not after ForwardRenderer::begin_frame has been called for the frame being recorded: the header it moves is the one that frame’s uniform block has already been written from.

A renderer that has never captured re-centres the header and captures nothing: there is no image to write slabs into, every group still names the placeholder, and the first ForwardRenderer::capture_probe_visibility covers the scrolled volume whole.

§It moves the geometry and not the light

What a step re-captures is the visibility of the probes it exposed, which is what the maps are about. The rows are not touched, so under ProbeUpdate::Authored a probe that a step brought in keeps the irradiance the probe that left had — authored for somewhere else. A volume that scrolls therefore wants ProbeUpdate::EveryFrame, whose gather refills every row from the scene each frame and has no such gap; docs/backlog.md carries what an authored one would need instead.

§Errors

HalError from the recapture or from the position rewrite. The volume keeps the steps it had on either failing path, so a renderer that could not capture a slab does not go on drawing with rows about somewhere else.

Source

pub const fn probe_volume(&self) -> ProbeVolume

Where the irradiance clipmap stands right now — the header the frame block carries, ForwardRenderer::follow_probe_volume’s scroll included.

Source

pub const fn vertex_buffer(&self) -> BufferHandle

The vertex pool every mesh here is resident in — what SkinningDesc::vertices takes.

The skinning pass reads a bind pose out of this buffer and writes the deformed vertices back into another run of it, which is what makes a skinned draw an ordinary draw. It must be this pool’s buffer: a Skinning built against any other writes vertices no draw here can reach.

Source

pub const fn attribute_base(&self) -> u32

Where that pool’s attribute region begins, in words — what SkinningDesc::attribute_base takes.

The buffer holds two streams, so a pass that writes it needs the boundary as well as the handle; a Skinning built with the wrong one writes a mesh’s attributes over another mesh’s positions. See MeshPool::attribute_base.

Source

pub fn reserve_skinned( &mut self, mesh: usize, ) -> Result<SkinnedMesh, MeshPoolError>

Reserves a skinned region for description mesh mesh.

The whole of what a caller needs to skin something, in one value: hand SkinnedMesh::skin_range a palette and a set of bindings to get the frame’s SkinRange, hand the result to begin_skinned_frame, and place it with add_skinned_instance. The bases and the parity never have to be spelled by the caller at all — see crate::skinning::SkinnedMesh, where the ping-pong lives.

The mesh keeps its own entry and the region takes none, so the same description mesh can be drawn skinned through this and in its bind pose through add_instance in the same frame, both resolving through the one table entry it already had.

Give it back with release_skinned.

§Errors

Whatever SkinnedMesh::reserve refuses: a vertex pool with no room for both halves. Two vertex runs per skinned primitive is what a scene’s Capacities has to have been sized for.

§Panics

If mesh is past the end of the description this renderer was built from, on add_instance’s terms — and if it names a Geometry::Dag, which cannot be drawn out of a skinned region at all. A DAG is refused rather than skinned wrongly: its coarser levels are separate vertex runs no dispatch writes, so a cut that descended past level 0 would draw whatever the pool happened to be holding there.

Source

pub fn release_skinned(&mut self, skinned: SkinnedMesh)

Gives skinned’s region back to the vertex pool.

The device must not still be drawing it: this records no barrier, on SkinnedMesh::release’s terms. Objects placed through it are not removed — remove_instance is what does that, and an instance left behind goes on drawing its source mesh’s geometry out of vertices the pool has handed back. Remove the objects first.

Source

pub fn add_skinned_instance( &mut self, desc: &SkinnedInstanceDesc<'_>, ) -> Result<InstanceHandle, InstancePoolError>

Places a skinned object in the scene.

add_instance with a reserved region in place of a description mesh. The renderer keeps the object in a list of its own and re-points it every begin_skinned_frame at the half of the region that frame’s dispatch fills, so the parity is never something a caller writes.

A skinned object driven by plain begin_frame is therefore left pointing wherever it last was, which after the first frame is the pose of the frame before — the reason the two entry points are separate calls rather than a flag.

§Errors

InstancePoolError::PoolFull, on add_instance’s terms.

§Panics

If SkinnedInstanceDesc::material is past the end of the description this renderer was built from, on add_instance’s terms.

Source

pub fn set_skinned_instance( &mut self, handle: InstanceHandle, desc: &SkinnedInstanceDesc<'_>, )

Rewrites the skinned object handle names — its region, its material and its transform.

set_instance for an object placed by add_skinned_instance, and the call a character’s transform changes through. A stale handle writes nothing.

Passing a handle this renderer has never seen skinned adopts it: the object joins the re-pointed list from here on. That is what lets a caller swap a bind-pose instance over to a region without removing and replacing it.

§Panics

On add_skinned_instance’s terms.

Source

pub fn set_lights(&mut self, lights: &[Light])

The lights in the frame beside the sun, which begin_frame still takes on its own.

Topic 44’s light list, minus its first row: the sun is row 0 of every frame’s list and the ones set here follow it, in the order given. That order is the one a froxel keeps a prefix of when it runs out of budget — see ForwardRenderer::light_capacity and the overflow counter beside it — so it is a caller’s lever and not an accident.

The sun keeps a parameter of its own because it is the light that owns the ambient term and the shadow cascades, neither of which a Light has. What it stopped being is a special case in the shader, which is what the list bought.

Takes effect at the next begin_frame, which is what uploads the rows.

§Panics

If there are more lights than ForwardRenderer::light_capacity leaves room for once the sun has its row. Refused rather than truncated: a light missing from the list is missing from every froxel, and no counter in the frame would report it — the overflow counter counts what a froxel’s budget refused, which is a different number.

Source

pub const fn light_capacity(&self) -> u32

Rows the light list holds, the sun’s included.

Source

pub const fn grid(&self) -> Grid

This frame’s froxel grid, as begin_frame sized it from the viewport and the camera.

Exposed for the reason lod_params is: a test that wants to know which froxel a point was shaded out of has to use the grid the frame really used, and re-deriving it would be a second copy of the arithmetic rather than a reading of the first.

Source

pub fn light_grid_buffer(&self, frame: usize) -> BufferHandle

frame’s froxel grid buffer, for a test copying out what the clustering pass decided.

§Panics

If frame is not a slot this was built with.

Source

pub const fn set_lod_error_budget(&mut self, budget: f32)

The pixel budget the descent compares a group’s projected error against.

One pixel until this is called — see the constant this crate keeps it in. Larger is coarser: a group projecting over the budget is expanded and its children are drawn, so raising it stops the descent higher up the DAG.

Takes effect at the next begin_frame, which is what writes it into the frame block.

Source

pub const fn set_lod_hold_ratio(&mut self, ratio: f32)

How far below the budget an already-expanded group is held before it collapses again — topic 25’s hysteresis, as a fraction of the budget.

LOD_HOLD_RATIO until this is called. A ratio of one removes the band, which makes the two budgets equal and the previous frame’s answer stop mattering — the setting a test uses to show that the band is what stops a drifting camera flickering, on the same code path and one number apart.

Takes effect at the next begin_frame, which is what writes it into the two params blocks.

Source

pub const fn lod_params(&self) -> [f32; 3]

What the last begin_frame handed the descent: pixels per unit at one unit from the eye, and the pixel budget.

Pixels per unit at one unit from the eye, the budget an unexpanded group starts expanding over, and the budget an expanded one is held down to.

What ClusterDag::expand takes, so a caller reading cluster_selection back can run the same frames host-side rather than re-deriving the numbers from the camera and hoping they agree. [0.0, 0.0, 0.0] before the first frame.

Source

pub const fn shadow_lod_params(&self) -> [f32; 3]

The same three numbers the shadow cascades selected under, which is lod_params with both budgets multiplied by SHADOW_LOD_BIAS — topic 25’s shadow LOD bias, as the parameters it actually reaches the GPU as.

The pixels-per-unit is the camera’s, unchanged, because the cascades select from the camera’s eye at the camera’s scale; see begin_frame. [0.0, 0.0, 0.0] before the first frame.

Source

pub fn cluster_range(&self, mesh: usize) -> Option<ClusterRange>

Where description mesh mesh’s clusters are in the cluster pool — every level of it, as one run — or None off the mesh path, where there is no cluster pool at all.

The base a reader adds a (level, cluster) to in order to index cluster_selection: the levels are laid down finest first and contiguously, so level d cluster c is at base + (clusters of levels below d) + c. A flat mesh is one level, so its run is its clusters and c indexes it directly.

§Panics

If mesh is past the end of the description this renderer was built from, on add_instance’s terms.

Source

pub fn cluster_selection(&self, frame: usize) -> Option<BufferHandle>

The buffer frame’s amplification stage recorded its chosen cut into: one u32 per resident cluster, 1 where the cluster was drawn.

None where there is no amplification stage, which is every device that reports no Features::TASK_SHADER and every non-mesh geometry path.

This is topic 25’s observable and nothing in the frame reads it. A frame whose every cluster came from one level is a plausible picture and matches any golden blessed from it, so a golden cannot show per-cluster selection happening at all; this can. It is TRANSFER_SRC, and copying it out is the caller’s to record.

Source

pub fn shadow_selection( &self, frame: usize, cascade: usize, ) -> Option<BufferHandle>

The same, for cascade’s shadow pass: the cut that cascade’s amplification stage chose this frame.

The shadow LOD bias’ observable. A budget the cascades merely were passed is a parameter; the cut they reached under it is the behaviour, and this is the only thing that carries it out of a frame — the colour pass overwrites cluster_selection after the cascades have run. Indexed and read exactly as that buffer is, through cluster_range.

None where there is no amplification stage, and where cascade is not one of shadow::CASCADES.

Source

pub fn level_buckets(&self, mesh: usize) -> &[u32]

The buckets description mesh mesh’s levels draw through, finest first — element d is level d’s bucket, and it is empty on the mesh path.

This is the uniform cut’s observable, and it is the indirect arguments rather than a buffer of its own: draw_gen.slang scatters an instance into the bucket for the level it selected, so exactly one of these buckets comes out of a frame with a non-zero instance count and which one it is is the chosen level. A reader takes DrawGen::args_offset of each and looks at DrawIndexedArgs::instance_count.

Empty on GeometryPath::MeshShader, where a mesh is one bucket and the level is chosen per cluster instead — see cluster_selection, which is that path’s observable.

These are the buckets of the scene’s first material mode — OPAQUE in any scene that has an opaque material, since the table is every mesh’s levels once per mode the scene holds, mode by mode in DEPTH_MODES order. An instance of another mode selects the same level and lands in that level’s bucket in its own mode’s run, which this does not name; every scene in this tree that reads this accessor is all opaque, so “exactly one of these has a non-zero instance count” holds for them as it always did.

§Panics

If mesh is past the end of the description this renderer was built from, on add_instance’s terms.

Source

pub fn draw_args(&self, frame: usize) -> BufferHandle

frame’s indirect draw arguments, crcbl_shaders::draw_gen::DRAW_ARGS_SIZE bytes per bucket — what a reader of level_buckets copies out.

§Panics

If frame is not a slot this renderer was built with.

Source

pub fn camera_cull_buffers(&self, frame: usize) -> (BufferHandle, BufferHandle)

frame’s survivor list for the primary camera and the culling statistics beside it — cull.slang’s entries, tags and all, in the first DrawGen::visible_capacity words of the first buffer, and their count in word INSTANCE_SURVIVOR_WORD of the second — for a test holding the GPU’s occlusion verdicts against crate::cull’s oracle. The first buffer holds the routes and runs behind the list; see crate::draw_gen.

§Panics

If frame is not a slot this renderer was built with.

Source

pub fn cull_records(&self) -> (Vec<GpuInstance>, Vec<GpuMesh>)

What the primary camera’s cull reads, as the oracle in crate::cull takes it: every instance slot the pool has handed out, and the whole mesh table — both decoded from the host’s own copies of what was uploaded.

Source

pub fn shadow_generator(&self, cull: usize) -> &DrawGen

The generator behind shadow cull cull — a cascade’s below shadow::CASCADES, a light slot’s after — for a test reading back what a point light’s face culls kept.

§Panics

If cull is not one of the renderer’s shadow culls.

Source

pub fn occlusion_pyramid( &self, ) -> Vec<(ImageHandle, ImageViewHandle, (u32, u32))>

The primary camera’s farthest-depth pyramid — every level’s image, view and extent, level 1 first — or empty before a frame culled by occlusion.

For a test reading a level back: the images carry TRANSFER_SRC for exactly that, and they hold the last frame’s early depth once that frame has finished.

Source

pub fn add_passes<'a>( &'a mut self, graph: &mut RenderGraph<'a>, pool: &TransientPool, target: ImageId, extent: (u32, u32), ) -> ImageId

Adds the forward and tonemap passes to graph, rendering into target, and returns the HDR scene target they went through.

target is normally the imported swapchain image. Everything else — the HDR scene colour, the depth buffer, and every barrier between them — is the graph’s.

The returned ImageId is the Rgba16Float frame the tonemap read: the scene colour with the screen-space reflections already added, not the target the forward pass wrote. A caller that wants to add a pass of its own after the tonemap — a debug overlay, or a readback proving the HDR range is real — declares a read of it and the graph works out the transition, exactly as it does for the tonemap.

The two are the same description and different images, which is the design’s off-switch as data rather than as a branch: a frame with RenderEffects::REFLECTIONS off adds neither pass, returns the forward pass’s own id, and is bit-identical.

§Which passes this adds is effects

Resolved by the begin_frame that opened this frame and read here — see crate::effects for the four layers and for what each toggle removes. Every effect is on by default, which is the frame every caller drew before the toggles existed.

A switched-off effect is fewer passes and one different bound descriptor, never a shader permutation: the shadow atlas keeps its reversed-Z clear and reads as fully lit, the occlusion binding falls back to the renderer’s white 1×1, and the reflection pair simply is not there.

§The ground grid comes last, and after the tonemap

set_ground_grid is what puts it in the frame, and it is off by default. When it is on, its pass is added after the tonemap and writes target rather than the HDR scene colour, depth-tested against the scene depth: the grid is reference chrome, and a grid drawn before the tonemap would be exposed and tonemapped like geometry, so its colour would move with how bright the scene is. See crate::grid.

§pool is where the shadow atlas’s incoming state comes from

It must be the same pool the caller is about to compile and execute against, because the atlas and its placeholder are imports this renderer owns across frames and the pool’s ledger is the record of what the last executed graph left them in — TransientPool::imported_image_use, with None read as ResourceState::Undefined. Reading it here rather than carrying a field of our own is what keeps the declaration and the audit (InitialClaim::Tracked) one answer instead of two that drift: a frame whose compile fails is a frame that never ran, and a field advanced at build time would already have moved on without it.

Source

pub fn add_skinned_passes<'a>( &'a mut self, graph: &mut RenderGraph<'a>, pool: &TransientPool, target: ImageId, extent: (u32, u32), skinning: &Skinning, ) -> ImageId

add_passes for a frame that skins: the same frame with skinning’s dispatch in front of every pass that draws.

§This takes the pass rather than its BufferId, and that is the point

Skinning::add_pass hands back the id of the vertex pool so that a mesh pass can declare a read of it and be ordered after the dispatch. The obvious seam is therefore an id parameter here — and it is the wrong one, because every way of getting it wrong is silent. A caller can pass the id of a different import, add the skinning pass after this one, or not add it at all, and in each case the graph orders nothing, the draws read the region before the compute write has been made visible, and what comes out is a mesh that flickers between two poses on hardware and looks perfect under a validation layer.

So this takes the Skinning and adds the pass itself, first, with this renderer’s own frame slot, and declares the read on the three passes that pull vertices out of the pool — the shadow atlas, the depth prepass and the forward pass. There is no order for a caller to get right, because there is only one call.

A frame whose begin_skinned_frame was handed no ranges adds no dispatch and no declarations, and is the frame add_passes would have built.

§It records one pass more than MAX_PASSES

That constant is the bound on add_passes and stays so; the skinning dispatch is Skinning::MAX_PASSES, and MAX_TIMED_PASSES — what a caller sizes PassTimers with — already sums the two.

Source

pub fn add_skinned_passes_with_overlay<'a, F>( &'a mut self, graph: &mut RenderGraph<'a>, pool: &TransientPool, target: ImageId, extent: (u32, u32), skinning: &Skinning, overlay: F, ) -> ImageId

add_skinned_passes with one game-owned overlay inserted after the display-space frame is complete and before antialiasing or render-scale reconstruction.

The callback receives the display target and its matching scene depth attachment at the internal render extent. It may add graph passes that sample display and attach depth read-only; it must leave both images in states its declarations name. The forward renderer continues with its existing resolve and upscale passes after the callback returns.

Source

pub fn add_passes_with_views<'a, F>( &'a mut self, graph: &mut RenderGraph<'a>, pool: &TransientPool, frame: FrameTargets<'_>, overlay: F, ) -> ImageId

add_skinned_passes_with_overlay for a frame that also draws secondary views — see create_view.

The scene’s passes are recorded once: one skinning dispatch (where skinning is Some), one shadow atlas, one probe gather. Then each view in views records its own cull, clustering and frame into its own target, and the primary camera’s frame into target comes last — so overlay may read a view’s target, which is already drawn by then.

Every view named must have been begun this frame by begin_view.

§Panics

If a ViewTarget in FrameTargets::views names ViewId::PRIMARY, a view this renderer did not build, a view not begun this frame, or a view twice.

Source

pub const fn shadow_atlas_cached(&self) -> bool

Which lights hold the atlas’s light tiles this frame, and where each map was laid out.

The observable topic 45’s priority rung otherwise has none for. A map’s size leaves no trace in the picture that a golden can hold anyone to: a light demoted to a quarter of a cell draws a slightly softer shadow, which is a perfectly plausible frame and one a re-bless accepts. Selection::atlas_rect off this is what says which level the allocator actually handed out, and crates/crcbl/tests/mesh_e2e/shadow_tiles.rs is what reads it.

Named for the selection’s own subject rather than for its type, because Self::shadow_selection above is a buffer — the cut a cascade descended to — and two accessors of one name is a caller reaching for the wrong one.

It is this frame’s answer, written by Self::begin_frame: before the first frame every slot is free. Whether this frame took the shadow atlas as an earlier frame left it, rather than drawing it again.

Topic 45’s static-caching rung, read back. True means this frame recorded no shadow cull and no shadow pass, and every map sampled through Self::shadow_lights’s rectangles is the one the last frame that did draw put there — so a caller comparing two frames’ pass lists, draw counts or GPU timings has to know which of them redrew.

Decided by Self::begin_frame out of everything each group of the atlas is a function of — see ForwardRenderer::shadow_group_record — and it answers false before the first frame, because no frame has been opened and so none of them has held anything.

Whole-atlas, and since the cadence rung a frame can be neither. A frame that redraws one map and holds another answers false here and false from Self::shadow_slot_redrawn for the maps it held; the two together are what say which.

Source

pub fn shadow_cascade_redrawn(&self, cascade: usize) -> bool

Whether this frame redrew cascade cascade’s map, rather than keeping the one an earlier frame put there.

Topic 45’s cadence rung, read back. The observable that rung otherwise has none for: a held map draws a shadow lagging its caster by a frame or two, which is a perfectly plausible picture and one a golden accepts — so nothing but this distinguishes a cadence that is working from one that is not running at all.

false for a cascade past shadow::CASCADES and before the first frame, which is the same answer for the same reason: no map was drawn there.

Source

pub fn shadow_slot_redrawn(&self, slot: usize) -> bool

Whether this frame redrew the maps of light slot slot — shadow::Selection::slots’ index — rather than keeping the ones an earlier frame put there.

Self::shadow_cascade_redrawn’s answer for the light region, and a point light’s shadow::POINT_FACES faces answer together: they cull once and draw one visible set, so they are redrawn or held as one.

Source

pub const fn shadow_faces_redrawn(&self) -> u32

How many tiles of the atlas this frame redrew.

What shadow::r_shadow_faces is spent in, read back — so a test can say the budget bound rather than that it was configured. A cascade costs one and a point light’s cube costs shadow::POINT_FACES.

Source

pub const fn set_shadow_cadence(&mut self, cadence: Option<Cadence>)

Pins the shadow cadence for this renderer, or hands it back to the console.

Self::set_effect_request’s shape at this knob: shadow::r_shadow_cadence and shadow::r_shadow_faces are process-global, so they are the default rather than the only answer — an application drawing two views at two qualities, or a test that needs a frame nothing else in the process can move, pins its own.

None hands it back, which is what a renderer starts at.

Read once per Self::begin_frame, on ForwardRenderer::frame_effects’ terms: this call decides it and add_passes acts on it.

Source

pub const fn shadow_cadence_reset(&self) -> bool

Whether this frame ignored the cadence for at least one map because the region that map covers had moved out from under it.

Topic 45’s “a moving light or camera cut resets it”, made precise: a map is reset rather than merely out of date when the centre it is projected from has moved further than the map’s own reach — a light further than its own radius, or a cascade’s eye further than the sphere that cascade was fitted to. Holding such a map is not a shadow that lags; it is a shadow of somewhere else.

A frame whose atlas was relaid — a light gained, lost or resized a tile, or shadows were switched on or off — answers true as well, and that frame redraws every map it has: the only clear this seam can make covers the whole image, so there is nothing left to hold.

Source

pub const fn shadow_lights(&self) -> &Selection

Source

pub const fn shadow_atlas(&self) -> ImageHandle

The shadow atlas, for a caller that wants to read it back.

The observable this whole slice can otherwise hide behind. A shadow pass that renders nothing leaves every texel at depth::CLEAR and produces a frame in which everything is lit — which is a perfectly plausible picture and matches any golden blessed from it. Copying this image back and finding a texel that is not the clear value is what distinguishes the two.

It is created with ImageUsage::TRANSFER_SRC for exactly that, and its extent is shadow::atlas_extent.

Source

pub const fn shadow_atlas_view(&self) -> ImageViewHandle

The view shadow_atlas is bound and imported through, for a reader importing the atlas into a graph of its own.

Source

pub const fn base_color_page(&self) -> UploadedTexture

The base-colour page every material row samples through GpuMaterial::base_color_texture, as the image and the view crate::texture uploaded.

What a render-to-texture view copies into. A second camera drawing into an image is only half of a monitor: the surface that shows it samples a page layer, and nothing above this crate can name the image that layer lives in.

A caller that wants to write it wants base_color_page_import instead: the graph can only order a copy against the draws that sample the page while both are declared, and the two declarations have to agree field for field. This one is the raw handles, for a caller that binds or reads them outside a graph.

It is created with ImageUsage::TRANSFER_DST, because the upload that filled it is a copy, so a per-frame copy into it needs no new usage flag. Its extent is PageDesc::extent of PageKind::BaseColor squared and it has one layer per PageDesc::layers entry of that kind; the description is the caller’s, so the caller already knows both. A description naming no base-colour layer gets a 1×1 placeholder instead — see this module’s PAGE_PLACEHOLDER_TEXEL.

Source

pub const fn base_color_page_import(&self) -> ImportedImage

The base-colour page as this renderer declares it to a graph.

add_passes imports exactly this value under BASE_COLOR_PAGE_LABEL and declares a read of it on every pass whose bind group names the page, so a caller that writes the page — a render-to-texture view copied into one layer — gets the graph to order its write against those draws.

A caller that writes it imports this value rather than one of its own. RenderGraph::import_image hands the second importer the id the first got, which is what puts the write and the reads on one state tracker, and it does that only while the two declarations agree in every field — a disagreement is GraphError::ImportDeclarationConflict at compile. Reading the declaration off the renderer that owns the page is what makes them one answer instead of two constants that have to be kept equal by hand.

InitialClaim::Tracked with ResourceState::ShaderRead both ways: crate::texture leaves an uploaded page in that state, and the trailing barrier the final_state asks for puts it back there at the end of every frame — so the pool’s ledger and this declaration are the same answer, which is what Tracked has the graph check.

Source

pub const fn normal_page(&self) -> UploadedTexture

Topic 43 §2’s normal page, the raw handles.

base_color_page’s counterpart, on every one of its terms: one D2Array image, one layer per PageDesc::layers entry of PageKind::Normal, at that kind’s own extent, and created with ImageUsage::TRANSFER_DST so a per-frame copy into a layer needs no new usage flag. What it is not is the same format: it is Rgba8Unorm, where the base-colour page is Rgba8UnormSrgb, and topic 44’s rung 2 is where that is argued.

Source

pub const fn normal_page_import(&self) -> ImportedImage

The normal page as this renderer declares it to a graph, on base_color_page_import’s terms exactly — including that a caller writing a layer imports this value rather than one of its own, so the write and the draws land on one state tracker.

Source

pub const fn mro_page(&self) -> UploadedTexture

Topic 43 §2’s packed metallic-roughness-occlusion page, the raw handles.

normal_page’s counterpart, on every one of its terms and at the same Rgba8Unorm format: a layer of it is glTF’s occlusion, roughness and metallic in r, g and b, which are numbers rather than a colour — see this module’s MRO_PAGE_FORMAT.

Source

pub const fn mro_page_import(&self) -> ImportedImage

The metallic-roughness-occlusion page as this renderer declares it to a graph, on base_color_page_import’s terms exactly.

Source

pub const fn emissive_page(&self) -> UploadedTexture

Topic 43 §2’s emissive page, the raw handles.

base_color_page’s counterpart down to the format: an emissive texel is a colour, so this image is Rgba8UnormSrgb and the sampler decodes it — see this module’s EMISSIVE_PAGE_FORMAT.

Source

pub const fn emissive_page_import(&self) -> ImportedImage

The emissive page as this renderer declares it to a graph, on base_color_page_import’s terms exactly.

Source

pub fn spin(seconds: f32) -> Mat4

The model matrix for a cube spinning at seconds into the run.

Two axes at incommensurable rates, so the animation never repeats and every face comes into view — which is what makes “the cube is spinning” observable rather than a claim about a matrix.

Source

pub const fn target_format(&self) -> Format

The format the tonemap pass renders into.

Source

pub fn set_ground_grid( &mut self, device: &dyn Device, style: Option<GridStyle>, ) -> Result<(), HalError>

Switches the infinite ground grid on with style, or off with None.

Off by default. Every sample and every golden image predates the grid, so a renderer nobody has called this on records exactly the passes it always did — see crate::grid for what the pass is and add_passes for where in the frame it lands.

The first Some builds the pipeline and the uniform ring; later calls only replace the style, and a None leaves both built. Releasing them here would mean releasing blocks the frames in flight may still be reading, so they are released by destroy alone — the one call that already requires an idle device.

§Errors

HalError if the grid’s pipeline or its blocks could not be created. Nothing is left switched on when that happens: the grid stays as it was.

Source

pub fn debug_draw(&mut self) -> &mut DebugDraw

The debug draw layer’s immediate-mode buffer, to append to.

The UI’s debug item 5 (docs/notes/tooling.md): any system appends lines, boxes, spheres and frusta during the frame, and begin_frame uploads and clears what is there — so a segment lives exactly the frame it was appended in and nothing has to be un-appended. See crate::debug_draw for where the pass lands and for the console switch that has to be on before anything is drawn.

Appending is free while the layer is off, but building the geometry is the caller’s: a system whose overlay costs something to compute asks DebugDraw::enabled first.

Source

pub fn ground_grid(&self) -> Option<&GridStyle>

How the ground grid is drawn, or None where it is switched off.

The read-back half of set_ground_grid, and the observable a test asking “is the grid on” wants: a renderer that built the grid and then switched it off answers None, because what it draws is what the question is about.

Source

pub const fn set_exposure(&mut self, exposure: f32)

Sets the multiplier the tonemap pass applies before its clamp, clamped into EXPOSURE_MIN..=EXPOSURE_MAX.

The default is crcbl_shaders::tonemap::DEFAULT_EXPOSURE, which is the value tonemap.slang held as a compile-time constant until this became a runtime one — so a renderer nobody calls this on draws the frame it always drew, and every golden image is untouched.

It takes effect on the next begin_frame, which is what writes the block: a frame already recorded reads the value it was recorded with.

The clamp is here rather than at the call site so that no caller can reach a picture it cannot get back from, and so that a control which steps by reading this back and setting a multiple of it — which is what exposure is for — cannot wind up past the end and then need as many presses to come back.

Source

pub const fn set_exposure_adaptation( &mut self, adaptation: Option<ExposureAdaptation>, )

How far auto-exposure may travel toward its measurement in one frame.

None is the whole distance, which is what a renderer nobody calls this on does and what the pass did before adaptation existed — so no golden moved when this arrived. A view that wants the roll asks, and asks every frame, because ExposureAdaptation carries that frame’s own delta: this crate has no clock, and the frame time lives where the frame loop is.

It takes effect on the next begin_frame, which is what writes the block, and it does nothing at all on a frame that did not ask for RenderEffects::AUTO_EXPOSURE — the passes that read it are the ones that bit adds.

Source

pub const fn exposure_adaptation(&self) -> Option<ExposureAdaptation>

What set_exposure_adaptation was last handed.

Source

pub const fn set_tonemap_curve(&mut self, curve: TonemapCurve)

Which operator the tonemap pass runs on the exposed scene colour.

The ACES fit by default, because this renderer shades in linear HDR and the roll-off is what that range is for. What a caller asks for here is therefore usually the other one: tonemap.slang’s clamp is the identity on 0..=1, so display-referred content reaches the swapchain exactly, and a fixture that predicts a code value from a host model of the shading needs the frame to stay scene-referred. Every 2D sample in this tree draws through crate::sprite_pass and crate::ui_pass instead, so none of them reaches this pass at all.

It takes effect on the next begin_frame, for set_exposure’s reason: the block is written there, and a frame already recorded reads the value it was recorded with.

There is nothing to refuse and no supports_ probe beside it. The selector is a lane of a uniform block read by a branch every device already runs, so unlike the wireframe there is no second pipeline for a device to decline to build.

Source

pub const fn tonemap_curve(&self) -> TonemapCurve

The operator in force, on exposure’s terms: the value the next frame will be drawn with.

Source

pub fn set_render_scale(&mut self, scale: f32)

How large the internal render target is as a fraction of the extent begin_frame is handed, clamped to MIN_RENDER_SCALE..=1.0.

This is the largest performance knob this renderer has. Every pass before the upscale costs what its extent costs, so a scale of 0.7 is roughly half the shading work of 1.0; the UI is composited onto the target afterwards at native resolution, so text stays sharp while the 3D frame gets cheap. docs/notes/rendering.md (What the deleted 48-post-processing plan left behind) is where that trade is written down.

1.0 is not a special case with a fast path, it is the absence of the feature. At full scale the internal extent is the caller’s, the post chain writes the target directly, and no upscale pass is recorded — which is what makes a renderer nobody has called this on draw the frame it drew before the knob existed, bit for bit.

Above 1.0 is clamped away rather than supported. Supersampling wants a box or Lanczos reduction and upscale.slang is a Catmull-Rom reconstruction; running it as a minification filter would alias, which is the opposite of what a caller asking for it wants. A non-finite scale is clamped to 1.0 for the same reason a NaN extent would be refused: the failure it produces is a zero-sized target somewhere downstream.

Takes effect on the next begin_frame, on set_exposure’s terms exactly — a frame already recorded is drawn at the scale it was recorded with.

Source

pub const fn render_scale(&self) -> f32

The render scale in force, after the clamp set_render_scale applied.

The read-back half, on exposure’s terms.

Source

pub fn set_anisotropy( &mut self, device: &dyn Device, anisotropy: f32, ) -> Result<(), HalError>

The anisotropy the base-colour page is sampled with, in force from the next begin_frame.

Topic 43’s filtering rung, the player’s half: anisotropy_for is what a renderer nobody has called this on samples with, and this is what a settings row moves it to. Clamped to 1.0..=max_sampler_anisotropy where the device was granted Features::SAMPLER_ANISOTROPY and to exactly 1.0 where it was not — the row can turn the filter off or push it to the device’s ceiling, and nothing it asks reaches a create_sampler that would refuse it. A value that is not a number is the default, on set_render_scale’s terms.

A sampler is a resource a bind group holds by handle, so a new anisotropy is a new sampler, and every group of the mesh layout has to be rebuilt to name it. That happens per frame slot, at the slot’s own begin_frame, which is the moment the ring guarantees the slot’s previous submission has retired — the guarantee every host write in that call already leans on — so a frame in flight goes on naming the sampler it was recorded with, and the replaced sampler is destroyed once no slot names it. This call creates the sampler and nothing else, and asking for the anisotropy already in force creates nothing.

§Errors

create_sampler’s, and the renderer is unchanged — the sampler in force stays in force.

Source

pub const fn anisotropy(&self) -> f32

The anisotropy in force, after the clamp set_anisotropy applied.

The read-back half, on render_scale’s terms.

Source

pub fn anisotropy_for(caps: &DeviceCaps) -> f32

The anisotropy the base-colour page’s sampler is created with on a device of caps: DEFAULT_ANISOTROPY clamped to Limits::max_sampler_anisotropy where Features::SAMPLER_ANISOTROPY was granted, and 1.0 where it was not.

Granted, not supported. The feature is optional at every open site — Features::GPU_DRIVEN does not carry it — and a device opened without asking refuses a sampler above one even on hardware that has it, which is the shape every backend’s create_sampler documents. So the question is what this device was opened with, and a caller that wants the plan’s default has to name the feature beside the others it asks for. crcbl-webgpu withholds the feature and reports a ceiling of one, so a browser samples isotropically until docs/backlog.md’s ceiling decision is taken.

Source

pub const fn exposure(&self) -> f32

The exposure in force, after the clamp set_exposure applied.

The read-back half, on ground_grid’s terms: what a caller wants is the number the frame is drawn with, not the one it asked for — which is also what makes a multiplicative step land on the end of the range rather than run past it.

Source

pub fn supports_wireframe(device: &dyn Device) -> bool

Whether device can draw the wireframe view at all.

The question set_wireframe answers with an error, asked before anything is switched on — so an application can tell its user that this device has no wireframe rather than binding a key that fails, and can say so once at start-up instead of on every press. WebGPU has no line fill mode at all, so the browser is the case this exists for and not a hypothetical.

An associated function rather than a method: it is a fact about the device, and a caller wants it before it has decided anything.

Source

pub fn set_occlusion_culling(&mut self, culling: OcclusionCulling)

Asks every camera’s cull to drop what is hidden or too small to see — topic 03 §3.3’s occlusion cull and its small-feature test. See crate::occlusion_cull.

OcclusionCulling::occlusion changes no pixel: the first phase guesses from the previous frame’s depth, the second tests every rejected instance against this frame’s, and only the second’s rejections are dropped. OcclusionCulling::small_feature_pixels does change pixels, and is off unless a threshold is named.

Taken from the next begin_frame, and combined with the r_occlusion_cull and r_small_feature_px console switches — either side turning a cull on turns it on. A wireframe frame culls by the frustum alone, because a wireframe shows the edges a depth test would hide.

Source

pub fn set_point_face_culls(&mut self, on: bool)

Whether a point light’s shadow cull tags each caster with the faces of its cube it reaches, so each face draws only those — on by default.

Off is the cull this replaced: one test against the light’s box, and every caster in it drawn into all six faces for the rasteriser to clip. The two write the same atlas, texel for texel — the six faces’ pyramids tile the box, so a caster a face drops has no texel in that face’s tile — and the switch exists so a test can hold them against each other and a price can be read off both.

Source

pub fn set_shadow_view_tamper(&mut self, tamper: Option<fn(&mut FrameUniforms)>)

A test hook: from the next begin_frame, rewrites every block the shadow atlas’s depth pass is fed with tamper on its way to the GPU, or stops doing so with None — the default, and the only value a frame outside a test runs under.

Applied after the atlas cache has read the blocks, so the rewrite is invisible to the decision whether to redraw a map and visible only to the depth pass that draws it. That is what makes it a probe of the shaders: crcbl’s mesh_e2e shadow_block_reads draws the atlas with each UniformsReader::ColourOnly entry of FRAME_UNIFORMS_READERS perturbed through here and holds the depth to the untampered frame’s, bit for bit. It reaches the atlas’s views alone — not the probe updater’s shadows-off writes, which draw nothing into the atlas.

Source

pub const fn occlusion_culling(&self) -> OcclusionCulling

What set_occlusion_culling last asked for, before the console switches and the wireframe are applied.

Source

pub fn resolved_occlusion_culling(&self) -> OcclusionCulling

The culls the next frame runs: occlusion_culling with the console switches applied, and nothing on a wireframe frame.

Source

pub fn set_wireframe( &mut self, device: &dyn Device, on: bool, ) -> Result<(), HalError>

Draws the scene’s triangles as lines, or goes back to filling them.

Off by default. Every sample and every golden image predates the view, so a renderer nobody has called this on records exactly the frame it always did.

§What it is, and what it is not

The colour pass alone changes fill mode. The depth prepass and the shadow cascades keep drawing filled triangles, because they are what the occlusion pair and the shadow lookups read and depth drawn as lines is depth with holes in it. So a wireframe frame is the same geometry, the same shading and the same lights, rasterised as edges: what was inside a triangle becomes the clear colour, and what was on its edge stays lit.

§It is built on the first true

The pipeline is compiled here rather than beside the filled one at with_scene, and that is the trade this call makes: one pipeline compile on the first press — a hitch, in a view the user just asked for — against a second compile in the start-up of every sample, golden run and headless test that never asks for one. Later calls only flip the switch, and a false leaves the pipeline built, for set_ground_grid’s reason: releasing something the frames in flight may still be recording against is what destroy — which already requires an idle device — is for.

§Errors

HalError::UnsupportedFeatures naming Features::POLYGON_MODE_LINE when on is true on a device that has not got it — ask supports_wireframe first. Refused rather than quietly filled: a caller who asked for a wireframe and got a solid frame back with no error has no way to tell that from a wireframe of a solid-looking model.

HalError from the pipeline otherwise. Nothing is left switched on when either happens: the view stays as it was.

Source

pub const fn wireframe(&self) -> bool

Whether the colour pass draws lines instead of filled triangles.

The read-back half of set_wireframe, and the observable a test asking “is this frame a wireframe” wants: a renderer that built the pipeline and then switched it off answers false, because what it draws is what the question is about.

Source

pub const fn set_normals_view(&mut self, on: bool)

Draws each surface’s world-space normal instead of shading it, so a modeller can see whether the normals a document carries are sane.

Off by default, on set_wireframe’s terms: it is a tool’s view of a document, and every sample and every golden image predates it. It takes effect on the next begin_frame, which is what writes the block.

§What the colours mean

The conventional encoding, n * 0.5 + 0.5 into RGB: +X reads red, +Y green, +Z blue, and a face whose winding was inverted reads the complement of the colour it should have. A missing or degenerate normal reads as whatever the vertex data actually holds rather than as the plausible shading a light would have given it, which is the point.

§World space, not view space

The two diagnose different things and this one is world space, so a face keeps its colour while the camera orbits: “is this face inverted” is then something a modeller sees, instead of inferring it from a picture that re-colours whenever they move. View-space normals answer the other question — is this normal smooth, is this seam split — by re-colouring on purpose, and they are not a thing this block could express anyway: it carries view_proj and no separate view matrix, so there is no rotation in the shader to take a normal into eye space with.

§It builds nothing and adds no pass

Unlike the wireframe, which needs a second pipeline and so a device that can build one: this is one lane of the frame’s uniform block — see FrameUniforms::NORMALS_VIEW_ON — read by a branch in the fragment stage every device already runs. There is nothing to refuse and nothing to release, which is why it cannot fail and there is no supports_ probe beside it.

The tonemap still applies: at DEFAULT_EXPOSURE its operator is the identity on 0..=1 and the encoded normal reaches the swapchain exactly, and at any other exposure the picture is scaled per channel — so which channel dominates a face never changes, but a caller reading exact values wants set_exposure left alone.

Source

pub const fn set_fog(&mut self, fog: Fog)

Sets the exponential height fog the colour pass composites over every shaded surface.

Topic 43 §4’s cheapest large win: distance reads as distance, a valley fills while a hilltop stays clear, and it costs four numbers in a block every pipeline already binds.

§It adds no pass and cannot fail

On set_normals_view’s terms exactly — two rows of the frame’s uniform block, read by arithmetic in the fragment stage every device already runs. There is nothing to build, so there is nothing to refuse and no supports_ probe beside it.

§Off is exactly off

Fog::NONE is the default and a zero density is an exact identity, not an approximate one: the optical depth is zero, its transmittance is exactly one, and mesh.slang composites as lit * t + fog * (1 - t) rather than as a lerp, which at t == 1 would return fog + (lit - fog) and lose the low bits of an HDR radiance far from the fog colour. So this feature moves no frame it is not switched on for.

§What it does not fog

The screen-space reflections ssr_blur.slang adds after this pass, which arrive unfogged onto an already-fogged surface — see docs/backlog.md. Fog is applied where the radiance is finished, and the reflection composite is one pass later.

Source

pub const fn set_sky(&mut self, sky: Sky)

Lights the scene with a gradient sky, on top of whatever ambient and irradiance grid it already has.

Topic 43 §8’s rung. Sky is three radiances — zenith, horizon, ground — and what reaches a surface is that gradient projected onto the L1 basis the probe grid already uses, so a surface facing up receives the sky and one facing down the ground’s bounce. Three colours, no extra pass.

§It adds no pass and cannot fail

On set_fog’s terms exactly — three rows of the frame’s uniform block and three dot products in a fragment stage every device already runs. Nothing to build, so nothing to refuse and no supports_ probe beside it.

§Off is exactly off

Sky::NONE is the default and a black gradient projects to every coefficient zero — each is a product with a zero factor — so the fragment stage adds max(0, 0) and the ambient sum is the one it was before this existed, bit for bit.

§What it does not do

Draw anything. The background is still the scene target’s clear colour, and a scene lit by a sky it cannot see is what this rung leaves behind until the pass that draws the gradient lands. The environment ssr.slang falls back to on a missed ray is still the probe grid’s, so a mirror under a sky still reflects whatever the probes hold.

Source

pub fn set_atmosphere(&mut self, atmosphere: Option<Atmosphere>)

Replaces the gradient with Hillaire’s atmosphere, or None to put the gradient back.

Topic 43 §8. A frame with an atmosphere takes it for all three of the things a sky is: the background the sky pass draws, the L1 ambient term mesh.slang adds, and the environment ssr.slang falls back to when a ray hits nothing. The Sky a caller may also have set is not read on those frames.

§What it costs

A march on the host, not on the device. The first begin_frame after this is called marches crcbl_shaders::atmosphere::SkyView whole, which is tens of milliseconds of CPU — a renderer with no LUT has no sky, so that one is paid where it is asked for. Every later move of the sun is marched SKY_VIEW_BUILD_ROWS rows per frame with the last finished LUT still drawn, so no frame after the first pays the whole march; refresh_sky_view is where that is written down, including what a sun that moves every frame gets. A frame whose sun has not moved costs the comparison that finds nothing to do and nothing else: the LUT’s two projections are cached beside it. The device pays four buffer loads and a blend, which is what the gradient pays.

§Off is exactly off

None is the default, and a renderer nobody calls this on writes the same block, adds the same passes and draws the same frame it did before this existed — sky.slang’s arm is crcbl_shaders::sky::ATMOSPHERE_OFF, which is exactly zero.

§What it does not do

Draw the sun. The LUT holds the scattered sky and not the disc, as the paper’s does; the sun itself is the DirectionalLight the forward pass already shades with, and pointing the two the same way is the caller’s job.

Put the air in front of a surface. That is the paper’s third LUT and this engine’s froxel column, and neither reads this.

Source

pub fn set_water(&mut self, bodies: &[WaterBody]) -> Result<(), BodyError>

The bodies of water every view draws — docs/plan/55-water.md’s rung 1, and this crate’s water module for how.

Replaces whatever was set before. Each body is meshed here, by crcbl_water::surface_mesh, and the result is uploaded to each frame slot as that slot next begins, so the call touches no device and a frame still in flight keeps the buffers it was submitted with.

§Off is exactly off

An empty slice is the default, and a renderer with no bodies records no water pass at all: the frame it draws is the one it drew before this existed, bit for bit. Water is content, not a RenderEffects bit, on set_sky’s terms.

§Errors

crcbl_water::BodyError for the first body that cannot be meshed — too few points, a non-finite coordinate, an outline that crosses itself, a negative coefficient — and then nothing is replaced: the bodies set before this call go on drawing.

Source

pub fn water(&self) -> &[WaterBody]

The bodies of water this renderer draws, as they were last set.

Source

pub fn set_grass( &mut self, device: &dyn Device, queue: QueueHandle, field: Option<&GrassField>, ) -> Result<(), SetError>

The field of grass every view draws — docs/plan/57-grass.md’s rungs G1 and G3, and this crate’s grass module for how.

Replaces whatever was set before. The field’s ground, cover map, blade table and per-tile blocks are uploaded here, and the buffers a dispatch writes are created here; a field replaced while a frame is in flight leaves its resources alive until the ring has come round, so the call is safe at any point between frames.

§Off is exactly off

None is the default, and a renderer with no field records no grass pass at all: the frame it draws is the one it drew before this existed, bit for bit. Grass is content, not a RenderEffects bit, on set_water’s terms.

§Errors

crate::grass::SetError::Field for a description the field itself refuses — no tiles, a zero texel scale, an empty blade table — and then nothing is replaced: the field set before this call goes on drawing. crate::grass::SetError::Hal for a seam call that failed, on the same terms.

Source

pub fn grass(&self) -> Option<&GrassField>

The field of grass this renderer draws, as it was last set.

Source

pub fn grass_buffers(&self) -> Option<GrassBuffers>

The two buffers the grass generation pass writes, or None for a renderer with no field.

What crcbl‘s render_e2e copies back to check the placement blade by blade and to read each slot’s instance count, on froxel_buffers’ terms — see crate::grass::GrassBuffers for the layout. They hold whatever the last frame that generated left there, which for a field nobody has drawn yet is undefined rather than empty.

Source

pub fn set_wind_layers( &mut self, device: &dyn Device, queue: QueueHandle, layers: Option<&WindLayers>, ) -> Result<(), WindLayerError>

The two authored wind layers docs/plan/56-wind.md’s decision 1 names, as the GPU copy of the field samples them.

None restores the calm placeholder: one texel of no deflection and one of zero intensity, which is what makes a field with no weather set stand still. A replaced pair waits for the ring exactly as a replaced field does.

§Errors

crate::grass::WindLayerError for a layer that is not four bytes a texel of the grid it came with, or a seam call that failed.

Source

pub const fn set_wind(&mut self, params: WindParams)

The wind’s uniform block for the frames from here on — crcbl_wind::WindField::gpu_params, which is where the authoritative f64 formula is narrowed to f32.

Everything in it is camera-relative or already wrapped, so a caller writes it once per frame from the field’s own state and never from a world-scale coordinate. The default is a base speed of zero, which is calm.

Source

pub const fn wind(&self) -> WindParams

The wind block this renderer writes, as it was last set.

Source

pub const fn atmosphere(&self) -> Option<Atmosphere>

The atmosphere this renderer draws, if it has one.

Source

pub const fn set_lod_view(&mut self, on: bool)

Draws each cluster tinted by the DAG level it was decimated to, instead of shading it.

The picture cluster LOD’s whole claim rests on: one mesh spanning several levels across its own surface is a statement a test can assert and nobody can see, and this is what makes it visible. The mesh path tints per cluster; the two indirect paths select one level per instance and have no per-cluster level at all, so they draw one flat grey — which is the comparison rather than a shortfall.

Costs what set_normals_view costs: one lane of the frame’s uniform block, read by a branch every device already runs. Nothing to build, nothing to refuse, nothing to release.

Wins over the normals view when both are on, because the two share a lane and the fragment stage tests this one first.

Source

pub const fn lod_view(&self) -> bool

Whether the colour pass tints clusters by their DAG level.

What was asked for, not what is drawn. The three debug views share one lane and resolve in one order, so a renderer with this and set_heatmap both on draws the heatmap and still answers true here — the caller’s setting is what a caller’s toggle has to read back, and debug_view is what says which one the frame actually took.

Source

pub const fn set_heatmap(&mut self, on: bool)

Shades each cluster by the projected screen-space error the LOD selection judged it on, instead of shading it.

The LOD tint’s sibling, and the other half of topic 25’s pair: set_lod_view answers “which level am I looking at”, and this answers “how close to the budget is this, and where is the selection about to switch”. The number is the one draw_gen.slang’s group_is_expanded compared against the budget — a cluster’s producing group’s error, projected from this frame’s eye at this frame’s pixels per unit.

§What the colours mean

A ramp that climbs in luminance from a cold floor to white, with a hue break at each of the two budgets: the hold budget where the hysteresis band starts, and the expand budget at the top, which is white. So the two budgets draw themselves as contour lines across the surface, and “brighter is closer to switching” reads even in a greyscale screenshot. mesh_cluster.slang‘s HEAT_UNDER_LOW carries the ramp in full, and crcbl_shaders’ the_heatmap_ramp_climbs_in_luminance is what holds it to being readable as an ordering.

A cluster nothing simplified — the original surface, at the bottom of the DAG — costs exactly zero and takes the ramp’s floor.

§Mesh path only, and that is the capability rather than a shortfall

A per-cluster error exists only where selection is per cluster. GeometryPath::IndirectCount and GeometryPath::IndirectPerBatch choose one level per instance, so there is no per-cluster number for them to shade by and mesh.slang’s vertex stage writes the same flat grey the LOD tint gets. Standing the two beside each other is the comparison.

§It builds nothing and adds no pass

One lane of the frame’s uniform block, on set_normals_view’s terms exactly — plus one storage-buffer read in the mesh stage, which the mesh path’s layout already carries. Nothing to build, nothing to refuse, nothing to release.

Wins over both the LOD tint and the normals view when several are on; see debug_view, which is that order stated once.

Source

pub const fn heatmap(&self) -> bool

Whether the colour pass shades clusters by their projected error.

What was asked for, not what is drawn, on lod_view’s terms.

Source

pub const fn set_occlusion_view(&mut self, on: bool)

Draws the ambient-occlusion channel alone, as grey, instead of shading.

One is white and fully occluded is black — the buffer the forward pass multiplies its ambient term by, shown as itself. This is how the AO ladder — GTAO against the eight-tap hemisphere — is compared at all: a composited frame shows occlusion times albedo times ambient, and a difference in the first is not separable from a difference in the other two by looking at the result.

§What it draws with occlusion switched off

White, everywhere. A frame without RenderEffects::AMBIENT_OCCLUSION binds a 1×1 white image in place of a computed channel, and this view shows that image rather than pretending to a channel nothing computed — “no occlusion was computed” and “nothing occludes here” are the same value to the shading, and the view does not get to disagree with the shading about it.

§It builds nothing and adds no pass

One lane of the frame’s uniform block, on set_normals_view’s terms exactly. Unlike the tint and the heatmap it needs nothing from the geometry stage, so it draws on every GeometryPath rather than on the mesh-shader one alone.

Wins over every other view when several are on; see debug_view, which is that order stated once.

Source

pub const fn occlusion_view(&self) -> bool

Whether the colour pass draws the occlusion channel instead of shading.

What was asked for, not what is drawn, on lod_view’s terms.

Source

pub const fn set_motion_view(&mut self, on: bool)

Draws each fragment’s motion vector instead of shading it.

The two components are stretched by MOTION_VIEW_SCALE and centred on grey, into red and green, with blue left at zero. A pixel at rest is grey in both channels to within one half-float step — MOTION_VIEW_SCALE says why not exactly — and a surface travelling right and down the screen brightens both.

§It is the motion-vector target’s only reader today

The forward pass writes a motion vector into a third colour attachment on every frame — see crate::targets::motion — and no pass reads it yet; TAA (docs/backlog.md) is the first that will. This view is therefore what says the subtraction behind it is the right one, which is why it exists ahead of a consumer.

§It builds nothing and adds no pass

One lane of the frame’s uniform block, on set_normals_view’s terms exactly, and like the occlusion view it needs nothing from the geometry stage that a shaded frame does not already produce — so it draws on every GeometryPath.

Wins over every other view when several are on; see debug_view, which is that order stated once.

Source

pub const fn motion_view(&self) -> bool

Whether the colour pass draws the motion vector instead of shading.

What was asked for, not what is drawn, on lod_view’s terms.

Source

pub const fn set_bent_normal_view(&mut self, on: bool)

Draws the occlusion channel’s bent direction instead of shading.

The three channels beside the visibility scalar, passed through as the colour: the conventional n * 0.5 + 0.5, so +X reads red, +Y green and +Z blue, which is the mapping set_normals_view already uses for a surface normal. A fragment the occlusion pass had no direction for reads as the mid grey the zero sentinel encodes to.

§What it is for

The bent direction is what the ambient term is sampled along, and a composited frame cannot show it: ambient times albedo times a direction-dependent irradiance is one colour, and a direction that is subtly wrong looks like a lighting choice. This draws the direction alone, which is how a corner that leans the wrong way out of its own wall is a thing a reviewer sees rather than infers.

§What it draws with occlusion switched off

Mid grey, everywhere. A frame without RenderEffects::AMBIENT_OCCLUSION binds a 1×1 placeholder holding BENT_NORMAL_NONE in those three channels, and this view shows that image rather than pretending to a direction nothing computed — which is the same answer the shading takes, since mesh.slang reads that sentinel as “use the shading normal”.

§It builds nothing and adds no pass

One lane of the frame’s uniform block, on set_normals_view’s terms exactly, and like the occlusion view it needs nothing from the geometry stage — so it draws on every GeometryPath.

Wins over every other view when several are on; see debug_view, which is that order stated once.

Source

pub const fn bent_normal_view(&self) -> bool

Whether the colour pass draws the bent direction instead of shading.

What was asked for, not what is drawn, on lod_view’s terms.

Source

pub const fn set_cascade_view(&mut self, on: bool)

Tints the shaded picture by the cascade each sun-lit fragment’s shadow was sampled from.

Topic 45’s eighth decision made the cascade switch a band rather than a step, and this is the picture that band is judged in: each fragment’s shading multiplied by CASCADE_TINTS of the cascade it selected, and inside the band by the blend of the two — the same weight the visibility itself was mixed with. So the boundary reads as a gradient, and a seam where two cascades disagree shows up as a step in the gradient rather than as a ring somebody has to already suspect.

§It keeps the shaded picture, which is why it loses to every other view

Every other view replaces the frame; this one multiplies it, so the geometry stays readable underneath and the shadow the cascades produced is still in the picture being coloured. That is also what puts it last in debug_view’s order: with a replacing view on there is no shading left for a tint to reach.

§What it draws where no cascade covers a fragment

Nothing at all — CASCADE_TINT_NONE is white. A surface facing away from the sun and one past the last cascade’s reach are both that, because neither was sampled through a cascade, and a frame drawn without RenderEffects::SHADOWS is white everywhere for the same reason. Colouring those would be inventing a cascade for a pixel no map covers.

§It builds nothing and adds no pass

One lane of the frame’s uniform block, on set_normals_view’s terms exactly, and like the occlusion view it needs nothing from the geometry stage — so it draws on every GeometryPath.

Source

pub const fn cascade_view(&self) -> bool

Whether the colour pass tints the picture by the sun’s cascades.

What was asked for, not what is drawn, on lod_view’s terms — and here that gap is the usual case rather than the corner one: this view loses to every other one, so a renderer with any of them also on answers true here and draws that one.

Source

pub const fn set_atlas_view(&mut self, on: bool)

Draws the shadow atlas itself over the finished frame: the D32Float image crate::shadow budgets, letterboxed at its own aspect, each texel’s stored depth as a grey and a border round every occupied slot.

Sundial’s atlas viewer, and the answer to a question no other view can be asked: which slot holds which map, and which slots hold nothing. A tile that was never rendered into, or rendered at the wrong viewport, lights a scene fully — so the frame it produces is plausible and every golden blessed from it passes. Here it is a rectangle that is visibly empty.

§It is a pass, and it is the only debug view that is

Every other view rides in one lane of the frame’s uniform block and is a branch in mesh.slang, because every other view is a function of the fragment being shaded. The atlas is not: it is one image the whole frame shares. So this switch adds crate::atlas_view’s full-screen pass to the frame instead — after the tonemap, in display space, for that module’s reason — and the frame block is byte-identical either way.

§Where it resolves, and what it costs when it is off

Below every replacing view and above set_cascade_view’s tint — see debug_view, which is that order stated once. A frame that resolved anything else records no pass, no pipeline bind and no block read, which is what makes the off position bit-identical on crate::sky_pass’s terms.

Source

pub const fn atlas_view(&self) -> bool

Whether the frame draws the shadow atlas over the picture.

What was asked for, not what is drawn, on lod_view’s terms: a renderer with a replacing view also on answers true here and draws that one.

Source

pub const fn set_frozen_selection_eye(&mut self, eye: Option<Vec3>)

Pins the eye topic 25’s selection is projected from, so the cut stops following the camera.

None is the default and means “the camera’s own eye”, which is what every frame before this existed did. Some(eye) selects detail for a viewer standing at eye while the frame is still drawn, culled and lit from wherever the camera actually is.

§What it is for

Per-cluster LOD is only checkable from somewhere other than the point that chose it. Looked at from the selecting eye, a cut that is far too coarse and a cut that is exactly right produce the same silhouette — that is what a screen-space error budget means — so the one viewpoint where a wrong cut cannot be seen is the viewpoint every unfrozen frame is judged from. Pin the eye and fly away from it, and the boundaries between levels become geometry a reviewer can walk up to and look at edge-on.

§Only the selection freezes

The frame has three places a viewer position is read, and this moves exactly one of them:

  • the selection — draw_gen.slang’s select_level, which reads DrawGenParams::camera_position and is the only thing that decides the cut. It writes the group hysteresis state that the mesh path’s amplification stage then descends, so freezing this one field freezes the cut on the per-cluster path and the two indirect paths alike. This is what moves.
  • the frustum culls — cull.slang’s instance test and mesh_cluster.slang’s per-cluster one, whose planes are extracted from the frame’s own view-projection and never read a camera position at all. Unaffected, and it has to be: a frame culled against a frustum the reviewer has flown out of would draw nothing.
  • the normal cone — mesh_cluster.slang’s cluster_survives, which reads FrameUniforms::camera_position and asks which way a cluster faces relative to the viewer. That question is about the eye the picture is drawn from, not the eye it was selected for; frozen, a reviewer who flew round to the other side of the face would have every cluster now facing them rejected for facing away from a viewpoint nobody is standing at. It stays live.

The split is not new. DrawGenParams::camera_position and FrameUniforms::camera_position are already separate fields carrying different values on a shadow cascade — that one holds the sun while this one stays the camera, because detail is denominated in the camera’s pixels and facing is asked about the light. This freezes the same seam from the other side, and needs no new binding, no new shader input and no shader change of any kind.

§It freezes the cascades’ selection too

begin_frame hands the same eye to every shadow cascade’s draw generator, because a cascade selects detail for the camera — see SHADOW_LOD_BIAS. A frozen camera cut over a live shadow cut would be a shadow silhouette sliding under a fixed one, which is a difference in the picture that belongs to neither.

§The heatmap reads the live eye, and says so

set_heatmap shades a cluster by its producing group’s projected error, computed in the mesh stage from FrameUniforms::camera_position — the eye that stays live. So under a frozen selection the two overlays answer different questions: the cut is the one chosen at the pinned eye, and the heat is what the error would be if it were chosen from here now. That is readable — flying towards the face brightens the clusters the frozen cut is not refining, which is the selection’s sensitivity made visible — but it does mean the ramp’s contours stop coinciding with the level boundaries while frozen. set_lod_view is the overlay that composes unconditionally: a cluster’s level is a property of the cut and of nothing else.

Carrying the pinned eye into the mesh stage as well would need a second position in the frame block, which is a new shader input in every backend for one overlay’s benefit; docs/backlog.md holds that trade-off.

Source

pub const fn frozen_selection_eye(&self) -> Option<Vec3>

Where the selection is pinned, or None while it follows the camera.

The read-back half of set_frozen_selection_eye, and what a debug panel says “frozen at” out of — “frozen” without the position is a row nobody can act on.

Source

pub const fn debug_view(&self) -> DebugView

Which of the debug views the next frame will actually draw.

The one place the precedence is decided, and every other statement of it in this crate reads it back from here. The switches ride in one float lane of the frame block — see FrameUniforms::HEATMAP_VIEW_ON — and the shaders test the outermost threshold first, so a sentinel for an outer view clears every threshold below it. Resolving here rather than letting each caller guess is what stops “which view is on” being answered differently by a menu row, a debug panel and the picture.

Source

pub const fn normals_view(&self) -> bool

Whether the colour pass draws world-space normals instead of shading.

The read-back half of set_normals_view, on wireframe’s terms: what it draws is what the question is about.

Source

pub const fn draws(&self) -> &DrawGen

The cull and draw-argument passes, and the buffers they produce.

What a caller reads the culling statistics out of — topic 03 §3.6’s delayed readback ring is DrawGen::visible_count — and what crcbl-vk’s end-to-end suite copies back to check the generated arguments against the draws this pass used to record itself.

Source

pub fn exposure_buffers(&self, frame: usize) -> ExposureBuffers

frame’s auto-exposure measurement: the bins the histogram pass filled and the exposure the reduce wrote out of them.

What crcbl‘s mesh_e2e copies back to check the histogram bin by bin against crcbl_shaders::exposure, on draws’ terms — see ExposureBuffers. Both hold whatever the last frame that measured left there, so a frame drawn without RenderEffects::AUTO_EXPOSURE hands back the frame before it rather than nothing.

§Panics

If frame is not a slot this renderer was built with.

Source

pub fn froxel_buffers(&self, frame: usize) -> FroxelBuffers

frame’s froxel column: the buffers the froxel volume’s three passes write, and the block they read.

What crcbl‘s mesh_e2e copies back to check the column froxel by froxel against crcbl_shaders::volumetric, on draws’ terms — see FroxelBuffers.

§Panics

If frame is not a slot this renderer was built with.

Source

pub const fn effect_request(&self) -> EffectRequest

The three layers a caller supplies to the toggle resolution order — see crate::effects.

Read back rather than only written, so a caller changing one layer does not have to remember the other two: take this, edit the field it owns, hand it back to set_effect_request.

Source

pub const fn set_effect_request(&mut self, request: EffectRequest)

Replaces all three requested layers, and resolves them at the next begin_frame.

The frame in flight does not move. begin_frame freezes what it resolved and add_passes records that, because the two halves of a frame have to agree about which culls were parametrised: begin_frame skips a shadow cull’s parameter write when shadows are off and add_passes skips its dispatch, and a request landing between the two would dispatch a cull against numbers nothing zeroed.

Source

pub const fn set_camera_stack(&mut self, stack: &CameraStack)

Replaces the camera layer with what stack asks for, and leaves the other three where they are.

The file half of crate::stack reaching the renderer: a view that has a render stack writes it here, and the player’s [engine.video] clamp, the antialiasing rung they picked and any programmatic override are untouched — which is the property that makes the four layers four rather than one. A caller that wants to move more than this layer builds an EffectRequest and uses set_effect_request.

The frame in flight does not move, on set_effect_request’s terms and for its reason: this writes the request and begin_frame is what resolves it.

Source

pub const fn effects(&self) -> RenderEffects

What the frame the last begin_frame opened draws.

The resolved set, not a layer: every effect in it has survived the camera’s stack, the player’s quality clamp, any programmatic override and the device — which is the one question a test asking “did this frame have shadows in it” wants answered.

RenderEffects::all before the first frame, which is what a renderer nobody has changed would draw.

Source

pub fn resolved_effects(&self) -> RenderEffects

What a frame begun now would draw: the whole order applied to the current request.

effects’ question one frame earlier, and the one a caller reporting its own configuration wants — a debug panel built at startup has no frame behind it yet, and printing what the last one drew would print a default.

A debug view takes the antialiasing resolve off — either tier of it — whatever the four layers said. Those views are readouts rather than pictures — a pixel’s colour is the cluster’s projected error or its DAG level, read back against a legend — and a filter that blends two clusters’ shades invents a ramp position no cluster occupies. apps/quarry’s heatmap and LOD tests are the consumers that count a frame’s distinct colours.

Source

pub const fn resolved_tonemap_curve(&self) -> TonemapCurve

Which tonemap operator the next frame runs: tonemap_curve’s answer for a shaded frame, and the clamp for a readout.

resolved_effects’ argument, applied to the operator instead of to the resolve. A debug view’s pixels are data — an encoded normal, an occlusion channel, a cascade’s colour code — and a curve is a monotone remapping of every one of them. apps/alcove’s --bent-view reads a normal back and compares it against the geometry’s own, which under ACES is 49 code values out; the clamp is the identity on 0..=1, so it is the operator that leaves a readout readable. A caller that wants a curved readout has none, deliberately: there is no reading it would make easier.

Source

pub const fn device_effects(&self) -> RenderEffects

Which effects this device permits, which is the fourth layer and clamps last.

Every one of them today — see ForwardRenderer::device_effects, which is where that is argued per effect rather than asserted.

Source

pub const fn geometry_path(&self) -> GeometryPath

Which GeometryPath this renderer was built for — not what the device reports, but what it actually built.

The device may prefer a path below its capability ceiling when a higher one uses emulation. This reports the preference actually built, rather than the ceiling: GeometryPath::MeshShader here means build created a mesh pipeline out of mesh_cluster.slang and its cluster buffers, and created no raster pipeline for the pass to fall back to. So a frame this renderer drew came out of a mesh stage, and a silent degradation is not a state it has — which is the claim a golden image on its own could never make, because a fall-through draws the same picture.

Source

pub const fn culls_clusters(&self) -> bool

Whether this renderer built §3.5’s per-cluster cull — an amplification stage in front of the mesh stage, rejecting a surviving instance’s back-facing and off-screen clusters.

false on the two indirect tails, which draw index ranges and have no stage to put it in, and on a device with Features::MESH_SHADER and no Features::TASK_SHADER — a real and supported state, not a degradation: that device draws every cluster of every surviving instance and the picture is the same one.

The instance cull runs on every path either way, and is unaffected by this.

It is asked of the renderer rather than of the device for ForwardRenderer::geometry_path’s reason: this reports what was built, so true means DrawGen::visible_count’s cluster word is a number the frame produced rather than the zero the clearing pass left.

Source

pub const fn selects_levels(&self) -> bool

Whether this renderer can choose which level of a Geometry::Dag mesh an object is drawn at, and therefore whether ForwardRenderer::add_instance may be given one at all.

Topic 25’s selection happens in the amplification stage where there is one, and in the cull pass where the tail is indirect and a level is an ordinary index range. One device shape has neither: a mesh stage with Features::MESH_SHADER and no Features::TASK_SHADER draws through mesh_cluster.slang’s un-amplified meshMain, which emits every cluster of the bucket — and a DAG’s bucket is every level end to end, so the frame is several overlapping copies of one surface. That is a real and supported device state rather than a degradation, so this reports it instead of refusing to build.

A Geometry::Flat mesh is one level and is unaffected: its clusters carry ClusterSelect::ALWAYS and every path draws it from every camera, which is why this is asked only before placing a DAG.

Asked of the renderer rather than of the device for ForwardRenderer::culls_clusters’ reason: it reports what was built.

Source

pub const fn frame(&self) -> usize

Which frame-in-flight slot the last ForwardRenderer::begin_frame rotated to, which is the slot every per-frame buffer is indexed by.

Source

pub fn counters(&self) -> FrameCounters

What the last add_passes recorded, and what it cannot know.

Zero draws until a frame has been built: this reports what was recorded, not what a frame would record.

§The triangles are None here, on every geometry path

Every draw this renderer records except the full-screen passes’ and the debug draw layer’s is indirect: the instance count and the index range live in the argument buffer draw_gen.slang wrote, so the CPU records the call and learns nothing about what it covered. That is true of GeometryPath::MeshShader and of both indirect tails alike — the three differ in which call is recorded, not in who decides the counts — so FrameCounters::triangles is None whatever the device supports. Nothing counts a triangle on the GPU either, and a cluster count times a nominal triangles-per-cluster would read as authoritative and be neither.

§The instances drawn come back off the GPU, a few frames late

FrameCounters::drawn is cull.slang’s survivor count, off crate::cull_stats’s delayed ring, plus the frame’s direct draws — the ones here whose instance the CPU knows about, and the ones that are also in instances. So the pair is comparable: the same quantity submitted and kept.

The camera’s cull alone. The shadow culls test other frustums and their survivors are counted into buffers of their own; adding them here would give a “drawn” larger than “submitted” on any frame with a shadow in it.

It is None — the row says indirect — for the first few frames of a renderer’s life, while the ring has not come round, and for good on a device that would not give out a readback. cull_frame is which frame the number is about whenever there is one.

FrameCounters::instances is known and is the plan’s “submitted” half: the live instances add_passes hands the cull dispatches, plus the frame’s direct draws — every full-screen pass’s triangle and the debug draw layer’s line list.

Source

pub fn cull_stats(&self) -> Option<CullStats>

What the camera’s cull kept, on the frame the ring has reached.

Topic 03 §3.6’s one permitted readback, and None until it has come round — see crate::cull_stats for the latency and for what makes it free of any wait. counters is where this reaches the panel; it is exposed on its own because the frame number and the cluster word are both things a test asserts about directly.

Source

pub fn present_target( image: ImageHandle, view: ImageViewHandle, format: Format, extent: (u32, u32), ) -> ImportedImage

Describes the imported swapchain image the frame ends in.

A helper rather than something every caller writes, because getting initial/final_state wrong is exactly the hand-written barrier this slice removed: an acquired image’s contents are undefined, and the compositor may only be handed one in ResourceState::Present.

Source

pub fn destroy(self, device: &dyn Device)

Releases everything, in dependency order. The device must be idle.

Trait Implementations§

Source§

impl Debug for ForwardRenderer

Source§

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

Formats the value using the given formatter. 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> 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, 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.