From ba812048474049fdbc72b586362787caa2e5d0c9 Mon Sep 17 00:00:00 2001 From: gurrgur Date: Sun, 22 Nov 2026 13:37:42 +0100 Subject: [PATCH 1/2] FSR 3.1 and frame generation no longer allocate their images in protected or AMD device-coherent memory, which turned the whole picture into noise on RADV The SDK's findMemoryTypeIndex keeps the last matching memory type, and RADV lists protected (TMZ) and DEVICE_COHERENT_AMD / DEVICE_UNCACHED_AMD device-local types after the plain ones. The runtime enables neither feature, so on a Radeon 780M (Mesa 26.3) every FSR pass read garbage. Those types are now skipped. On unified-memory GPUs (Adreno under Turnip), where every device-local type is host-visible, it falls back to a host-visible device-local type instead of failing every texture allocation. Co-Authored-By: Claude Opus 5.5 --- runtime/third_party/FidelityFX/README.md | 6 +++++ .../FidelityFX/sdk/src/backends/vk/ffx_vk.cpp | 22 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/runtime/third_party/FidelityFX/README.md b/runtime/third_party/FidelityFX/README.md index e784cf55..ce7f67a9 100644 --- a/runtime/third_party/FidelityFX/README.md +++ b/runtime/third_party/FidelityFX/README.md @@ -43,3 +43,9 @@ Changes of our own (marked "TotK Recomp"): - `sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_callbacks_glsl.h`: the luma history's storage image is declared `rgba16f`, the format of its images (R16G16B16A16_FLOAT in `ffx_fsr3upscaler.cpp`). It was `rgba8`, which the Vulkan validation layer reports as a format mismatch with undefined loads and stores. +- `sdk/src/backends/vk/ffx_vk.cpp` `findMemoryTypeIndex`: memory types with `PROTECTED`, `DEVICE_COHERENT_AMD` or + `DEVICE_UNCACHED_AMD` are skipped, since the runtime enables neither protected memory nor device-coherent memory. The + function keeps the last matching type, and RADV lists those types after the plain device-local ones, so on a Radeon + 780M (Mesa 26.3) FSR 3.1's images were allocated in them and its whole output was noise. When no device-local type + without `HOST_VISIBLE` exists (unified-memory GPUs: Adreno under Turnip) it takes a host-visible device-local one + instead of failing every texture allocation. diff --git a/runtime/third_party/FidelityFX/sdk/src/backends/vk/ffx_vk.cpp b/runtime/third_party/FidelityFX/sdk/src/backends/vk/ffx_vk.cpp index c3e5032f..892b8c25 100644 --- a/runtime/third_party/FidelityFX/sdk/src/backends/vk/ffx_vk.cpp +++ b/runtime/third_party/FidelityFX/sdk/src/backends/vk/ffx_vk.cpp @@ -402,14 +402,28 @@ uint32_t findMemoryTypeIndex(VkPhysicalDevice physicalDevice, VkMemoryRequiremen vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memProperties); uint32_t bestCandidate = UINT32_MAX; + // TotK Recomp: unified-memory GPUs (Adreno under Turnip) have no device-local type without HOST_VISIBLE: the first + // host-visible one is taken rather than failing when no invisible type exists. + uint32_t visibleCandidate = UINT32_MAX; + VkMemoryPropertyFlags visibleProperties = 0; for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) { if ((memRequirements.memoryTypeBits & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & requestedProperties)) { - // if just device-local memory is requested, make sure this is the invisible heap to prevent over-subscribing the local heap - if (requestedProperties == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT && (memProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + // TotK Recomp: types that need a device feature the application did not enable are skipped. The loop keeps + // the last match, and RADV lists protected (TMZ) and AMD device-coherent/uncached device-local types after + // the plain ones: FSR 3.1's images landed in them and every pass read noise. + if (memProperties.memoryTypes[i].propertyFlags & (VK_MEMORY_PROPERTY_PROTECTED_BIT | VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD | + VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD)) continue; + // if just device-local memory is requested, make sure this is the invisible heap to prevent over-subscribing the local heap + if (requestedProperties == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT && (memProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { + if (visibleCandidate == UINT32_MAX) + visibleCandidate = i, visibleProperties = memProperties.memoryTypes[i].propertyFlags; + continue; + } + bestCandidate = i; outProperties = memProperties.memoryTypes[i].propertyFlags; @@ -419,6 +433,10 @@ uint32_t findMemoryTypeIndex(VkPhysicalDevice physicalDevice, VkMemoryRequiremen } } + if (bestCandidate == UINT32_MAX && visibleCandidate != UINT32_MAX) { + bestCandidate = visibleCandidate; + outProperties = visibleProperties; + } return bestCandidate; } From 96f9f868bac73df07514c062425ed79bde5085ca Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Mon, 23 Nov 2026 14:43:07 +0300 Subject: [PATCH 2/2] THIRD_PARTY_NOTICES.md counts the FidelityFX backend's memory type choice among our own changes to the SDK Co-Authored-By: Claude Opus 5.5 --- THIRD_PARTY_NOTICES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index c6a8174b..03a5a8b2 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -30,7 +30,7 @@ Code copied or adapted from another project is listed here with its source, the | SDL 3.4.20, dynamic link, `SDL3.dll` copied next to `totk.exe`. Developer builds use the MSYS2 build (`mingw-w64-ucrt-x86_64-sdl3`, which imports `libiconv-2.dll`, LGPL-2.1, unmodified, copied beside it); the installer release ships the upstream release `SDL3-3.4.20-win32-x64.zip`, which imports no libiconv | https://libsdl.org, Copyright (c) 1997-2026 Sam Lantinga | zlib | `runtime/input_win.c` (gamepad input, rumble, gyro and accelerometer) | | libopus (MSYS2 `mingw-w64-ucrt-x86_64-opus`), dynamic link, `libopus-0.dll` copied next to `totk.exe` | https://opus-codec.org, Copyright (c) 2001-2023 Xiph.Org, Skype Limited, Octasic, Jean-Marc Valin, Timothy B. Terriberry, CSIRO, Gregory Maxwell, Mark Borgerding, Erik de Castro Lopo, Mozilla, Amazon | BSD-3-Clause | `runtime/ov_media.c` (nn::codec hardware Opus decoder) | | Dear ImGui 1.91.9 (core and Vulkan back end, unmodified), as vendored by LAS Recomp | https://github.com/ocornut/imgui, via https://github.com/peiikai/LASRecomp @ `da35b83a9611d046a9a681aae668d7085954d37f` (`third_party/imgui/`), Copyright (c) 2014-2025 Omar Cornut | MIT | `runtime/third_party/imgui/` (compiled into `totk.exe` for the in-game menu, `runtime/ui/`) | -| AMD FidelityFX SDK 1.1.4 subset (public host and shader headers, frame interpolation, optical flow and FSR 3 upscaler components, the Vulkan backend `ffx_vk.cpp` and its GLSL shaders, shared helpers), with four marked Savage Wind patches (64-byte aligned backend scratch arrays, doubled context size where `wchar_t` is 4 bytes, all six descriptor pool sizes, the upscaler's Catmull-Rom history reprojection) and one of ours (the upscaler's luma history declared `rgba16f`) | https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/tree/v1.1.4, Copyright (C) 2024 Advanced Micro Devices, Inc., via https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`third_party/FidelityFX/`) | MIT | `runtime/third_party/FidelityFX/` (compiled into `totk.exe`; licence text in `runtime/third_party/FidelityFX/LICENSE.txt`, shipped as `licenses/FidelityFX-SDK-LICENSE.txt`) | +| AMD FidelityFX SDK 1.1.4 subset (public host and shader headers, frame interpolation, optical flow and FSR 3 upscaler components, the Vulkan backend `ffx_vk.cpp` and its GLSL shaders, shared helpers), with four marked Savage Wind patches (64-byte aligned backend scratch arrays, doubled context size where `wchar_t` is 4 bytes, all six descriptor pool sizes, the upscaler's Catmull-Rom history reprojection) and two of ours (the upscaler's luma history declared `rgba16f`, the backend's memory type choice skipping protected and AMD device-coherent types) | https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/tree/v1.1.4, Copyright (C) 2024 Advanced Micro Devices, Inc., via https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`third_party/FidelityFX/`) | MIT | `runtime/third_party/FidelityFX/` (compiled into `totk.exe`; licence text in `runtime/third_party/FidelityFX/LICENSE.txt`, shipped as `licenses/FidelityFX-SDK-LICENSE.txt`) | | SavageWindRecomp FidelityFX build support, frame generation and FSR 3 upscaler set-up: the SDK-to-clang compat header, the glslang SPIR-V shader generator with its resource reflection and its FSR 3 upscaler permutations, the blob lookup and the backend and context creation of `runtime/nvn/vulkan/framegen.cpp`, the upscaler context with its shared images and the dispatch parameters of `runtime/nvn/vulkan/fsr3.cpp`, the pair's present spacing of `runtime/nvn/vulkan/device.c` `present_wait_turn` | https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`third_party/FidelityFX/ffx_compat.h`, `tools/ffx_shaders.py`, `runtime/nvn/vulkan/framegen.cpp`, `runtime/nvn/vulkan/fsr3.cpp`, `runtime/nvn/vulkan/device.c`) | MIT | `runtime/third_party/FidelityFX/ffx_compat.h`, `runtime/third_party/FidelityFX/spirv/ffx_shaders_vk.h` and `ffx_fsr3upscaler_vk.h` (output of `tools/ffx_shaders.py`), `tools/ffx_shaders.py`, `runtime/vk_fg.cpp`, `runtime/vk_fsr3.cpp`, `runtime/vk_backend.c` (`present_pair`) | | SavageWindRecomp settings menu: two-pane option rows (row look, left / right stepping, hold speed-up, description pane), the menu style and tab bar | https://github.com/Revivedx/SavageWindRecomp @ `575ad88e02f9a89a9a885d90039d48af33c982f4` (`runtime/ui/option_rows.mm`, `runtime/ui/menu.mm`), Copyright (c) 2026 Revivedx and the Savage Wind Recomp contributors, Copyright (c) 2026 Peiikai | MIT | `runtime/ui/option_rows.cpp`, `runtime/ui/option_rows.h`, `runtime/ui/menu.cpp` | | SavageWindRecomp GPU overlap one-off readback rule: a target not read back within the last 16 frames (64-entry table) makes the frame wait wait up to the value that rendered it | https://github.com/Revivedx/SavageWindRecomp @ `bf6146c14c37fee8781a601e5a544b93dff6d75e` (`runtime/nvn/vulkan/exec.c` readback_schedule, renderer_wait_seq), Copyright (c) 2026 Revivedx and the Savage Wind Recomp contributors, Copyright (c) 2026 Peiikai | MIT | `runtime/vk_texture.c` (oneoff_streaming, vk_texture_oneshot) |