perf(vk): warm FSR 4 pipelines during shader preparation #1886
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1886
Loading…
Reference in a new issue
No description provided.
Delete branch "DYNMK/Longshot:perf/fsr4-prepare-pipelines"
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
Build and persist the FSR 4 Vulkan pipelines before the first gameplay frame.
Evidence
Testing
Tested:
949f48f9(onmain @ 2210931c), the FSR 4-enabled Vulkan renderer compiled and linked on Windows (llvm-mingw) and Arch Linux (WSL 2), and the exact PR renderer reached Native HDR gameplay twice with the nightly 612 host matching the baseline runs' settings and save. Follow-upe4f2b0e0changes onlytests/test_prepare_cache_save.py. Rebased cleanly ontomain @ a8b2d8cd(655ab0cc,2aa940c0): the six intermediate commits onmain(#1809,#1866,#1727,#1873,#1646,#1888) do not touchvk_fsr4.*,vk_main.cpp, or the FSR 4 cache/warm-up path (#1873touchesgpu/vk/vk_draw.cpponly forlongshot_pipelines.binnote reads and rebased with zero conflicts), so the Windows gameplay runs and measurements still hold. Linux runtime behavior on native AMD Vulkan remains to be tested.2aa940c0in Arch Linux (WSL 2):test_fsr4_own_cache.py,test_prepare_stall.py,test_note_refs_once.py,test_utf8_paths.py,test_switch_table.py,test_doc_anchors.py,test_thinlto_tls.py, andtest_log_levels.pyall pass;test_prepare_cache_save.pycompiles, passes the warm-up call-order checks, and hits only the pre-existing progress-ratio failure (AssertionError: ('refresh', 'most', 'zero', ['0.166', '0.666', '0.750'])) reproduced onmain.python -I -B tests/run_all.py --strict, matchingmise run test) in Arch Linux (WSL 2) onmain @ 2210931cbase with pinned Python 3.12, Vulkan/SPIR-V headers, glslang 16.6.0, and .NET: 807 passed, 59 failed, 17 skipped (17 Windows-only / hardware-Vulkan / Unicorn-with-game-files checks skipped by the runner).e4f2b0e0:test_fsr4_own_cache.py,test_prepare_stall.py,test_utf8_paths.py,test_switch_table.py,test_doc_anchors.py,test_thinlto_tls.py,test_log_levels.py.test_recording_admission.pyfailed intermittently under--jobs 8and passed on rerun one4f2b0e0(and passed onmain @ 2210931c).test_prepare_cache_save.pyfailed to compile on949f48f9untile4f2b0e0stubbedfsr4_prepare_shaders()and asserted warm-up ordering; one4f2b0e0it compiles, passes the call-order checks, and hits only the same pre-existing progress-ratio failure (AssertionError: ('refresh', 'most', 'zero', ['0.166', '0.666', '0.750'])) reproduced onmain @ 2210931c.test_vbytes.pytimed out at 600 s on both this PR andmain @ 2210931c.test_recording_admission.py) also fail onmain @ 2210931cin the same WSL environment (0 failures unique to this PR):test_appimage_player_build.py,test_bug_report_defaults.py,test_capture_read_once.py,test_capture_readback_visibility.py,test_crash_dialog.py,test_crt_options.py,test_damage_debug_menu.py,test_dev_ab.py,test_dev_packs.py,test_display_startup_failure.py,test_dlss_feature_size.py,test_draw_binds.py,test_draw_stream_visibility.py,test_failed_compile_keeps_objects.py,test_frame_overlap.py,test_fsr3fi_hud_layer.py,test_fsr_image_retirement.py,test_fsr_uniform_ownership.py,test_guest_imported.py,test_high_fps_fixes.py,test_host_guest_writes.py,test_hud_layout_row.py,test_libc_hooks.py,test_lift_cache.py,test_linux_preflight.py,test_linux_pressure.py,test_linux_tools.py,test_linux_update.py,test_log_open_failure.py,test_low_vram_texture_mips.py,test_make_game_ngx.py,test_mise_build.py,test_missing_nup.py,test_mods_list.py,test_mods_size_table.py,test_ngx_sdk.py,test_nonuniform_image_arrays.py,test_pass_barrier.py,test_pending_guest_import.py,test_pipeline_play_cache.py,test_prepare_cache_save.py,test_present_queue_default.py,test_present_source_crop.py,test_profiling_mode.py,test_psychov35_fsr3_fg.py,test_readback_timeout_source.py,test_replay_write_order.py,test_sampler_admission.py,test_slow_frames.py,test_song_note_cue.py,test_staging_burst.py,test_texel_buffer_ownership.py,test_ub_update_batch.py,test_upscaler_rows.py,test_vbytes.py,test_vcore_escape.py,test_vk_occlusion_queries.py,test_walk_key.py.Still to test:
windows+amd(RX 7000/9000 and lower-memory AMD cards): prepare shaders from an empty FSR 4 cache and start gameplay with FSR 4 enabled, expectingvk: AMD FSR 4: ... pipeline preparation finishedduring preparation and cache hits on first gameplay dispatch (@Beanstalk).linux+amd(Mesa RADV) andsteamdeck: prepare shaders and start gameplay, expecting FSR 4 warm-up whenamd_fidelityfx_upscaler_vk.sois present or clean early-out with no preparation regression when absent (@Beanstalk).windows+nvidia: prepare shaders and start gameplay, expecting clean early-out with no preparation regression (@Beanstalk).RX_VK_FSR4_TUNE=0) and persistence-disabled (RX_VK_PCACHE_LOAD=0) configurations on AMD Windows, plus Linux RADV withamd_fidelityfx_upscaler_vk.soinstalled if not bundled on Test Farm nodes (by hand).Measurements
Verdict: The PR moves cold FSR 4 pipeline creation into preparation. Both PR runs entered gameplay with all three optimized layers available from cache. A warm driver cache can already supply those layers on main, so these runs do not establish a general frame-time improvement.
Setup: Windows 11, RX 6900 XT, Adrenalin 26.11.2, FSR 4.1.2, Native HDR at 2560×1440. Interleaved main → PR → main → PR, same nightly 612 host, same renderer path, settings, Kokiri save and 10-second gameplay hold. Each run began without Longshot's dedicated FSR cache. The driver cache and game shader caches were retained across runs, so the first and second pairs can have different driver-cache states.
2210931c949f48f9Main's first run still had an optimized build in progress at shutdown. Both PR runs reported 0.0 s per optimized layer from cache at gameplay precision. Median preparation was 19.07 s on main and 73.03 s on the PR. Median Native HDR context creation was 87.7 ms and 76.7 ms, respectively. This measures context creation only. Scene-load hitches and later HDR/SDR context transitions remain outside the patch.
The existing
RX_VK_FSR4_HDRswitch retains its default. Preparation respects it when deciding whether to warm the Native HDR context.Risks
Door: Two-way. Reverting removes the preparation phase. Driver validation and the dedicated cache format stay the same.
Blast Radius: FSR 4.
A cold preparation can add roughly two minutes on this GPU. Two contexts are warmed when Native HDR is selected. Memory headroom can still prevent building optional optimized layers. This change leaves live HDR/SDR context recreation and texture streaming outside its scope.
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
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11, RX 6900 XT, Adrenalin 26.11.2: the pre-rebase implementation ran in native HDR gameplay at 1440p and reused all three optimized FSR 4.1.2 pipelines. SDR and Native HDR offscreen preparation completed. Exact rebased-head gameplay retest is pending.
Possibly related, for context:
The exact PR renderer built and linked on Windows with llvm-mingw and on Arch WSL with FSR 4 enabled. Focused Linux cache, dispatch and SPIR-V checks passed. Native Linux GPU runtime coverage remains open.
Completed the interleaved Windows RX 6900 XT comparison using main
2210931cand PR head949f48f9. The exact PR renderer reached Native HDR gameplay twice and reused all three prepared FSR 4 layers in both runs. The description includes the measured preparation cost and driver-cache limitation. The strict WSL suite is still running.Finished the full strict WSL repository suite (python -I -B tests/run_all.py --strict, matching mise run test): 807 passed, 59 failed, 17 skipped.
e4f2b0e0to stub sr4_prepare_shaders() and verify warm-up ordering; it now compiles, passes the call-order checks, and hits only the same pre-existing progress-ratio failure (AssertionError: ('refresh', 'most', 'zero', ['0.166', '0.666', '0.750'])) reproduced on main @2210931c.e4f2b0e0(and on main @2210931c).2210931c.2210931cin the same WSL environment (0 failures unique to this PR) and are listed in the updated description.Marking ready for review.
WIP: perf(vk): warm FSR 4 pipelines during shader preparationto perf(vk): warm FSR 4 pipelines during shader preparatione4f2b0e06b2aa940c048Rebased cleanly onto current main (8b2d8cd, heads
655ab0ccand2aa940c0) with zero conflicts.2210931cand 8b2d8cd (#1809, #1866, #1727, #1873, #1646, #1888) touch gpu/vk/vk_fsr4.*, gpu/vk/vk_main.cpp, or the FSR 4 cache/warm-up path (#1873 touches gpu/vk/vk_draw.cpp only for longshot_pipelines.bin note reads), so the Windows RX 6900 XT gameplay runs and interleaved measurements against main @2210931cstill hold.2aa940c0in Arch Linux (WSL 2): est_fsr4_own_cache.py, est_prepare_stall.py, est_note_refs_once.py, est_utf8_paths.py, est_switch_table.py, est_doc_anchors.py, est_thinlto_tls.py, and est_log_levels.py all pass; est_prepare_cache_save.py compiles, passes the warm-up call-order checks, and hits only the pre-existing main progress-ratio failure.@Beanstalk Please test this PR against main on
windows+amd,linux+amd,steamdeck, andwindows+nvidia: prepare shaders from an empty FSR 4 cache (longshot_fsr4_pipelines.bin) and start gameplay fromkokiri-start.windows+amd(especially RX 7000/9000 and lower-memory AMD cards): please report whether preparation logsvk: AMD FSR 4: ... pipeline preparation finished (... optimized layers ready), writeslongshot_fsr4_pipelines.bin, and hits cache on the first gameplay FSR 4 dispatch without stalls or device lost.linux+amd(Mesa RADV) andsteamdeck: please confirm FSR 4 warm-up works whenamd_fidelityfx_upscaler_vk.sois present, or early-outs cleanly with no preparation regression when absent.windows+nvidia: sanity check that--prepare-shadersearly-outs cleanly with no regression.@DYNMK only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.