fix(vk): FSR 4's shader preparation warms the model the player picked, and LONGSHOT_FSR builds again #2140

Merged
HumanBean merged 2 commits from dyst/Longshot:fix/fsr4-warm-model into main 2026-11-21 23:41:51 +00:00
Member

Summary

Since #1989, no build with AMD FSR 4 (LONGSHOT_FSR=1: make_game.py --fsr, CI's FSR jobs) compiles. It stops at
gpu/vk/vk_fsr4.cpp:1536: error: no matching function for call to 'make_context'. #1886 added the shader preparation's
warm-up call, make_context(width, height, mode != 0). #1989 then gave make_context the model as a fourth parameter
with no default. It updated the per-frame call in prepare but not the warm-up's, and each PR built on its own.
Builds without FSR 4 never compile that code, so only the FSR builds broke.

The warm-up now asks for fsr4_model(), as prepare does each frame. That is the Model row as saved (menu_init
reads it in pick_device, before the preparation runs), or RX_VK_FSR4_MODEL. The pipelines it warms are then those
of the model the game will use: with Lite picked, Lite's.

To see the bug on main, compile vk_fsr4.cpp with -DLONGSHOT_FSR, or run RX_VK_ONLY=1 LONGSHOT_FSR=1 nx2/build.py --standalone.

Read first: fsr4_prepare_shaders in gpu/vk/vk_fsr4.cpp, then tests/test_fsr4_prepare_model.py.

Fixes #2122

Testing

Tested: Windows 11, llvm-mingw clang 23.1.5 (the Builder's) and TDM gcc 10.3.

  • tests/test_fsr4_prepare_model.py (new) cuts fsr4_prepare_shaders out of vk_fsr4.cpp. It builds it against
    stand-ins whose make_context takes the file's own parameters and records each call. It checks the contexts the
    preparation makes: the shown output, LDR, and HDR after it with Native HDR (none with RX_VK_FSR4_HDR=0), each of
    the model fsr4_model gives, Auto and Lite. On main @ 8aa74983 it fails with both compilers, with the build's own
    error (no matching function for call to 'make_context', 4 arguments wanted, 3 given). Here it passes with both. It
    also fails when the call passes FSR4_MODEL_AUTO whatever was picked: "warmed for the Auto model, but the player
    picked Lite".
  • vk_fsr4.cpp whole, -fsyntax-only with -DLONGSHOT_FSR and the renderer's flags and include folders (clang): on
    main the one error at 1536:21, here none.
  • RX_VK_ONLY=1 LONGSHOT_FSR=1 RX_RELEASE=1 nx2/build.py --standalone (the renderer, as CI's FSR jobs build it):
    "the Vulkan back end: with AMD FSR 4", every file compiled (0 failed, vk_fsr4.cpp in 29 s) and longshot_vk.dll linked. On main this build stops at vk_fsr4.cpp.
  • test_fsr4_own_cache.py, which reads fsr4_prepare_shaders's text, still passes (clang; with TDM gcc 10.3 it fails
    on main and here alike, on FILE_DISPOSITION_INFO missing from that toolchain's Windows headers).
  • tests/run_all.py: 719 passed, 88 failed, 132 skipped on Windows (llvm-mingw first on PATH, the compile cache off). The 87 failing checks run again on main @ 8aa74983 fail there too, all 87: none fails only here. The 88th, tests/test_vbytes.py (the translator's), timed out at 600 s while it ran beside the renderer build; it reads no file this changes. They are this PC's (Windows toolchain and missing tools), not this change's.

Not run in the game: this PC has an NVIDIA RTX 3080, where AMD's FSR 4 library doesn't load and
fsr4_prepare_shaders returns before the changed line.

Still to test:

  • Linux: CI's LONGSHOT_FSR=1 renderer build (.forgejo/workflows/build-linux.yml) on this head, expecting it to pass where it fails on main (CI)
  • Windows, AMD RDNA 4 with AMD's FSR 4 library: Upscaler FSR 4, Model Lite, then Auto; run the shader preparation
    (the launcher's last phase, or --prepare-shaders). Expecting vk: AMD FSR 4: SDR pipeline preparation finished
    for each model in longshot_log.txt, with no Lite was asked for but no Lite provider is hooked unless the GPU has
    no Lite. In play, expecting the first FSR 4 frames not to stall on building the model's pipelines (@Beanstalk).

Measurements

Nothing to measure: a build fix, and the warm-up makes the same contexts as before for the model now named.

Risks

Small. The warm-up makes one context per HDR mode, as before, now of the picked model. With Lite picked on a GPU
without a Lite provider, make_context falls back to Auto and logs it once, as in play. A revert is enough. Nothing
changes for a player after updating, beyond FSR 4 builds compiling again.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (The changed line runs only with
    AMD's FSR 4 library loaded; this PC is NVIDIA: the AMD run in Still to test)
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: the FSR renderer build in Testing. Linux: CI's FSR job, build-linux.yml, on this PR's head)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary Since #1989, no build with AMD FSR 4 (`LONGSHOT_FSR=1`: `make_game.py --fsr`, CI's FSR jobs) compiles. It stops at `gpu/vk/vk_fsr4.cpp:1536: error: no matching function for call to 'make_context'`. #1886 added the shader preparation's warm-up call, `make_context(width, height, mode != 0)`. #1989 then gave `make_context` the model as a fourth parameter with no default. It updated the per-frame call in `prepare` but not the warm-up's, and each PR built on its own. Builds without FSR 4 never compile that code, so only the FSR builds broke. The warm-up now asks for `fsr4_model()`, as `prepare` does each frame. That is the Model row as saved (`menu_init` reads it in `pick_device`, before the preparation runs), or `RX_VK_FSR4_MODEL`. The pipelines it warms are then those of the model the game will use: with Lite picked, Lite's. To see the bug on main, compile `vk_fsr4.cpp` with `-DLONGSHOT_FSR`, or run `RX_VK_ONLY=1 LONGSHOT_FSR=1 nx2/build.py --standalone`. Read first: `fsr4_prepare_shaders` in `gpu/vk/vk_fsr4.cpp`, then `tests/test_fsr4_prepare_model.py`. Fixes #2122 ## Testing **Tested:** Windows 11, llvm-mingw clang 23.1.5 (the Builder's) and TDM gcc 10.3. - `tests/test_fsr4_prepare_model.py` (new) cuts `fsr4_prepare_shaders` out of `vk_fsr4.cpp`. It builds it against stand-ins whose `make_context` takes the file's own parameters and records each call. It checks the contexts the preparation makes: the shown output, LDR, and HDR after it with Native HDR (none with `RX_VK_FSR4_HDR=0`), each of the model `fsr4_model` gives, Auto and Lite. On main @ 8aa74983 it fails with both compilers, with the build's own error (`no matching function for call to 'make_context'`, 4 arguments wanted, 3 given). Here it passes with both. It also fails when the call passes `FSR4_MODEL_AUTO` whatever was picked: "warmed for the Auto model, but the player picked Lite". - `vk_fsr4.cpp` whole, `-fsyntax-only` with `-DLONGSHOT_FSR` and the renderer's flags and include folders (clang): on main the one error at 1536:21, here none. - `RX_VK_ONLY=1 LONGSHOT_FSR=1 RX_RELEASE=1 nx2/build.py --standalone` (the renderer, as CI's FSR jobs build it): "the Vulkan back end: with AMD FSR 4", every file compiled (`0 failed`, `vk_fsr4.cpp` in 29 s) and `longshot_vk.dll` linked. On main this build stops at `vk_fsr4.cpp`. - `test_fsr4_own_cache.py`, which reads `fsr4_prepare_shaders`'s text, still passes (clang; with TDM gcc 10.3 it fails on main and here alike, on `FILE_DISPOSITION_INFO` missing from that toolchain's Windows headers). - `tests/run_all.py`: 719 passed, 88 failed, 132 skipped on Windows (llvm-mingw first on PATH, the compile cache off). The 87 failing checks run again on main @ 8aa74983 fail there too, all 87: none fails only here. The 88th, `tests/test_vbytes.py` (the translator's), timed out at 600 s while it ran beside the renderer build; it reads no file this changes. They are this PC's (Windows toolchain and missing tools), not this change's. Not run in the game: this PC has an NVIDIA RTX 3080, where AMD's FSR 4 library doesn't load and `fsr4_prepare_shaders` returns before the changed line. **Still to test:** - Linux: CI's `LONGSHOT_FSR=1` renderer build (`.forgejo/workflows/build-linux.yml`) on this head, expecting it to pass where it fails on main (CI) - Windows, AMD RDNA 4 with AMD's FSR 4 library: Upscaler FSR 4, Model Lite, then Auto; run the shader preparation (the launcher's last phase, or `--prepare-shaders`). Expecting `vk: AMD FSR 4: SDR pipeline preparation finished` for each model in `longshot_log.txt`, with no `Lite was asked for but no Lite provider is hooked` unless the GPU has no Lite. In play, expecting the first FSR 4 frames not to stall on building the model's pipelines (@Beanstalk). ## Measurements Nothing to measure: a build fix, and the warm-up makes the same contexts as before for the model now named. ## Risks Small. The warm-up makes one context per HDR mode, as before, now of the picked model. With Lite picked on a GPU without a Lite provider, `make_context` falls back to Auto and logs it once, as in play. A revert is enough. Nothing changes for a player after updating, beyond FSR 4 builds compiling again. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (The changed line runs only with AMD's FSR 4 library loaded; this PC is NVIDIA: the AMD run in Still to test) - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows: the FSR renderer build in Testing. Linux: CI's FSR job, `build-linux.yml`, on this PR's head) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fsr4_prepare_shaders is only compiled with LONGSHOT_FSR, so a change to make_context that leaves its warm call behind
breaks those builds and no other. The check cuts the function out of vk_fsr4.cpp and builds it against stand-ins whose
make_context takes the file's own parameters, then checks the contexts it makes: the shown output, LDR then HDR with
Native HDR, each of the model fsr4_model gives (Auto and Lite).

It fails on main: the warm call passes three arguments to a make_context that takes four since #1989 (#2122).

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): FSR 4's shader preparation warms the model the player picked, and LONGSHOT_FSR builds again
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
CI / Conventional Commit title (pull_request) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Third-party parts / As their notes say (pull_request) Successful in 19s
CI / Website build and checks (pull_request) Failing after 25s
PR description / Description follows the template (pull_request_target) Failing after 5s
32b952d69f
#1989 gave make_context the model as a fourth argument after #1886's preparation call to it, which passed three: every
LONGSHOT_FSR build stopped at vk_fsr4.cpp:1536 ("no matching function for call to 'make_context'"). The preparation now
asks for fsr4_model(), as the per-frame path does: the Model row as saved (menu_init reads it before the preparation runs),
or RX_VK_FSR4_MODEL, so the pipelines it warms are those of the model the game will use.

Fixes #2122

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean changed title from WIP: fix(vk): FSR 4's shader preparation warms the model the player picked, and LONGSHOT_FSR builds again to fix(vk): FSR 4's shader preparation warms the model the player picked, and LONGSHOT_FSR builds again 2026-11-21 23:41:42 +00:00
HumanBean deleted branch fix/fsr4-warm-model 2026-11-21 23:41:52 +00:00
Author
Member

@Beanstalk On Windows with an AMD RDNA 4 card and AMD's FSR 4 library: set Upscaler to FSR 4 and Model to Lite, run the shader preparation (the launcher's last phase), then start the game and play a minute in Kokiri Forest. Then the same with Model set to Auto. Expecting, for each model, vk: AMD FSR 4: SDR pipeline preparation finished in longshot_log.txt, no Lite was asked for but no Lite provider is hooked (unless the card has no Lite), and the first FSR 4 frames in play without a stall while the model's pipelines build.

@Beanstalk On Windows with an AMD RDNA 4 card and AMD's FSR 4 library: set Upscaler to FSR 4 and Model to Lite, run the shader preparation (the launcher's last phase), then start the game and play a minute in Kokiri Forest. Then the same with Model set to Auto. Expecting, for each model, `vk: AMD FSR 4: SDR pipeline preparation finished` in longshot_log.txt, no `Lite was asked for but no Lite provider is hooked` (unless the card has no Lite), and the first FSR 4 frames in play without a stall while the model's pipelines build.
Member

@dyst this PR is closed or unknown to the farm.

@dyst this PR is closed or unknown to the farm.
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!2140
No description provided.