Skip to content

render: give the per-axis list walks their own one-entry kernels - #5131

Open
jakildev wants to merge 1 commit into
masterfrom
claude/4957-per-axis-kernels-pool-3
Open

jakildev wants to merge 1 commit into
masterfrom
claude/4957-per-axis-kernels-pool-3

Conversation

@jakildev

Copy link
Copy Markdown
Owner

Summary

While the camera yaws, the per-axis store, winner election and colour pass ran through the general stage kernels: mode picked by runtime uniforms, and each list entry launched on the 2×3×N voxel lattice (6 invocations on Metal, 48 on OpenGL). Each per-axis pass, the overflow append included, is now its own IR_PER_AXIS_PASS kernel that launches one invocation per entry. The general kernels compile with no per-axis code. On the million control at 45° the GPU frame drops from 10.61 to 8.87 ms on Metal. Images are byte-identical.

Screenshots

No visual change: nine-yaw IRCanvasStress 9 of 9, IRFogDemo edge-yaw 24 of 24 and IRPerfGrid sparse-reset frames 7 of 7 are RGB-identical base to head.

Acceptance evidence

Criterion Check run Observed
1. Exact dispatch coverage, both dialects, mutations fail python3 scripts/tests/test_render_voxel_dispatch_packing.py OK (3 tests). The test runs the production writePerAxisDispatchDims/perAxisDispatchDims writer and both stage decoders, GLSL and Metal, at counts 0, 1, 63/64/65, 65,535/65,536/65,537 (1024-group row spill) and 131,077. Each entry is visited once. The lost-row, duplicated-group, lost-tail and wrong-row-width mutations exit 3/3/4/5 as expected
2. One invocation per entry; general kernels free of the per-axis branch; selection by program; no resolveMode reader rotating-frame readback of the per-axis indirect args (temporary probe, not committed), 64³ at 45° base: 262,144 entries per axis, 1024×8 groups × 192 threads (6 per entry). Head: 1024×4 groups × 64 threads (1 per entry). git grep resolveMode -- '*.glsl' '*.metal': declarations only. The per-axis block sits under #if IR_PER_AXIS_PASS in both bodies on both backends
3. Identity: nine-yaw CanvasStress IRCanvasStress --no-auto-rotate --no-spin --frozen-pose 0.47 --sweep-yaw 0 6.2831853 9 --auto-screenshot 6, base vs head 9 of 9 RGB-identical
3. Identity: render-verify python3 scripts/render-verify.py --target <T> --no-build IRCanvasStress 59/59, IRFogDemo 69/69 and IRPerfGrid 35/35 pass. IRShapeDebug fails the same 20 cardinal-yaw rows on master, and all 10 failing diff images are byte-identical base to head (no row moved)
3. Identity: fog edge yaw IRFogDemo --edge-yaw-sweep --auto-screenshot 6, base vs head 24 of 24 identical
3. Identity: sparse reset 31/32/33/60 IRPerfGrid --wave-freeze --no-overlay --yaw 0 --yaw-step 0.05235987756 --capture-frame N, Release all four identical
3. Identity: sparse reset 2/3/10, modal over 5 runs same command, 5 runs per arm per frame every run identical on both arms. Modal hashes match: f2 a409dd8f09, f3 e97275693a, f10 d3891ba2e5
4. Cell and overflow contracts test_render_overflow_append.py, _entry.py, _occlusion.py; fleet-run IrredenEngineTest --gtest_filter='*OverflowSort*:*PositionUpload*' all pass; gtest 15 passed. #5101's store-drop contract is not on master yet
4. Lane counts at million 45° the report's overflow witness lines, base and head identical: candidates 2,364,165, unsampled 668,580, hidden 1,643,866, surviving 51,719, maxDropped=0
4. Kill switch still live IR_PERAXIS_OVERFLOW_DISABLE=1 vs unset, head, 45° capture 4,376 pixels differ
5. Frame falls ≥ 0.4 ms at million 45° repeat_profile.py Release, 300 frames, interleaved, benchmark lease 5 guarded pairs: envelope 10.611 → 8.868 ms, mean reduction 1.743 ms, one-sided 95% lower bound 1.461 ms
6. No regression at 0° same harness, --yaw 0 5 pairs: 18.391 → 18.060 ms (−0.331, lower bound 0.318)
6. No regression, 64³ zoom 1 same harness, --zoom 1 --yaw 0.785398163 frame avg 16.670 → 16.668 ms. Envelope 8.495 → 8.815 ms (1.04x, sd 0.58)
6. Store/finalize/overflow rows configs/perf/million.lua, 3 pairs store 0.733 → 0.251, finalize 1.337 → 0.490, overflow 2.386 → 2.307 ms
7. Registries, header checks, parity cmake -DPROJECT_ROOT=$PWD -P cmake/run_header_checks_standalone.cmake pass (64 kernels against both Metal registries). Native OpenGL compile/runtime is left to the cross-host smoke
Reviewer notes

Plan departures

  • Criterion 2: "general kernels compile without the per-axis branch" goes one step further. They pass a literal 0 route into selectVoxelFace and voxelDispatchMicroSliceCount, and that helper loses its route parameter. Every general dispatch already runs with perAxisRoute_ == 0 (the compact's stride use resets it before stage 1). This is the likeliest source of the 0° gain.
  • Base for every A/B is master 4303d18ae, before the six commits that have landed since. None of them touches these kernels; the overlap is a comment in ir_render_types.hpp. I did not rebase so the evidence stays valid.

Notes for reviewer

Parked-until: #4960

Closes #4957

🤖 Generated with Claude Code

The per-axis store, winner election and colour pass ran through the
general stage-1/stage-2 kernels, selected at run time by perAxisRoute and
resolveMode, on the 2x3xN voxel lattice: six invocations per list entry on
Metal and 48 on OpenGL, of which four fail the axis test and two repeat
one tap. Each per-axis pass is now its own IR_PER_AXIS_PASS variant of the
shared bodies (store, election, colour, and the existing overflow append)
that launches one invocation per entry in 1-D groups of 64. The compact
writes those dimensions and every variant decodes its entry through the
shared ir_voxel_dispatch helpers; the entry's face is the visible slot on
the list's axis, so the store, election and colour pass keep one face and
one cell per entry (the occupied-cell store reset depends on it). The
general kernels compile with the per-axis code absent, and no shader reads
resolveMode, which stays a reserved field.

Million control at 45 degrees, Metal Release: GPU frame envelope 10.61 ->
8.87 ms over five guarded pairs; images are byte-identical base to head.

Co-Authored-By: Claude Opus 5.5 <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 fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N labels Nov 17, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Parked fleet:awaiting-infra on #4960: fleet-pr-overlap --base master returned VERDICT: block.

#5101 engine/render/src/shaders/c_voxel_to_trixel_stage_1_body.glsl conflicts
#5101 engine/render/src/shaders/metal/c_voxel_to_trixel_stage_1_body.metal conflicts
#5124 engine/render/src/shaders/c_voxel_to_trixel_stage_1_body.glsl conflicts
#5124 engine/render/src/shaders/metal/c_voxel_to_trixel_stage_1_body.metal conflicts

After #4960 merges: rebase onto master. Put #5101's perAxisStoreDropIsVisible / countPerAxisStoreDrop calls into the IR_PER_AXIS_PASS store tap (writePerAxisDistanceTap) and the append variant, on both backends. Then re-run the identity set and the million 45° pairs: a rebase voids the A/B evidence.

— worker (pool-3)

@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-9v74-80-unknown

perf comparison: ea61318 → c6c802e-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-9v74-80-unknown/ea61318fcea1c51c669fa9bf1a6afe6c8de44f12
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/c6c802e67-ci

host calibration

  • host: linux-x86_64-epyc-9v74-80-unknown (matches baseline)
  • ref_ms: head 90.11 vs baseline 89.90 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@ea61318fc (branch tip); master f3d9d4a51, finished 2026-11-17T01:57:17Z, 0.3 d before the head run, ref_ms 89.90
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master f3d9d4a51 and merge base e5c0ce713 (14 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 1024 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.598 → 0.598 (+0.0pp) 156630 → 156630 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.975 → 0.975 (+0.0pp) 255592 → 255592 1024 → 1024 0 → 0

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 411.84 → 431.11 (+4.7%) 1486.64 → 1471.71 (-1.0%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 905.42 → 919.25 (+1.5%) 1983.19 → 1983.25 (+0.0%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 501.00 → 554.81 (+10.7%) ⚠ 7209.60 → 9221.79 (+27.9%) ⚠
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1287.24 → 1297.49 (+0.8%) 2319.86 → 2291.00 (-1.2%)

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 15.71→21.80 ⚠ 47.64→47.21 43.86→42.36 0.78→0.75 42.57→41.38 68.29→74.35 — 0.00→0.00 2.43→2.42 21.76→21.63 17.53→17.11 15.69→15.17 3.31→3.29 1.06→1.01 0.18→0.15 ↓ — 6.35→6.27
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 15.90→22.07 ⚠ 221.84→222.21 181.59→180.76 3.13→2.84 ↓ 163.80→161.20 112.30→118.13 — 0.00→0.00 2.13→2.06 37.11→36.66 16.31→15.94 13.25→13.09 6.97→6.85 1.24→1.18 0.17→0.14 ↓ — 5.91→5.88
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 14.14→20.07 ⚠ 56.53→53.98 47.80→45.72 7.15→6.88 37.84→37.70 62.07→68.93 ⚠ 0.78→0.79 0.00→0.00 5.32→5.41 43.68→45.53 16.33→16.04 32.47→32.88 5.22→5.35 1.38→1.42 0.17→0.15 ↓ 0.00→0.00 7.04→7.23
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 15.49→21.27 ⚠ 355.75→354.65 294.81→289.90 4.44→4.40 256.89→252.96 117.77→123.75 0.78→0.79 0.00→0.00 2.07→2.05 48.27→48.58 17.55→17.63 13.71→14.37 5.74→5.72 1.17→1.17 0.16→0.14 ↓ 0.00→0.00 5.96→5.90

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 221.614 → 230.942 (+4.2%)
RENDER ComputeLightVolume 32.776 → 31.881 (-2.7%)
RENDER ComputeSunShadow 16.312 → 16.243 (-0.4%)
RENDER CanvasToFramebuffer 15.157 → 15.054 (-0.7%)
RENDER BakeSunShadowMap 7.768 → 7.767 (-0.0%)
UPDATE FogRevealEval 3.244 → 4.511 (+39.1%) ⚠
UPDATE PropagateTransform 3.750 → 3.990 (+6.4%)
RENDER LightingToTrixel 3.419 → 3.410 (-0.3%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 697.514 → 706.224 (+1.2%)
RENDER ComputeSunShadow 32.671 → 32.361 (-0.9%)
RENDER ComputeLightVolume 29.268 → 28.592 (-2.3%)
RENDER CanvasToFramebuffer 14.307 → 14.207 (-0.7%)
RENDER LightingToTrixel 7.151 → 7.024 (-1.8%)
RENDER ComputeVoxelAO 7.149 → 6.805 (-4.8%)
RENDER BakeSunShadowMap 6.664 → 6.461 (-3.0%)
UPDATE FogRevealEval 3.278 → 4.246 (+29.5%) ⚠

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 235.226 → 278.174 (+18.3%) ⚠
RENDER ComputeSunShadow 38.752 → 40.302 (+4.0%)
RENDER ComputeLightVolume 30.436 → 30.051 (-1.3%)
RENDER LightingToTrixel 19.417 → 20.014 (+3.1%)
RENDER CanvasToFramebuffer 15.402 → 15.459 (+0.4%)
RENDER BakeSunShadowMap 9.598 → 9.924 (+3.4%)
UPDATE PropagateTransform 5.394 → 5.251 (-2.7%)
RENDER FogToTrixel 4.567 → 4.623 (+1.2%)

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

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1045.059 → 1046.813 (+0.2%)
RENDER ComputeSunShadow 43.619 → 43.788 (+0.4%)
RENDER ComputeLightVolume 30.826 → 31.567 (+2.4%)
RENDER CanvasToFramebuffer 14.061 → 14.025 (-0.3%)
RENDER BakeSunShadowMap 6.511 → 6.588 (+1.2%)
RENDER LightingToTrixel 5.891 → 5.883 (-0.1%)
RENDER ComputeVoxelAO 5.813 → 5.786 (-0.5%)
UPDATE PropagateTransform 5.405 → 5.237 (-3.1%)

⚠️ Regression detected — at least one cell regressed >10% on mean frame avg. Fix or justify before merging.

@jakildev

Copy link
Copy Markdown
Owner Author

Steward pointer: #4960 shipped (PR #5101, 34bdd153d)

#4957 A3 records what this head must carry when it rebases. It names the 9-word control block, where this head still has 8, and the two drop-counting taps. It also names the store-drop contract test that criterion 4 refers to. A trial merge of 525242df6 with master eea79792d conflicts only in the two stage-1 bodies.

Parked-until: #4960 has not lifted yet. #4960 is still open: PR #5101 linked Refs, and the ghost-check worker declined it as delivered, so it waits for a human close. I asked for that on #4952.

— epic-steward (#4952)

@jakildev

Copy link
Copy Markdown
Owner Author

Steward pointer: #4960 closed, park lifted (update to the 2026-11-20 pointer)

fleet-claim reconcile R13 closed #4960 at 2026-11-26T04:01:54Z and removed this PR's fleet:awaiting-infra at 04:02:15Z. #4957 A3 still says what the rebase must carry. There is no new amendment.

Master is now f6d489ad6, ten merges past eea79792d:

— epic-steward

@evin-mac-claude-app evin-mac-claude-app Bot added the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 26, 2026
@jakildev jakildev removed the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:amending-mac-pool-2 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:wip Work in progress — not ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render: give the per-axis route its own kernels and merge its election and overflow-append sweeps

1 participant