Repository navigation
render: pair the served pick with its newest completed frame in one drain - #5228
Conversation
…rain The --gui-test PICK_FRAME_CURRENT latch compared getMouseTrixelPick()'s frame id with a second newestCompletedMouseTrixelPickFrameId() call. Each call drains the readback ring again, and on OpenGL a timestamp-query fence can retire between the two, so the second read came out one frame newer than a pick that was in fact the newest. On the Windows GL host 1-4 of shot 3's 30 frames missed per run, and the all-or-nothing actual= string reported that as current=0/30. MouseTrixelPick now carries newestCompletedFrameId_, filled by resolveServedPick from the same history state the served record came from. The latch makes one pick call per frame and keeps the id pair. PICK_FRAME_CURRENT and PICK_STALE_CLEAR report their true counts, and the first miss's served/newest ids. The pick contract states the one-result rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the rule clear of the in-flight rewrite of the record and INPUT result sections, so the two edits merge independently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jakildev
left a comment
There was a problem hiding this comment.
Review — render: pair the served pick with its newest completed frame in one drain
Verdict: approve
The result now carries the comparison frame from the same immutable history snapshot as the served pick, removing the second-drain race without changing the standalone newest-completed query.
Acceptance (issue #5220)
4 of 4 met. The phase-0 serial probes changed polling timing and suppressed the miss; the recorded served/second-read pairs still establish the completion advance, and the PR documents that departure and its replacement evidence.
Checked
- Read the complete PR and issue threads, all changed files in context, and the overlapping changes in #5135 and #5161; no semantic disagreement found.
- Exact head
38fcc8b46134ef839f4232d9af89ddd0fc8fdc44:fleet-build --detach --target IrredenEngineTestcompleted successfully (fleet-jobs: 20261120T042126Z-build-2eeedf succeeded exit=0). fleet-run IrredenEngineTest --gtest_filter='PresentedPick.*': 7/7 passed.- CI format, header, comment-reference, whitespace, and fleet gates passed; Linux build and perf gate were still pending when reviewed.
- Windows OpenGL evidence records three 49/49 positive runs, the expected 48/49 negative control, and the mutation control isolating the previous-served pairing case.
🤖 Reviewed by Codex GPT-5 (review-pr skill)
Opus recheck not required (reviewed at opus class).
|
Cross-host smoke OK on macos (fresh checkout + IRShapeDebug --auto-screenshot 10 — build clean, exit 0, no log warnings). |
Perf gateHead host slug: perf comparison: cb2e87f → b59aaea-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 |
214.703 → 223.041 (+3.9%) |
| RENDER | CanvasToFramebuffer |
14.330 → 25.418 (+77.4%) ⚠ |
| RENDER | ComputeLightVolume |
24.978 → 25.284 (+1.2%) |
| UPDATE | FogRevealEval |
7.136 → 8.292 (+16.2%) ⚠ |
| RENDER | BakeSunShadowMap |
6.007 → 6.037 (+0.5%) |
| UPDATE | PropagateTransform |
3.483 → 3.795 (+9.0%) |
| RENDER | UpdateVoxelSetChildren |
2.147 → 3.098 (+44.3%) ⚠ |
| UPDATE | LuaWaveStateToOffset |
2.542 → 2.979 (+17.2%) ⚠ |
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
713.424 → 731.471 (+2.5%) |
| RENDER | CanvasToFramebuffer |
13.360 → 36.424 (+172.6%) ⚠ |
| RENDER | ComputeLightVolume |
21.534 → 23.154 (+7.5%) |
| UPDATE | FogRevealEval |
7.943 → 8.197 (+3.2%) |
| RENDER | ComputeVoxelAO |
6.756 → 7.004 (+3.7%) |
| RENDER | BakeSunShadowMap |
5.044 → 5.259 (+4.3%) |
| UPDATE | PropagateTransform |
3.455 → 3.646 (+5.5%) |
| RENDER | UpdateVoxelSetChildren |
2.297 → 3.167 (+37.9%) ⚠ |
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
234.442 → 238.799 (+1.9%) |
| RENDER | CanvasToFramebuffer |
14.537 → 36.953 (+154.2%) ⚠ |
| RENDER | ComputeSunShadow |
34.544 → 30.997 (-10.3%) ↓ |
| RENDER | ComputeLightVolume |
24.263 → 24.076 (-0.8%) |
| RENDER | LightingToTrixel |
18.559 → 18.772 (+1.1%) |
| RENDER | BakeSunShadowMap |
7.924 → 8.295 (+4.7%) |
| UPDATE | FogRevealEval |
6.789 → 7.803 (+14.9%) ⚠ |
| UPDATE | PropagateTransform |
4.692 → 4.825 (+2.8%) |
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1
| pipeline | system | avg ms (base→head) |
|---|---|---|
| RENDER | SingleVoxelToCanvasFirst |
1084.329 → 1112.350 (+2.6%) |
| RENDER | CanvasToFramebuffer |
13.217 → 45.629 (+245.2%) ⚠ |
| RENDER | ComputeLightVolume |
24.282 → 22.437 (-7.6%) ↓ |
| UPDATE | FogRevealEval |
6.477 → 7.762 (+19.8%) ⚠ |
| RENDER | ComputeVoxelAO |
5.572 → 5.813 (+4.3%) |
| RENDER | BakeSunShadowMap |
5.204 → 5.457 (+4.9%) |
| UPDATE | PropagateTransform |
4.695 → 4.854 (+3.4%) |
| RENDER | UpdateVoxelSetChildren |
2.328 → 3.200 (+37.5%) ⚠ |
Summary
On OpenGL,
IRShapeDebug --gui-testfailednewest_completed_pick_frameintermittently, atcurrent=0/30. The latch compared the served pick with a second, separately drainednewestCompletedMouseTrixelPickFrameId()read, and a GL fence can retire between the two calls.MouseTrixelPicknow carriesnewestCompletedFrameId_from the same history state as the served record (resolveServedPick), and the latch makes one pick call per frame.PICK_FRAME_CURRENTandPICK_STALE_CLEARnow report their true counts plus the first miss's id pair, and the pick contract states the one-result rule.Screenshots
No visual change: this touches the pick result and the GUI-test harness only, not any rendered output.
Acceptance evidence
Host: Windows 10, NVIDIA GeForce RTX 3060 Ti, OpenGL,
windows-debug, code at024cdc1fd(the head commit after it is doc-only).python3 scripts/gui-verify.py IRShapeDebug -- --gui-test×3[gui-verify] 49/49 assertions passed, exit 0, on all three; each hasnewest_completed_pick_frame result=PASS actual=current=30/30python3 scripts/gui-verify.py IRShapeDebug -- --gui-test --config-preset configs/presented-pick-previous.lua48/49; the only FAIL isnewest_completed_pick_frame result=FAIL actual=current=0/30 first_miss=served:115,newest:116fleet-build --target IrredenEngineTest;ctest --test-dir build -R PresentedPick100% tests passed, 0 tests failed out of 7(4 new cases: newest served, previous served, empty history, accept-after-resolve)resolveServedPickfillingnewestCompletedFrameId_fromresult.frameId_, same ctest86% tests passed, 1 tests failed out of 7: onlyPresentedPick.ServedPreviousPairsBelowTheNewestCompletedFrame--gui-testtotal stays 49Reviewer notes
Plan departures
completedSubmissionSerial()reads before each call hide the race: 8 runs, 0/240 missed frames, 49/49 every time. The failing table therefore records served id and second-read id only, captured into locals and logged once after both reads. A second read newer than the served id already proves completion advanced between the reads, because the ring hands over a slot only once its serial completes. In the polled arm the serial still advanced between the two polls on 1–5 frames per run, yet the first drain caught up every time.actual=wording.current=<K>/<N>, plusfirst_miss=served:<id>,newest:<id>when a frame misses.PICK_STALE_CLEARgives its truecurrent=<K>/<N>.optimizeskipped. The only per-frame production change is one 8-byte field write pergetMouseTrixelPick()call. The harness latch now makes one fewer draining call per frame.Phase 0: master
eea79792d, shot 3, trailing 30 frames, run e1 of 6Missed frames per run: 2, 1, 2, 4, 2, 3 (14/180). Every miss has the same shape: the first call drained nothing, the second read is served + 1, and served is never 0. The old all-or-nothing
actual=current=0/30reported a 2-frame miss as 30 misses.Reading, not measured: on a missed frame the first drain accepted no record, so it never reached
glGetNamedBufferSubData. The window between the two drains is only microseconds of CPU work. That favours a fence retiring inside the window over a readback stall. The fix does not depend on which.After: same diagnostic on the PR head, plus the
newestCompletedFrameId_column--gui-testpresented-pick-previous.lua)current=0/30 first_miss=served:116,newest:117Completion still advances between two separate reads. The latch no longer takes a second read, so the race cannot fail it.
Notes for reviewer
format-changedcan't run on this host (no clang-format on PATH). WSL clang-format 18--dry-runover the five C++ files flags only existing lines (render_manager.cpp:351,:711, where versions 18 and 22 disagree), none added here. CIformat-checkis the gate.fleet-pr-overlap --base master:VERDICT: overlap, every trial merge clean. Check the shared files for semantic disagreement:#5135 docs/design/pick-frame-contract.md clean#5135 engine/render/src/render_manager.cpp clean#5135 test/render/gpu_readback_ring_test.cpp clean#5161 engine/render/include/irreden/render/presented_pick.hpp clean#5161 engine/render/src/render_manager.cpp cleanCloses #5220
🤖 Generated with Claude Code