Repository navigation
render: cull source-face alpha cutouts per face, force early tests - #5198
Conversation
GL shaded every fragment of the 128 coincident caster canvases before depth-testing them, because the early-route source-face fragment stage could discard: 13,568 invocations for 106 owned samples, each one running the exact overflowed-tile sun query. The alpha cutout is a per-face constant (faceColor is flat), so the shared vertex stage now clips any face with alpha < 0.1 to the route check's clipped position, neither fragment stage discards, and the early route forces early fragment tests (GLSL layout, Metal attribute). Pixels and tie owners are unchanged. Windows GL far-128 entityCanvasToFb: 63.2 -> 3.3 ms Debug and 63.9 -> 3.2 ms Release (one-sided 95% upper bound -93.9% / -94.4%). The witness reads 1.00 invocations per owned sample; diagnose matches the oracle and master's frame at exact RGB in all five cases. The controller now reads Metal's window-only composite row and prints a Metal guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jakildev
left a comment
There was a problem hiding this comment.
Review — render: cull source-face alpha cutouts per face, force early tests
Verdict: needs-fix
The implementation and focused controller/source checks are sound, but the retained witness artifacts make the required whitespace check fail.
Needs-fix
docs/perf/sun-overflowed-tile-query/windows-opengl-early-tests/.gitattributes— every committed nestedwitness.csvis CRLF and failsgit diff --check; the-textattribute preserves the byte-hashed evidence but does not disable the whitespace checker. Add the appropriatewhitespace=-trailing-spaceexception for those CSVs (without normalizing them), then re-run the check. This is currently the PR's failing requiredwhitespaceCI job.
Acceptance (issue #4935)
4 of 5 established locally/from retained evidence; criterion 4 remains unmet until the required whitespace CI check passes. Criterion 5 is correctly routed to the macOS follow-up label and is not graded on this host.
Checked
- Read the complete issue #4935 and PR #5198 discussion, PR head
c1e62526c85644b343c279c98129fd02156b7d53, implementation shaders, controller changes, contract tests, and retained-evidence summaries. python3 scripts/tests/test_render_source_face_early_depth.py— PASS (4 tests).python3 scripts/tests/test_render_source_face_order.py— PASS.python3 docs/perf/sun-overflowed-tile-query/test_controller.py— PASS (42 tests).git diff --check origin/master...HEAD— FAIL: CRLF is reported as trailing whitespace across the new nested witness CSVs;git check-attrreportstext: unset,whitespace: unspecified.- PR checks:
whitespacefails; build, perf, fleet, and render-harness jobs were still pending when reviewed.
Test plan the author should run before merge
- Add the narrowly scoped whitespace attribute, then confirm
git diff --check origin/master...HEADis clean and wait for the required CI checks.
🤖 Reviewed by Codex GPT-5 (review-pr skill)
Escalation: author-agent to address, then re-request review.
Opus recheck required: cross-backend fragment-depth state and the macOS guard need a final pass after the CI fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed feedback:
— worker |
jakildev
left a comment
There was a problem hiding this comment.
Review — render: cull source-face alpha cutouts per face, force early tests
Verdict: approve
The re-review verifies the sole prior needs-fix: the CRLF exception is scoped to retained witness CSVs, preserves their byte-hash contract, and restores the required whitespace check.
Acceptance (issue #4935)
4 of 5 criteria are established by retained evidence and local contract checks.
| Criterion | Grade | Basis |
|---|---|---|
| Hidden shading removed | met | Witness evidence reports 1.00 invocation per owned sample across all five cases. |
| Windows GL cut | met | Debug and Release upper bounds are -93.9% and -94.4%, exceeding the -50% requirement. |
| Pixels and exact-query behavior | met | Diagnose evidence reports oracle matches and exact-RGB pre-tree equality across all five cases. |
| Contract and controller regressions | met | The source-contract, source-order, and controller tests exist and pass locally. |
| Metal performance/correctness guard | unverifiable | The macOS/Metal-only shipped-head run remains routed to fleet:needs-macos-host. |
Checked
- Read the complete issue #4935 and PR #5198 threads, prior review, author response, current head
d742ad4d967fca7621b9dc8c8f53606c80efe6bd, and current PR checks. docs/perf/sun-overflowed-tile-query/windows-opengl-early-tests/.gitattributeslimitswhitespace=cr-at-eolto retainedwitness.csvfiles while retaining-text.git check-attr text whitespace -- .../witness.csvreportstext: unsetandwhitespace: cr-at-eol.git diff --check origin/master...HEAD— PASS.python3 scripts/tests/test_render_source_face_early_depth.py— PASS (4 tests).python3 scripts/tests/test_render_source_face_order.py— PASS.python3 docs/perf/sun-overflowed-tile-query/test_controller.py— PASS (42 tests).- PR checks: whitespace, shader parity, format, Python lint, header, and instruction checks pass; linux build, perf gate, render harness, and fleet tests are still running.
Test plan the author should run before merge
- Let the remaining CI jobs complete successfully.
- Complete the pending macOS guard and diagnose evidence on the assigned host.
🤖 Reviewed by Codex GPT-5 (review-pr skill)
Opus recheck required: this core cross-backend fragment-depth change and its pending macOS runtime guard require the final review pass.
jakildev
left a comment
There was a problem hiding this comment.
Review — render: cull source-face alpha cutouts per face, force early tests
Verdict: approve
Sonnet flagged cross-backend fragment-depth state and the pending macOS guard. On closer read, I confirm the state transition is safe: face alpha is constant for the whole instance and clips every vertex together; only the no-depth-write/no-discard route forces early tests; and the fallback route remains late-tested and writes fragment depth.
Acceptance (issue #4935)
| Criterion | Result | Evidence |
|---|---|---|
| Hidden shading is eliminated | Met | Retained 128x witness falls from 128 fragment invocations to 1. |
| Windows GL work is materially reduced | Met | Five paired arms report a -93.9% Debug and -94.4% Release median change. |
| Pixels and exact-query behavior are unchanged | Met | All five diagnostics retain exact path counts, and the full-frame pre/post images have zero RGB delta. |
| Shader contract and regression coverage are preserved | Met | Structural checks and mutations cover missing early tests, ungated early tests, restored discard, and dropped/inclusive face culling. |
| Metal performance/correctness guard | Unverifiable here | The shipped-head five-pair Metal timing guard and diagnose sequence remains assigned to the needs-macos-host lane. |
Checks performed
- Read the complete issue and PR threads and reviewed head
d742ad4d967fca7621b9dc8c8f53606c80efe6bd. - Reviewed GLSL/Metal parity, depth-route selection, and Opus-only risks. The patch introduces no cross-frame resource ownership, lifetime, race, allocator, or cache changes.
test_render_source_face_early_depth.py: 4 passed;test_render_source_face_order.py: 1 passed; controller tests: 42 passed.git diff --check origin/master...HEADpassed; retained CRLF witness data is covered bywhitespace=cr-at-eol.- Inspected retained witness, paired timing, diagnostic, and exact screenshot-hash evidence.
fleet-build --target IRCanvasStresspassed on macOS, andfleet-run IRCanvasStress --auto-screenshot 10completed cleanly on M4 Max with runtime-compiled Metal shaders; the captured frame was visually clean.
CI and remaining host validation
render-harness-testsis red on an unrelatedMetalRenderPassBindingscompile failure also present onmaster; the changed source-face regression test passes locally.fleet-testsis red ontest_fleet_queue_list.sh, the same baseline failure seen on an earliermasterrevision; this PR does not modify the fleet implementation or tests. The aggregate gate reflects those two failures.linux-buildandperf-gatewere still pending at review time.- The local Metal smoke proves compile/run correctness only. The
needs-macos-hostlane should still run the full five-pair performance guard and diagnose on regression.
Human merge authority is preserved.
🤖 Reviewed by Codex GPT-5 using the review-pr workflow
Perf gateHead host slug: Perf gate — no class-matched baselineNo capture of Captures considered:
|
|
Cross-host smoke OK on macos (fresh checkout + IRShapeDebug --auto-screenshot 10 — build clean, exit 0, ir-run RESULT=CLEAN, 22 screenshots, no shader/compile warnings). Note: the log carries one non-compile runtime line, |
Perf gateHead host slug: perf comparison: 622ec2a → fb0be2f-cibaseline: host calibration
thresholds: regress ≥ 10%, improve ≥ 5% voxel cull effectiveness
frame timing (ms)
GPU frame timing (ms; separate from stage samples)
GPU stage timing (avg ms per sampled invocation)
top CPU systems by avg ms (head)
|
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
220.332 → 220.488 (+0.1%) |
| RENDER | ComputeLightVolume |
25.801 → 26.146 (+1.3%) |
| RENDER | CanvasToFramebuffer |
14.533 → 14.813 (+1.9%) |
| RENDER | ComputeSunShadow |
12.367 → 12.436 (+0.6%) |
| UPDATE | FogRevealEval |
8.528 → 8.978 (+5.3%) |
| RENDER | BakeSunShadowMap |
5.893 → 5.938 (+0.8%) |
| UPDATE | PropagateTransform |
3.649 → 3.745 (+2.6%) |
| UPDATE | LuaWaveStateToOffset |
2.998 → 3.352 (+11.8%) ⚠ |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
722.030 → 722.799 (+0.1%) |
| RENDER | ComputeSunShadow |
25.501 → 25.853 (+1.4%) |
| RENDER | ComputeLightVolume |
23.044 → 22.534 (-2.2%) |
| RENDER | CanvasToFramebuffer |
13.772 → 13.724 (-0.3%) |
| UPDATE | FogRevealEval |
7.590 → 8.205 (+8.1%) |
| RENDER | ComputeVoxelAO |
6.878 → 6.974 (+1.4%) |
| RENDER | BakeSunShadowMap |
5.167 → 5.161 (-0.1%) |
| RENDER | LightingToTrixel |
4.889 → 4.954 (+1.3%) |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
236.216 → 237.974 (+0.7%) |
| RENDER | ComputeSunShadow |
35.942 → 36.292 (+1.0%) |
| RENDER | ComputeLightVolume |
24.511 → 24.616 (+0.4%) |
| RENDER | LightingToTrixel |
18.975 → 19.446 (+2.5%) |
| RENDER | CanvasToFramebuffer |
14.572 → 15.023 (+3.1%) |
| RENDER | BakeSunShadowMap |
8.014 → 8.275 (+3.3%) |
| UPDATE | FogRevealEval |
7.175 → 7.783 (+8.5%) |
| UPDATE | PropagateTransform |
4.643 → 4.834 (+4.1%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1093.643 → 1102.508 (+0.8%) |
| RENDER | ComputeSunShadow |
34.490 → 34.192 (-0.9%) |
| RENDER | ComputeLightVolume |
24.729 → 24.788 (+0.2%) |
| RENDER | CanvasToFramebuffer |
13.456 → 13.715 (+1.9%) |
| UPDATE | FogRevealEval |
7.599 → 7.179 (-5.5%) ↓ |
| RENDER | ComputeVoxelAO |
5.789 → 5.745 (-0.8%) |
| RENDER | BakeSunShadowMap |
5.163 → 5.254 (+1.8%) |
| UPDATE | PropagateTransform |
4.736 → 4.863 (+2.7%) |
Summary
On GL, depth-hidden source-face fragments no longer run the sun-shadow query. The early-route fragment stage could
discard, so GL shaded all 128 coincident caster canvases before applying the depth test, and each fragment ran the exact overflowed-tile query.The alpha cutout is constant per face, so the shared vertex stage now clips faces with alpha < 0.1. Neither fragment stage discards, and the early route forces early fragment tests on both backends. The Windows GL
far-128composite falls 95%, with pixels and tie owners unchanged. The controller now reads Metal's window-only composite row, so the Metal guard can run.Screenshots
No visual change: the shipped production frame equals master's at exact RGB, 0 px changed, over the whole frame in all 5
IRCanvasStressdiagnostic cases (row 3 below).Acceptance evidence
run_matrix.py witness --build debug --pre-tree <pre>/debug --variants production ablationwindows-opengl-early-tests/debug/witness/summary.md)run_matrix.py ab-timing --build debug --pre-tree <pre>/debug --cases far-128(5 pairs, all CLEAN, quiet-guarded)far-12863.213 → 3.339 ms, −94.7%, one-sided 95% upper bound −93.9%run_matrix.py ab-timing --build release --pre-tree <pre>/release --cases far-128run_matrix.py diagnose --build debug --pre-tree <pre>/debugproduction_matches_oracle: truein all 5 cases: 371 entered / 234 hit on the 4 exact-path cases, 0 / 0 onfar-128-filler-first-frozen.production_matches_pre_tree: truewith 0 px changed in receiver crop, stack crop and whole frame, all 5 casespython3 scripts/tests/test_render_source_face_early_depth.pyRan 4 tests … OK. Mutations rejected:drop_early_tests,early_tests_on_fallback,restore_discard,drop_alpha_cull,inclusive_alpha_cull, on both backends. The Metal check reads[[early_fragment_tests]]on the declaration ahead offragment SourceFaceFragmentpython3 scripts/tests/test_render_source_face_order.pyOK, glsl + metalexact_permutation=PASS sorted_keys=PASS guard=PASSpython3 docs/perf/sun-overflowed-tile-query/test_controller.pyRan 42 tests … OK, including the Metal window-only fixture, the GL refusal of that row, the Metal guard and the early-tests refusal on the shipped treerender-verify.py --target IRCanvasStress --no-build(shipped Debug)all 31 checks PASS (28 skipped — references pending). The skips are thecylinder_receiver*rows, which have no windows-debug reference. No failures, so there is nothing to grade against mastercommandBufferSpans; diagnose oracle-match)run_matrix.py ab-timing --build debug --cases far-128+diagnose --build debugon macOSfleet:needs-macos-host.summary.mdprints themetal_guardverdict. The plan-time probe of this exact change gave 0.983× / 0.994×Reviewer notes
Plan departures
00b5da049(the merge-base). The change is shader-only, so both trees run one binary (Debug320005d17eed…, Releasea5b14aa2c7eb…).pre-tree/tree.diffis exactly the reversed shader diff.diagnosegained--pre-tree, which captures master's production frame per case in the same session. A comparison against the older committed captures would cross master's later lighting re-bless.metal_guardinsummarize_ab.layout(early_fragment_tests) in;sits in the shared fragment body under#if IR_SOURCE_FACE_EARLY_DEPTH, mirroring the Metal attribute, not in the wrapper. Theearly-testscontrol now refuses when that body already carries the line.Notes for reviewer
queryHierarchy = falsepost arm sits 0.07–0.08 ms above pre in both builds (Release lower bound +0.054 ms). That is about 1/800 of the saving and is not attributed.windows-opengl-early-tests/.gitattributesmarkswitness.csvas-text.witness.jsonhashes the CRLF bytes the engine writes, and normalization would break that record. It also setswhitespace=cr-at-eolso thewhitespacegate (git diff --check) accepts those CRLF endings without normalizing them; the olderwindows-opengl-mechanism/CSVs already mismatch for this reason.fleet-pr-overlap:VERDICT: overlap. render: size per-axis stores from content height (#4960) #5101, docs: capture overflow-rejection camera ordering in docs/design/per-axis-trixel-canvas-rotation.md (#5086) #5124 and scripts: grade yaw crossings by cardinal-only pixels #5195 each editdocs/agents/VALIDATION-RENDER-FEATURES.md, and all three trial merges are clean. This PR changes only the source-face early-depth row.Closes #4935
🤖 Generated with Claude Code