fix(vk): FSR 3.1 frame generation's images let go when another one makes the frames #1869
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1869
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:fix/fsr-idle-own-use"
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
#1158 lets frame generation's images go 120 presents after nothing uses them. For FSR 3.1's own images it counted the
wrong thing: any present that recorded made frames counted as FSR in use, whichever one made them. So after a player
used FSR 3.1 FG and then chose Built-in FG (or DLSS FG), FSR 3.1's images were never let go: at 2560x1440 2x that is
about 150 MiB of VRAM kept for the rest of the run. futondestroyer found this in review 1583 (comment 38853) and
TrashPanda in review 1644. futondestroyer's comment 47385 asked to count FSR's actual use, a reset or a history-only
present included, rather than the frame finally shown.
To see it on main: play in a window with Upscaler DLSS, Frame generation 2x, Frame generation by FSR 3.1 FG. Then
switch Frame generation by to Built-in FG and keep playing. The log never shows
vk: fsr3fi: frame generation off: its ... images let go, and the GPU's memory doesn't go down.What changes:
fsr3fi_framesnow marks the present (fsr_given) just before eachfsr3fi::generatecall, once itsinputs are taken. A reset or a history-only call (no frame to make) counts too, and so does a present whose FSR result
isn't shown.
framegen_idletakes that mark, clears it for the next present and counts FSR's own idle presents by it.The shared images still count any recorded present as in use, so #1158's queue-before-idle protection stays as it was.
Both counts are now one small rule with no Vulkan in it (
framegen_idle_rule::step).The result: 120 presents after the switch to Built-in FG, the log shows
its 35 images let goand the GPU's memorydrops by 150-160 MiB, with no frame-time hitch.
Read first:
gpu/vk/framegen_idle.h(step),framegen_idleandfsr3fi_framesingpu/vk/vk_framegen.cpp.mooki's point (comment 47180) is in too: the header now gives the log line's size for the built-in images, about 112 MB
at 2560x1440 2x and 823 MB at 4K 8x, not 150 and 800.
See #1158.
Testing
Tested: Windows 11 Pro 26200, RTX 4070 SUPER, NVIDIA 617.42, in the game in a window (frame generation doesn't run
headless), at this head and at main
89c3d21ebuilt from the same base. The kokiri-start save, standing. The rows wereset through the control bridge: Upscaler NVIDIA DLSS, Frame generation 2x, Frame generation by FSR 3.1 FG. FSR 3.1 made
600 of 600 presents' frames, then Frame generation by was set to Built-in FG for 45 s. With this PR,
vk: fsr3fi: frame generation off: its 35 images let goappears in both runs and the GPU's memory steps down at that point. On main theline never appears and the memory doesn't step. Nothing looked wrong in either build, and no device loss.
Two more runs of this PR added a third step: Frame generation by set back to FSR 3.1 FG after the release. FSR 3.1 made
its images again (
1 made frame(s) at 2560x1440), it made 598-600 of each 600 presents' frames again, and there wasno device loss.
Checks:
tests/test_framegen_idle.py,tests/test_vram_held_idle.py,tests/test_fsr3fi_hud_mask.pyandtests/test_switch_table.pypass.gpu/vk/vk_framegen.cppwith the builder's flags has no errors.run_all.py --changed 89c3d21egives 26 passed, 2 failed, 1 skipped. The 2 failures,tests/test_crt_options.pyandtests/test_present_source_crop.py, fail on main too.run_all.py(whatmise run testruns, here without--strictand withouttest-deps' glslang and Python packages): this head gives 743 passed, 69 failed, 69 skipped; main
89c3d21egives742 passed, 69 failed, 70 skipped. The same 69 fail on both: the box's tools, listed below. The extra pass is
tests/test_framegen_idle.py, which now takes run_all's compiler (g++ here) and runs on Linux.The 69 checks that fail on main
89c3d21etoo (WSL)missing,nx2/test_mesh_first_types.py, and intests/: test_appimage_player_build, test_bug_report_defaults,test_capture_read_once, test_capture_readback_visibility, test_crash_dialog, test_crt_options, test_damage_debug_menu,
test_dev_ab, test_dev_packs, test_discover, test_display_startup_failure, test_dlss_feature_size, test_draw_binds,
test_draw_stream_visibility, test_early_split_before_draw, test_failed_compile_keeps_objects, test_frame_overlap,
test_fsr_image_retirement, test_fsr_uniform_ownership, test_guest_imported, test_high_fps_fixes, test_hold_gpu,
test_host_guest_writes, test_hud_layout_row, test_image_view_retry, test_libc_hooks, test_lift_cache, test_lift_lookups,
test_link_skip, test_linux_pressure, test_linux_tools, test_linux_update, test_log_open_failure, test_longshot_saves,
test_low_vram_texture_mips, test_make_game_cache, test_make_game_ngx, test_mise_build, test_missing_nup, test_mods_list,
test_mods_size_table, test_ngx_sdk, test_pass_barrier, test_pending_guest_import, test_pipeline_play_cache,
test_prepare_cache_save, test_present_queue_default, test_present_source_crop, test_profiling_mode,
test_psychov35_fsr3_fg, test_readback_early, test_readback_late, test_readback_timeout_source, test_replay_write_order,
test_sampler_admission, test_slow_frames, test_song_note_cue, test_split_before_draw, test_staging_burst,
test_texel_buffer_ownership, test_thinlto_tls, test_ub_update_batch, test_upscaler_rows, test_vcore_escape,
test_vk_occlusion_queries, test_walk, test_walk_key.
The new checks fail on main:
tests/test_framegen_idle.pyruns the FSR sequences: FSR for 1 present, then 120 presents by another; an FSR reset orhistory-only present at 119; the row turned Off or to another one during an FSR present. With FSR's count fed
recordedagain (main's wiring), 2 of them fail.tests/test_fsr3fi_hud_mask.pychecks the mark. Run against main's source, its new history-only check fails.Still to test:
its ... images let goline about 2 s after the switch (by hand). This PC's builds didn't offer DLSS FG, so only Built-in FG wasthe other one here.
frame interpolation offline, and nothing wrong on screen (by hand).frames again after it (@Beanstalk linux: FSR 3.1 FG then Built-in FG then FSR 3.1 FG, the fsr3fi lines).
Measurements
Verdict: after a switch from FSR 3.1 FG to Built-in FG at 2560x1440 2x, FSR 3.1's 35 images are let go 120 presents
later: the GPU's memory steps down 150-160 MiB, where main keeps them for the run. The frame time around the release
doesn't change.
Setup: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB, NVIDIA 617.42, Ryzen 9 9950X3D (SMT off), 32 GB. Windowed
2560x1440, mailbox, uncapped. The kokiri-start save, standing. Upscaler NVIDIA DLSS, Frame generation 2x, Frame
generation by FSR 3.1 FG for 40 s, then Built-in FG for 45 s. Runs were interleaved main, PR, PR, main. GPU memory is
nvidia-smi's
memory.used, sampled once a second with the game's present number, and the step is the two sampleseither side of present +120 after the switch. Frame times are from
RX_VK_FRAME_TRACE, by present number.89c3d21ec2e7a8fcfsr3fi: frame generation off: its N images let goafter the switchits 35 images let go(runs 2, 3)The two turn-back-on runs of this PR (Built-in FG, then FSR 3.1 FG again) gave the same release step: 8831 → 8677
and 8789 → 8636 MiB (-154, -153).
In every run, main's and this PR's alike, the GPU's memory also moves by up to about 150 MiB a few thousand presents
later (8996 → 9059 → 8868, for example). That is the scene's own textures, not the release: it is why the table takes
the step at the release itself rather than the whole run's average.
Risks
What could break: FSR 3.1's images are now let go after a switch to another frame generation, where before they
were kept. Choosing FSR 3.1 FG again makes them again on its next present. That is the path a resize already takes
(
fsr3fi::prepare), with no device wait:fsr3fi::releasehands the images to its retirement list, which frees themonce the GPU is past them. Turned back on in two runs, the images were made again within about 16 presents (the GPU's memory up 150-170 MiB).
The slowest frame then was 13.0-13.2 ms, against 12.4-12.9 ms for FSR 3.1 FG's p99 after it. The shared images and #1158's hang protection are unchanged.
Turning it off: there is no switch; a revert is enough.
After updating: nothing changes in saves,
longshot_options.inior the caches.Still held: FSR 3.1's HUD mask images (
hud.before/after/source/hudless/fit/layerinvk_framegen.cpp)are still kept after a switch away from FSR 3.1 FG, as on main. They are replaced only on a size change. They're left
for a separate change:
framegen_hud_beforemakes them on the replay's worker threads, and freeing them needshud_free_deadto run outsidehud_source. So it isn't the same small change.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.g++ but not the Linux build's clang, lld, VMA headers or FFmpeg, and fetching them was not done.)
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
@Beanstalk linux and steamdeck: in a window, Upscaler as available, Frame generation 2x by FSR 3.1 FG for 40 s, then Built-in FG for 45 s, then FSR 3.1 FG again for 30 s,
RX_VK_FRAME_TRACE=1. Expectingfsr3fi: frame generation off: its N images let goonce, about 120 presents after the switch to Built-in FG, FSR 3.1's frames made again after the switch back, no device loss, and no frame-time spike at the release.(Earlier runs on #1846 and #1847 today ended in
errorbefore building: the farm's checkout of main failedgit rev-parse --verify HEAD^{commit}in packs.py's cmd_base, so nothing was measured there.)Beanstalk test farm
Commit
c2e7a8f· tier reviewed · approved by GummiNaomi · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)On Linux and Steam Deck, this plan attempts the requested 40-second FSR 3.1, 45-second Built-in, and 30-second FSR 3.1 sequence in Kokiri Forest, taking about 13 minutes per tester. It checks the release log count, device loss, frame times, and screenshots against main. The farm runs without a window, however, and the PR says frame generation does not run headless; the requested frame trace is also unavailable under farm rules. Consequently, a missing release will fail the plan, but the result cannot establish the 120-present timing or confirm that FSR-generated frames resume.
kokiri-start(settings fullscreen=0, frame_generation=2, frame_generation_by=1), then measure fsr-before for 40 s (after 0 s warm-up), take the picture fsr-before to compare with main, set frame_generation_by to 0, measure builtin for 45 s (after 0 s warm-up), take the picture builtin to compare with main, set frame_generation_by to 1, measure fsr-after for 30 s (after 0 s warm-up), take the picture fsr-after to compare with main; 1 run on each side.Done (started 13:14 UTC). Comment
@Beanstalkto run it again.