Files
totk-pc-recomp/runtime/third_party/FidelityFX
14ccef9a80 AMD FSR 3.1 upscales the 3D scene on the FidelityFX SDK 1.1.4 sources behind scene_upscaler = fsr3, off by default
scene_upscaler (off | dlss | fsr3, read at start) replaces the dlaa toggle on the Screen tab; without the key dlaa = 1
still means DLSS, so nobody gets FSR 3.1 without picking it. The DLSS mode row is the upscaling mode of both engines,
the DLSS model, characters' mask, fixed exposure and effects-after rows show only with DLSS, and the performance
overlay names the upscaler that ran and its mode. resolution.c sizes the scene for the engine picked at start.

runtime/vk_fsr3.cpp drives the SDK's upscaler context on its Vulkan backend directly, as Savage Wind's fsr3.cpp does:
one context per output size with the output as its largest render size (the modes and the dynamic resolution need
no new context), HDR input (the light target before the bloom, where DLSS reads it), render-size motion vectors with
the per-object pass, the camera jitter, the camera's planes and field of view from the scene block (vk_fg_camera; a
cut starts a new history), FSR's sharpening off. vk_dlaa.c calls it at the DLSS point after the recorder's drain;
the NGX path is left as it was. The backend's per-frame rings hold four dispatches: a dispatch waits for the one three
back should it still be in flight. Frame generation stays off while FSR 3.1 runs (logged once).

The SDK subset gains the upscaler component, its shader headers, FSR 1's (its RCAS) and its GLSL, from Savage Wind's
copy unchanged; tools/ffx_shaders.py --effects fu builds its blobs (HDR, 32- and 16-bit floats) into
spirv/ffx_fsr3upscaler_vk.h, and vk_fg.cpp's blob lookup hands those out through vk_fsr3_blob. The luma history's
storage image is declared rgba16f, its images' format (rgba8 in the SDK; the validation layer reported it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Revivedx <82332536+Revivedx@users.noreply.github.com>
2026-11-20 14:39:57 +03:00
..

AMD FidelityFX SDK 1.1.4 (subset)

From https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/tree/v1.1.4, MIT (LICENSE.txt), via Savage Wind (https://github.com/Revivedx/SavageWindRecomp, MIT, third_party/FidelityFX). runtime/vk_fg.cpp drives the frame interpolation and optical flow of FSR 3 on the SDK's Vulkan backend directly, without the SDK's frame interpolation swapchain or its ffx-api DLL layer; runtime/vk_fsr3.cpp drives the FSR 3.1 upscaler the same way.

What is here:

  • sdk/include/FidelityFX/host: the SDK's public headers; gpu: the shader headers of frame interpolation, optical flow, the FSR 3 upscaler, SPD (which optical flow and the upscaler include) and FSR 1 (the upscaler's RCAS). The host headers of the other effects stay, unchanged, because the SDK's own headers include each other.
  • sdk/src/components/frameinterpolation, opticalflow, fsr3upscaler: the three effects.
  • sdk/src/backends/vk/ffx_vk.cpp and its shaders/frameinterpolation, shaders/opticalflow, shaders/fsr3upscaler (GLSL).
  • sdk/src/shared: the SDK's assert, message and object-management helpers.
  • sdk/src/backends/shared/ffx_shader_blobs.h: the declaration of the blob lookup, which runtime/vk_fg.cpp implements (the upscaler's blobs through runtime/vk_fsr3.cpp vk_fsr3_blob).
  • spirv/ffx_shaders_vk.h: the shaders compiled to SPIR-V with their bindings, by tools/ffx_shaders.py (glslangValidator from MSYS2 UCRT64 or the Vulkan SDK) in place of the SDK's Windows-only FidelityFX_SC.exe. Only the permutations used. Committed like runtime/*_spv.h: AMD's shaders, no game data. Regenerate after changing the GLSL: python tools/ffx_shaders.py.
  • spirv/ffx_fsr3upscaler_vk.h: the same for the FSR 3 upscaler (python tools/ffx_shaders.py --effects fu), one permutation per pass: HDR input (the scene's linear light before the bloom), render-size motion vectors without jitter, depth not inverted, the reference Lanczos and Savage Wind's Catmull-Rom history reprojection, in 32-bit and 16-bit floats (the 16-bit ones where the SDK asks for them and the device has shaderFloat16 and shaderInt16).
  • ffx_compat.h: force-included into the SDK's sources (tools/build_game.py, rule cc_ffx) so they build with clang.

Changes to the SDK's files (marked "Savage Wind" in them):

  • sdk/src/backends/vk/ffx_vk.cpp: the arrays the backend lays out in its scratch memory are aligned to 64 bytes instead of 4, and start 64-byte aligned after its context. With 4, clang's aligned SSE stores into them (movdqa) faulted; MSVC emits unaligned ones.
  • sdk/include/FidelityFX/host/ffx_types.h: the contexts' default size is doubled outside Windows, where wchar_t (their resources' debug names) is 4 bytes instead of 2.
  • sdk/src/backends/vk/ffx_vk.cpp: the global descriptor pool is created with all six of the sizes it lists. It passed five, leaving out the storage buffers (the validation layer reports it).
  • sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_reproject.h: the history reprojected with a Catmull-Rom filter from 5 bilinear samples (FFX_FSR3UPSCALER_OPTION_REPROJECT_CATMULL_ROM_5), a Savage Wind addition.

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.