Expand description
The debug draw layer: an immediate-mode buffer of world-space line segments, drawn pre-tonemap in HDR.
any system ──line/aabb/sphere/frustum──▶ DebugDraw's segment buffer
│ begin_frame: upload + clear
▼
scene colour ──▶ debug-draw ──▶ scene colour
▲
scene depth (tested, never written)The UI’s debug item 5 (docs/notes/tooling.md) is what this is, and
topic 43’s foundations block is where it was
scheduled: the layer the four owed views —
topic 45’s cascade overlay and atlas view,
topic 25’s cluster bounds and the light list’s
reach — are drawn through.
World-anchored text is not here, and it is not deferred silently: text
needs a glyph atlas and a rasteriser seam, crcbl_ui::text::FontAtlas and
crate::ui_pass already own one between them, and folding a second
consumer of it into this module would double the diff and put a screen-space
pass and a world-space one in one file. docs/backlog.md carries what the
slice needs. Everything this module offers is geometry.
§Immediate mode, on crate::ui_pass’s shape
A system appends during the frame; the buffer is uploaded and cleared by
the ForwardRenderer::begin_frame
that opens the next one, so a segment survives exactly the frame it was
appended in and nothing has to be un-appended. That is the same ring the UI
draw list rides — one host-visible buffer per frame in flight, grown by
doubling, and a count committed only after the upload succeeded.
§Pre-tonemap, in HDR
docs/plan/18-render-features.md’s interaction rule fixed this before the
layer existed: “Debug overlays (debug draw, gizmos) render pre-tonemap in HDR
(they’re in the world) except UI-space panels.” So a colour appended here is
linear radiance and is exposed and tonemapped like geometry — which is what
makes a debug line read as being in the scene rather than painted over it,
and it is the opposite of crate::grid’s decision, whose own header says
why reference chrome goes the other way.
crate::forward is what puts the pass in the frame, and it lands
immediately before the tonemap: after the reflection composite, the bloom
chain and the auto-exposure histogram, so a debug line neither reflects in a
surface, blooms, nor moves the exposure the scene is metered at, and before
the tonemap, so it is exposed with everything else.
§Nothing is drawn until something asks for it
r_debug_draw is off by default and a frame that appended no segment
records no pass at all — no pipeline, no buffer, no barrier — which is
what makes every golden image in the workspace identical to the one it was
blessed as. The pipeline itself is built lazily, on the first frame that has
both, so a renderer nobody draws through never pays for it either.
Structs§
- Debug
Draw - The immediate-mode buffer every system appends to, and the pass that draws it.
- Debug
Vertex - One endpoint of one segment, matching
debug_draw.slang’sDebugVertex.
Constants§
- SPHERE_
SEGMENTS - How many segments each of a sphere’s three great circles is drawn with.
Statics§
Functions§
- frustum_
corners - The eight world-space corners of the view volume
view_projprojects, orNonewhere that volume has no finite corners.