[PR #145] runtime: AMD's PC FidelityFX upscaler on the layer's Vulkan device (RT-344) #196

Open
opened 2026-11-26 20:17:06 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/145
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9877


📝 Commits (8)

  • c8d136d runtime: AMD's PC FidelityFX upscaler on the layer's Vulkan device (RT-344)
  • e312253 ffx_vk: enable the extensions the upscaler's shaders use; the test fails on validation errors (#4999 review)
  • be631db ffx_vk_dispatch_test: the console's 1080p configuration and a 4K case
  • a2766d2 ffx_vk: the loader's choice depends on GPU and driver, not on architecture alone
  • 8abab27 docs: FSR 4.1.2 on RDNA4 under AMD's Windows driver (RX 9060 XT), and the shader errors there too
  • c1e976a ffx_vk: load the provider by full path instead of changing the process DLL search path
  • a1cbccb Merge remote-tracking branch 'origin/main' into rt-344-ffx-vk
  • 6f014cf Merge remote-tracking branch 'origin/main' into rt-344-ffx-vk

📊 Changes

6 files changed (+672 additions, -5 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+32 -0)
📝 runtime/CMakeLists.txt (+11 -0)
➕ runtime/src/ffx_vk_backend.cpp (+71 -0)
➕ runtime/src/ffx_vk_backend.h (+70 -0)
📝 runtime/test/ffx_api_min.h (+25 -5)
➕ runtime/test/ffx_vk_dispatch_test.cpp (+463 -0)

📄 Description

Carried over from old PR 9877 by AwkGrep256 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9877, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
AwkGrep256: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Resubmitted unchanged: this was #4999, closed at the repository's move to the organisation (the members-only switch, 22:25–22:49 UTC) with no review comment; reopening it is refused. Same branch and head (6f014cfc1), which merges cleanly on main 7e39a81ea. The test reports from other contributors are on #4999.

Item: RT-344 (claim: https://github.com/ItsNotRexed/Leonida/issues/4933#issuecomment-7093985805; finding by amarovndres: https://github.com/ItsNotRexed/Leonida/issues/4816#issuecomment-7093381681). It's the AMD counterpart of #4801, and it touches none of #4801's files.

It has run on native Windows on AMD (RDNA4 and RDNA3 with FSR 4.1.2, and an RDNA2 iGPU) and on NVIDIA, and under Wine on RDNA4 and NVIDIA; see "Tested". Parts 1 and 2 of the shim that uses this backend are #5139 and #5171.

Why

The game calls the five FFX functions of the package's amd_fidelityfx_upscaler_xbox.dll. That DLL's 29 INT8 programs would have to be translated, and it only builds one table: 1080p, Quality (docs/d3d12_vulkan.md A.3, docs/fspx.md).

AMD's public FidelityFX SDK 2.4.0 (2026-10-28) ships a signed Vulkan loader, amd_fidelityfx_loader_vk.dll. Its release notes put the upscaler "at feature parity with DX12". So the same FFX calls can be answered on the layer's own VkDevice, with no D3D12 device and no D3D12↔Vulkan hand-off. That hand-off is the part #4801 leaves open. The loader picks the newest upscaler the GPU and driver support. Measured: FSR 4.1.2 on RDNA4 under RADV and on RDNA3 under AMD's Windows driver 26.11.2; FSR 3.1.6 on an RDNA2 iGPU and on NVIDIA (a2766d20 corrects the comments, which had said RDNA4 and RDNA2 discrete only).

What

  • runtime/src/ffx_vk_backend.{h,cpp} (about 120 lines). It:
    • loads the loader from LEONIDA_FFX_DIR, or from next to the program;
    • creates the upscale context with the Vulkan backend descriptor in place of the console one, keeping the game's flags and sizes;
    • reports the provider the loader chose;
    • passes dispatches through, with VkImage resources and a VkCommandBuffer;
    • lists wanted_device_extensions, the device extensions the upscaler's shaders use. These are the ones AMD's own sample device enables where present: VK_KHR_compute_shader_derivatives, VK_KHR_cooperative_matrix and VK_EXT_shader_float8.
  • runtime/test/ffx_api_min.h: adds the Vulkan backend descriptor and the provider-version query, written out from the SDK's MIT headers (ffx_api.h, vk/ffx_api_vk.h). fsr_dispatch_test still builds.
  • runtime/test/ffx_vk_dispatch_test.cpp:
    • Two cases, each on its own context: 1280x720 → 1920x1080, the one configuration the console's DLL builds (A.3), and 1920x1080 → 3840x2160 (4K). (The first commits ran 1280x720 → 2560x1440, which is what the reviewers ran.)
    • Inputs, all procedural with no game data: an RGBA16F checkerboard, depth 0 (inverted), zero motion.
    • 30 upscales per case with a Halton jitter, using the game's measured context flags (HDR, inverted depth, auto exposure) plus AMD's debug checking.
    • Checks: every output value is finite, and the centre of every output square is within 0.1 of its input.
    • The device enables the wanted extensions it has, with all their features.
    • LEONIDA_VK_VALIDATION=1 runs it under the Khronos validation layer, and any validation error fails it, except five named by VUID and text in known_provider_error. Those five are in AMD's FSR 4.1.2 shaders; see the next section. A missing layer fails the run too.
    • Prints the provider and the time per upscale. It skips (77) without a GPU or without the DLL; LEONIDA_VK_DEVICE picks the GPU.
  • runtime/CMakeLists.txt: the test, Windows builds only, next to the other Vulkan tools.
  • docs/d3d12_vulkan.md A.3: what was measured.

Not in this PR, as in #4801: the shim that routes the game's calls here and maps its resources to the layer's images.

Licence

  • No AMD binary is in the repository. The user points LEONIDA_FFX_DIR at the SDK's Kits/FidelityFX/signedbin.
  • AMD's licence for those DLLs allows redistribution in binary form and forbids reverse engineering. This code only calls their public API.
  • The declarations come from the SDK's MIT headers, in the existing ffx_api_min.h.

Validation (after whattheflop's review, e312253b)

  • The fix. whattheflop's Windows run found FSR 3.1.6's shader modules using compute-shader derivatives the test device hadn't enabled (VUID-VkShaderModuleCreateInfo-pCode-08740/08742). The test now enables the wanted extensions.
  • Checked under RADV, with the host's validation layer beneath Wine (VK_INSTANCE_LAYERS), since Wine's Vulkan doesn't show layers to Windows programs:
    • On the iGPU (FSR 3.1.6) the layer is now silent, apart from one vkCreateDevice-…-01387 raised by Wine's own device setup.
  • What remains on the RX 9070 XT (FSR 4.1.2) is inside AMD's shaders, and no device setup removes it:
    • they declare SPV_NV_cooperative_matrix2, which RADV doesn't offer on that GPU;
    • spirv-val rejects an OpFConvert on cooperative-matrix types and an OpStore to an image;
    • three storage images (rw_reprojected_color, rw_history_color, rw_mlsr_output_color) get 3-component writes on RGBA16F views (OpImageWrite-08795).
      These are the five known_provider_error entries.
  • The rules, applied to the logged messages:
    • 9070 XT: 41 known provider errors, 0 counted.
    • iGPU after the fix: 0.
    • The iGPU run before the fix: 4 counted, so that run would now fail.

Tested

Built with clang-cl 23.1.5 + xwin (SDK 10.0.26100) through runtime/cmake/clang-cl-xwin.cmake. Run with ctest -R ffx_vk_dispatch under Wine 11.22 on CachyOS (kernel 7.3.5, Mesa 26.3.1 RADV), FidelityFX SDK 2.4.0 DLLs:

At be631db9, per upscale (submit + wait); every case passes with every square right and 0 non-finite values:

GPU providers offered context gets 720p → 1080p 1080p → 4K
RX 9070 XT (RDNA4, gfx1201) 4.1.2, 3.1.6, 2.3.4 FSR 4.1.2 0.41 ms 1.22 ms
Ryzen 7 9800X3D iGPU (RDNA2, gfx1036) 3.1.6, 2.3.4 FSR 3.1.6 10.1 ms 35.3 ms

From reviewers:

  • amarovndres, at 3c05c379 (#5139): RX 9060 XT (RDNA4), AMD Windows driver 26.10.1. All three wanted extensions are offered; the loader chose FSR 4.1.2: 1.27 ms to 1080p and 4.16 ms to 4K, every square right, and #5139's layer test passes too.
    • Under validation: no hazards, and only the five known_provider_error entries. So those are in AMD's shaders on AMD's driver too.
  • RSK2707X, at be631db9: RX 7600 (RDNA3, gfx1102), AMD Windows driver 26.11.2. The loader chose FSR 4.1.2: 4.56 ms to 1080p and 16.98 ms to 4K, every square right.
    • With LEONIDA_VK_VALIDATION=1: 0 validation errors, and 10 provider errors, all the 08795 writes known_provider_error lists. So those are in AMD's shaders on AMD's own driver too.
  • CryingLaughing, at be631db9: RTX 4080, native Windows, driver 621.01. FSR 3.1.6 at both sizes, every square right, zero validation errors (Khronos 1.4.357).
  • Kam471, at 8af9ed0b (#5139): RTX 5070 Ti, native Windows. FSR 3.1.6, 880/880 and 1980/1980.

At c8d136d4:

  • whattheflop: native Windows 11, the same iGPU, AMD driver 32.0.21030.2001, MSVC. FSR 3.1.6, 880/880, 0 non-finite, 16.8 ms. The missing-loader skip returned 77. That run found the extension issue fixed in e312253b.

  • Kev-Ball: RTX 3080 Ti (NVIDIA 620.73.04), CachyOS, Wine 11.22, built with llvm-mingw. The loader chose FSR 3.1.6, 880/880, 0 non-finite, 0.69 ms.

  • The test can fail: with the dispatch call removed, both cases fail (440/880 and 990/1980 squares).

  • Without LEONIDA_FFX_DIR it skips: amd_fidelityfx_loader_vk.dll not found.

  • tests/test_ctest_registration.py, test_cmake_vulkan_missing.py, test_build_runtime_fallback.py, test_runtime_paths.py and the test_docs_* checks pass.

  • Covered since: whattheflop confirmed the extension fix on Windows (e312253b, 0 errors). RSK2707X ran FSR 4.1.2 on AMD's Windows driver (RX 7600).

  • Not run: Intel.

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/145 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9877` --- ### 📝 Commits (8) - [`c8d136d`](https://github.com/ubiquitarianism/leonida/commit/c8d136d45d5b40bbfeca9a2ecaf9ef744d090110) runtime: AMD's PC FidelityFX upscaler on the layer's Vulkan device (RT-344) - [`e312253`](https://github.com/ubiquitarianism/leonida/commit/e312253b950962d74afa6f8aa35b13b3b40db3a5) ffx_vk: enable the extensions the upscaler's shaders use; the test fails on validation errors (#4999 review) - [`be631db`](https://github.com/ubiquitarianism/leonida/commit/be631db9dc45a8c444fe33b951309fb7ddc2e511) ffx_vk_dispatch_test: the console's 1080p configuration and a 4K case - [`a2766d2`](https://github.com/ubiquitarianism/leonida/commit/a2766d202e54eca1a66bd5f3b0e796e4937f59fa) ffx_vk: the loader's choice depends on GPU and driver, not on architecture alone - [`8abab27`](https://github.com/ubiquitarianism/leonida/commit/8abab278ba25ea99ed5ac7e38df6ccd26c2d1ee6) docs: FSR 4.1.2 on RDNA4 under AMD's Windows driver (RX 9060 XT), and the shader errors there too - [`c1e976a`](https://github.com/ubiquitarianism/leonida/commit/c1e976a0e1c093f209c931e060848097556205c0) ffx_vk: load the provider by full path instead of changing the process DLL search path - [`a1cbccb`](https://github.com/ubiquitarianism/leonida/commit/a1cbccb4155105b3f3729b3fbb8d666201ca4685) Merge remote-tracking branch 'origin/main' into rt-344-ffx-vk - [`6f014cf`](https://github.com/ubiquitarianism/leonida/commit/6f014cfc1c11ee232664c8075eae58b9305b30c5) Merge remote-tracking branch 'origin/main' into rt-344-ffx-vk ### 📊 Changes **6 files changed** (+672 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+32 -0) 📝 `runtime/CMakeLists.txt` (+11 -0) ➕ `runtime/src/ffx_vk_backend.cpp` (+71 -0) ➕ `runtime/src/ffx_vk_backend.h` (+70 -0) 📝 `runtime/test/ffx_api_min.h` (+25 -5) ➕ `runtime/test/ffx_vk_dispatch_test.cpp` (+463 -0) </details> ### 📄 Description > Carried over from **old PR 9877** by `AwkGrep256` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9877`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `AwkGrep256`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Resubmitted unchanged: this was `#4999`, closed at the repository's move to the organisation (the members-only switch, 22:25–22:49 UTC) with no review comment; reopening it is refused. Same branch and head (`6f014cfc1`), which merges cleanly on `main` `7e39a81ea`. The test reports from other contributors are on `#4999`. Item: **RT-344** (claim: https://github.com/ItsNotRexed/Leonida/issues/4933#issuecomment-7093985805; finding by amarovndres: https://github.com/ItsNotRexed/Leonida/issues/4816#issuecomment-7093381681). It's the AMD counterpart of `#4801`, and it touches none of `#4801`'s files. It has run on native Windows on AMD (RDNA4 and RDNA3 with FSR 4.1.2, and an RDNA2 iGPU) and on NVIDIA, and under Wine on RDNA4 and NVIDIA; see "Tested". Parts 1 and 2 of the shim that uses this backend are `#5139` and `#5171`. ### Why The game calls the five FFX functions of the package's `amd_fidelityfx_upscaler_xbox.dll`. That DLL's 29 INT8 programs would have to be translated, and it only builds one table: 1080p, Quality (`docs/d3d12_vulkan.md` A.3, `docs/fspx.md`). AMD's public FidelityFX SDK **2.4.0** (2026-10-28) ships a signed **Vulkan** loader, `amd_fidelityfx_loader_vk.dll`. Its release notes put the upscaler "at feature parity with DX12". So the same FFX calls can be answered on the **layer's own `VkDevice`**, with no D3D12 device and no D3D12↔Vulkan hand-off. That hand-off is the part `#4801` leaves open. The loader picks the newest upscaler the GPU and driver support. Measured: FSR 4.1.2 on RDNA4 under RADV and on RDNA3 under AMD's Windows driver 26.11.2; FSR 3.1.6 on an RDNA2 iGPU and on NVIDIA (`a2766d20` corrects the comments, which had said RDNA4 and RDNA2 discrete only). ### What - **`runtime/src/ffx_vk_backend.{h,cpp}`** (about 120 lines). It: - loads the loader from `LEONIDA_FFX_DIR`, or from next to the program; - creates the upscale context with the Vulkan backend descriptor in place of the console one, keeping the game's flags and sizes; - reports the provider the loader chose; - passes dispatches through, with `VkImage` resources and a `VkCommandBuffer`; - lists `wanted_device_extensions`, the device extensions the upscaler's shaders use. These are the ones AMD's own sample device enables where present: `VK_KHR_compute_shader_derivatives`, `VK_KHR_cooperative_matrix` and `VK_EXT_shader_float8`. - **`runtime/test/ffx_api_min.h`:** adds the Vulkan backend descriptor and the provider-version query, written out from the SDK's MIT headers (`ffx_api.h`, `vk/ffx_api_vk.h`). `fsr_dispatch_test` still builds. - **`runtime/test/ffx_vk_dispatch_test.cpp`:** - Two cases, each on its own context: **1280x720 → 1920x1080**, the one configuration the console's DLL builds (A.3), and **1920x1080 → 3840x2160** (4K). (The first commits ran 1280x720 → 2560x1440, which is what the reviewers ran.) - Inputs, all procedural with no game data: an RGBA16F checkerboard, depth 0 (inverted), zero motion. - 30 upscales per case with a Halton jitter, using the game's measured context flags (HDR, inverted depth, auto exposure) plus AMD's debug checking. - Checks: every output value is finite, and the centre of every output square is within 0.1 of its input. - The device enables the wanted extensions it has, with all their features. - `LEONIDA_VK_VALIDATION=1` runs it under the Khronos validation layer, and any validation error fails it, except five named by VUID and text in `known_provider_error`. Those five are in AMD's FSR 4.1.2 shaders; see the next section. A missing layer fails the run too. - Prints the provider and the time per upscale. It skips (77) without a GPU or without the DLL; `LEONIDA_VK_DEVICE` picks the GPU. - **`runtime/CMakeLists.txt`:** the test, Windows builds only, next to the other Vulkan tools. - **`docs/d3d12_vulkan.md` A.3:** what was measured. **Not in this PR**, as in `#4801`: the shim that routes the game's calls here and maps its resources to the layer's images. ### Licence - No AMD binary is in the repository. The user points `LEONIDA_FFX_DIR` at the SDK's `Kits/FidelityFX/signedbin`. - AMD's licence for those DLLs allows redistribution in binary form and forbids reverse engineering. This code only calls their public API. - The declarations come from the SDK's MIT headers, in the existing `ffx_api_min.h`. ### Validation (after whattheflop's review, `e312253b`) - **The fix.** whattheflop's Windows run found FSR 3.1.6's shader modules using compute-shader derivatives the test device hadn't enabled (`VUID-VkShaderModuleCreateInfo-pCode-08740`/`08742`). The test now enables the wanted extensions. - **Checked under RADV**, with the host's validation layer beneath Wine (`VK_INSTANCE_LAYERS`), since Wine's Vulkan doesn't show layers to Windows programs: - On the iGPU (FSR 3.1.6) the layer is now **silent**, apart from one `vkCreateDevice-…-01387` raised by Wine's own device setup. - **What remains on the RX 9070 XT (FSR 4.1.2)** is inside AMD's shaders, and no device setup removes it: - they declare `SPV_NV_cooperative_matrix2`, which RADV doesn't offer on that GPU; - spirv-val rejects an `OpFConvert` on cooperative-matrix types and an `OpStore` to an image; - three storage images (`rw_reprojected_color`, `rw_history_color`, `rw_mlsr_output_color`) get 3-component writes on RGBA16F views (`OpImageWrite-08795`). These are the five `known_provider_error` entries. - **The rules, applied to the logged messages:** - 9070 XT: 41 known provider errors, 0 counted. - iGPU after the fix: 0. - **The iGPU run before the fix: 4 counted**, so that run would now fail. ### Tested Built with clang-cl 23.1.5 + xwin (SDK 10.0.26100) through `runtime/cmake/clang-cl-xwin.cmake`. Run with `ctest -R ffx_vk_dispatch` under **Wine 11.22** on CachyOS (kernel 7.3.5, Mesa 26.3.1 RADV), FidelityFX SDK 2.4.0 DLLs: At `be631db9`, per upscale (submit + wait); every case passes with every square right and 0 non-finite values: | GPU | providers offered | context gets | 720p → 1080p | 1080p → 4K | |---|---|---|---|---| | RX 9070 XT (RDNA4, gfx1201) | 4.1.2, 3.1.6, 2.3.4 | **FSR 4.1.2** | 0.41 ms | **1.22 ms** | | Ryzen 7 9800X3D iGPU (RDNA2, gfx1036) | 3.1.6, 2.3.4 | FSR 3.1.6 | 10.1 ms | 35.3 ms | From reviewers: - **amarovndres**, at `3c05c379` (`#5139`): **RX 9060 XT** (RDNA4), AMD **Windows** driver 26.10.1. All three wanted extensions are offered; the loader chose **FSR 4.1.2**: 1.27 ms to 1080p and 4.16 ms to 4K, every square right, and `#5139`'s layer test passes too. - Under validation: no hazards, and only the five `known_provider_error` entries. So those are in AMD's shaders on AMD's driver too. - **RSK2707X**, at `be631db9`: **RX 7600** (RDNA3, gfx1102), AMD **Windows** driver 26.11.2. The loader chose **FSR 4.1.2**: 4.56 ms to 1080p and 16.98 ms to 4K, every square right. - With `LEONIDA_VK_VALIDATION=1`: **0 validation errors**, and 10 provider errors, all the `08795` writes `known_provider_error` lists. So those are in AMD's shaders on AMD's own driver too. - **CryingLaughing**, at `be631db9`: **RTX 4080**, native **Windows**, driver 621.01. FSR 3.1.6 at both sizes, every square right, zero validation errors (Khronos 1.4.357). - **Kam471**, at `8af9ed0b` (`#5139`): **RTX 5070 Ti**, native **Windows**. FSR 3.1.6, 880/880 and 1980/1980. At `c8d136d4`: - **whattheflop:** native **Windows** 11, the same iGPU, AMD driver 32.0.21030.2001, MSVC. FSR 3.1.6, 880/880, 0 non-finite, 16.8 ms. The missing-loader skip returned 77. That run found the extension issue fixed in `e312253b`. - **Kev-Ball:** **RTX 3080 Ti** (NVIDIA 620.73.04), CachyOS, Wine 11.22, built with llvm-mingw. The loader chose **FSR 3.1.6**, 880/880, 0 non-finite, 0.69 ms. - **The test can fail:** with the `dispatch` call removed, both cases fail (440/880 and 990/1980 squares). - **Without `LEONIDA_FFX_DIR`** it skips: `amd_fidelityfx_loader_vk.dll not found`. - `tests/test_ctest_registration.py`, `test_cmake_vulkan_missing.py`, `test_build_runtime_fallback.py`, `test_runtime_paths.py` and the `test_docs_*` checks pass. - **Covered since:** whattheflop confirmed the extension fix on Windows (`e312253b`, 0 errors). RSK2707X ran FSR 4.1.2 on AMD's Windows driver (RX 7600). - **Not run:** Intel. No game files. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
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
starred/leonida#196
No description provided.