fix(vk): the shader preparation's bar counts the compute programs at their cost, and leaves the prediction out on Most #1618

Merged
HumanBean merged 3 commits from HumanBean/Longshot:fix/prepare-bar into main 2026-11-18 17:11:29 +00:00
Owner

Type: fix · Risk: low · Tested on: Linux, RTX 3090 (on main before #1567) · Needs: a re-run on current main; Windows Intel Arc; Mesa Intel

TL;DR

During a build, the launcher's "Prepare shaders" row could sit at 0% for many minutes, then start moving. The game prepares its slowest shaders first but counted each as one small step, so the bar barely moved while they ran. This PR counts each shader by roughly what it costs and drops a step the default setting never runs from the total. On an RTX 3090 from a cold cache, main sat at 0.0% for 4 minutes and first reached 1% at 291 s; with this change it reached 1% at 94 s and 10% at 173 s.

Breakdown

  • Who it helps: anyone building the game, most of all on Intel GPUs, where the stall lasted 40+ minutes.
  • What was wrong: compute programs go first and each takes seconds to minutes in the driver, but each counted as 1 of the seed's 38,809 programs. On Most, the skipped prediction step's guess also stayed in the bar's total.
  • What changes: the programs' count weighs a compute program the driver compiles as 16 graphics programs, moving with each compiled variant. On Most, the prediction is left out of the total from the start.
  • What does not change: what is prepared, in what order, how long it takes, the caches, the shader stamp, the launcher.
  • How it was checked: two cold --prepare-shaders runs (main and this change) on an RTX 3090 before the rebase onto #1567, plus a new game-free test.
  • What is still open: the measurement predates #1567 and should be re-run on current main. No tests were run on this PC, and nothing has been compiled since the rebase.
  • Risk: low. Only the numbers the bar reports change; a wrong weight makes it move unevenly, never stop.

Why

Players report the build's "Prepare shaders" step stuck at 0% for a long time, then progressing. The Intel Arc A730 report in #1522 showed it at 0% after 43:09. The game itself was busy the whole time: it prepares the compute programs first (each with up to 64 variants compiled by the driver), and those counted for almost nothing on the bar.

How to reproduce

Seen on: Windows, Intel Arc A730 (#1522); reproduced on Linux, RTX 3090, NVIDIA 620.70.06
Settings and switches: defaults (Compile shaders: Most)
Steps: build the game in the launcher with an empty shader cache, or run longshot --prepare-shaders --compile-shaders most with the program cache moved aside and a new driver shader cache folder
Expected: the Prepare shaders % moves from the start
Actual: it stays at 0% while the compute programs are compiled, then moves once the graphics programs start

What changed

The shader programs' part of the bar is now counted in "programs' worth" instead of one per program. The count shown stays "N / 38,809 shaders" and reaches the total only when all the work is done.

  • vk: PrepareWork in gpu/vk/vk_progress.h: the programs' count with each program at its cost. A graphics program is its 3 translations; a compute program the driver compiles adds 45 more (15 graphics programs' worth).
  • vk: prepare_run in gpu/vk/vk_draw.cpp reports work_of.done(work) instead of done / 3. Each compiled variant moves the count, up to its program's share. After #1567 only compute programs the compute plan compiles count at that cost (as many as the plan names); the rest are translated only. The pass apart (Mesa's Intel) fills that same share instead of restarting part 0 with a count of its own, which had held the bar still. warm_computes_apart takes a std::function for that.
  • vk: gpu/vk/vk_main.cpp: both starts (--prepare-shaders and the start-up screen) skip the prediction's part of the bar on Most before the programs run. Before, its guess (half again the programs) shrank their share, and the bar jumped once they were done.
  • gpu/vk/vk_shader.cpp is deliberately untouched: it is part of the shader stamp, and changing it would make every player prepare again.

Measurements

Verdict: on main (before #1567) the Prepare shaders % stayed at 0.0% for the first 4 minutes of a 369 s programs' part. With this change it moved from the start and reached 1% three times sooner. Both runs predate the rebase onto #1567.

Hardware: CachyOS (kernel 7.3.3), NVIDIA GeForce RTX 3090 (620.70.06), AMD Ryzen 9 7900X (24 threads), 32 GB
Scene: the shader preparation, no game scene
Method: longshot --prepare-shaders --compile-shaders most (12 workers) from two dev runtimes of one base (310e7c9d), each with its program cache moved aside and an empty NVIDIA shader cache folder, RX_VK_PREPARE_AGAIN=1. The @@progress lines are exactly the launcher's Prepare shaders %; I timestamped them and stopped each run 15 s after the programs' part ended. One run each, through the job queue in shared mode (a timing comparison was not the point, and the totals differ with the PC's other load).
How to reproduce: as above, with scripts/dev_build.py pack of main and of this branch on the same base

Prepare shaders % at Before: main @ 7daafa7a After: this PR @ 9bc63f6a (before the rebase)
30 s 0.0% 0.4%
60 s 0.0% 0.5%
120 s 0.0% 5.8%
180 s 0.0% 10.9%
240 s 0.1% 15.3%
first 1% 291 s 94 s
first 10% 350 s 173 s
end of the programs' part 10.9% → 20%+ jump (369 s) 16.3% → 38.5% (261 s; the prediction already out of the total)
before: vk: prepared 38809 shader programs (46667 new, 0 failed, 9927 compute pipelines; 9927 compute variants, 831 programs with texture variants, 59 at the limit) in 368.8 s
after:  vk: prepared 38809 shader programs (46667 new, 0 failed, 9927 compute pipelines; 9927 compute variants, 831 programs with texture variants, 59 at the limit) in 259.5 s

Since #1567, Most compiles only the listed compute programs, so main's stall on Most is likely shorter than measured here. On All, and on the Arc in #1522, every compute program still compiles. Records: docs/tested/2026-11-18-prepare-bar-humanbean-main-before01.md and ...-pr-after01.md.

Flags and settings

None

Testing

Tested: on the RTX 3090 above, one cold --prepare-shaders run each of main and this change (as committed before the rebase onto #1567). Both prepared the same 38,809 programs and 9,927 compute variants; with the change the bar moved from the start. Both the main pack and this branch's pack built cleanly (renderer and game).

Not tested: the rebased version (on #1567) has not been compiled or run. The rebase moved the weighting to count only the compute programs the plan compiles, and resolved a conflict in prepare_run's pass apart. python -I -B tests/run_all.py was not run on this PC, including the new tests/test_prepare_work.py and the updated tests/test_compute_warm_apart.py; CI runs them. The pass apart (Mesa's Intel) and the start-up screen's bar were not run.

Must be tested:

  • Linux, any GPU, current main vs this branch: the same cold --prepare-shaders --compile-shaders most A/B, expecting the bar to move from the start here and the run to finish (by hand, or Test Farm: @Beanstalk a cold shader preparation, comparing how the Prepare shaders % moves over time)
  • Windows, Intel Arc: a launcher build from an empty cache, expecting "Prepare shaders" to move within the first minutes rather than sit at 0% (Test Farm: @Beanstalk windows intel, a cold build's Prepare shaders %)
  • Linux, Mesa Intel (the pass apart): --prepare-shaders, expecting the bar to keep moving during "the compute pipelines of N compute programs compiled for the driver's cache" (Test Farm: @Beanstalk linux intel)

Risks

What could break: only the numbers the bar reports. A wrong weight makes it move unevenly or jump at the end of the programs' part (for example when the plan names keys this seed lacks); it never goes back and is not full before the work is done. warm_computes_apart now takes a std::function.

Turning it off: revert the commit

Compatibility: Nothing changes: no caches, stamp, options or MKWVK_API_VERSION change.

Issues

See #1522 (its Arc A730 "Prepare shaders at 0% after 43:09" is this bug; the issue also covers a slow Steam Deck build and "Loading pipelines 100%", which this does not fix)

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. (before the rebase only)
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). (not run on this PC)
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here. (added; not run here)
  • A check under tests/ that reads changed source updated in this PR, not weakened.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** Linux, RTX 3090 (on main before [#1567](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1567)) · **Needs:** a re-run on current main; Windows Intel Arc; Mesa Intel ## TL;DR During a build, the launcher's "Prepare shaders" row could sit at 0% for many minutes, then start moving. The game prepares its slowest shaders first but counted each as one small step, so the bar barely moved while they ran. This PR counts each shader by roughly what it costs and drops a step the default setting never runs from the total. On an RTX 3090 from a cold cache, main sat at 0.0% for 4 minutes and first reached 1% at 291 s; with this change it reached 1% at 94 s and 10% at 173 s. ## Breakdown - **Who it helps:** anyone building the game, most of all on Intel GPUs, where the stall lasted 40+ minutes. - **What was wrong:** compute programs go first and each takes seconds to minutes in the driver, but each counted as 1 of the seed's 38,809 programs. On Most, the skipped prediction step's guess also stayed in the bar's total. - **What changes:** the programs' count weighs a compute program the driver compiles as 16 graphics programs, moving with each compiled variant. On Most, the prediction is left out of the total from the start. - **What does not change:** what is prepared, in what order, how long it takes, the caches, the shader stamp, the launcher. - **How it was checked:** two cold `--prepare-shaders` runs (main and this change) on an RTX 3090 before the rebase onto #1567, plus a new game-free test. - **What is still open:** the measurement predates #1567 and should be re-run on current main. No tests were run on this PC, and nothing has been compiled since the rebase. - **Risk:** low. Only the numbers the bar reports change; a wrong weight makes it move unevenly, never stop. ## Why Players report the build's "Prepare shaders" step stuck at 0% for a long time, then progressing. The Intel Arc A730 report in #1522 showed it at 0% after 43:09. The game itself was busy the whole time: it prepares the compute programs first (each with up to 64 variants compiled by the driver), and those counted for almost nothing on the bar. ## How to reproduce **Seen on:** Windows, Intel Arc A730 (#1522); reproduced on Linux, RTX 3090, NVIDIA 620.70.06 **Settings and switches:** defaults (Compile shaders: Most) **Steps:** build the game in the launcher with an empty shader cache, or run `longshot --prepare-shaders --compile-shaders most` with the program cache moved aside and a new driver shader cache folder **Expected:** the Prepare shaders % moves from the start **Actual:** it stays at 0% while the compute programs are compiled, then moves once the graphics programs start ## What changed The shader programs' part of the bar is now counted in "programs' worth" instead of one per program. The count shown stays "N / 38,809 shaders" and reaches the total only when all the work is done. - vk: `PrepareWork` in `gpu/vk/vk_progress.h`: the programs' count with each program at its cost. A graphics program is its 3 translations; a compute program the driver compiles adds 45 more (15 graphics programs' worth). - vk: `prepare_run` in `gpu/vk/vk_draw.cpp` reports `work_of.done(work)` instead of `done / 3`. Each compiled variant moves the count, up to its program's share. After #1567 only compute programs the compute plan compiles count at that cost (as many as the plan names); the rest are translated only. The pass apart (Mesa's Intel) fills that same share instead of restarting part 0 with a count of its own, which had held the bar still. `warm_computes_apart` takes a `std::function` for that. - vk: `gpu/vk/vk_main.cpp`: both starts (`--prepare-shaders` and the start-up screen) skip the prediction's part of the bar on Most before the programs run. Before, its guess (half again the programs) shrank their share, and the bar jumped once they were done. - `gpu/vk/vk_shader.cpp` is deliberately untouched: it is part of the shader stamp, and changing it would make every player prepare again. ## Measurements **Verdict:** on main (before #1567) the Prepare shaders % stayed at 0.0% for the first 4 minutes of a 369 s programs' part. With this change it moved from the start and reached 1% three times sooner. Both runs predate the rebase onto #1567. Hardware: CachyOS (kernel 7.3.3), NVIDIA GeForce RTX 3090 (620.70.06), AMD Ryzen 9 7900X (24 threads), 32 GB Scene: the shader preparation, no game scene Method: `longshot --prepare-shaders --compile-shaders most` (12 workers) from two dev runtimes of one base (310e7c9d), each with its program cache moved aside and an empty NVIDIA shader cache folder, `RX_VK_PREPARE_AGAIN=1`. The `@@progress` lines are exactly the launcher's Prepare shaders %; I timestamped them and stopped each run 15 s after the programs' part ended. One run each, through the job queue in shared mode (a timing comparison was not the point, and the totals differ with the PC's other load). How to reproduce: as above, with `scripts/dev_build.py pack` of main and of this branch on the same base | Prepare shaders % at | Before: main @ 7daafa7a | After: this PR @ 9bc63f6a (before the rebase) | |---|---|---| | 30 s | 0.0% | 0.4% | | 60 s | 0.0% | 0.5% | | 120 s | 0.0% | 5.8% | | 180 s | 0.0% | 10.9% | | 240 s | 0.1% | 15.3% | | first 1% | 291 s | 94 s | | first 10% | 350 s | 173 s | | end of the programs' part | 10.9% → 20%+ jump (369 s) | 16.3% → 38.5% (261 s; the prediction already out of the total) | ``` before: vk: prepared 38809 shader programs (46667 new, 0 failed, 9927 compute pipelines; 9927 compute variants, 831 programs with texture variants, 59 at the limit) in 368.8 s after: vk: prepared 38809 shader programs (46667 new, 0 failed, 9927 compute pipelines; 9927 compute variants, 831 programs with texture variants, 59 at the limit) in 259.5 s ``` Since #1567, Most compiles only the listed compute programs, so main's stall on Most is likely shorter than measured here. On All, and on the Arc in #1522, every compute program still compiles. Records: `docs/tested/2026-11-18-prepare-bar-humanbean-main-before01.md` and `...-pr-after01.md`. ### Flags and settings None ## Testing **Tested:** on the RTX 3090 above, one cold `--prepare-shaders` run each of main and this change (as committed before the rebase onto #1567). Both prepared the same 38,809 programs and 9,927 compute variants; with the change the bar moved from the start. Both the main pack and this branch's pack built cleanly (renderer and game). **Not tested:** the rebased version (on #1567) has not been compiled or run. The rebase moved the weighting to count only the compute programs the plan compiles, and resolved a conflict in `prepare_run`'s pass apart. `python -I -B tests/run_all.py` was not run on this PC, including the new `tests/test_prepare_work.py` and the updated `tests/test_compute_warm_apart.py`; CI runs them. The pass apart (Mesa's Intel) and the start-up screen's bar were not run. **Must be tested:** - Linux, any GPU, current main vs this branch: the same cold `--prepare-shaders --compile-shaders most` A/B, expecting the bar to move from the start here and the run to finish (by hand, or Test Farm: `@Beanstalk` a cold shader preparation, comparing how the Prepare shaders % moves over time) - Windows, Intel Arc: a launcher build from an empty cache, expecting "Prepare shaders" to move within the first minutes rather than sit at 0% (Test Farm: `@Beanstalk windows intel`, a cold build's Prepare shaders %) - Linux, Mesa Intel (the pass apart): `--prepare-shaders`, expecting the bar to keep moving during "the compute pipelines of N compute programs compiled for the driver's cache" (Test Farm: `@Beanstalk linux intel`) ## Risks **What could break:** only the numbers the bar reports. A wrong weight makes it move unevenly or jump at the end of the programs' part (for example when the plan names keys this seed lacks); it never goes back and is not full before the work is done. `warm_computes_apart` now takes a `std::function`. **Turning it off:** revert the commit **Compatibility:** Nothing changes: no caches, stamp, options or `MKWVK_API_VERSION` change. ## Issues See #1522 (its Arc A730 "Prepare shaders at 0% after 43:09" is this bug; the issue also covers a slow Steam Deck build and "Loading pipelines 100%", which this does not fix) ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [ ] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. (before the rebase only) - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). (not run on this PC) - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [ ] A game-free test added for the fix, failing on `main` and passing here. (added; not run here) - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The check fails on main: prepare_run counts each compute program as one of the
seed's 38,809, and the prediction's guess stays in the bar's total on Most.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
prepare_run takes the compute programs first, each with its texture variants
compiled by the driver (seconds each, minutes on Intel's drivers), and counted
each as one program of 38,809: the 2,186 of them moved the programs' part of the
bar by under 6%, so the launcher's Prepare shaders row sat at 0% for as long as
they took (43 minutes on an Arc A730), then moved once the graphics programs
started. The count is now in programs' worth (PrepareWork, vk_progress.h): a
compute program with its compiles counts as sixteen graphics programs, each
compiled variant moving it; the pass apart (Mesa's Intel) maps onto the same
share instead of restarting the programs' part with a count of its own.

On Compile shaders = Most (the default) no prediction runs, but its guess, half
again the programs, stayed in the bar's total until the programs were done:
both starts now leave it out before the programs run.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(tested): the shader preparation's bar on main and with the fix, an RTX 3090 from a cold program cache
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 11s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 16s
Third-party parts / As their notes say (pull_request) Successful in 17s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 10s
c376dfc6ec
Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Tested in game: Linux (CachyOS, kernel 7.3.3), RTX 3090, NVIDIA 620.70.06, Ryzen 9 7900X: one cold longshot --prepare-shaders --compile-shaders most each of main 7daafa7a and this change (9bc63f6a, before the rebase onto #1567), from two runtimes of one base with the program cache moved aside and an empty driver shader cache. Same work in both (38,809 programs, 9,927 compute variants). The @@progress the launcher shows: main 0.0% for the first 4 min, 1% first at 291 s; this change 1% at 94 s, 10% at 173 s. The rebased version has not been run.

Tested in game: Linux (CachyOS, kernel 7.3.3), RTX 3090, NVIDIA 620.70.06, Ryzen 9 7900X: one cold longshot --prepare-shaders --compile-shaders most each of main 7daafa7a and this change (9bc63f6a, before the rebase onto #1567), from two runtimes of one base with the program cache moved aside and an empty driver shader cache. Same work in both (38,809 programs, 9,927 compute variants). The @@progress the launcher shows: main 0.0% for the first 4 min, 1% first at 291 s; this change 1% at 94 s, 10% at 173 s. The rebased version has not been run.
Collaborator

Possibly related, for context:

  • issue #1178 Game: shader preparation takes hours on Iris Xe with Mesa on Debian — Open report of very slow Mesa Intel shader preparation
  • issue #407 Game: up-front shader preparation does not finish on Intel Arc (Windows) with compiles one at a time — Open Intel Arc report of stalled shader preparation
Possibly related, for context: - issue #1178 Game: shader preparation takes hours on Iris Xe with Mesa on Debian — Open report of very slow Mesa Intel shader preparation - issue #407 Game: up-front shader preparation does not finish on Intel Arc (Windows) with compiles one at a time — Open Intel Arc report of stalled shader preparation
HumanBean changed title from WIP: fix(vk): the shader preparation's bar counts the compute programs at their cost, and leaves the prediction out on Most to fix(vk): the shader preparation's bar counts the compute programs at their cost, and leaves the prediction out on Most 2026-11-18 17:11:06 +00:00
HumanBean deleted branch fix/prepare-bar 2026-11-18 17:11:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1618
No description provided.