1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
//! Renderer: the 3D frame — meshes, materials, lights, effects — built on
//! `crcbl-frame`'s render graph and UI pass, everything above the HAL seam.
//!
//! The graph, the transient pool, the texture uploads, the pass timers and the
//! UI pass are [`crcbl_frame`]'s, re-exported here under the paths they have
//! always had ([`graph`], [`transient`], [`texture`], [`timing`], [`ui_pass`]),
//! so a program that draws only a UI can depend on that crate alone.
//!
//! ```text
//! camera + light ──▶ ForwardRenderer ──adds passes──▶ RenderGraph
//! │ compile()
//! ▼
//! ordered passes + exact barriers + transients
//! │ execute()
//! ▼
//! crcbl-hal ──▶ crcbl-vk / null / …
//! ```
//!
//! # The one rule
//!
//! **No manual barriers outside the graph, ever** — stage 2
//! §2.4, and it is the reason this crate exists rather than the frame loop
//! living in each sample. Passes say what they read and write;
//! [`graph::RenderGraph::compile`] works out the transitions, the layout
//! changes, the transient aliasing and the final states, and
//! [`graph::CompiledGraph::execute`] is the only code in the engine that calls
//! [`pipeline_barrier`](crcbl_hal::CommandEncoder::pipeline_barrier) during a
//! frame.
//!
//! The barriers outside it are the **startup uploads**: [`mesh_pool`]'s staging
//! copy into the geometry pools, [`texture`]'s for every image ([`ui_pass`]'s
//! glyph atlas and [`sprite_pass`]'s sheets), and [`draw_gen`]'s copy zeroing
//! the LOD hysteresis state, which is device-local because a shader writes it
//! and so cannot be zeroed by a host write. Each runs before any frame exists
//! and has no graph to belong to; each is called out at the call site. The one
//! that also runs later is [`texture`]'s — between two frames, never inside
//! one, on an image no frame names yet, and blocking until its copy lands — when
//! [`ForwardRenderer::replace_page`](forward::ForwardRenderer::replace_page)
//! reloads a material page or
//! [`ForwardRenderer::set_grass`](forward::ForwardRenderer::set_grass) replaces
//! a field. There are no others, and a barrier recorded during a frame from
//! anywhere but [`graph::CompiledGraph::execute`] is a bug.
//!
//! # Nothing here knows a backend
//!
//! This crate depends on `crcbl-hal`, `crcbl-core`, `crcbl-frame`,
//! `crcbl-shaders`, `glam`, and the two description-only crates whose data it turns into pixels — `crcbl-ui`
//! for [`ui_pass`]'s draw list and `crcbl-sprite` for [`sprite_pass`]'s sample
//! modes, neither of which depends on a backend or on this crate.
//! It contains no `ash`, no `crcbl-vk`, and no `#[cfg(target_os = …)]`, per
//! the HAL rules in `docs/notes/backends.md` — which also name the render graph
//! specifically as living above the seam rather than in it. The graph compiles
//! identically against [`NullBackend`](crcbl_hal::null), which is what makes the
//! graph-compile suite `docs/notes/process.md` calls a non-negotiable anchor
//! run on every machine, with no ICD in the room.
//!
//! # Two tiers, one renderer
//!
//! Topic 03's rule is that **the lesser path (once "Tier B") is a
//! constraint on data layout, not a separate renderer**, and no pass here reads
//! a push constant. [`forward`]'s camera has been in a uniform buffer since P1
//! for exactly that reason; [`sprite_pass`] followed it; and [`ui_pass`] — which
//! draws every sample's HUD, and which WebGPU's lack of push constants had made
//! this crate's one permutation axis, with a `ConstantDelivery` enum and a
//! second `.slang` — joined them in 2026-08.
//!
//! So the tier costs one indirection where a push constant would have served,
//! and buys one artifact per shader, one code path per pass, and nothing to
//! select between at device-open time. [`ui_pass`]'s own docs carry the trade in
//! full, including what the split had cost.
//!
//! # What this crate is *not*, at P1
//!
//! No backend registry (see below), no material *system*, no scene, no
//! scheduler. [`material_table`] is §3.2's table and only that — a row of
//! factors and one base-colour texture layer that an instance's id selects; the
//! authoring, templates, permutations and the other texture slots a material
//! system means are `docs/plan/37-materials.md`'s and are not here.
//!
//! The one thing on that list that has since moved whole is culling:
//! [`cull`] is §3.3's frustum test and the CPU reference `cull.slang` is checked
//! against, [`draw_gen`] runs that shader and turns its survivors into indirect
//! draw arguments, and [`forward`] draws from those rather than recording a draw
//! per object. The graph is still a linear pass list with computed barriers,
//! which is what §2.4's risk list asks for by name: "No multi-queue scheduling,
//! no reordering. Resist."
//!
//! ## The registry deliberately did not move here
//!
//! `crcbl-vk`'s crate docs floated moving the GPU backend registry into this
//! crate at P1.3. It did not move, because it would make `crcbl-render` depend
//! on `crcbl-vk` — and `crcbl-vk`'s end-to-end suite depends on `crcbl-render`,
//! since the only honest way to test a render graph against real Vulkan is to
//! run the real graph. That is a dependency cycle through dev-dependencies:
//! legal in Cargo, and a confusing thing to have created in exchange for moving
//! four lines out of the crate whose entire job is to be the one name a game
//! depends on. The registry stays in `crcbl`.
//!
//! # Example
//!
//! ```
//! use crcbl_hal::null::NullInstance;
//! use crcbl_hal::{DeviceDesc, Instance, QueueKind, ResourceState};
//! use crcbl_render::graph::RenderGraph;
//! use crcbl_render::transient::{TransientImageDesc, TransientPool};
//!
//! let instance = NullInstance::gpu_driven();
//! let adapter = instance.adapters().remove(0);
//! let device = instance.create_device(&DeviceDesc::for_adapter(adapter.id))?;
//! let queue = device.queue(QueueKind::Graphics).expect("always present");
//!
//! // The pool outlives the graph: it owns the physical images, and it is what
//! // remembers what the last frame left them in.
//! let mut pool = TransientPool::new();
//!
//! let mut graph = RenderGraph::new(queue);
//! let scene = graph.create_image("scene", crcbl_render::targets::scene_color((64, 48)));
//! graph
//! .add_render_pass("clear")
//! .clear_color(scene, [0.0, 0.0, 0.0, 1.0])
//! .execute(|_| {});
//!
//! let compiled = graph.compile(&pool)?;
//! assert_eq!(compiled.passes().len(), 1);
//! // Nothing has ever used this pool, so the transient really is undefined and
//! // the graph transitions it before use. A second frame through the same pool
//! // would start from `ColorAttachment` — which is the barrier that orders it
//! // after this one.
//! let barriers = compiled.passes()[0].barriers();
//! assert_eq!(barriers.images[0].from, ResourceState::Undefined);
//! assert_eq!(barriers.images[0].to, ResourceState::ColorAttachment);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// The frame core's modules, under the paths this crate has always given them:
// the graph, the transient pool, the texture uploads, the mip chains and the
// frame counters live in `crcbl-frame`, which a program that draws only a UI
// depends on without the rest of this crate.
pub use ;
/// The GPU pass that fills a probe's visibility map: a depth cube per probe,
/// resolved into the octahedral layer `mesh.slang` reads.
/// The compute pass that reads the irradiance probes' reflective
/// shadow map into every probe row of a volume the scene asked to be updated.
/// The static geometry a probe's visibility map is captured from, and the
/// console variable that decides whether the frame reads one.
/// The reflective shadow map: the sun's near cascade drawn a second time as
/// what it reflects, where it is and which way it faces.
pub use ;
pub use ;
pub use ;
/// Re-exported because [`SheetDesc::sample`] is spelled in it: a crate whose
/// public API names a foreign type and does not export it is one every caller
/// has to add a dependency for.
///
/// [`NineSlice`] and [`Rect`] are here for the same reason —
/// [`NineSliceSource`]'s fields are spelled in both.
pub use ;
/// Re-exported for the same reason: [`menu_skin`] returns a [`MenuSkin`], and
/// a caller that can name this crate's menu art should not have to add a second
/// dependency to lay out and draw the menu it skins. It is also what lets an
/// end-to-end suite that depends on this crate take a golden image of the real
/// menu rather than of a replica.
pub use ;
pub use FontAtlas;
/// Re-exported for the same reason as [`Menu`]: [`MenuSkin`]'s buttons are a
/// [`ButtonSkin`] drawn per [`ButtonState`], and its insets are
/// [`SkinInsets`].
pub use ;
/// Re-exported because [`ForwardRenderer::set_water`] is spelled in them, on
/// [`SampleMode`]'s terms below: a caller setting water should not need a
/// dependency of its own to name what it sets.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use menu_skin;
pub use ;
pub use ;
pub use OcclusionCulling;
pub use OrbitCamera;
pub use PassStats;
pub use ;
pub use Cascades;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use FroxelBuffers;
/// Everything this crate exposes to the debug console.
///
/// One list per crate, gathered by the engine at one seam — debug-console
/// decision 2 in `docs/notes/tooling.md`, whose worked example in the plan was
/// this crate. It holds [`debug_draw::r_debug_draw`], the switch the debug draw
/// layer reads once a frame, the occlusion chain's own — `ssao::r_ssao_slices`
/// and `ssao::r_ssao_blur_passes`, which `crate::ssao`'s header argues are two
/// variables rather than one quality knob, `ssao::r_ssao_intensity` and
/// `ssao::r_ssao_radius`, which that header argues are not on their ladder at
/// all because neither moves the budget, and `ssao::r_ssao_bent_normals`, which
/// is the one of them that is on by default because it is the rung rather than
/// a purchase on top of it, and `ssao::r_ssao_split`, which is not a knob on the
/// effect at all but the comparison seam `crate::split` describes — and the
/// shadow cadence's two,
/// `shadow::r_shadow_cadence` and `shadow::r_shadow_faces`, which
/// `crate::shadow`'s cadence module argues are two for the same kind of reason:
/// how long a map may be held and how many may be redrawn at once are different
/// purchases — and the shadow filter's two, `shadow::r_shadow_filter` and
/// `shadow::r_shadow_split`, which are that module's answer to the occlusion
/// chain's technique pair: which rung of topic 45's filter
/// ladder runs, and the seam that puts it beside the one that ships — and the
/// sun's two bias counts, `shadow::r_shadow_bias` and
/// `shadow::r_shadow_normal_offset`, which are two variables for the reason
/// topic 45's seventh decision gives: one moves the compared
/// depth towards the light and the other moves the receiver sideways along its
/// own normal, so acne and peter-panning are pulled by different numbers and a
/// single knob could not show the pair moving against each other — and
/// `ssr::r_ssr_resolution`, the share of the scene the reflection march runs
/// at. `tests/console_table.rs` is
/// what keeps this list in step with what the source actually declares.