Repository navigation
render: floor the camera screen residual top-down on every backend - #5201
Conversation
The screen-pixel half of the camera sub-pixel split applied the iso-to- screen sign inside floor(). On OpenGL (screen Y bottom-up, sign -1) that made floor(-a) = -ceil(a), so a camera with a fractional y residual drew the whole frame one screen row lower than Metal and the receiver-shadow oracle put it. Both residual helpers (the snapped split and its continuous-zoom twin) now floor top-down and sign afterwards, the same convention as the framebuffer half. Metal's sign is +1, so it is unchanged by construction. Every reader (the blit, sprites, depth-tested primitives, probes, mouse mapping) takes the residual from these helpers, so they move with the frame. An explicit screen-sign parameter lets the new tests pin both backends' y sense on any host. Twenty-seven windows-debug references with a fractional-y camera are re-blessed; each is the old image moved up one row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Perf gateHead host slug: perf comparison: c03fe48 → deb11d0-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 |
298.046 → 298.924 (+0.3%) |
| RENDER | ComputeLightVolume |
35.887 → 34.591 (-3.6%) |
| RENDER | ComputeSunShadow |
19.925 → 19.315 (-3.1%) |
| RENDER | CanvasToFramebuffer |
18.227 → 17.885 (-1.9%) |
| RENDER | BakeSunShadowMap |
10.420 → 10.202 (-2.1%) |
| UPDATE | FogRevealEval |
6.578 → 6.293 (-4.3%) |
| UPDATE | PropagateTransform |
4.948 → 4.570 (-7.6%) ↓ |
| RENDER | ComputeVoxelAO |
4.434 → 4.366 (-1.5%) |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
992.838 → 983.287 (-1.0%) |
| RENDER | ComputeSunShadow |
40.580 → 39.630 (-2.3%) |
| RENDER | ComputeLightVolume |
32.529 → 30.991 (-4.7%) |
| RENDER | CanvasToFramebuffer |
17.101 → 16.462 (-3.7%) |
| RENDER | ComputeVoxelAO |
11.089 → 10.800 (-2.6%) |
| RENDER | LightingToTrixel |
9.445 → 9.018 (-4.5%) |
| RENDER | BakeSunShadowMap |
8.988 → 8.757 (-2.6%) |
| UPDATE | FogRevealEval |
6.633 → 6.064 (-8.6%) ↓ |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
346.948 → 335.583 (-3.3%) |
| RENDER | ComputeSunShadow |
67.001 → 65.217 (-2.7%) |
| RENDER | LightingToTrixel |
38.626 → 38.105 (-1.3%) |
| RENDER | ComputeLightVolume |
35.479 → 33.301 (-6.1%) ↓ |
| RENDER | BakeSunShadowMap |
23.074 → 22.806 (-1.2%) |
| RENDER | CanvasToFramebuffer |
18.942 → 18.784 (-0.8%) |
| RENDER | FogToTrixel |
7.359 → 7.356 (-0.0%) |
| UPDATE | PropagateTransform |
6.053 → 7.339 (+21.2%) ⚠ |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1504.717 → 1501.892 (-0.2%) |
| RENDER | ComputeSunShadow |
53.380 → 54.088 (+1.3%) |
| RENDER | ComputeLightVolume |
33.333 → 34.295 (+2.9%) |
| RENDER | CanvasToFramebuffer |
16.508 → 16.416 (-0.6%) |
| RENDER | BakeSunShadowMap |
9.077 → 8.900 (-1.9%) |
| RENDER | ComputeVoxelAO |
8.784 → 8.799 (+0.2%) |
| RENDER | LightingToTrixel |
7.400 → 7.623 (+3.0%) |
| UPDATE | PropagateTransform |
6.169 → 6.492 (+5.2%) |
jakildev
left a comment
There was a problem hiding this comment.
Review — render: floor the camera screen residual top-down on every backend
Verdict: needs-fix
The sign-after-floor change is coherent across the snapped and continuous paths, and the reference updates match the intended one-row move, but the PR's own formatting gate is red.
Needs-fix
test/math/camera_subpixel_test.cpp::CameraSubPixelOffsets.MatchesTheReferenceDecomposition— the current head failsformat-check; clang-format 22.1.3 rewrites the six-elementcameraSamplesinitializer onto separate lines. Apply the CI diff (or runfleet-build --target format-changed) and push so the required validator is green.
Acceptance (issue #5190)
- 3 of 4 criteria are established by the shipped tests and Windows/OpenGL evidence.
- Metal runtime verification is deferred: the formula is unchanged for Metal's
+1sign and the explicit-sign tests cover it, but this review did not complete anIrredenEngineTestrun on macOS.
Praise
- Both residual helpers use the same top-down convention, and the positive-fire tests exercise both backend signs rather than trusting the review host's compile-time backend.
Checked
- Read the complete PR and issue #5190 threads, the plan corrections, the full diff, and all changed source/test/design files in context.
- Confirmed head
6398edc2b18256d42e376107a7440d6d4926f763; standalone base ismaster. fleet-jobs wait --timeout 540 20261119T122614Z-build-0a38bd: succeeded, exit 0;IrredenEngineTestbuilt on macOS/Metal.- Independently compared all 27 changed Windows PNG references against
origin/master; every interior is an exact one-row upward translation. git diff --check origin/master...HEAD: clean.- GitHub
format-check: failed because clang-format rewrites thecameraSamplesinitializer; linux-build and perf-gate were still in progress when reviewed.
Test plan the author should run before merge
- Apply clang-format 22.1.3's rewrite and confirm
format-checkpasses on the amended head. - Re-run the camera residual tests on the amended head; retain the macOS smoke debt until a clean Metal run records it.
🤖 Reviewed by Codex GPT-5 (review-pr skill, opus review class)
Opus recheck not required (reviewed at opus class).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed feedback:
|
Perf gateHead host slug: perf comparison: 622ec2a → 55ae438-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.758 (+0.2%) |
| RENDER | ComputeLightVolume |
25.801 → 25.853 (+0.2%) |
| RENDER | CanvasToFramebuffer |
14.533 → 15.036 (+3.5%) |
| RENDER | ComputeSunShadow |
12.367 → 12.542 (+1.4%) |
| UPDATE | FogRevealEval |
8.528 → 8.812 (+3.3%) |
| RENDER | BakeSunShadowMap |
5.893 → 5.933 (+0.7%) |
| UPDATE | PropagateTransform |
3.649 → 3.619 (-0.8%) |
| UPDATE | LuaWaveStateToOffset |
2.998 → 3.413 (+13.8%) ⚠ |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
722.030 → 721.137 (-0.1%) |
| RENDER | ComputeSunShadow |
25.501 → 25.441 (-0.2%) |
| RENDER | ComputeLightVolume |
23.044 → 22.605 (-1.9%) |
| RENDER | CanvasToFramebuffer |
13.772 → 13.568 (-1.5%) |
| UPDATE | FogRevealEval |
7.590 → 7.074 (-6.8%) ↓ |
| RENDER | ComputeVoxelAO |
6.878 → 6.923 (+0.7%) |
| RENDER | BakeSunShadowMap |
5.167 → 5.383 (+4.2%) |
| RENDER | LightingToTrixel |
4.889 → 5.066 (+3.6%) |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
236.216 → 236.450 (+0.1%) |
| RENDER | ComputeSunShadow |
35.942 → 36.125 (+0.5%) |
| RENDER | ComputeLightVolume |
24.511 → 23.914 (-2.4%) |
| RENDER | LightingToTrixel |
18.975 → 19.625 (+3.4%) |
| RENDER | CanvasToFramebuffer |
14.572 → 14.725 (+1.0%) |
| RENDER | BakeSunShadowMap |
8.014 → 8.288 (+3.4%) |
| UPDATE | FogRevealEval |
7.175 → 7.342 (+2.3%) |
| UPDATE | PropagateTransform |
4.643 → 4.786 (+3.1%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1093.643 → 1123.250 (+2.7%) |
| RENDER | ComputeSunShadow |
34.490 → 34.709 (+0.6%) |
| RENDER | ComputeLightVolume |
24.729 → 25.381 (+2.6%) |
| RENDER | CanvasToFramebuffer |
13.456 → 13.847 (+2.9%) |
| UPDATE | FogRevealEval |
7.599 → 7.558 (-0.5%) |
| RENDER | ComputeVoxelAO |
5.789 → 5.912 (+2.1%) |
| RENDER | BakeSunShadowMap |
5.163 → 5.396 (+4.5%) |
| UPDATE | PropagateTransform |
4.736 → 4.852 (+2.4%) |
jakildev
left a comment
There was a problem hiding this comment.
Review — render: floor the camera screen residual top-down on every backend
Prior-review resolution
- ✅
test/math/camera_subpixel_test.cpp::CameraSubPixelOffsets.MatchesTheReferenceDecomposition— the requested clang-format 22.1.3 initializer layout is present atac8e1b692, and the liveformat-checkis green.
Verdict: approve
The only post-review change is the requested formatting fix; it resolves the prior finding without changing executable behavior, and all current required checks are green.
Acceptance (issue #5190)
- 3 of 4 criteria are established by the shipped tests and Windows/OpenGL evidence.
- Criterion 3's Metal runtime clause remains unverifiable on the author host; the sign-after-floor change is algebraically unchanged for Metal's
+1sign and explicitly tested, while the macOS smoke lane retains the runtime verification debt.
Checked
- Confirmed exact head
ac8e1b692db4b90d11a9a35d487b5cacab15b23fon standalone basemaster. - Compared the amend against the previously reviewed head: one test initializer was reformatted; no executable code, render references, or other files changed.
git diff --check origin/master...HEAD: clean.- Live GitHub checks are green, including
format-check,linux-build,perf-gate, and the aggregateall-checksstatus. - Re-read the complete PR and issue #5190 threads, the prior review, worker response, amended diff, and applicable math/test/demo rules. No local executable was run for this delta-only re-review.
Test plan the author should run before merge
- Re-run the focused camera residual tests on the amended head (author reports 59/59 pass).
- Record the deferred Metal runtime result through the macOS smoke lane.
🤖 Reviewed by Codex GPT-5 (review-pr skill, opus review class)
Opus recheck not required (reviewed at opus class).
Re-runs the subpos/subneg receiver-shadow polygon matrix on Windows/OpenGL at master 1bff5ea, which carries PR #5201's fix for the one-row camera residual offset. All 26 captures are RESULT=CLEAN. Every graded row's count dictionary equals Metal's: 0/0/0 with the opt-in on, and the fallback arms reproduce 18/638/0. With the earlier origin and near/mid passes, the polygon criterion holds at all 18 placements. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary
On OpenGL, a camera with a fractional y screen residual drew the whole frame one screen row lower than Metal, and lower than where the receiver-shadow oracle places it.
IRMath::cameraSubPixelOffsetsand its continuous-zoom twincameraRasterScreenResidualapplied the iso-to-screen sign insidefloor(), so GL's-1turned the floor into a ceil. Both helpers now floor top-down and sign afterwards, like the framebuffer half already does. Metal's sign is+1, so it is unchanged by construction.Every residual reader (the blit, sprites, depth-tested primitives, probes, mouse mapping) takes its value from these helpers, so all of them move with the frame. 27
windows-debugreferences whose camera has a fractional y residual are re-blessed. Each one is the old image moved up exactly one row.Acceptance evidence
fleet-run IrredenEngineTest --gtest_filter='CameraSubPixel*:CameraRaster*:CameraZoom*'camera_subpixel_test.cppcompiled standalone against a header copy with the sign moved back inside both floorsFractionalYResidualFloorsTopDown…×2,FractionalYIsMonotoneTopDown…)subpos/subnegyaw 0.6, fog 0 and 16,IR_PERAXIS_SURFACE_LIGHTING=1, no shiftrender_receiver_shadow_polygon.check_imagenear×4,mid×4, origin ×8RESULT=CLEAN, 2560×1440 target, no GL errorsfloor(a)·1 = floor(a·1); the new tests run the+1sign explicitly on this host and passIrredenEngineTest. The mac smoke lane runs itIRShapeDebugpython3 scripts/render-verify.py --target IRShapeDebugIRFogDemopython3 scripts/render-verify.py --target IRFogDemoIRPerfGridpython3 scripts/render-verify.py --target IRPerfGridIRCanvasStresspython3 scripts/render-verify.py --target IRCanvasStressnew(x, y) == old(x, y + 1)fog_ceiling_treatment_yaw9reads 99.417%, with a largest delta of 10. Every residual pixel is within the comparator'smax_delta64 (largest 57). Each unshifted comparison reads 91.1–99.98%fleet-run IrredenEngineTestToolSpawnTest×2 andFontMakerSource.SavedHeadersCompile, tracked Windows-host failures (#5180)Reviewer notes
Plan departures
test/render/depth_tested_primitives_test.cppGeometryUsesCameraPixelPhaseAtFractionalPanexpected+0.5on GL. It now expects-0.5on both backends, the same rewrite asSnappedPlacementMatchesTheDisplayedRaster.screenSignparameter, defaulting toIRPlatform::kIsoToScreenSign. Existing call sites are unchanged.camera_subpixel_test.cppnext to the snapped one (CameraRasterScreenResidual.FractionalYResidualFloorsTopDownUnderEitherScreenSign), not incamera_zoom_policy_test.cpp.Notes for reviewer
IRLightingSdfBlockerfails 3 rows on this host:zoom4_origin,zoom4_offset_3_5andzoom8_origin, each at match ≥ 99.98% and max delta 123. All three use whole-number cameras, where the residual is 0 under both formulas, so this change cannot move them. That makes them existing windows-debug drift, and they are not re-blessed here.format-changedcannot run here. The CIformat-checkrewrite of thecameraSamplesinitializer is applied verbatim in the head commit.fleet-pr-overlapreportsVERDICT: overlapand every trial merge is clean: render: size per-axis stores from content height (#4960) #5101 and docs: capture overflow-rejection camera ordering in docs/design/per-axis-trixel-canvas-rotation.md (#5086) #5124 touchir_math.hpp(other helpers), and render: record the OpenGL render-verify sweep for the gather filter #5199 touchesdocs/design/continuous-camera-zoom.md.C:\msys64\tmp\p5190\on the Windows host (mutation.py,matrix.py,grade.py,shiftcheck.py).Closes #5190
🤖 Generated with Claude Code