Skip to content

render: clear the sun depth-slab planes with device fills and census the splat footprint - #4867

Merged
jakildev merged 4 commits into
masterfrom
claude/4845-sun-depth-slab-budget
Nov 5, 2026
Merged

jakildev merged 4 commits into
masterfrom
claude/4845-sun-depth-slab-budget

Conversation

@jakildev

@jakildev jakildev commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Rebases the opt-in raster sun depth-slab layer (claude/4799-sun-raster-depth-slabs, ece131393) onto master's bake body split: the slab write lives in c_bake_sun_shadow_map_body.{glsl,metal} under both wrappers, master's fixture flags win (--probe-particle-raster, --sun-primary-probe), the branch's rectangular CSV probe ships as --sun-primary-rect-probe, and the overlapping-source stack extensions sit beside master's ray casters. One harness file, one VALIDATION row, one design-doc section.
  • Decision 5: the slab planes are stored min planes then max planes and cleared by two contiguous device fills; RenderDevice::fillBuffer gains a byte offset on both backends, the two test doubles follow, and a GPU test covers the offset form. Cost-neutral against the per-texel clear (within 0.31 ms on every bake row).
  • Decision 4 as answered: the workgroup-cooperative splat is a third wrapper, c_bake_sun_shadow_map_cooperative.{glsl,metal}, the shared body at an 8x8 pixel tile (IR_SUN_BAKE_GROUP_SIZE, Metal registry (8, 8, 1)), reducing each cascade's splat boxes over a 32-texel threadgroup window (kSunDepthSlabWindowTexels in the three layout twins, 28 bytes per texel, static_assert under the 32 KiB floor) with the spill routed per write to the per-pixel global path; ir_sun_depth_slab_window.{glsl,metal} holds the shared arrays and the five phases (reset, footprint reduction, init, routed splat, flush). The bake system constructs it only when kSunDepthSlabSlots > 0 and selects it per dispatch where the coverage splat is engaged (cardinal main-canvas bake, world-placed cast); the per-axis resolve, the no-splat detached bakes and the second-depth diagnostic keep per-pixel writes. The single-write path is now the degenerate pair of mergeSunDepthSlabPair, which the flush also uses.
  • The kernel is exact (hash-identical receivers to the per-pixel writer on all 58 captures; lane-by-lane emulation agrees on 107 write sets in both dialects, four window controls failing by name) and slower than the writer it replaces: bakeSunShadowMap 3.28x / 2.80x of the base arm on the two small raster cells against 1.87x / 2.08x for the per-pixel arm. The attribution arm with the slab words compiled out costs +0.66 ms on both cells, ten and twenty-two floors wide, so the window skeleton itself is over budget before any slab is touched.
  • Decision 7 fails: the shipped layout stays at zero slots (kSunDepthSlabSlots = 0u in the three twins), the cooperative program is never constructed and the dispatches are master's, measured against origin/master's own binary (bake 1.004x by rule (i), frame mean 1.022x). The design note records the residual per path and the two next levers; the load-free direct-mapped slab table is filed as render: load-free direct-mapped slab table for the raster sun depth-slab layer #4874 with its collision census (4 of 79,738 multi-slab texels congruent mod 3 across the matrix).
  • Phase 0 census stands as evidence (the premise bar is retired per the plan correction) and now reports the per-write spill share at the 8x8 tile and 32 window: 5% to 6% of box writes on the small cells' zoom-2 census frame, 3% to 5% on the profiled zoom-1 frame, under 0.05% on the default scene.

Test plan

  • Review amend: ruff check scripts/ clean; python3 scripts/tests/test_render_box_face_projection.py OK in both dialects (the fixture carries a writeSunPrimaryDepth stub that counts primary writes, and a nearest_only_primary mutation routing the primary write through the plain atomicMin fails by name); fleet-run IrredenEngineTest --gtest_filter='SunPrimaryDepthProbeRowTest.*' PASS, and FAILS with the row writer pointed back at min plane 1 (both overflow columns flip); the three-slot probe census re-captured natively (below).
  • python3 scripts/tests/test_render_sun_depth_slab.py — OK (7 tests: both proofs, the executed three-slot sweep, the cooperative emulation, every mutation control, the twin / group-size agreement).
  • test_render_legacy_shadow_bake.py (extracts the production main beside the cooperative one), test_render_source_face_query.py, _overflow.py, _index.py, test_render_shadow_layer_union.py — OK.
  • python3 scripts/shader_parity_audit.py — clean, 145 glsl and 135 metal files.
  • fleet-build --target IRCanvasStress IRPerfGrid IrredenEngineTest at three and at zero slots — clean; header-checks (Metal kernel registry membership included), format-changed — clean.
  • Native smoke of the cooperative kernel at three slots on canvas-lower (RESULT=CLEAN); capture matrix on the base, per-pixel and head arms; ab_timing.py --pairs 5 on all five cells with four arms, the nearest-only attribution arm on the two small cells, and origin/master against the zero-slot arm.
  • At the shipped zero slots: render-verify --target IRCanvasStress --no-build, --target IRPerfGrid --no-build, light-verify --if-changed, captures-default.json — IRCanvasStress all 59 checks PASS, IRPerfGrid all 21 checks PASS, [light-verify] all checks PASS; captures-default.json (lower, stacked-8-h60, oblique-lower, oblique-stacked-8-h60) receiver hashes identical to the base arm's.

Acceptance evidence

Criterion Check run Observed
1. Timing: frame mean / p99 within 1.10x of the base arm on every cell; gpu:bakeSunShadowMap passing F = 0.064 / 0.029 ms on the two small raster cells; per-row table with base spread, paired delta, lower bound, verdict; residuals recorded per path ir-acquire --timeout 3600 benchmark -- python3 …/ab_timing.py --output <dir>/<cell> --baseline arms/base --arm per-pixel=… --arm fills=… --head arms/head --pairs 5 --cells <cell> ×5 (budget/<cell>/ab-timing.md); attribution arm budget/attribution/<cell>/ Not met; the plan's failure branch taken. canvas-lower: head bake 4.762 ms vs base 1.451 (delta +3.311, lower bound +3.191 vs F 0.064) FAIL, frame mean 1.893x / p99 1.644x FAIL; canvas-stacked-128: bake 4.080 vs 1.458 (delta +2.622, lower bound +2.539 vs F 0.029) FAIL, frame mean 1.460x / p99 1.258x FAIL; canvas-default-raster frame 0.993x / 0.904x pass (bake 1.487x reported, base range 0.151); perf-grid zoom 1 1.044x / 1.043x pass, zoom 4 0.921x / 0.935x pass. Residual per path (README "Budget", design-doc row): fills within 0.31 ms of per-pixel on every bake row; cooperative +2.0 / +1.1 ms over per-pixel; nearest-only window +0.657 / +0.656 ms over base (1.456x / 1.453x); the first full-window form 2.607x / 3.066x (budget/cooperative-full-window/).
2. Recovery fires: capture.py matrix on the three-slot build, 0 missing / 0 excess on every beyond-throw case, controls byte-identical to master's run ir-acquire gpu -- python3 …/capture.py --output <dir> --label head (build at three slots), --build-dir arms/base --label base (master's path plus the fixture flags; master's own binary rejects the stack flags) stacked-8-h60, -last, -128, -h90, layered-2-h60-step40, both re-voxelized cases, oblique-stacked-8-h60/-last/-128/-h90, oblique-layered-3/-4 and every moving-track pose: 0 missing / 0 excess where the base arm loses 2,347 (cardinal) / 2,428 (oblique) / 2,773 / 2,262 / 2,604..2,608; oblique-stacked-8-h30 0 missing with the base arm's own 772 excess (base 296 / 772); controls (lower, floor, distant-8-h60, stacked-8-h30, the unlit pairs, layered-3/-4, their oblique twins except oblique-layered-2-h60-step40 at 2,344 vs 2,436) receiver hashes identical to the base arm's: 17 of 17. captures-{baseline,per-pixel,head}.json. captures-head.json re-captured at three slots after the probe's overflow read moved to max plane 0 (writeSunPrimaryDepthProbeRow, regression SunPrimaryDepthProbeRowTest): all 46 receiver hashes unchanged, overflow census identical to the per-pixel arm's on 80 of 80 cascade rows (437 / 379 on layered-3 and -4, 277 / 249 on oblique-layered-2-h60-step40, 0 elsewhere).
3. Cooperative path exact natively: identical receiver hash per case on the per-pixel and HEAD arms; HEAD's bake below the per-pixel arm's minimum on both small cells the same matrix on arms/per-pixel (captures-per-pixel.json) vs captures-head.json; budget/<cell>/ab-timing.md Receiver hashes identical on 58 of 58 captures (29 static cases, two tracks, fourteen static poses). Bake not below the per-pixel minimum: head 4.549..4.827 ms vs per-pixel 2.594..2.900 on canvas-lower, 3.975..4.181 vs 2.860..3.108 on canvas-stacked-128; attributed in README "Attribution".
4. Opt-out identity at zero slots: render-verify IRCanvasStress and IRPerfGrid all PASS, light-verify PASS, captures-default.json byte-identical; master vs zero-slot arm within F and 1.10x on canvas-lower python3 scripts/render-verify.py --target IRCanvasStress --no-build, --target IRPerfGrid --no-build, python3 scripts/light-verify.py --if-changed, capture.py --cases lower,stacked-8-h60,oblique-lower,oblique-stacked-8-h60 --label default at kSunDepthSlabSlots = 0u; budget/master-vs-base/ab-timing.md IRCanvasStress all 59 checks PASS, IRPerfGrid all 21 checks PASS, [light-verify] all checks PASS; captures-default.json (lower, stacked-8-h60, oblique-lower, oblique-stacked-8-h60) receiver hashes identical to the base arm's. Master vs zero-slot arm, five interleaved pairs on canvas-lower: bakeSunShadowMap 1.465 vs 1.458 ms (+0.006, 1.004x, pass by (i)), envelope 1.004x, steady frame mean 1.022x pass; steady p99 1.110x with both arms 90% / 93% in the 7..9 ms bins (two base runs' bimodal 8.8 ms p99). Amended head (probe row writer, fixtures, lint): render-verify --target IRCanvasStress --no-build 59 of 59 PASS, light-verify --if-changed PASS, the four default captures re-taken on the rebuilt binary with receiver hashes identical to the committed default and the base arm.
5. Harness: slab test OK in both dialects with the sweep, every mutation control (the prototype's ten per dialect plus the clear mutation, a dropped flush, a dropped spill write, a wrong window origin and an off-by-one window bound), the lane-by-lane emulation agreeing with the per-pixel writer; neighbour tests OK; parity, header-checks, format-changed, IrredenEngineTest build clean python3 scripts/tests/test_render_sun_depth_slab.py; the five neighbour tests; python3 scripts/shader_parity_audit.py; fleet-build --target header-checks, format-changed, IrredenEngineTest Ran 7 tests … OK: 61750 write sets (200 overflowed, 18440 recovered …) and 107 cooperative write sets agree with the per-pixel writer (153953 spilled writes, 411 dropped at the cascade edge, 39060 overflowed texels) in both dialects; dropped_flush, dropped_spill, wrong_window_origin, inclusive_window_bound each fail with cooperative window disagrees with the per-pixel writer; the twin test checks kSunDepthSlabWindowTexels across the three twins and the group size across the two wrappers, the system constant and the Metal registry. Neighbours OK; shader_parity_audit: clean; all three targets built. Amended head: ruff check scripts/ clean (the eight E501 lines rewrapped), test_render_box_face_projection.py OK with the slab-write stub and the new nearest_only_primary control, test_render_legacy_shadow_bake.py OK, the probe-row gtest PASS with its positive control. CI: fleet-tests on this head fails on test_fleet_tests_workflow_paths.sh / test_fleet_test_subjects.py (unregistered scripts/perf/sdf_controls.py), fixed on master by #4878 and not in this branch's fork point; it clears on the merge rebase.
6. Decision recorded: design-doc row, README cost section and PR body state adopted or compiled out with per-cell readings; kSunDepthSlabSlots matches in the three twins grep -n 'kSunDepthSlabSlots = ' engine/prefabs/irreden/render/sun_face_query_layout.hpp engine/render/src/shaders/ir_sun_face_query_layout.glsl engine/render/src/shaders/metal/ir_sun_face_query_layout.metal 0u in all three; compiled out, the design-doc row and "cost and the budget work" section carry the four-arm readings, the attribution and the two recorded levers; README "Budget" sections and this body likewise.

Plan departures

  • Decision 1: the branch's rectangular CSV probe ships as --sun-primary-rect-probe (the plan left the name to the implementer); master's --sun-primary-probe flag is unchanged.
  • Decision 2: the second-depth diagnostic wrapper keeps per-pixel writes (its "nearest slot's loser" semantics depend on per-write atomic returns), as the direction confirms; the slab extrema are fed under both wrappers.
  • Decision 4 (as corrected): the phases run reset, footprint reduction, init, splat, flush rather than init first, so a tile without a caster has an empty footprint and does no window work and a caster tile clears and flushes only the rectangle its boxes reach; the direction's sequence (init, reduce, splat, flush) was measured first (budget/cooperative-full-window/) and is within the spread of the restructure. The single slab write delegates to mergeSunDepthSlabPair (the same loads and atomics as the prototype's loop, now one copy), and the window's shared claim restates that loop over the shared words because GLSL cannot pass a shared array.
  • Decision 6: the plan's --baseline <zero-slot-build> --head build form is preserved; the driver takes --arm name=tree so every arm interleaves in one window. The capture baseline is the zero-slot base arm, since master's own binary rejects the stacked scenes' fixture flags (plan, Verified current state); master's binary is measured in cost on canvas-lower (criterion 4).
  • Phase 0 mechanism: the probe reads the main canvas depth and projects through the resident FrameDataVoxelToCanvas / FrameDataSun uploads with the CPU iso twins; it also reports 8x8 grouping and a 64 window, and now the per-write spill share. The committed census frame is the zoom-2 capture shot (16,008 caster pixels on the lower cell); the timing cells profile at zoom 1, whose frame (4,002 casters) is committed beside it as footprint/<cell>-zoom1.csv.
  • Plan correction (fillBuffer census): both test doubles take the four-argument override; the three-argument form is a non-virtual convenience, so the nine production callers and the Python-generated stubs are unchanged.
  • The legacy bake harness (test_render_legacy_shadow_bake.py) extracts the production main from behind the cooperative #if and stubs IRPrefab::Camera::getYawSplit plus the RasterBakeDispatch selector; same controls, same expected failures.
  • The host display slept during one timing attempt (Discovered 0 display monitors); every GPU window ran under caffeinate -d -i -u, and the one quiet-window breach (exit 76, canvas-lower attempt 1) was retaken whole.

Notes for reviewer

Linux perf-gate on the design-unblocked head (53c77f701-ci vs perf-baseline@955715317, master 4d4a9c114, 1.3 d old, no measured master improvement to the merge base): passes; bakeSunShadowMap GPU stage 14.84→15.56 / 28.15→27.94 / 65.19→65.48 / 25.53→24.50 ms on the four llvmpipe cells, the system row at most +9.2% (IRLuaPerfGrid zoom 1, under the 10% threshold, the other three within ±2.2%). At zero slots the bake dispatches are master's, so the earlier flagged run against the 2.9-day-old baseline reads as runner drift.

fleet-pr-overlap --base master: VERDICT: overlap — #4864 shares engine/render/src/metal/metal_render_impl.cpp and test/render/gpu_compute_dispatch_test.cpp, both trial merges clean (this PR's hunks there are the fillBuffer offset overload and one upload test, unchanged this iteration).

Design-unblocked resume: the direction's decision 4 is built, measured and found over budget, so the shipped render path is master's (zero slots). The diff a reviewer should read: the window include and the cooperative body under its define (both dialects), the bake system's rasterBakeDispatch selection, the harness emulation and controls, the probe's spill share, and the evidence (budget/, captures-*.json, README, design doc). The frozen arms' identities are in budget/*/manifests.json and the capture JSONs; the per-pixel and fills arms are pool-2's frozen trees from the previous iteration (same binary hashes as the committed manifests), the head arm is this head at three slots.

Closes #4845

🤖 Generated with Claude Code

jakildev and others added 2 commits November 1, 2026 19:30
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the splat footprint

The opt-in raster sun depth-slab layer, rebased onto the bake body split,
stays compiled out at zero slots. Its slab planes are now stored min planes
then max planes and cleared by two contiguous device fills through a
RenderDevice::fillBuffer that takes a byte offset on both backends; the
per-texel clear kernel no longer loops over slots. Measured on three frozen
build trees in guarded interleaved windows, the fills are cost-neutral
against the per-texel clear, so the writer's dependent loads carry the
layer's 2x bake cost on the two small raster cells.

A capture-only footprint probe reports, per bake workgroup and cascade, the
sun-texel bounding box of the pixels' splat boxes and the share that fits a
fixed shared-memory window at 16x16 and 8x8 grouping. At the 32-texel window
the 32 KiB threadgroup floor allows for three slots, 54% / 81% of the small
raster cells' caster pixels fit (78% on the default scene), so the
workgroup-cooperative splat is not written here; the census and the
multi-arm timing driver carry the data the design decision needs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jakildev jakildev added fleet:wip Work in progress — not ready for review fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 2, 2026
@jakildev

jakildev commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

NEEDS-DESIGN

Phase 0 of the plan (footprint probe before the kernel) measured the cooperative-splat premise below its bar, so per the plan this PR stops after decision 5 (fills) with the layer compiled out. Contract break: decision 4 (workgroup-cooperative splat over a fixed window under the 32 KiB threadgroup floor) and criterion 3 cannot be honoured as written; criterion 1's two small raster cells stay far outside the gate without it (bake 1.93x to 2.11x, frame mean 1.30x to 1.69x on the current tree, three frozen arms, five guarded interleaved rounds, budget/<cell>/ab-timing.md).

The census (footprint/*.csv, README "Budget, phase 0"; validated against the bake's own primary-texel census within 2.5%): per 16x16 bake workgroup the median tile spans 27 (cascade 0) / 20 (cascade 1) base texels on the small raster cells and 23 / 22 on the default scene, plus the 14-texel splat halo. Fraction of caster pixels whose box fits a window anchored at the group's bounding-box minimum:

Cell Group Cascade 32 40 48 64
canvas-lower / stacked-128 16x16 0 54% 85% 89% 97%
canvas-lower / stacked-128 16x16 1 81% 90% 96% 99%
canvas-lower / stacked-128 8x8 0 94% 94% 94% 99.6%
canvas-lower / stacked-128 8x8 1 94% 95% 99% 100%
canvas-default-raster 16x16 0 / 1 78% / 85% 99.5% / 99.7% 100% 100%
canvas-default-raster 8x8 0 / 1 99.8% / 99.9% 100% 100% 100%

Nearest word + three (min, max) pairs = 28 B per window texel, so the 32 KiB floor holds a 32 window (28,672 B): 54% / 81% / 78% against the plan's 95% / 90%. The redundancy a tile reduction removes is real (29x to 43x box writes per texel inside a tile; 164x per written texel across tiles). The fills (decision 5) are cost-neutral: within 0.12 ms of the per-texel clear on every bake and envelope row, so the writer's dependent loads are the whole cost.

Questions (one decision needed; options with my view):

  • Which window shape and per-texel representation does the cooperative splat take, given the census?
    • (a) 8x8 workgroups, 32 window, full representation (28 B/texel, 28,672 B): fits 94% of the small cells and 99.8% of the default scene; the bake kernels' dispatch and the Metal threadgroup registry entries change from 16x16 to 8x8 (both wrappers; the per-axis and detached dispatches share the body). 64 threads flush 1,024 window texels (16 each). My preference: it keeps decision 4's exactness argument unchanged (same claim logic in shared memory, three slots, overflow bit) and needs no new fallback class.
    • (b) 16x16, 48 window, nearest + one (min, max) pair (12 B/texel, 27,648 B): fits 89% / 96% / 100%; a texel whose tile touches a second slab spills that write to the per-pixel global path. Fewer shared atomics per write but a new "second slab in tile" fallback the harness must emulate.
    • (c) 16x16, 40 window, nearest + two pairs (20 B/texel, 32,000 B): 85% / 90% / 99.5%; same spill class as (b) for a third slab.
    • (d) Accept the 32 window at 16x16 as planned and let 46% / 19% of the small cells' pixels take the per-pixel path; measure anyway. Cheapest to build, least likely to pass the gate.
  • Does the 95% / 90% premise threshold stand as the go / no-go for the kernel, or is the gate the timing alone (pixels outside the window are exact either way, only slower)? If timing alone, (a) can proceed without re-measuring the premise.

Everything else in the plan holds: rebase (decisions 1 to 3) done, fills and fillBuffer offset (decision 5) done and measured, the probe committed, the layer compiled out at zero slots with the design-doc row and README recording the per-cell readings. The resumed worker needs the kernel (decision 4 as answered), the harness emulation with the three window controls, the capture matrix on the per-pixel and cooperative arms (criteria 2, 3), the master-vs-base cost cross-check (criterion 4), and decision 7.

@jakildev jakildev added fleet:design-blocked Worker escalated for architectural input mid-task; architect should respond fleet:reviewing-mac-pool-3 labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-9v45-96-unknown

perf comparison: ec70f10 → aae963c-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-9v45-96-unknown/ec70f10c01d23624051e8c800651a24d365eb254
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/aae963caf-ci

host calibration

  • host: linux-x86_64-epyc-9v45-96-unknown (matches baseline)
  • ref_ms: head 63.75 vs baseline 57.81 (load_factor 1.10×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@ec70f10c0 (branch tip); master ef578cf13, finished 2026-10-30T06:47:02Z, 2.9 d before the head run, ref_ms 57.81
  • weighting: raw (class-matched capture; load_factor 1.10×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master ef578cf13 and merge base 8a3840064 (25 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 262144 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.788 → 0.788 (+0.0pp) 156630 → 156630 262144 → 262144 50080 → 50080 (1.000×)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 262144 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.990 → 0.990 (+0.0pp) 255592 → 255592 262144 → 262144 3862 → 3862 (1.000×)

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 316.79 → 315.73 (-0.3%) 1066.40 → 1027.47 (-3.7%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 789.82 → 776.63 (-1.7%) 1545.76 → 1498.27 (-3.1%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 374.51 → 384.44 (+2.7%) 5352.30 → 5282.95 (-1.3%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1038.25 → 1035.69 (-0.2%) 1765.57 → 1707.06 (-3.3%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 41.55→42.00 41.33→40.41 36.55→36.30 0.67→0.63 ↓ 36.45→35.30 4.99→4.52 ↓ — 0.00→0.00 1.25→2.23 ⚠ 4.76→10.01 ⚠ 14.71→13.11 ↓ 12.88→12.62 3.28→2.63 ↓ 1.13→0.92 ↓ 0.18→0.13 ↓ — 6.27→5.29 ↓
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 79.40→77.47 244.57→241.27 156.41→153.62 4.78→2.42 ↓ 138.90→137.47 4.74→4.66 — 0.00→0.00 1.10→2.06 ⚠ 11.51→18.25 ⚠ 13.01→11.80 ↓ 11.18→10.58 ↓ 6.15→5.44 ↓ 1.43→1.00 ↓ 0.18→0.12 ↓ — 5.95→4.90 ↓
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 34.41→37.38 46.16→46.67 37.51→38.01 5.65→5.73 29.86→30.64 5.64→5.55 0.72→0.73 0.00→0.00 0.76→0.65 ↓ 25.80→28.77 ⚠ 11.84→11.52 24.91→25.30 4.17→4.12 1.20→1.20 0.13→0.12 ↓ 0.00→0.00 6.09→5.78 ↓
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 81.24→80.65 301.09→301.78 248.74→248.31 3.77→3.72 217.66→215.96 5.05→4.80 ↓ 0.77→0.73 ↓ 0.00→0.00 0.69→0.51 ↓ 7.89→14.93 ⚠ 12.22→11.65 10.81→10.45 4.76→4.11 ↓ 1.32→0.97 ↓ 0.15→0.12 ↓ 0.00→0.00 5.63→4.84 ↓

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 164.152 → 162.096 (-1.3%)
RENDER ComputeLightVolume 27.204 → 25.399 (-6.6%) ↓
RENDER CanvasToFramebuffer 12.842 → 11.608 (-9.6%) ↓
RENDER BakeSunShadowMap 1.225 → 7.160 (+484.5%) ⚠
RENDER ComputeSunShadow 4.687 → 4.986 (+6.4%)
UPDATE PropagateTransform 2.792 → 2.823 (+1.1%)
RENDER LightingToTrixel 3.394 → 2.736 (-19.4%) ↓
UPDATE FogRevealEval 2.312 → 2.659 (+15.0%) ⚠

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 630.881 → 617.456 (-2.1%)
RENDER ComputeLightVolume 23.692 → 22.028 (-7.0%) ↓
RENDER ComputeSunShadow 11.466 → 13.786 (+20.2%) ⚠
RENDER CanvasToFramebuffer 12.352 → 10.665 (-13.7%) ↓
RENDER BakeSunShadowMap 1.089 → 6.458 (+493.0%) ⚠
RENDER LightingToTrixel 6.399 → 5.581 (-12.8%) ↓
RENDER ComputeVoxelAO 5.526 → 5.228 (-5.4%) ↓
UPDATE PropagateTransform 2.609 → 2.716 (+4.1%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 167.005 → 170.925 (+2.3%)
RENDER ComputeSunShadow 25.352 → 24.354 (-3.9%)
RENDER ComputeLightVolume 23.052 → 23.203 (+0.7%)
RENDER LightingToTrixel 14.689 → 14.564 (-0.9%)
RENDER CanvasToFramebuffer 11.851 → 11.551 (-2.5%)
RENDER BakeSunShadowMap 1.836 → 8.364 (+355.6%) ⚠
UPDATE PropagateTransform 3.727 → 3.861 (+3.6%)
RENDER FogToTrixel 3.556 → 3.574 (+0.5%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 859.274 → 857.277 (-0.2%)
RENDER ComputeLightVolume 22.681 → 21.829 (-3.8%)
RENDER ComputeSunShadow 7.820 → 10.897 (+39.3%) ⚠
RENDER CanvasToFramebuffer 11.706 → 10.685 (-8.7%) ↓
RENDER BakeSunShadowMap 1.105 → 5.970 (+440.3%) ⚠
RENDER LightingToTrixel 4.901 → 4.234 (-13.6%) ↓
RENDER ComputeVoxelAO 4.129 → 3.950 (-4.3%)
UPDATE PropagateTransform 3.837 → 3.911 (+1.9%)

@jakildev

jakildev commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Architect direction

Design answerer, dispatched on this non-epic block. Both questions are engine design and are decided below; nothing here is a product call.

1. The gate is timing; the premise bar is retired

Decision 7 is the gate: bakeSunShadowMap against F = 0.064 / 0.029 ms by (i) or (ii), steady frame mean and p99 within 1.10x by point estimate, all five cells. The 95% / 90% premise was a proxy for the residual that writes outside the window add, and the census scores it at the wrong granularity: the probe counts a pixel as unfit when any texel of its 15x15 box leaves the window (reach.x < W && reach.y < W in writeSunBakeFootprintProbe), while the kernel's natural unit is the write. At the per-pixel arm's measured delta (+1.54 ms on canvas-lower), a 6% per-pixel spill alone is about +0.09 ms, above F before the kernel costs anything; the same tiles spilled per write (only the texels outside the window) cost a fraction of that. So: spill per write (§2), re-score the census per write and commit it as evidence beside the pixel-level table, no new premise bar, proceed to the kernel.

2. Shape: option (a), with three corrections

8x8 pixel tile, 32x32 window, full representation (nearest word + three (min, max) pairs = 28 B per texel, 28,672 B), the branch's claim logic in threadgroup memory. Your preference, and derivable from the record: it keeps decision 4's exactness argument intact and adds no fallback class.

The invariant the kernel and the harness rest on, stated once: the primary layer's final state is a function of the write set alone. Nearest word = min over the set (associative, so byte-identical under any grouping); slabs = the set union of the writes' slabs with per-slab extrema, overflow sticky once a texel has seen more than three distinct slabs (the receiver answers from the nearest word on overflow, so which three slots survive is unobservable). Any writer that partitions the write set across paths is exact iff every write lands exactly once in a path that ends in the global merge. Window size, group shape and anchor never enter exactness; they only move cost.

Corrections to decision 4 as planned:

  • Spill per write, not per pixel. For each (dx, dy) of a pixel's box: inside the window → shared claim; outside → writeSunPrimaryDepth on global, the helper that exists today. A pixel never takes a whole-box path.
  • A third wrapper, not a group-size change to the existing kernels. c_bake_sun_shadow_map_cooperative.{glsl,metal} includes the body under a cooperative define, declares the 8x8 local size (the body's local_size literal moves under a macro, default 16) and the shared window; one registry line at (8, 8, 1) for that kernel alone. c_bake_sun_shadow_map, _second_depth and c_clear_sun_shadow_map stay at 16x16 and byte- and cost-identical to master, which is what criterion 4 measures. The bake system constructs the cooperative program only when kSunDepthSlabSlots > 0 and selects it per dispatch when that dispatch's splat radius is non-zero (main canvas; detached casters that keep their splats); radius-0 dispatches (the per-axis resolve, no-splat detached) keep the production wrapper and its per-pixel write, since one write per pixel has no redundancy to remove. This follows the render module's hot-kernel rule (compile-time specialisation of the shared body, no dispatch-uniform runtime mode branch) and resolves the plan's registry gotcha. Decision 2 stands: the second-depth diagnostic keeps per-pixel writes.
  • The window is a layout constant. kSunDepthSlabWindowTexels = 32u in the three layout twins beside the slot count, with a static_assert in the C++ twin that window² × (1 + 2 × slots) × 4 ≤ 32768; the harness asserts the three twins agree, as it does for the slot count.

Kernel contract (everything not listed is the implementer's call):

  • Per cascade, sequentially through the one window: initialise (nearest and min words to 0xFFFFFFFF, max words to 0, the same sentinels as the global planes), barrier; reduce the group's base-texel minimum (shared atomicMin on x and y), barrier; anchor = minimum − radius; splat with per-write routing; barrier; flush; barrier before the next cascade's initialise. Every lane reaches every barrier: a lane with no caster, a culled fog pixel or a pixel outside the canvas predicates its work and still runs the barriers and its share of the flush (the plan's gotcha).
  • Flush: each lane walks 1,024 / 64 = 16 window texels. A texel whose nearest is EMPTY is skipped; one whose map position lies outside the cascade is dropped exactly as writeSunTexel drops it today; otherwise one global atomicMin of the nearest word, then per claimed shared slot one global merge of the pair (claim with the compare-swap on the shared min's slab as writeSunDepthSlab does, then atomicMin / atomicMax of the two words), and a shared overflow bit propagates with atomicOr. The shared sets plus the spilled writes are the per-pixel write set, so overflow fires on the same texels.
  • GLSL: the shared arrays are file-scope shared declarations in a fragment only the cooperative wrapper includes (ir_sun_depth_slab_window.glsl; the Metal twin takes threadgroup pointers, the c_build_sun_hierarchy precedent). Register the new paths in shader_names.hpp; functionUsesImageAtomicScratch is unchanged (no image atomics).

Rejected: (b) and (c) add a second spill class (a second slab inside one tile) that the census did not measure and that concentrates on exactly the stacked-caster edges the layer exists to repair, each with its own harness emulation and controls; one censused spill class is the design. (d) at 16x16 the median footprint is 41 texels against a 32 window on the two gated cells; at the measured per-write cost any double-digit spill share fails F.

3. Harness (criterion 5)

As planned, plus one control: a spill write dropped instead of routed to global must fail by name. The lane-by-lane emulation uses the barriers as phase boundaries and compares the flushed-plus-spilled global state with the per-pixel writer's on every write set, including the sets that overflow.

4. Gate, adoption and the failure branch

Decision 7 is unchanged; criteria 1 to 4 and 6 are unchanged; the arms are decision 6's (base, per-pixel, fills, HEAD). If the bake row fails on either small cell, finish per decision 7 (compiled out, residual per path, the failing cell and row named in the PR body) and add one attribution arm: the cooperative kernel with the slab words compiled out (nearest only through the window), so the design note separates window overhead from slab-merge cost. Record in the design note, do not build, the two next levers: 256 threads over the 8x8 tile (four lanes per pixel splitting the box rows) if the attribution reads as occupancy; a load-free direct-mapped slab table (slot = slab mod slots, fire-and-forget atomicMin / atomicMax, the receiver trusting an extremum only when its slab equals the queried slab and answering from the nearest word otherwise) if the cost is the merge's dependent loads. That lever's premise is a collision census, distinct slabs congruent mod three on one texel across the README matrix, computable from the per-pixel arm's --sun-primary-rect-probe CSVs with no GPU run; attach it to an unlabeled follow-up if that branch is taken.

The perf-gate comment of 04:53Z flags bakeSunShadowMap on all four llvmpipe cells against a baseline 2.9 days older than the merge base. At zero slots this PR's bake path is master's, and the merged Morton-order PR's gate flagged the same row against a 0.2-day-old baseline, so it reads as the runner's; the resumed worker still attributes it (raw artifact, diagnostic pair, the perf-gate traps) before claiming criterion 4 on the Linux lane.

5. Docs and plan

Source of truth for the layer's model: docs/design/sun-face-index-capacity.md § "Depth-slab extrema: the opt-in layer", which this PR already owns (decision 3) and criterion 6 rewrites; the invariant in §2 lands there in this PR, so no separate docs task is filed. A ## Plan corrections comment on the backing issue carries the replaced decision 4, the replaced phase 0 paragraph and the criterion 5 addition verbatim; no Plan stale: flip is owed. fleet:fable and fleet:needs-macos-host go on this PR before the design-unblock edge (the timing lane is this host's Metal M4 Max; the GLSL twin is authored alongside and executes in the CPU harness).

Read this direction alongside the issue's ## Plan comment and both ## Plan corrections before resuming.

@jakildev jakildev added fleet:fable Model-affinity tag (fable class — opt-in for hard work); heavy lane dispatches it on Fable fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file and removed fleet:design-blocked Worker escalated for architectural input mid-task; architect should respond fleet:reviewing-mac-pool-3 labels Nov 2, 2026
…er compiled out

Builds decision 4 as the design answer corrected it: a third bake wrapper,
c_bake_sun_shadow_map_cooperative, runs the shared body at an 8x8 pixel
tile and reduces each cascade's splat boxes over a 32-texel threadgroup
window (kSunDepthSlabWindowTexels in the three layout twins, 28 bytes per
texel under the asserted 32 KiB floor), routing each box write per texel
between the shared claim and the per-pixel global write. The bake system
constructs it only with slots compiled in and dispatches it where the
coverage splat is engaged; the production, second-depth and clear kernels
stay at 16x16. The single slab write is the degenerate pair of the merge
the flush uses.

The kernel is exact (receiver hashes identical to the per-pixel writer on
all 58 captures; the harness emulates the window lane by lane with the
barriers as phase boundaries and agrees on every write set, four window
controls failing by name) and slower than the writer it replaces: the
bake row at 3.28x / 2.80x of the base arm on the two small raster cells,
with the nearest-only window skeleton alone costing +0.66 ms against
floors of 0.064 / 0.029 ms. Decision 7 fails, so the shipped layout stays
at zero slots and the dispatches are master's (measured against master's
binary: bake 1.004x, frame mean 1.022x). The design note records the
residual per path and the two next levers; the footprint probe now reports
the per-write spill share.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jakildev jakildev removed fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file fleet:wip Work in progress — not ready for review fleet:amending-mac-pool-1 labels Nov 2, 2026
@jakildev

jakildev commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Addressed the design direction (decision 4 as corrected, phase 0 spill share, criterion 5 controls):

  • Built the cooperative splat as a third wrapper, c_bake_sun_shadow_map_cooperative.{glsl,metal}, 8x8 tile, 32-texel threadgroup window (kSunDepthSlabWindowTexels in the three twins, static_assert under 32 KiB), per-write spill, shared arrays and phases in ir_sun_depth_slab_window.{glsl,metal}; the bake system constructs it only at slots > 0 and selects it where the splat is engaged. The single slab write is now the degenerate pair of the merge the flush uses.
  • Exact natively and in the harness: receiver hashes identical to the per-pixel writer on all 58 captures; lane-by-lane emulation agrees on 107 write sets in both dialects; dropped flush, dropped spill, shifted flush origin and inclusive window bound fail by name; a twin test ties the window constant and the 8x8 group size across the wrappers, the system and the Metal registry.
  • Over budget: bakeSunShadowMap 3.28x / 2.80x of the base arm on canvas-lower / canvas-stacked-128 (per-pixel arm 1.87x / 2.08x). The attribution arm with the slab words compiled out still costs +0.66 ms on both cells (10 / 22 floors), so the window skeleton itself fails before any slab work; the shared-memory claim adds +2.6 / +2.0 ms. The first full-window form and the footprint-rectangle restructure both measured; neither reaches the floor.
  • Decision 7 fails: shipped at zero slots, dispatches master's, measured against master's own binary (bake 1.004x by (i), frame mean 1.022x); render-verify, light-verify and the default capture replay byte-identical at zero slots. Design-doc row and cost section, README Budget sections and the PR body record the residual per path; the direct-mapped slab table lever is filed as render: load-free direct-mapped slab table for the raster sun depth-slab layer #4874 with its collision census (4 of 79,738 multi-slab texels).
  • Perf-gate attribution for the Linux lane still owed on the new head's run once CI posts it; at zero slots the bake path is master's.

Evidence under docs/pr-screenshots/claude/4799-sun-raster-depth-slabs/ (budget/, budget/attribution/, budget/cooperative-full-window/, budget/master-vs-base/, captures-{baseline,per-pixel,head,default}.json, footprint/*-zoom1.csv).

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — render: clear the sun depth-slab planes with device fills and census the splat footprint

Verdict: needs-fix

Needs-fix

  • IRPrefab::SunShadow::writeSunPrimaryDepthProbe (engine/prefabs/irreden/render/sun_shadow_probe.hpp:398) reads the overflow bit from slabs[width + i]. The buffer is populated plane-major as all kSunDepthSlabSlots min planes followed by all max planes, so on the intended three-slot build this indexes min plane 1 rather than max plane 0. The CSV overflow column, and therefore capture.py's committed overflow census, can be wrong. Read max plane 0 at slabs[kSunDepthSlabSlots * width + i] and add a probe-level regression that enables more than one slot and distinguishes min plane 1 from max plane 0.
  • The current head's mandatory python-lint check fails with eight E501 errors in the changed harnesses: scripts/tests/test_render_legacy_shadow_bake.py:47 and scripts/tests/test_render_sun_depth_slab.py:427,469,686,695,927,939,942. This is the PR's own red CI result and must be clean before merge.

Acceptance (issue #4845)

Criterion Grade Evidence
1. Timing and attribution Met via the specified failure branch The five-cell evidence is committed; both gated cells fail, and the required nearest-only attribution plus residuals and next levers are recorded.
2. Recovery matrix Met by committed evidence The PR reports the beyond-throw matrix repaired and 17/17 control receiver hashes identical to the base arm. The overflow-column defect above still needs correction so the probe evidence is trustworthy.
3. Cooperative exactness and speed Exactness met; speed unmet and handled by compile-out Receiver hashes agree on all 58 captures and the emulation agrees on 107 write sets. The cooperative arm is slower than the per-pixel arm on both gated cells, so decision 7 correctly keeps the feature disabled.
4. Zero-slot opt-out identity Met by committed evidence The shipped zero-slot arm reports both render verifiers and light-verify passing, identical default captures, bake at 1.004x, and steady mean at 1.022x versus master.
5. Harness and build checks Not established on the current head The PR records its local harness/build checks, but current python-lint is red; linux-build, render-harness-tests, and fleet-tests were still pending at review time.
6. Decision and layout twins Met The README, design note, and PR body record compile-out and residual costs; all three twins ship zero slots and the same 32-texel window.

Praise

  • The failure branch is unusually well attributed: the nearest-only arm separates the window skeleton from the slab merge, and the shipped zero-slot path preserves the current render behavior instead of forcing an over-budget experiment into production.

Test plan the author should run before re-review

  • ruff check scripts/
  • Add and run a multi-slot regression for writeSunPrimaryDepthProbe's overflow-plane selection.
  • Let linux-build, render-harness-tests, and fleet-tests complete successfully on the amended head.

Reviewed by Codex (GPT-5), runtime codex.

Opus recheck required: this changes core render shaders, cross-backend atomics, and threadgroup synchronization.

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:reviewing-mac-pool-3 labels Nov 2, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 2, 2026
…slab write in the box-face fixture

The rectangle probe's CSV row now comes from writeSunPrimaryDepthProbeRow,
which takes the slot count and reads the sticky overflow bit from max
plane 0 (planar storage puts it right after the last min plane); the old
read landed on min plane 1, whose EMPTY sentinel carries the same bit, so
every single-slab texel reported overflow. A gtest drives the row writer
at three slots with the two words disagreeing both ways. The head arm's
capture matrix is re-taken with the corrected probe: receiver hashes
unchanged on all 46 captures, overflow census identical to the per-pixel
arm's on every cascade row.

The box-face fixture stubs writeSunPrimaryDepth in both dialects, asserts
the primary layer alone goes through it, and adds a nearest-only mutation
that fails by name. The eight over-long harness lines are rewrapped.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jakildev

jakildev commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Addressed feedback (review of 2026-11-02T08:45Z):

  • test_render_box_face_projection.py::test_fog_cut_shape_index_and_depth_layer: the fixture now carries a writeSunPrimaryDepth stub for both dialects (the Metal call's leading sunDepthBuf argument is stripped as the sibling test does) that counts primary writes; the production body asserts the primary layer's write goes through it and the indexed fallback stays a nearest-only atomicMin, and a nearest_only_primary mutation fails by name (exit 7). Both dialects OK, all five variants.
  • writeSunPrimaryDepthProbe overflow column: the row formatter is now writeSunPrimaryDepthProbeRow(..., slots) reading the flag from max plane 0 (slabPlanes[slots * stride + column]); test/render/sun_shadow_probe_test.cpp (SunPrimaryDepthProbeRowTest) drives it at three slots with a texel whose min plane 1 is EMPTY and max plane 0 unflagged, and one with the reverse, so both overflow columns flip under the old read (positive control run: FAILS with the index pointed back at plane 1, PASSES restored). The committed captures-head.json was wrong (e.g. floor reported 1,225 overflowed texels on single-slab rows); re-captured at three slots with the corrected probe under ir-acquire gpu: all 46 receiver hashes unchanged, the overflow census identical to the per-pixel arm's on 80 of 80 cascade rows. README and the PR body's criterion 2 row updated; the Phase 0 table was already the per-pixel arm's and stands.
  • python-lint: the eight E501 lines rewrapped; ruff check scripts/ clean. test_render_sun_depth_slab.py (7 tests) and test_render_legacy_shadow_bake.py OK after the rewraps.
  • Zero-slot identity on the amended head: render-verify --target IRCanvasStress --no-build all 59 checks PASS, light-verify --if-changed all checks PASS, the four captures-default.json cases re-captured on the rebuilt binary with receiver hashes identical to the committed default and the base arm (JSON refreshed to the new binary hash).
  • Not amended: fleet-tests / gate on this head fail on the unregistered scripts/perf/sdf_controls.py subject, fixed on master by build: register scripts/perf/sdf_controls.py as a fleet-tests subject #4878 after this branch's fork point; a master merge here would void the zero-slot capture identity, so it clears on the merge rebase. Linux perf-gate on the previous head passed; attribution added to the body.

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — render: clear the sun depth-slab planes with device fills and census the splat footprint

Verdict: approve

Prior-review resolution

  • ✅ scripts/tests/test_render_box_face_projection.py::BoxFaceProjectionTest::test_fog_cut_shape_index_and_depth_layer — the fixture now provides the slab-aware primary writer in both dialects, asserts that only primary-layer writes use it, and the nearest_only_primary mutation fails at its named control — verified at 353ada28e.
  • ✅ IRPrefab::SunShadow::writeSunPrimaryDepthProbeRow — overflow is read from max plane 0 at slots * stride + column; the three-slot regression makes min plane 1 and max plane 0 disagree in both directions — verified at 353ada28e.
  • ✅ scripts/tests/test_render_legacy_shadow_bake.py and scripts/tests/test_render_sun_depth_slab.py — the eight E501 findings are rewrapped and Ruff is clean — verified at 353ada28e.

Acceptance (issue #4845)

Criterion Grade Basis
1. Timing and attribution met via the specified failure branch The committed evidence records both gated bake failures, the nearest-only attribution arm, residuals, and the two next levers; the shipped slot count remains zero.
2. Recovery matrix met The corrected head capture keeps the prior receiver-hash sequence exactly, and its overflow sequence matches the per-pixel arm exactly across the recorded rows.
3. Cooperative exactness and speed met via compile-out The slab harness still proves agreement on all 107 cooperative write sets in both dialects; the over-budget cooperative path remains disabled.
4. Zero-slot opt-out identity met by committed evidence The amended evidence records the zero-slot render/light verification and unchanged default receiver captures.
5. Harness and build checks met for the amendment Local Ruff, box-face projection, legacy bake, and seven-test slab harness runs pass; IrredenEngineTest builds and both SunPrimaryDepthProbeRowTest cases pass. GitHub linux-build, render-harness-tests, fleet-tests, and perf-gate were still pending when reviewed, so they are not claimed green here.
6. Decision and layout twins met The layer remains compiled out at zero slots and the decision/evidence record remains consistent.

Praise

  • The regression distinguishes the exact two planar words involved in the original bug in both directions, so it would fail for the prior index rather than merely exercising the corrected output shape.

Validation reviewed

  • ruff check scripts/tests/test_render_box_face_projection.py scripts/tests/test_render_legacy_shadow_bake.py scripts/tests/test_render_sun_depth_slab.py — pass.
  • python3 scripts/tests/test_render_box_face_projection.py — 2 tests pass in both dialects.
  • python3 scripts/tests/test_render_legacy_shadow_bake.py — 3 tests pass.
  • python3 scripts/tests/test_render_sun_depth_slab.py — 7 tests pass; both dialects agree on 107 cooperative write sets.
  • fleet-build --target IrredenEngineTest — pass.
  • fleet-run IrredenEngineTest '--gtest_filter=SunPrimaryDepthProbeRowTest.*' — 2 tests pass.

Reviewed by Codex (GPT-5), runtime codex.

Opus recheck not required (reviewed at opus class).

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-7763-64-unknown

perf comparison: a39c8ac → 72c0845-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-7763-64-unknown/a39c8ac258120f5ba954bc0d9e976fa3278dd6a7
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/72c0845e7-ci

host calibration

  • host: linux-x86_64-epyc-7763-64-unknown (matches baseline)
  • ref_ms: head 103.58 vs baseline 103.95 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@a39c8ac25 (branch tip); master 45cf005a8, finished 2026-11-03T04:41:55Z, 1.5 d before the head run, ref_ms 103.95
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master 45cf005a8 and merge base 4e8e10656 (3 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 262144 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.788 → 0.788 (+0.0pp) 156630 → 156630 262144 → 262144 50080 → 50080 (1.000×)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 262144 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.990 → 0.990 (+0.0pp) 255592 → 255592 262144 → 262144 3862 → 3862 (1.000×)

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 497.04 → 501.48 (+0.9%) 1736.72 → 1801.78 (+3.7%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 1279.98 → 1286.38 (+0.5%) 2588.51 → 2638.16 (+1.9%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 661.44 → 686.12 (+3.7%) 12290.31 → 13686.15 (+11.4%) ⚠
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1736.57 → 1747.40 (+0.6%) 3028.88 → 3070.71 (+1.4%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 66.99→67.81 66.51→66.36 58.93→58.31 0.96→0.99 54.97→55.78 5.75→5.63 — 0.00→0.00 2.81→2.80 15.21→15.84 11.94→12.06 23.11→23.36 3.85→4.05 1.27→1.36 0.19→0.24 ⚠ — 7.98→8.34
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 109.11→111.29 416.71→416.63 261.71→263.15 4.04→4.08 233.24→234.49 5.17→5.14 — 0.00→0.00 2.41→2.40 27.66→28.58 10.37→10.54 19.26→19.40 8.34→8.34 1.47→1.68 ⚠ 0.17→0.21 ⚠ — 7.44→7.66
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 60.26→59.39 81.24→83.39 66.07→66.93 13.15→13.76 47.97→48.37 8.60→9.01 1.12→1.14 0.00→0.00 0.87→1.01 ⚠ 62.83→68.34 10.65→10.77 56.24→61.06 8.01→8.33 1.81→1.86 0.17→0.23 ⚠ 0.00→0.00 9.00→9.38
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 120.51→121.70 536.65→536.53 424.94→427.95 6.35→6.34 366.04→368.76 5.63→5.58 1.17→1.15 0.00→0.00 0.75→0.88 ⚠ 24.64→24.94 10.46→10.65 19.42→19.43 6.77→6.79 1.59→1.75 0.17→0.22 ⚠ 0.00→0.00 7.43→7.75

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 256.310 → 256.908 (+0.2%)
RENDER ComputeLightVolume 34.529 → 34.869 (+1.0%)
RENDER CanvasToFramebuffer 17.421 → 18.059 (+3.7%)
RENDER BakeSunShadowMap 10.231 → 10.540 (+3.0%)
RENDER ComputeSunShadow 7.654 → 7.952 (+3.9%)
UPDATE PropagateTransform 4.943 → 4.912 (-0.6%)
UPDATE FogRevealEval 4.273 → 4.295 (+0.5%)
RENDER LightingToTrixel 4.024 → 4.211 (+4.6%)

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1027.979 → 1032.135 (+0.4%)
RENDER ComputeLightVolume 29.161 → 29.426 (+0.9%)
RENDER ComputeSunShadow 21.416 → 22.259 (+3.9%)
RENDER CanvasToFramebuffer 16.262 → 16.407 (+0.9%)
RENDER ComputeVoxelAO 9.306 → 9.711 (+4.4%)
RENDER BakeSunShadowMap 8.616 → 8.640 (+0.3%)
RENDER LightingToTrixel 8.543 → 8.526 (-0.2%)
UPDATE PropagateTransform 4.472 → 4.450 (-0.5%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 290.147 → 301.919 (+4.1%)
RENDER ComputeSunShadow 55.651 → 60.847 (+9.3%)
RENDER LightingToTrixel 35.503 → 39.459 (+11.1%) ⚠
RENDER ComputeLightVolume 32.468 → 33.461 (+3.1%)
RENDER BakeSunShadowMap 22.592 → 23.443 (+3.8%)
RENDER CanvasToFramebuffer 17.400 → 18.197 (+4.6%)
RENDER FogToTrixel 7.108 → 7.385 (+3.9%)
UPDATE PropagateTransform 6.358 → 6.214 (-2.3%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1459.634 → 1466.132 (+0.4%)
RENDER ComputeLightVolume 29.423 → 29.600 (+0.6%)
RENDER ComputeSunShadow 18.270 → 18.344 (+0.4%)
RENDER CanvasToFramebuffer 16.184 → 16.656 (+2.9%)
RENDER BakeSunShadowMap 8.842 → 8.949 (+1.2%)
RENDER ComputeVoxelAO 7.740 → 7.806 (+0.9%)
RENDER LightingToTrixel 6.894 → 6.972 (+1.1%)
UPDATE PropagateTransform 6.141 → 6.177 (+0.6%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend fleet:fable Model-affinity tag (fable class — opt-in for hard work); heavy lane dispatches it on Fable fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render: bring the opt-in raster sun depth-slab layer inside the frame budget

1 participant