fix(vk): torch flames no longer vanish when the replay falls behind the game, as with V-Sync On #3000
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3000
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/wb-pending-capture"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Torch flames appeared, vanished and came back for a player with V-Sync On on a 60 Hz screen and Threaded rendering on. With V-Sync Auto or Off, or Threaded rendering Off, they stayed lit (#2992).
What was wrong: the write-back diff's shadow is our copy of what the game last had in memory. A page the game wrote was reported to the shadows as soon as its capture was made, and by the collection even before that. With the replay behind the game, the write-back of an earlier submission then filled the shadow from live guest memory, with the game's newer words. The mirror's older words looked like a GPU change, and were written over the game's new data. A flame's record the game had just written was lost.
What this changes (
gpu/vk/vk_memory.cpp):take_capturereports a capture's pages, in the replay's order;capture_makeno longer does.memory_collect_writtenreports only the pages no capture will take. A page left to the next capture is reported when that one is taken.memory_rb_refreshcopies the mirror into the shadow too. It gives the mirror the game's newer words before their capture is taken, so a counter the game clears and the GPU counts up to the same value again would otherwise not be written back (found in a separate review of the first version).See the bug on
main: Forest Temple main room with all four Poes beaten, V-Sync On on a 60 Hz screen, Threaded rendering on Auto. On a PC where V-Sync doesn't hold the present, make each present wait for a 16.7 ms tick at the top ofdo_present.Read first:
take_capture,memory_collect_writtenandmemory_rb_refresh, thentests/test_wb_pending_capture.py.This is not the lock-on arrows' bug (#2863, the write-back's span): the arrows' fix stays as it is.
Fixes #2992. See #2363, #2777 and #1789, which may be the same bug and haven't been tested with this.
Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.47, Ryzen 9 9900X3D. V-Sync doesn't hold the present on this PC, so the runs used a temporary delay (a present waits for a 16.7 ms tick) to put the replay behind as it is on the player's PC: about 42 jobs queued at a present and 2300 to 2900 late pages in 600 takes, against 27 to 60 and mostly 3300 to 4300 in the player's log.
tests/test_wb_pending_capture.pyfails onmainat the first case, fails without each part of the fix, and passes here (g++ and clang++).mise run test: 825 pass, 55 fail, 48 skipped;mainat the same commit: 824, 55, 48. 54 of the failures fail on both (listed below).test_present_semaphoresfailed here only and passed 5 of 5 times alone, with the fix and without;test_longshot_ctlfailed onmainonly.The 54 checks that fail here and on main (this PC)
auto_handheld,blocks_at_start,bug_report,builder_channel,control_picture,coverage_run,crash_record,crt_options,dev_ab,dev_build,dev_migrate,dev_update,draw_stream_visibility,framegen_hdr,framegen_resources,fs_path_utf8,fsr_uniform_ownership,game_boundary,image_reaper_threads,image_view_retry,input_background,keyboard_menu_option,keyboard_option,lifter,linux_pressure,loaded_modules_drop,log_batch,log_levels,menu_keys,mise_build,oot_menu_mouse,oot_state_tap,option_ids,parity_gates,perf_send,present_acquire_ahead,present_image_free,present_source_crop,profile_symbols,program_cache_cleanup,program_cache_one_variant,readback_timeout_reuse,recording_admission,run_all_mingw,screensaver,switch_table,target_retention,temporal_present_bandwidth,tex_desc_memo,text_keyboard_policy,upscaler_round_trip,vram_compact,windows_display_startup,windows_on_linuxStill to test:
Measurements
Verdict: the flames are fixed under the delay. No speed difference shown (within the spread in three places); Hyrule Field leaned slower, with the fix on always first.
Setup: Windows 11, RTX 5080, NVIDIA 621.47. Flames: one build with the fix switched on and off by a temporary switch, Forest Temple main room, 300 screenshots each, the 16.7 ms delay. Speed:
dev.py ab, the same kind of build and switch (not the PR's own binary), uncapped, 720p window, 67 % resolution, 60 s a run, interleaved, the median; the fix off first in each pair for the first three rows.56823e27(the fix switched off)eaba99a7e(switched on)Risks
wb_diff.compwrites whole 16-byte vectors, so a game write in the same vector as a GPU change can still be lost. Shadows can still be filled from newer guest memory after the replay's own writes, for a new shadow, and for pools without one. These were there before.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Forest Temple main room (the player's save) and the Fire Temple entrance, RTX 5080, NVIDIA 621.47, Windows 11, with a temporary 16.7 ms wait at each present to put the replay behind as it is on the player's PC: fix off, a flame missing in 161 of 300 screenshots; fix on, in 0 of 300. The flames were watched by eye with the first version of the fix only.
The same spots in one build, the fix switched off and on, with the 16.7 ms wait at each present: the Forest Temple main room (top) and the Fire Temple entrance (bottom). One picture of each; the flames come and go with the fix off.
Description updated: the flames were also watched by eye with this head's code, in the Forest Temple main room with the same 16.7 ms wait at each present (a build with the temporary test switches added): smooth, all four lit. One short look, the game open about 42 s in all.
@review
Recommendation: Request changes. The delayed-replay test shows the torch fix working on one Windows NVIDIA system, but the changed readback path still needs in-game validation and Tier 1 hardware coverage. Head-only CI failures also remain. (It stands on L4: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 8s.)The change delays reporting captured CPU writes until replay takes the capture and keeps the write-back shadow aligned with refreshed readback pages. This protects newer game writes from an earlier submission’s write-back, at the cost of additional GPU copies and a barrier.
Blocking (2): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 8s.CI / Website build and checks (pull_request)fails on this head and passes on the base branch: Failing after 26s.Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:5310: Validate the final readback change against exposure flicker in play. (more on the line) Do: Run the final head in the Forest Temple and Fire Temple with a still camera and pause menu, checking brightness over time and comparing with main where the counter failure can be observed.gpu/vk/vk_memory.cpp:5308: Check the additional readback copies and barrier on the affected Tier 1 platforms. (more on the line) Do: Run the torch scenes with V-Sync on and compare frame times and smoothness with main on AMD RADV, Windows AMD and Steam Deck, including Linux coverage. (@fixdoes its part first: Reduce or batch the extra refresh copies and barrier if an alternative can preserve the shadow’s ordering.)gpu/vk/vk_memory.cpp:3618: Confirm the fix on the player’s original setup without the artificial present delay. (more on the line) Do: Have the player test the Forest Temple reproduction with V-Sync on and threaded rendering enabled, checking that all flames remain lit and move smoothly.@fixcan do L2, L4 and L5.Checks: Still running:
CI / Game-free checks (run_all.py, part 1/2) (pull_request),CI / Game-free checks (run_all.py, part 2/2) (pull_request).More: does it help, other systems, switches, what was read
Does it help: Yes, under the reported artificial delay: on an RTX 5080, a flame was missing in 161 of 300 Forest Temple screenshots with the fix off and 0 of 300 with it on. The player’s original PC has not yet been tested; the reported speed differences on the 5080 were within run-to-run spread.
Other systems: The write-back and readback paths can affect exposure counters and other GPU-written data, as well as frame pacing on NVIDIA, AMD, Linux and Steam Deck. The fixture covers a counter sequence, but the final readback change has not been validated for brightness in play or on the other Tier 1 systems.
Switches: None added, changed or removed.
Reviewed:
eaba99a7e0against56823e27a1: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the complete diff, both changed tests and commit messages. Traced the changed capture, collection, refresh, shadow and write-back paths and their callers; skimmed the rest of gpu/vk/vk_memory.cpp and related renderer code. docs/review-checklist.md and the sibling Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during this read-only review. The author reports game testing and the test results in the PR; two head-only CI checks fail and two game-free checks are still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -3609,0 +3615,4 @@// the replay behind, the write-backs of the submissions before come after that: a page unknown to its shadow there is filled// from guest memory with the words the game has written since, the mirror's older ones differ from them, and the diff put// them back over the game's (issue 2992: torch flames). tests/test_wb_pending_capture.py)if (!c->pages.empty()) shadow_written(c->pages.data(), (int64_t)c->pages.size());L3 (should fix): Confirm the fix on the player’s original setup without the artificial present delay.
When: The reported reproduction uses a temporary delay on a different GPU and CPU. It produces a similar replay backlog and fixes the captured screenshots, but the original 60 Hz V-Sync behavior and flame motion have not been checked with this head.
Do: Have the player test the Forest Temple reproduction with V-Sync on and threaded rendering enabled, checking that all flames remain lit and move smoothly.
@ -5292,0 +5305,4 @@bool shadowed = false;for (auto& [pp, rs] : by_pool) {if (!pp->shadow) continue;if (!shadowed) transfer_barrier(up);L2 (should fix): Check the additional readback copies and barrier on the affected Tier 1 platforms.
When: Every refreshed readback range with a shadow now adds a mirror-to-shadow copy, and each refresh with such a range adds a barrier. Only a Windows RTX 5080 was measured; AMD, Linux and Steam Deck may have different copy and synchronization costs or behavior.
Do: Run the torch scenes with V-Sync on and compare frame times and smoothness with main on AMD RADV, Windows AMD and Steam Deck, including Linux coverage.
@ -5292,0 +5307,4 @@if (!pp->shadow) continue;if (!shadowed) transfer_barrier(up);shadowed = true;shadow_sync_copy(up, pp->mirror, *pp, rs);L1 (should fix): Validate the final readback change against exposure flicker in play.
When: A readback counter can be cleared by the game and updated by the GPU while captures are pending. The fixture covers this sequence, but the reported frame-by-frame check also passed without the readback fix, so it did not distinguish correct exposure from the failure.
Do: Run the final head in the Forest Temple and Fire Temple with a still camera and pause menu, checking brightness over time and comparing with main where the counter failure can be observed.
L4, L5: both checks also fail on
mainat this pull request's base,56823e27, for the same reasons, so they aren't from this change:Third-party parts and guide screenshots: "Guide screenshot check failed: 3 issue(s)" on this head and on main. Run on this PC,check_guide_screenshots.py --review-sourcesalso gives 3 issues on both.Website build and checks: "The table names no condition for Simulated turf" on this head and on main.L1: the still camera and the pause menu were measured frame by frame in both temples, in a build with this head's fix and temporary test switches: no frame off by 0.5 %. The version without the readback part showed no flicker either, so it doesn't prove the fix of that part. It stays in Still to test.
L2, L3: agreed, not done. Both are in Still to test.
Description updated, for L1: the person I work for played this head's fix for about 5 minutes in the Forest Temple and noticed no flicker (RTX 5080, NVIDIA 621.47, the 16.7 ms wait at each present, a build with the temporary test switches added). The replay was behind for part of that time: the late pages in 600 takes ranged from 0 to 13624. Seen by eye, so a small or rare flicker could have been missed; the version without the readback part was not played to compare.
@Beanstalk
Beanstalk test farm · ✅ passed
Commit
eaba99a· approved by llun (reviewed) · dashboardDone (started 09:12 UTC, last report 10:36 UTC). Comment
@Beanstalkto run it again.anyCouldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
any, report 2:Insufficient frame-time evidence for 4 required comparison(s). See rule results.What was tested
What will be tested · default plan (AI failed: the model's response ended with error)
The AI plan failed: the model's response ended with error; using the default plan.
kokiri-start, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side.Measurements on `any`, for the PR description
Verdict: pass on any (2 reports): no rule failed and no PR run crashed.
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+window+dlss+xess
NVIDIA GeForce RTX 4090, 621.40.013th Gen Intel(R) Core(TM) i7-13700K, 32 GB RAM; 2: windows+intel+intel-proprietary+igpu+windowIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMScene: title, from the title screen; hyrule-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side, title 20 s after 5 s warm-up; hyrule-field: 2 game starts a side, field 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)56823e2eaba99aFlags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
anyNVIDIA GeForce RTX 4090, 621.40.013th Gen Intel(R) Core(TM) i7-13700K, 32 GB RAManyIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM