WIP: fix(vk): a start that compiled its noted pipelines writes the pipeline cache before the title #903
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
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
testing wanted
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!903
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:precompile-save-before-title"
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?
Type: fix · Risk: medium · Tested on: Linux game-free checks; Steam Deck OLED (SteamOS 3.9.5, RADV) with no long precompile, so no save · Needs: Steam Deck (a start that compiles, to the title, and the start after it); Windows, any GPU (the write's time)
Why
A start that had to compile its noted pipelines should keep them, so the next start finds them. On a Steam Deck a start compiled all 32,438 of them for about 20 minutes and kept none in our pipeline cache, because in play the cache is written only once it has grown 64 MB, and those pipelines grew it by 4.3 MB (RADV keeps a pipeline as its key and its shaders' hashes, and the code was already there). The next start could find them only in the driver's own folder.
The compile in that case came from Game Mode's
RADV_FORCE_VRS_CONFIG_FILE, which the sibling PR "fix(linux): a start from the Steam Deck's Game Mode no longer compiles every pipeline the preparation built" removes. A start still compiles everything after a driver update, or withRX_VK_HALF_RATE_SHADING=1. #789 (a driver update warms the noted pipelines again underRX_VK_LOAD=create) is related; that path already writes the cache, and this PR covers the other one. No issue on the tracker covers it (searched: pipeline cache save, before the title, noted pipelines).How to reproduce
Seen on: SteamOS 3.9.5 (Steam Deck OLED), RADV VANGOGH, Mesa 26.2.0-devel
Settings and switches: defaults;
RADV_FORCE_VRS_CONFIG_FILEnaming a file (as Game Mode does) on main, to make the start compileSteps: prepare outside Game Mode, start with the variable set, wait through "Loading pipelines" to the title, quit, and start the same way again.
Expected: the second start finds the pipelines in our cache.
Actual:
vk: pipeline cache 4303 KB larger in play: written once it is 64 MB larger, or by a forced save; the cache file is not written, and the second start depends on what the driver's folder kept.What changed
A start whose noted pipelines took
RX_VK_PRECOMPILE_SAVE_S(30 s) or more to build writes the pipeline cache before the title, with the start-up screen showing it as saving. The log says what the save did and how long it took. The warm pass underRX_VK_LOAD=create, which already wrote the cache, now reports the same way.gpu/vk/precompile_save.h(new, standard library only):after_sreads the switch;duedecides the save (the build took that long, the precompile reached its end, and this is a game start, since the preparation's process writes the cache anyway);saidputs what a save did into words.gpu/vk/vk_draw.cpp:precompile_run: whendue, it setsprepare_saving_now(the start-up screen's saving state, asprecompile_warmdoes), callspipeline_cache_save(true), and logsvk: precompile: its pipelines took N s (compiled, not found in the caches): the pipeline cache <what it did>, in T ms, before the title.precompile_warm: its forced save logsthe pipeline cache <what it did>, in T msinstead of an unconditional "written out".pipeline_cache_saverecords how each save ended inpcache_save_outcome, thread-local: a forced save runs on its caller's thread.docs/development.md's row forRX_VK_PRECOMPILE_SAVE_S.tests/test_precompile_save.pywithtests/precompile_save_test.cpp.tests/pipeline_cache_save_test.cpp, which compiles the realpipeline_cache_save, also checks the recorded outcome: written with its size, nothing new, fetch failed, write failed.This changes behaviour on every platform: after any precompile of 30 s or more (the first start after a driver update on Windows, for one) the whole cache is written before the title, only when it grew. That costs seconds once, and what was compiled is no longer lost if the game is closed or crashes before play writes it.
Measurements
Verdict: not yet measured: the save before the title has not run in the game. The Deck run that verified the sibling fix had no precompile of 30 s or more (12-21 s), so no save, as intended. The run that times the save (a start with
RX_VK_HALF_RATE_SHADING=1and the file, to the title, then again from that cache) is queued.Baseline: the After column is the local integration
vrs-verify(bfc69759): main @aa95d35fwith this PR and its two siblings.Hardware: Steam Deck OLED, AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), SteamOS 3.9.5 (20261023.100), 16 GB
Scene: the start-up, up to the title; scratch game folders, each start with a fresh copy of the same warm caches; headless, defaults
Method: the log's
vk: precompile:andvk: pipeline cachelines, the time to the title and the cache file's size; 4 starts interleaved a, b, b, aHow to reproduce: as in the sibling fix's run; for the save,
RX_VK_HALF_RATE_SHADING=1withRADV_FORCE_VRS_CONFIG_FILEnaming a1x1fileaa95d35f(with other open PRs)53c0be91(invrs-verifybfc69759)written once it is 64 MB larger: never writtenFlags and settings
One new switch, on by default.
RX_VK_PRECOMPILE_SAVE_S=<s>0: never)LONGSHOT_PREPARE_ONLYvk_main.cpp, not a switch)Testing
Tested:
tests/test_precompile_save.py: fails at the test commit (49d11cab) and passes at the fix.tests/test_pipeline_cache_save.py, which compiles the realpipeline_cache_save, passes.gpu/vk/precompile_save.hcompiled alone with g++ (libstdc++) and llvm-mingw clang (libc++, Windows target).vrs-verify) that found their pipelines; none saved before the title, as intended.gpu/vk/vk_draw.cppwhole-file syntax check with the build's renderer flags, Linux (clang) and Windows (llvm-mingw): the same as main @f637b42d(Linux 103 warnings and main's one narrowing error at an unchanged line; Windows 0 errors, 105 warnings).tests/run_all.pyon Linux: 529 passed, 18 failed, 79 skipped (tools this PC lacks), 8 at once, on this PR merged with its two siblings onto main @f637b42d. The 18 fail the same way on main @f637b42drun alone:test_appimage_player_build,test_bake_portability,test_crash_dialog,test_crt_options,test_env_on,test_lift_cache,test_lift_cleanup_error,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_options_budget_once,test_pipeline_tour,test_readback_late,test_vk_occlusion_queries,test_vk_pgo,test_walk_key. The checks that read this PR's files pass, among themtest_driver_env_choose,test_driver_cache_env,test_precompile_save,test_pipeline_cache_save,test_prepare_stall,test_display_startup_failureandtest_tested_configurations.Not tested: the save before the title in the game; its time on a Deck's internal storage, a microSD card and Windows; a full renderer build and run on Windows (the change is platform-neutral code).
Must be tested:
cache/restored before each start, setRX_VK_HALF_RATE_SHADING=1andRADV_FORCE_VRS_CONFIG_FILEnaming a file holding1x1, start to the title, expectingvk: precompile: its pipelines took ~1200 s (compiled, not found in the caches): the pipeline cache written, N MB, in T ms, before the titlewith the start-up screen saying it saves; then start again the same way from that cache, not the backup, expecting the precompile in seconds. 2 runs.longshot_vk_pipelines.binout of the cache folder (or start after a driver update), start the game, expecting the same line when the precompile took 30 s or more and nothing otherwise, and report T.Risks
What could break: a start that compiled for 30 s or more now writes the whole pipeline cache before the title, on every platform: seconds, more on a microSD card or a slow disk. A start that took 30 s while finding its pipelines (a slow disk) asks the driver for the cache's size and writes nothing when it didn't grow.
Turning it off:
RX_VK_PRECOMPILE_SAVE_S=0.Compatibility: nothing changes in the caches beyond
longshot_vk_pipelines.binbeing written earlier; saves,longshot_options.iniand the vk ABI are unchanged.Checklist
Everyone
type(scope): description) of the status line's type.RX_VK_HALF_RATE_SHADING=1is queued)main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md). (waits on the Deck run above)mainand passing here.tests/that reads changed source updated in this PR, not weakened.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.