WIP: feat(vk): add AMD FSR 4 Frame Generation (MLFI 4.0.2) #2831

Draft
nwgat wants to merge 2 commits from nwgat/Longshot:feat/fsr4-framegen into main
First-time contributor

Summary

Adds standalone AMD FSR 4 Frame Generation (ML Frame Interpolation 4.0.2) via the AMD FidelityFX SDK v2.4.0 (amd_fidelityfx_loader_vk.dll + amd_fidelityfx_framegeneration_vk.dll) on supported AMD GPUs, plus 10-bit PQ Native HDR support (A2B10G10R10_UNORM_PACK32) integrated with Longshot's Native HDR framegen buffers.

  • Runs directly on the replay command buffer without FFX's proxy swapchain (FFX_FRAMEGENERATION_FLAG_NO_SWAPCHAIN_CONTEXT_NOTIFY), executing ffxConfigure → ffxDispatchDescFrameGenerationPrepareV2 (with reversed depth, render-pixel actor motion, and world-space camera basis from vk_fsr3_inputs) → ffxDispatchDescFrameGeneration (numGeneratedFrames = 1, up to 2×).
  • Works with any upscaler (FSR 4, FSR 3.1, XeSS, DLSS, Game, or Off) and supports both Fixed 2× and Auto modes.
  • Switching Frame generation to Auto on a GPU where FSR 4 FG is available automatically selects FSR 4 FG (opts.framegen_by = 3) and enables AMD Anti-Lag 2 (opts.antilag = 1, synced via menu_antilag_changed), while keeping both rows manually overridable.
  • Reuses Longshot's 10-bit PQ framegen buffers (color_format) in Native HDR and composites crisp 10-bit PQ HUD pixels onto generated frames via shaders/fg_hud_fsr4_pq.comp (and the learned HUD layer hud.over_pipe / hud.over_pipe_rgba8 in SDR).
  • RX_VK_FSR4_FG=0|1 forbids or forces FSR 4 FG for a run; DLSS FG (NGX and Streamline) and XeSS paths are untouched.

Files to read first: gpu/vk/vk_fsr4_fg.h, gpu/vk/vk_fsr4_fg.cpp, gpu/vk/vk_framegen.cpp, gpu/vk/menu/framegen.cpp, gpu/vk/fsr3_math.h, gpu/vk/framegen_rows.h, and tests/test_fsr4_fg.py.

Testing

Tested:

  • Hardware / OS: Windows 11, AMD Radeon RX 9070 XT (RDNA 4), Adrenalin 26.11.2 (LLPC), Ryzen 9 5900X, 3840×2160 @ 120 Hz.
  • In-game: Loaded 3D gameplay with FSR 4 4.1.2 + FSR 4 FG 4.0.2 (providers 4.0.2, 3.1.6; using 4.0.2), verified context creation and frame generation in SDR and Native HDR PQ.
  • Checks (rebased onto main @ cb0a2763):
    • Passed: test_fsr4_fg.py, test_framegen_by_row.py, test_framegen_dlss_cap.py, test_pacing_policy.py, test_menu_i18n.py (14/14), test_menu_i18n_count.py, test_menu_ini_keys.py, test_pass_barrier.py, test_fsr3fi_hud_mask.py, test_antilag.py, test_framegen_fixed_pace.py.
    • Syntax/compile checked (g++ -std=c++20) both with and without -DLONGSHOT_FSR: vk_framegen.cpp, vk_temporal.cpp, menu/framegen.cpp, vk_fsr4_fg.cpp, vk_fsr3_inputs.cpp.

Still to test:

  • Windows AMD RDNA 4 (rebased head d84c9d8b): re-verify in-game SDR, Native HDR PQ (10-bit HUD composite), Auto mode (with Anti-Lag 2 auto-enable), and Fixed 2× after the main @ cb0a2763 rebase (by hand).
  • Windows NVIDIA RTX 40/50 (NGX & Streamline DLSS FG): verify DLSS FG menu stepping, Streamline restart flow, and zero regressions (@Beanstalk / by hand).
  • Linux Mesa RADV / Intel Arc / non-RDNA4 AMD: verify clean probe fallback (FSR4_FG_SKIP_NO_LIBRARY / FSR4_FG_SKIP_NO_MODEL) and builds without --upscaler fsr4 (@Beanstalk / CI).

Measurements

Verdict: Pending — interleaved A/B frame-time and pacing measurements against main @ cb0a2763 (FSR 4 FG 2× vs FSR 3.1 FG 2× vs FG Off in SDR and Native HDR) still to be recorded while in WIP.

Setup: Windows 11, AMD Radeon RX 9070 XT, Adrenalin 26.11.2, 3840×2160 @ 120 Hz.

Before: main @ cb0a2763 After: this PR @ d84c9d8b
Frame rate / GPU time / pacing TBD TBD

Risks

  • Adds MIT-licensed AMD FidelityFX SDK v2.4.0 frame-generation headers (third_party/fidelityfx/framegeneration/include/ffx_framegeneration*.h); no AMD binaries ship with Longshot.
  • RX_VK_FSR4_FG=0 disables FSR 4 FG completely for a run; reverting the branch restores main with no save, cache, or longshot_options.ini incompatibility (an older ini's frame_generation_by=0 stays FSR 3.1 FG / DLSS FG).
  • Needs re-verification in-game on d84c9d8b after adapting to upstream's 10-bit Native HDR (3f94da5d), Streamline (6e6f1160, 450e63b8), and 45 FPS cap (53607d0d) changes.

Checklist

Ready for review

  • One topic, on current main (cb0a2763); the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (Ran earlier pre-rebase build on RX 9070 XT; needs quick re-run on rebased d84c9d8b.)
  • mise run test passes (any failure that also fails on main is named). (Targeted unit tests passed; full mise run test not yet run.)
  • Measured against main, or Measurements says why there is nothing to measure. (Interleaved measurements TBD in WIP.)
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible. (Note: adds MIT-licensed FFX SDK 2.4.0 headers under third_party/fidelityfx/framegeneration/include/ with PROVENANCE.md / README.md / scripts/fetch.py / mise.lock updated.)

When it applies

  • A switch added or changed: RX_VK_FSR4_FG added with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • The SPIR-V headers regenerated (gpu/vk/shaders/fg_hud_fsr4_pq_comp_spv.h).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Compiled with MinGW g++ on Windows; Linux build pending CI.)
  • Screenshots of the same spot on main and here, for a change that shows on screen. (Pending in-game capture on d84c9d8b.)
  • Docs updated (docs/dev/reference/upscalers.md, docs/user/graphics-and-controls.md).

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.
## Summary Adds standalone **AMD FSR 4 Frame Generation (ML Frame Interpolation 4.0.2)** via the AMD FidelityFX SDK v2.4.0 (`amd_fidelityfx_loader_vk.dll` + `amd_fidelityfx_framegeneration_vk.dll`) on supported AMD GPUs, plus 10-bit PQ Native HDR support (`A2B10G10R10_UNORM_PACK32`) integrated with Longshot's Native HDR framegen buffers. - Runs directly on the replay command buffer without FFX's proxy swapchain (`FFX_FRAMEGENERATION_FLAG_NO_SWAPCHAIN_CONTEXT_NOTIFY`), executing `ffxConfigure` → `ffxDispatchDescFrameGenerationPrepareV2` (with reversed depth, render-pixel actor motion, and world-space camera basis from `vk_fsr3_inputs`) → `ffxDispatchDescFrameGeneration` (`numGeneratedFrames = 1`, up to 2×). - Works with any upscaler (FSR 4, FSR 3.1, XeSS, DLSS, Game, or Off) and supports both **Fixed 2×** and **Auto** modes. - Switching **Frame generation** to **Auto** on a GPU where FSR 4 FG is available automatically selects **FSR 4 FG** (`opts.framegen_by = 3`) and enables **AMD Anti-Lag 2** (`opts.antilag = 1`, synced via `menu_antilag_changed`), while keeping both rows manually overridable. - Reuses Longshot's 10-bit PQ framegen buffers (`color_format`) in Native HDR and composites crisp 10-bit PQ HUD pixels onto generated frames via `shaders/fg_hud_fsr4_pq.comp` (and the learned HUD layer `hud.over_pipe` / `hud.over_pipe_rgba8` in SDR). - `RX_VK_FSR4_FG=0|1` forbids or forces FSR 4 FG for a run; DLSS FG (NGX and Streamline) and XeSS paths are untouched. Files to read first: `gpu/vk/vk_fsr4_fg.h`, `gpu/vk/vk_fsr4_fg.cpp`, `gpu/vk/vk_framegen.cpp`, `gpu/vk/menu/framegen.cpp`, `gpu/vk/fsr3_math.h`, `gpu/vk/framegen_rows.h`, and `tests/test_fsr4_fg.py`. ## Testing **Tested:** - **Hardware / OS:** Windows 11, AMD Radeon RX 9070 XT (RDNA 4), Adrenalin 26.11.2 (LLPC), Ryzen 9 5900X, 3840×2160 @ 120 Hz. - **In-game:** Loaded 3D gameplay with FSR 4 4.1.2 + FSR 4 FG 4.0.2 (`providers 4.0.2, 3.1.6; using 4.0.2`), verified context creation and frame generation in SDR and Native HDR PQ. - **Checks (rebased onto `main @ cb0a2763`):** - Passed: `test_fsr4_fg.py`, `test_framegen_by_row.py`, `test_framegen_dlss_cap.py`, `test_pacing_policy.py`, `test_menu_i18n.py` (14/14), `test_menu_i18n_count.py`, `test_menu_ini_keys.py`, `test_pass_barrier.py`, `test_fsr3fi_hud_mask.py`, `test_antilag.py`, `test_framegen_fixed_pace.py`. - Syntax/compile checked (`g++ -std=c++20`) both with and without `-DLONGSHOT_FSR`: `vk_framegen.cpp`, `vk_temporal.cpp`, `menu/framegen.cpp`, `vk_fsr4_fg.cpp`, `vk_fsr3_inputs.cpp`. **Still to test:** - Windows AMD RDNA 4 (rebased head `d84c9d8b`): re-verify in-game SDR, Native HDR PQ (10-bit HUD composite), Auto mode (with Anti-Lag 2 auto-enable), and Fixed 2× after the `main @ cb0a2763` rebase (by hand). - Windows NVIDIA RTX 40/50 (NGX & Streamline DLSS FG): verify DLSS FG menu stepping, Streamline restart flow, and zero regressions (`@Beanstalk` / by hand). - Linux Mesa RADV / Intel Arc / non-RDNA4 AMD: verify clean probe fallback (`FSR4_FG_SKIP_NO_LIBRARY` / `FSR4_FG_SKIP_NO_MODEL`) and builds without `--upscaler fsr4` (`@Beanstalk` / CI). ## Measurements **Verdict:** Pending — interleaved A/B frame-time and pacing measurements against `main @ cb0a2763` (FSR 4 FG 2× vs FSR 3.1 FG 2× vs FG Off in SDR and Native HDR) still to be recorded while in WIP. Setup: Windows 11, AMD Radeon RX 9070 XT, Adrenalin 26.11.2, 3840×2160 @ 120 Hz. | | Before: main @ cb0a2763 | After: this PR @ d84c9d8b | |---|---|---| | Frame rate / GPU time / pacing | TBD | TBD | ## Risks - Adds MIT-licensed AMD FidelityFX SDK v2.4.0 frame-generation headers (`third_party/fidelityfx/framegeneration/include/ffx_framegeneration*.h`); no AMD binaries ship with Longshot. - `RX_VK_FSR4_FG=0` disables FSR 4 FG completely for a run; reverting the branch restores `main` with no save, cache, or `longshot_options.ini` incompatibility (an older ini's `frame_generation_by=0` stays FSR 3.1 FG / DLSS FG). - Needs re-verification in-game on `d84c9d8b` after adapting to upstream's 10-bit Native HDR (`3f94da5d`), Streamline (`6e6f1160`, `450e63b8`), and 45 FPS cap (`53607d0d`) changes. ## Checklist ### Ready for review - [x] One topic, on current `main` (`cb0a2763`); the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. *(Ran earlier pre-rebase build on RX 9070 XT; needs quick re-run on rebased `d84c9d8b`.)* - [ ] `mise run test` passes (any failure that also fails on `main` is named). *(Targeted unit tests passed; full `mise run test` not yet run.)* - [ ] Measured against `main`, or Measurements says why there is nothing to measure. *(Interleaved measurements TBD in WIP.)* - [ ] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. *(Note: adds MIT-licensed FFX SDK 2.4.0 headers under `third_party/fidelityfx/framegeneration/include/` with `PROVENANCE.md` / `README.md` / `scripts/fetch.py` / `mise.lock` updated.)* ### When it applies - [x] A switch added or changed: `RX_VK_FSR4_FG` added with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] The SPIR-V headers regenerated (`gpu/vk/shaders/fg_hud_fsr4_pq_comp_spv.h`). - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. *(Compiled with MinGW `g++` on Windows; Linux build pending CI.)* - [ ] Screenshots of the same spot on `main` and here, for a change that shows on screen. *(Pending in-game capture on `d84c9d8b`.)* - [x] Docs updated (`docs/dev/reference/upscalers.md`, `docs/user/graphics-and-controls.md`). ### 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.
Integrates standalone AMD FSR 4 Frame Generation (FidelityFX SDK v2.4.0,
MLFI 4.0.2) without proxy swapchain, supports Auto and Fixed 2x modes,
auto-selects FSR 4 FG and enables AMD Anti-Lag 2 when switching Frame
generation to Auto on supported GPUs, and adds unit tests and i18n.
feat(vk): add 10-bit PQ Native HDR path for AMD FSR 4 Frame Generation
Some checks failed
PR description / Title and description (pull_request_target) Successful in 14s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
946ffd684f
Allocates 10-bit A2B10G10R10_UNORM_PACK32 framegen buffers strictly for
AMD FSR 4 FG in Native HDR, adds rgb10_a2 copy/synth/HUD-composite
compute shaders, and passes the dynamic color format to FFX FG.
Author
First-time contributor

Tested in game: Windows 11, AMD Radeon RX 9070 XT, Adrenalin 26.11.2, 4K: FSR 4 FG 4.0.2 verified in 3D gameplay (SDR and Native HDR PQ)

Tested in game: Windows 11, AMD Radeon RX 9070 XT, Adrenalin 26.11.2, 4K: FSR 4 FG 4.0.2 verified in 3D gameplay (SDR and Native HDR PQ)
Member

Possibly related, for context:

  • PR #2204 WIP: fix(vk): preserve FSR HUD marking at reduced output resolution — Open FSR frame-generation HUD routing work overlaps shared vk_framegen HUD paths.
  • PR #2414 fix(vk): preserve 10-bit frame generation in Native HDR — Merged change provides the Native HDR 10-bit frame-generation format this builds on.
  • PR #2169 fix(vk): preserve Native HDR HUD colors in FSR frame generation — Merged Native HDR HUD-color handling is relevant to this new FSR-generated HUD composite.
  • PR #2706 perf(vk): cut 2880x1800 temporal and cropped-present GPU time -0.71 ms (+2.0-2.5% FPS) via 32-bit SDR targets and direct crop UVs — Merged frame-generation HUD and temporal-format changes share paths touched by this PR.
Possibly related, for context: - PR #2204 WIP: fix(vk): preserve FSR HUD marking at reduced output resolution — Open FSR frame-generation HUD routing work overlaps shared vk_framegen HUD paths. - PR #2414 fix(vk): preserve 10-bit frame generation in Native HDR — Merged change provides the Native HDR 10-bit frame-generation format this builds on. - PR #2169 fix(vk): preserve Native HDR HUD colors in FSR frame generation — Merged Native HDR HUD-color handling is relevant to this new FSR-generated HUD composite. - PR #2706 perf(vk): cut 2880x1800 temporal and cropped-present GPU time -0.71 ms (+2.0-2.5% FPS) via 32-bit SDR targets and direct crop UVs — Merged frame-generation HUD and temporal-format changes share paths touched by this PR.
nwgat force-pushed feat/fsr4-framegen from 946ffd684f
Some checks failed
PR description / Title and description (pull_request_target) Successful in 14s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to d84c9d8b1d
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 9s
2026-11-29 23:13:14 +00:00
Compare
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 9s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/fsr4-framegen:nwgat-feat/fsr4-framegen'
git switch 'nwgat-feat/fsr4-framegen'
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!2831
No description provided.