diff --git a/README.md b/README.md index 38780dce..84c1fbdb 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md). - Custom resolutions (1080p, 2k...), supersampling and AMD FSR 1 upscaling - NVIDIA DLSS / DLAA on RTX GPUs: the setup downloads `nvngx_dlss.dll` from NVIDIA's DLSS SDK repository (github.com/NVIDIA/DLSS, NVIDIA RTX SDK license) when it finds an RTX GPU; untick it in the setup to skip it +- AMD FSR 4 on Radeon RX 9000, 7000 and 6000 GPUs (FSR 3.1 on others), in the same modes as DLSS: the setup downloads + AMD's signed FSR SDK libraries (github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK, AMD FSR SDK license) when it + finds an AMD GPU; pick *Upscaler: AMD FSR* in the menu. Windows only: AMD's FSR SDK has no Linux libraries yet - HDR10 output with peak, game and HUD brightness settings - 16:10 (Steam Deck, handhelds), 3:2 (Surface, Framework), 21:9 and 32:9 (ultrawide) game resolutions, with the camera and the interface in that shape - Anisotropic texture filtering up to 16x, for sharp ground into the distance @@ -53,7 +56,8 @@ Requirements: Windows 10 or later, an x86-64 CPU with SSE4.2 (AVX2/FMA machines 2. Start `TotK-Setup.exe`. If SmartScreen warns about an unsigned app, choose *More info*, then *Run anyway*. 3. Pick your game files, the language and an install folder, and press *Start*. The setup builds the game once. With an NVIDIA RTX GPU it also downloads NVIDIA DLSS, unless you untick *Download NVIDIA DLSS*; turn DLSS on in the - menu (F1). + menu (F1). With an AMD GPU it downloads AMD FSR the same way; in the menu turn on *NVIDIA DLSS / DLAA* and pick + *Upscaler: AMD FSR*. 4. Play `totk.exe` from the install folder. ### Linux diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 47fdd0fc..248a2026 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -38,6 +38,8 @@ Code copied or adapted from another project is listed here with its source, the | MacNativeGames host movie decoder (`movie::Decoder` for VP9 over libvpx: entry list, buffer and event semantics, NV12 output format, PTS pacing) | https://github.com/ly05010419/MacNativeGames @ `b75be8cfa704df3701e86130c8ced268e79d6b11` (`games/totk/runtime/movie_host.c`, `movie_host.h`), Copyright (c) 2026 MacNativeGames contributors | MIT | `runtime/ov_movie.c`, `runtime/movie.h` | | libvpx 1.17.0 (MSYS2 `mingw-w64-ucrt-x86_64-libvpx`), static link (`libvpx.a`), no DLL shipped; the release notices must carry its BSD licence text and the WebM Project's `PATENTS` grant | https://chromium.googlesource.com/webm/libvpx, Copyright (c) 2010, The WebM Project authors | BSD-3-Clause | `runtime/ov_movie.c` (VP9 decoding of the `Event/Movie` WebM files) | | MacNativeGames TotK resolution patches: output, swapchain and scene size sites and instruction words for 1.2.1 and 1.4.3, the data-page layout, the HeapDef heap names and sizes | https://github.com/ly05010419/MacNativeGames @ `aaf6ba1f494fabaa209d049e528d6f923dfe822a` (`games/totk/runtime/game_patches.c`, `game_patches_v143.c`, `game_version.h`, `games/totk/scripts/make_output_res_overlay.py`), Copyright (c) 2026 MacNativeGames contributors | MIT | `recomp/patches-v121.txt`, `recomp/patches-v143.txt`, `runtime/resolution.c` | +| AMD FSR SDK ffx-api declarations (`ffx_api.h`, `ffx_api_types.h`, `vk/ffx_api_vk.h`, `upscalers/include/ffx_upscale.h`, trimmed to the declarations used, layouts unchanged) | https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK @ tag `v2.4.0`, Copyright (C) 2026 Advanced Micro Devices, Inc. | MIT | `runtime/ffx_api_min.h` | +| AMD FSR SDK signed binaries `amd_fidelityfx_loader_vk.dll` and `amd_fidelityfx_upscaler_vk.dll` (not in this repository or the release: the setup's `--fsr` step downloads AMD's copies into the install folder) | https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK @ tag `v2.4.0` (`Kits/FidelityFX/signedbin/`), Copyright (C) 2026 Advanced Micro Devices, Inc. | AMD FSR SDK license (`docs/license.md` of that tag): redistribution in binary form with its notice, no reverse engineering | loaded at run time by `runtime/vk_ffx.c` | | AMD FidelityFX Super Resolution 1.0 (`ffx_a.h`, `ffx_fsr1.h`, unmodified; licence text in `runtime/shaders/ffx/LICENSE.txt`) | https://github.com/GPUOpen-Effects/FidelityFX-FSR @ `a21ffb8f6c13233ba336352bdff293894c706575`, Copyright (c) 2021 Advanced Micro Devices, Inc. | MIT | `runtime/shaders/ffx/`, `runtime/shaders/fsr_easu.comp`, `runtime/shaders/fsr_rcas.comp` (compiled into `runtime/fsr_easu_spv.h`, `runtime/fsr_rcas_spv.h`) | | AMD Display Library (ADL) declarations: `AdapterInfo`, `ADLSingleSensorData`, `ADLPMLogDataOutput`, the `ADL_PMLOG_*` sensor numbers and the `ADL2_*` function signatures | https://github.com/GPUOpen-LibrariesAndSDKs/display-library @ `84c881cb2136f04287eb3af12de00a9e2867aa9e` (`include/adl_structures.h`, `include/adl_defines.h`, `include/adl_sdk.h`), Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. | MIT | `runtime/perfmon.c` | | Zstandard 1.5.7 (MSYS2 `mingw-w64-ucrt-x86_64-zstd`), static link | https://github.com/facebook/zstd, Copyright (c) Meta Platforms, Inc. and affiliates | BSD-3-Clause | `runtime/resolution.c` (the HeapDef table), `runtime/ov_zstd.c` (the game's zstd frames decoded on the host) | diff --git a/docs/architecture.md b/docs/architecture.md index c5931732..145a212c 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -135,6 +135,14 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app that computes last frame's position from last frame's blocks (the game writes them into two copies that take turns; the uniform snapshot keeps both) and writes the difference into the motion image. `TOTK_MV_CHECK` measures the vectors against the picture, `TOTK_DLAA_TIMES` times the passes on the GPU. `fxaa` switches the game's own FXAA pass. +- FSR (`vk_ffx.c`, `dlaa_backend = fsr`, Windows). The same frame, jitter, motion vectors and masks go to AMD's FSR + instead of DLSS: `vk_dlaa.c` `evaluate` calls `vk_ffx_dispatch` where it would call NGX, and everything around it is + shared. `amd_fidelityfx_loader_vk.dll` (FSR SDK 2.4) is loaded at run time from the executable's folder and finds + `amd_fidelityfx_upscaler_vk.dll` next to it; only the descriptor layouts of `ffx_api_min.h` are compiled in. At + start the upscaler's versions for the device are listed and the newest FSR 4 is pinned where the DLL offers it (the + DLL decides which GPUs get it), else its default (FSR 3.1). `vk_device.c` enables `VK_KHR_cooperative_matrix` and + `VK_EXT_shader_float8` with their features when the device has them. FSR also asks for the camera's near and far + distances and field of view, which `cam_params` reads from the projection in the scene camera block. - Occlusion queries never block the CPU; a result that is not ready counts as visible. - ASTC textures are uploaded as they are where the device reports `textureCompressionASTC_LDR`, and decoded by a compute shader everywhere else (`vk_astc.c`, `TOTK_ASTC`). The CPU decoder (`tex_astc*.c`) is the fallback and the test oracle. - Draw state. A draw whose program, bound state and textures repeat reuses the previous draw's shaders and skips rebuilding its descriptor sets; descriptor sets are written through update templates (`vk_exec_draw.c`, `vk_pipeline.c`). diff --git a/docs/installer.md b/docs/installer.md index 347e9434..db17852a 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -24,6 +24,7 @@ The install folder (`main.c` `portable_paths()` reads this layout; it stays port / totk.exe, SDL3.dll, libopus-0.dll, totk_xlate.exe nvngx_dlss.dll NVIDIA DLSS, downloaded by the setup's DLSS step when the player keeps it ticked + amd_fidelityfx_*_vk.dll AMD FSR (loader and upscaler), downloaded by the setup's FSR step likewise totk.ini language; the other keys as commented defaults (totk.ini.example) exefs/, romfs/ extracted from the player's files shared-fonts/ the Switch system fonts, with Chinese, Korean or Traditional Chinese text @@ -99,7 +100,13 @@ loads the saves 1.4.3 wrote. the library; NGX loads it from the folder of totk.exe for `dlaa` and the DLSS modes. A DLSS library already in the folder (a newer one the player put there) is kept. Without an RTX GPU the step only logs and does nothing; a failed download warns, the game runs without DLSS, and the next run of the setup tries again. -9. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write +9. **FSR** (the window's tick box, on by default, or `--fsr`; Windows with an AMD GPU): download + `amd_fidelityfx_loader_vk.dll` and `amd_fidelityfx_upscaler_vk.dll` from AMD's FSR SDK repository + (github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK, tag `v2.4.0`, `Kits/FidelityFX/signedbin/`, AMD FSR SDK + license) into the install folder and check their sizes and SHA-256 (`steps.py`, `Fsr`). Both go in only when both + downloaded and matched. `dlaa_backend = fsr` loads them from the folder of totk.exe. Libraries already in the folder + are kept; without an AMD GPU the step only logs; a failed download warns and the next run tries again. +10. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write `build-cache/rebuild.txt` in the install folder. A cancelled or failed setup resumes from the last finished step (`totk-install.json`). diff --git a/docs/settings.md b/docs/settings.md index 1b0193fe..2e16e4ff 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -166,6 +166,8 @@ Many rows below are developer tools that only act together with another setting | `dlaa_survey` (default `0`) | `1` logs what is drawn into the light target that DLSS reads. | Adds log output and per-draw work. | Caution | | `dlaa_times` (default `0`) | `1` times the DLSS passes on the GPU. | Adds GPU timestamps and log lines. | Caution | | `dlss_reactive` (default `0`) | `1` builds a reactive mask for DLSS where it ran. | Changes how DLSS blends moving areas; a test setting. | Caution | +| `fsr_debug` (default `0`) | `1` creates the FSR contexts (`dlaa_backend = fsr`) with AMD's API checks on, whose findings go to the log. | Adds log output and some CPU time per frame; a test setting. | Caution | +| `fsr_jitter_sign` (default `1`) | `-1` hands FSR the camera jitter with the opposite sign (`dlaa_backend = fsr`). | With the wrong sign FSR's picture wobbles and loses detail; a test setting for checking the convention. | Caution | | `mv_check` | Frame interval; every that many DLSS frames copies the light target and motion images to host memory and logs how well the vectors explain the picture. | Costs a GPU-to-host copy and a comparison on the completion thread at each interval. | Caution | | `mv_survey` (default `0`) | `1` notes the uniform blocks of each scene draw and compares them with those of earlier frames. | Adds per-draw work and log output. | Caution | | `mvobj_all` (default `0`) | `1` also lists draws for object motion that read no object blocks (terrain and grass). | More draws are checked and listed, which costs time. | Caution | diff --git a/installer/cli.py b/installer/cli.py index 14fa57ed..f3dfb633 100644 --- a/installer/cli.py +++ b/installer/cli.py @@ -1,5 +1,5 @@ """Command line: python -m installer --base FILE --update FILE --keys FILE --lang CODE --dest DIR [--firmware DIR] - [--root DIR] [--temp DIR] [--verify] [--dlss] + [--root DIR] [--temp DIR] [--verify] [--dlss] [--fsr] A first install needs every option. --firmware names the Switch firmware folder (an unpacked firmware or an emulator's Contents/registered); the setup extracts the system shared fonts from it when the language is Chinese, Korean or @@ -9,7 +9,9 @@ extraction has to run again. Prints JSON events on stdout (events.py). Exit code line, 3 cancelled (Ctrl+C or Ctrl+Break). --dlss downloads NVIDIA's DLSS library (nvngx_dlss.dll) from NVIDIA's DLSS SDK repository into the install folder on -Windows with an NVIDIA RTX GPU (steps.py, Dlss). +Windows with an NVIDIA RTX GPU (steps.py, Dlss). --fsr downloads AMD's FSR loader and upscaler +(amd_fidelityfx_loader_vk.dll, amd_fidelityfx_upscaler_vk.dll) from AMD's FSR SDK repository into the install folder on +Windows with an AMD GPU (steps.py, Fsr). """ import argparse import hashlib @@ -63,6 +65,8 @@ def main(argv=None): ap.add_argument('--verify', action='store_true', help='hash every kept file, also those this release made') ap.add_argument('--dlss', action='store_true', help="download NVIDIA's nvngx_dlss.dll (NVIDIA RTX SDK license) next " 'to the game, for dlaa and the DLSS modes') + ap.add_argument('--fsr', action='store_true', help="download AMD's FSR loader and upscaler DLLs (AMD FSR SDK " + 'license) next to the game, for dlaa_backend = fsr') args = ap.parse_args(argv) # The window cancels with Ctrl+Break to the installer's process group (CREATE_NEW_PROCESS_GROUP), which also reaches diff --git a/installer/gui.py b/installer/gui.py index b7d4ec86..40840070 100644 --- a/installer/gui.py +++ b/installer/gui.py @@ -273,6 +273,11 @@ class App: self.bind_text(dlss, 'text', 'ui.dlss') dlss.pack(anchor='w', pady=(dpi.px(8), 0)) self.label(f, 'ui.dlss_help', wraplength=WRAP, justify='left').pack(anchor='w', padx=(dpi.px(22), 0)) + self.fsr_var = tk.BooleanVar(value=True) + fsr = ttk.Checkbutton(f, variable=self.fsr_var) + self.bind_text(fsr, 'text', 'ui.fsr') + fsr.pack(anchor='w', pady=(dpi.px(8), 0)) + self.label(f, 'ui.fsr_help', wraplength=WRAP, justify='left').pack(anchor='w', padx=(dpi.px(22), 0)) self.update_hint = ttk.Label(f, wraplength=WRAP, justify='left') self.update_hint.pack(anchor='w', pady=(dpi.px(8), 0)) self.form_error = ttk.Label(f, style='Err.TLabel', wraplength=WRAP, justify='left') @@ -344,7 +349,7 @@ class App: def form(self): return Form(base=self.vars['base'].get(), update=self.vars['update'].get(), keys=self.vars['keys'].get(), firmware=self.vars['firmware'].get(), lang=self.selected_lang(), dest=self.vars['dest'].get(), - dlss=self.dlss_var.get()) + dlss=self.dlss_var.get(), fsr=self.fsr_var.get()) def set_prefill(self, name, value): self.programmatic = True @@ -619,7 +624,7 @@ class App: # ---- self test --------------------------------------------------------------------------------------------------- SAMPLE_START = {'type': 'start', 'release': 'selftest', 'mode': 'install', 'dest': 'Z:/selftest/TotK', 'log': 'D:\\log.txt', - 'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', 'cleanup']} + 'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', 'fsr', 'cleanup']} SAMPLE_RUN = [ SAMPLE_START, {'type': 'plan', 'run': ['check', 'fonts', 'extract'], 'skip': {}}, diff --git a/installer/guilogic.py b/installer/guilogic.py index 24b4d399..233d8795 100644 --- a/installer/guilogic.py +++ b/installer/guilogic.py @@ -27,7 +27,7 @@ TEXT = Path(__file__).resolve().parent / 'text' UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans') # what the language switch in the window's corner shows for each UI_LANGUAGE_LABELS = {'en': 'English', 'ru': 'Русский', 'pt-BR': 'Português (Brasil)', 'zh-Hans': '简体中文'} -STEP_ORDER = ('check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', 'cleanup') +STEP_ORDER = ('check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', 'fsr', 'cleanup') # message parameter -> catalog id prefix of the names that replace its raw values PARAM_NAMES = {'lang': 'lang.', 'known': 'lang.', 'step': 'step.', 'input': 'param.input.'} LANG_RU = 0x19 # primary language id of Russian in a Windows LANGID @@ -138,6 +138,7 @@ class Form: lang: str = '' dest: str = '' dlss: bool = False + fsr: bool = False def installed_state(self): """The recorded state of the install folder (totk-install.json), or None. Never raises.""" @@ -190,6 +191,8 @@ class Form: cmd.append('--verify') if self.dlss: cmd.append('--dlss') + if self.fsr: + cmd.append('--fsr') return cmd diff --git a/installer/steps.py b/installer/steps.py index 3c3c1e25..2ca999eb 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -1,5 +1,5 @@ -"""The ten setup steps of docs/installer.md: check, fonts, extract, lift, compile, prepare, pc_prompts, shapes, dlss, -cleanup. +"""The eleven setup steps of docs/installer.md: check, fonts, extract, lift, compile, prepare, pc_prompts, shapes, dlss, +fsr, cleanup. Extraction runs in this process through tools/extract.py (the package's sibling tools/, which ships with it); fonts runs the vendored extract_shared_fonts.py on the firmware folder; lift, compile and prepare run the bundled Python on @@ -8,7 +8,8 @@ recomp/gen.py, tools/build_game.py, tools/make_romfs_patches.py and tools/prepar with the bundled clang (hostcheck.c). Install folder: exefs/, romfs/ (romfs.bin, index.json), profile/, shared-fonts/ (Chinese and Korean text), totk.exe -and its DLLs, nvngx_dlss.dll (with --dlss), romfs-index.bin, romfs-patches/, romfs-patches-xbox/, +and its DLLs, nvngx_dlss.dll (with --dlss), amd_fidelityfx_loader_vk.dll and amd_fidelityfx_upscaler_vk.dll (with +--fsr), romfs-index.bin, romfs-patches/, romfs-patches-xbox/, romfs-patches-xbox-label/, romfs-patches-pc/, romfs-patches-x/ and romfs-patches-