diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f57e011..91493ab9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ Open pull requests against `dev`. Branch from the current `dev` and rebase on it - **The fix, not a disabled feature.** A crash that goes away with a feature off points at the bug in that feature. Turning the feature off for a vendor is not a fix. - **The frame time on weak hardware.** Game threads and the render thread do no file I/O, no GPU allocations, no per-draw state copies and no global atomic counters. Memory kept per frame or per object is freed. The full list with measured costs: [docs/pr-review-kit/02-performance.md](docs/pr-review-kit/02-performance.md), "What the hot path must not do". - **Other GPUs.** New Vulkan code queries each feature, extension, format and limit it uses and keeps a working path without it. Nothing is hardcoded from what one GPU reports. -- **Text in the catalogs.** Text a player sees gets an id in `runtime/ui_text.h` and an entry in `runtime/ui_text.c` for every menu language (English, Russian, Brazilian Portuguese, Simplified Chinese); installer text goes into `installer/text/*.json`. +- **Text in the catalogs.** Text a player sees gets an id in `runtime/ui_text.h` and an entry in `runtime/ui_text.c` for every menu language (English, Russian, Brazilian Portuguese, Simplified Chinese, German, French, Spanish, Italian, Dutch, Japanese, Korean, Vietnamese); installer text goes into `installer/text/*.json`. - **The generator owns generated C.** Change `recomp/`, never `generated/`. ### Checks by what you changed diff --git a/README.md b/README.md index 98dce1ef..06260a41 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,16 @@ 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 3.1 on any GPU, and AMD FSR 4 on Windows on the Radeon GPUs AMD's FSR SDK libraries support, in the same + modes as DLSS: for FSR 4 the setup downloads AMD's signed FSR SDK libraries + (github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK, AMD FSR SDK license), ticked by default with an AMD GPU - 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 - In-game settings menu (F1) and performance overlay (F10) - Play time across runs on the Game tab of the settings menu, kept in `playtime.txt` next to the saves - Discord Rich Presence ("Playing TotK Recomp" with the play time), off by default, own application id supported -- Setup in 11 languages, in-game menu in 4 ([Languages](#languages)) +- Setup in 12 languages, in-game menu in 12 ([Languages](#languages)) - Keyboard, mouse and gamepad with remapping, rumble and gyro - Stereo or 5.1 surround sound output - Xbox and PlayStation button prompts: Xbox's LB, RB, LT, RT, Menu, View and A, B, X, Y, or PlayStation's ○ × △ □, L1, R1, L2, R2, Options and Share, as labelled on the button to press, with either button layout @@ -43,7 +46,7 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md). The game keeps the text and voices of every language it shipped with. The port's own setup and in-game menu (F1) come in these; both follow the Windows display language, and the menu has its own choice on its Menu tab. A Traditional -Chinese Windows gets the Simplified Chinese setup. +Chinese Windows gets the Simplified Chinese setup and menu. | Language | Setup | In-game menu | |---|:---:|:---:| @@ -51,13 +54,14 @@ Chinese Windows gets the Simplified Chinese setup. | Русский | ✅ | ✅ | | Português (Brasil) | ✅ | ✅ | | 简体中文 | ✅ | ✅ | -| Deutsch | ✅ | English | -| Français | ✅ | English | -| Español | ✅ | English | -| Italiano | ✅ | English | -| Nederlands | ✅ | English | -| 日本語 | ✅ | English | -| 한국어 | ✅ | English | +| Deutsch | ✅ | ✅ | +| Français | ✅ | ✅ | +| Español | ✅ | ✅ | +| Italiano | ✅ | ✅ | +| Nederlands | ✅ | ✅ | +| 日本語 | ✅ | ✅ | +| 한국어 | ✅ | ✅ | +| Tiếng Việt | ✅ | ✅ | Spotted a clumsy phrase, or want your language added? The setup texts are in `installer/text/.json`, the menu texts in `runtime/ui_text.c`; open an issue or a pull request ([CONTRIBUTING.md](CONTRIBUTING.md)). Fixes from @@ -71,13 +75,14 @@ native speakers are welcome. ### Windows -Requirements: Windows 10 or later, an x86-64 CPU with SSE4.2 (AVX2/FMA machines get a faster build), a GPU with Vulkan 1.3 and `VK_EXT_external_memory_host`, about 36 GiB free during setup (20 GiB after). +Requirements: Windows 10 or later, an x86-64 CPU with SSE4.2 (AVX2/FMA machines get a faster build), a GPU with Vulkan 1.3 (`VK_EXT_external_memory_host` recommended: without it the game copies its memory pools and runs slower), about 36 GiB free during setup (20 GiB after). 1. Download `TotK-Setup--windows.zip` from [Releases](../../releases/latest) and unpack it. 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 *Download AMD FSR 4* ticked (the default with an AMD GPU) it downloads AMD's FSR SDK libraries; + in the menu, pick *AMD FSR 4* as the *3D scene upscaler*. 4. Play `totk.exe` from the install folder. ### Linux diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index c6a8174b..efa84dc9 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) | @@ -41,6 +41,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/VERSION b/VERSION index 8f0916f7..301cdc75 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 +0.5.1-rc1 diff --git a/docs/architecture.md b/docs/architecture.md index b9c545db..3cdc908b 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -59,8 +59,9 @@ MacNativeGames cannot run on x86-64 as is: its CPU path executes ARM64 code nati - Settings and menu: every key with its default is in one table (`cfg.c`), read from `totk.ini` and `TOTK_*` variables and written back when the in-game menu changes it. The menu and the performance overlay are Dear ImGui, drawn into the swapchain image (`runtime/ui/`); their text is in `ui_text.c` (English, Russian, Brazilian Portuguese, - Simplified Chinese). The Chinese glyphs come from a system font (Microsoft YaHei, `plat_font_path`) merged into the - font atlas. + Simplified Chinese, German, French, Spanish, Italian, Dutch, Japanese, Korean, + Vietnamese). The Chinese, Japanese and Korean glyphs + come from a system font (`plat_font_path`) merged into the font atlas. - OS calls the host makes go through `runtime/platform/` (`platform.h`, `win32.c`), so a Linux or macOS host adds one file instead of touching the rest. The split is not finished: `tools/check_platform.py` lists the Win32 uses left in the other files. #### Threads and cores @@ -87,7 +88,7 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app - NVN front end from MacNativeGames (`nvn_api_*.c`, `nvn_obj.h`, texture layout and deswizzle). The game records command buffers through it; nothing reaches the GPU until the game submits. - Vulkan 1.3 back end in place of MacNativeGames' Metal one. At `QueueSubmitCommands` the recorded NVN commands are replayed into Vulkan command buffers (`vk_exec*.c`). -- Memory pools. Apple's unified memory let MacNativeGames use the game's pools zero-copy. The back end imports the pools as host memory (`VK_EXT_external_memory_host`). On a discrete GPU, pools bound as buffers are mirrored in device-local memory and the pages the CPU wrote (write watch, above) are uploaded before a replay; idle pool regions are made read-only so the write-watch queries skip them (`vk_memory.c`). GPU-rendered textures are written back when the CPU reads them: on a pool invalidate, on a CPU copy, and for small targets once the CPU waits for a fence (`vk_texture.c`). +- Memory pools. Apple's unified memory let MacNativeGames use the game's pools zero-copy. The back end imports the pools as host memory (`VK_EXT_external_memory_host`); under Wine, or on a GPU without the extension, CPU-visible pools get shadow storage instead (host-visible copies, `vk_memory.c` `mirror_mode`). On a discrete GPU, pools bound as buffers are mirrored in device-local memory and the pages the CPU wrote (write watch, above) are uploaded before a replay; idle pool regions are made read-only so the write-watch queries skip them (`vk_memory.c`). GPU-rendered textures are written back when the CPU reads them: on a pool invalidate, on a CPU copy, and for small targets once the CPU waits for a fence (`vk_texture.c`). - Replay thread. `TOTK_REPLAY_ASYNC=1` moves the replay off the submitting thread onto a queue at most one frame behind the game; reads of GPU results wait for the newest writer instead of draining the queue (`vk_backend.c`). It is off by default. Where the game waits for the GPU it overlaps the replay with the game threads (a GTX 1650 in the Depths, issue #88), a gain measured only there; while it was the default, a GTX 1660 Ti at the 60 fps cap with the GPU at 26 % reported uneven motion (#659). It adds up to a frame of latency; `replay_async = 1` turns it on. - Chunked replay. A large submission is recorded in chunks by several threads (`TOTK_REPLAY_WORKERS`, 0 by default: the sequential replay; 4 is a good value from 8 logical processors) and the chunks go to the queue in order (`vk_exec.c`). A sequential scan keeps a copy of the queue state where each chunk starts and lists what a chunk would otherwise learn from the chunks before it: inline uniform updates, conditions, contact shadow marches, uniform drops. It also makes render targets live in replay order and notes the op, since a chunk can sample a storage before the chunk that renders it got there or after the scan went past a later target there: a chunk's texture slots resolve as of its own op, and the chunks after a texture with no entry yet wait for the chunk that makes it. DLSS's decisions (the G-buffer, the light target, the end of the scene, the scaling pass) are the scan's too, and its copy of the lit scene and its evaluation are records of the chunk that holds the op; a chunk's draws are jittered while they come before the scan's end of the scene. The evaluation waits until the chunks before it are recorded, as it reads what their draws noted (the camera block, the jitter, the per-object motion list, which chunks add to under one lock), and the chunks after it wait for it, as they sample its output. `TOTK_REPLAY_STATE_CHECK=1` compares the state after the last chunk with the scan's. - Frame ahead. `TOTK_SYNC_AHEAD=1` (`sync_ahead`, off by default) makes the one `nvnSyncWait` per frame that waits for the frame presented last wait for the frame before it, so the game builds the next frame while the GPU still runs the previous one (`nvn_api_core.c`, `nvnSyncWait`). The game then writes memory that in-flight work still reads. Two forms guard that. With shadow storage (`vk_memory.c`, the CPU-visible pools are host-visible copies of guest memory, on by default on Linux and Wine, `shadow = 1` (`TOTK_SHADOW=1`) on native Windows) a CPU write reaches the GPU only through the shadow copy made before each submit (`vk_mem_shadow_sync`), and a copy that would overwrite bytes an unfinished submission reads is queued as a GPU copy in the prologue command buffer of the part submitted next (`vk_mem_shadow_prologue`, `TOTK_SHADOW_DEFER=1`, the default with the feature) or, with `=0`, waited for on the replay thread (`shadow_reader_wait`). Only that one wait lags (identified by its call site, known for 1.1.0, 1.2.1 and 1.4.3). GPU writes into pool storage come back with their fence, so a buffer the game reads back every frame after that wait holds the result of the frame before; a buffer it has not read lately holds none, and its `nvnMemoryPoolInvalidateMappedRange` waits for the write (`vk_mem_shadow_read`): TotK reads single pixels through a buffer per request, and in the Depths zeros in one of them put Link in gloom. The exit line `mem: the game waited for a GPU write it reads` counts these waits and their time. On 1.4.3 the patch set `qstamp` (`recomp/patches-v143.txt`) lets the game take its depth query results one frame older; it follows the switch and is off when the switch is refused. The fence write-back of small render targets (`vk_texture.c`, `write_back_n`) does not wait for the GPU with `TOTK_WB_EAGER=1` (`wb_eager`, the default, but only while frame-ahead is in effect: with `sync_ahead` off or refused the setting does nothing and the write-back reads the image when it runs): `vk_sync_submit` has `vk_texture_eager_record` copy the targets that value rendered into staging buffers inside the same command buffer, so once the value has passed the write-back only copies from staging into the target's storage. Only a target that was written back within the last 64 timeline values is copied (the first write-back of a target takes the blocking path), and the staging of a target past that window, no longer wanted or released goes through the deferred free (`vk_defer_buffer_until`). A snapshot is used only when its value is the one that last rendered the target, nothing recorded a write to the image since (`wr_fence`) and the GPU has finished it; otherwise the write-back reads the image as before, and the exit line `vk: wb_eager:` counts the reasons. With frame-ahead in effect the exit line `vk: fence write-backs waited for the GPU` counts the write-backs that waited for a copy and the time they waited, for every value of the setting. `check` also reads the old way and compares. @@ -139,10 +140,22 @@ 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. +- AMD FSR (`scene_upscaler = fsr3` or `fsr4`). The same frame, jitter and motion vectors (with the per-object pass) + go to AMD's FSR instead of DLSS: `vk_dlaa.c` `evaluate` calls `fsr_evaluate` where it would call NGX, and everything + around it is shared, including the texture bias (AMD's log2(scene / output) - 1), `fsr_sharpness` (FSR's own RCAS in + place of the FXAA's sharpening), the skip of the game's FXAA and of its copy of the scene onto itself, and the dynamic + resolution held at 100 %. The camera's planes and field of view come from the scene camera block (`vk_fg.cpp` + `vk_fg_camera`). FSR 3.1 (`vk_fsr3.cpp`) is compiled from the FidelityFX SDK 1.1.4 sources and runs on any GPU. FSR 4 + (`vk_ffx.c`, Windows) is AMD's FSR SDK 2.4 signed libraries: `amd_fidelityfx_loader_vk.dll` 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 versions the libraries offer for the device are listed and the + newest FSR 4 is pinned; without one the scene upscaler stays off (no FSR 3 from the libraries). `vk_device.c` enables + `VK_KHR_cooperative_matrix` and `VK_EXT_shader_float8` with their features when FSR 4 is picked and the device has + them. Both hold one context per output size, made again when it changes. - 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`). -- Allocation: Vulkan Memory Allocator. Debugging: Vulkan validation layers, per-pass frame dumps (`TOTK_DUMP`, `vk_dump.c`) and a flight recorder (`TOTK_FLIGHT`). RenderDoc cannot capture, because it hides `VK_EXT_external_memory_host` from the application. +- Allocation: Vulkan Memory Allocator. Debugging: Vulkan validation layers, per-pass frame dumps (`TOTK_DUMP`, `vk_dump.c`) and a flight recorder (`TOTK_FLIGHT`). RenderDoc hides `VK_EXT_external_memory_host` from the application, so under it CPU-visible pools get shadow storage, as on any GPU without the extension; captures on that path are untested. Maxwell behaviour the back end has to match, and the TotK bugs other ports fixed: [maxwell.md](maxwell.md). diff --git a/docs/building.md b/docs/building.md index 8eb2a540..11294620 100644 --- a/docs/building.md +++ b/docs/building.md @@ -1,6 +1,7 @@ # Building from source -Windows 10 or later, an x86-64 CPU with SSE4.2, and a GPU with Vulkan 1.3 and `VK_EXT_external_memory_host`. The +Windows 10 or later, an x86-64 CPU with SSE4.2, and a GPU with Vulkan 1.3; `VK_EXT_external_memory_host` is recommended (without it CPU-visible pools get shadow storage, +slower and larger, see `vk_no_host_import` in [settings.md](settings.md)). The default build targets x86-64-v3 (AVX2/FMA); a CPU without them builds with `--cpu v2` instead and runs slower (see "Build"). Allow about 60 GB for the work folder. Extraction wants about 55 GB free while it runs and keeps about 35 GB afterwards. @@ -78,6 +79,9 @@ of them. .venv-py314\Scripts\python tools\extract.py ``` + `--skip-base-romfs` leaves out the base game's 17 GB RomFS image (`extracted 0 omfs`): no build step reads it, and + the update merge verifies what it takes from the base game file. Only a build of 1.0.0 itself needs it. + 4. Shader translator (no game files; again after a change to its sources, and `tools\make_release.py` stops on an older one). This publishes `build\xlate\totk_xlate.exe`: @@ -193,7 +197,7 @@ Vega 7 of a Ryzen 5 4600G at about 34 fps). Long play sessions and the Steam Dec Requirements: - Linux 6.7 or later: the write watch uses userfaultfd write protection with `PAGEMAP_SCAN`. SteamOS 3.8 qualifies. -- A Vulkan 1.3 driver with `VK_EXT_external_memory_host` (RADV, NVIDIA). +- A Vulkan 1.3 driver (RADV, NVIDIA). Linux uses shadow storage by default, so `VK_EXT_external_memory_host` is not needed. - Packages on Arch: ```sh diff --git a/docs/controls.md b/docs/controls.md index fc05cef4..4985e642 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -356,4 +356,4 @@ each line (`mouse_camera` in `runtime/input.c`); spread a turn over lines a fram ## RenderDoc capture (blocked) -`TOTK_RDOC=[,...]` (`runtime/rdoc_win.c`; `TOTK_RDOC_DIR`, `TOTK_RDOC_DLL`) loads RenderDoc before `vkCreateInstance`. RenderDoc hides `VK_EXT_external_memory_host`, which the back end requires for guest pool imports (`runtime/vk_memory.c`), so device creation fails under it. A capture needs a copy-based pool fallback first. +`TOTK_RDOC=[,...]` (`runtime/rdoc_win.c`; `TOTK_RDOC_DIR`, `TOTK_RDOC_DLL`) loads RenderDoc before `vkCreateInstance`. RenderDoc hides `VK_EXT_external_memory_host`, which guest pool imports need (`runtime/vk_memory.c`); without it the back end gives CPU-visible pools shadow storage, as on any GPU without the extension (`vk_no_host_import`). Captures on that path are untested. diff --git a/docs/installer.md b/docs/installer.md index e76c5365..ac0388ac 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -26,6 +26,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 4 (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 @@ -123,7 +124,15 @@ 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. -10. **Clean up** the temp folder, except the generated C and the objects (about 1.3 GB), and write +10. **FSR** (the window's tick box, on by default when Windows lists an AMD display adapter, `screens.py` + `windows_adapter_names`; or `--fsr`; Windows): 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. `scene_upscaler = fsr4` loads them from the folder of totk.exe and runs FSR 4 where they + offer it for the GPU. Libraries already in the folder are kept; a failed download warns, the game runs without FSR + 4, and the next run tries again. +11. **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`). @@ -181,8 +190,8 @@ python -m installer --base FILE --update FILE --keys FILE --lang CODE --dest DIR install sections, the explanations under More details, the share notice next to Start) in the Sun Valley ttk theme (`installer/vendor/sv_ttk/`, the platform theme when it does not load), step list with progress, space line, collapsible log, Cancel (Ctrl+Break to the CLI's process group, then it waits for the exit), finish screen with Open - folder. English, Russian, Brazilian Portuguese, Simplified Chinese, German, French, Spanish, Italian, Dutch, Japanese - or Korean (`guilogic.UI_LANGUAGES`), chosen from the Windows display language (every Chinese, zh-TW and zh-HK + folder. English, Russian, Brazilian Portuguese, Simplified Chinese, German, French, Spanish, Italian, Dutch, Japanese, + Korean or Vietnamese (`guilogic.UI_LANGUAGES`), chosen from the Windows display language (every Chinese, zh-TW and zh-HK included, gives Simplified Chinese; pt-PT and languages without a catalog give English), switchable in the window; every sentence is an id in `installer/text/.json`. The game language starts as the window's when the game has it; a Chinese or Korean window still starts with English, because that game text needs the Switch shared fonts, diff --git a/docs/mods.md b/docs/mods.md index 1fd24061..040d7cf6 100644 --- a/docs/mods.md +++ b/docs/mods.md @@ -123,14 +123,22 @@ The Mods tab order decides between a plugin and another mod's patch on the same plugin site over one of the port's own patches turns that built-in patch off while the mod is on. The rebuild refuses a plugin when its start-up or the code its redirects reach needs what the port does not give it: -system calls other than the few its start-up needs (memory queries and maps, the clock, debug output), library calls -outside a reviewed list (memory and string functions, the heap, text formatting), threads, services or input; a -redirect that is not one of exlaunch's hook shapes (inline hook, replace hook, call-site rewrite); or two runs of its -start-up that differ in code; or a start-up that crashes the service run or does not return within two minutes. The -row then says **Its plugin ... cannot run in the port** with the reason, and the mod stays off; **Use without its -code** uses the rest of it, including its other plugins that were built in. UltraCam stays refused: it hooks the graphics API, +system calls other than the few its start-up needs (memory queries and maps, the heap size, the clock, debug output), +or a library call the game itself never makes and a reviewed list does not hold (memory and string functions, the heap, +text formatting, mutexes, the clock, the system language, the SD card's files), such as network sockets or the module +loader. A library call the game makes (threads, input, time, its files) runs on the path the game runs on. A start-up +still gets only the system calls above, so it cannot start a thread or open a service; a redirect that is not one of exlaunch's hook shapes +(inline hook, replace hook, call-site rewrite, a branch into its code from inside a game function, a pointer in the +game's data swapped for one into its code); a write into the game's read-only data or into another module; two runs of +its start-up that differ in code; or a start-up that crashes the service run or does not return within two minutes. +The row then says **Its plugin ... cannot run in the port** with the reason, and the mod stays off; **Use without +its code** uses the rest of it, including its other plugins that were built in. UltraCam stays refused: it hooks the graphics API, reads input and opens sockets. +When a start-up calls into the middle of a game function, the rebuild lifts the game again with that address as a +function start and reruns the start-up, up to four times. A plugin that reads or writes files on the SD card gets +the folder `sdcard` in the game's profile folder in its place. + `plugin_trace = 1` in `totk.ini` logs the first call into each of a plugin's hooks (`plugins: hook entry ... reached`). ## Cheats diff --git a/docs/settings.md b/docs/settings.md index a8f63859..b8e23c26 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -115,6 +115,7 @@ Many rows below are developer tools that only act together with another setting | `mods_without_code` (default `0`) | `1` uses every mod without its code part, as if `mods_no_code` named them all. | See `mods_no_code`. | Caution | | `pipeline_cache` | Path of the Vulkan pipeline cache file (default `pipeline-cache.bin` beside `totk.exe`). | Moves the cache; a new path starts empty and pipelines are built again. | Caution | | `profile_dir` | Folder of the game profile, which holds the user account id that save data is named after; the default is a `profile` folder beside `totk.exe`, else the build-time path. | Another folder means a different set of saves. | Save risk | +| `restbl_cache` (default `0`) | `1`: with player mods, the resource size table merged at the last start is served again when nothing it was built from changed: every mod file and shipped table (path, size, write time, file id), the mod list and its order, the RomFS image and `totk.exe` itself. `/mods/` keeps the table and its `.key`. `0` builds it at every start. | Saves the merge at start: the pass over every mod file and the mods' packs (about 0.9 s with The Second Quest, 3,300 files; more with a texture pack). A changed, added or removed mod file, another order, a new build or game version builds the table again; a damaged kept table or key is built again too. A tool that rewrites a mod file with the same size and write time is not seen. | Caution | | `romfs` | Folder of the game's RomFS (with `romfs.bin`); a relative path is relative to `totk.exe`'s folder. | Without it, a `romfs` folder next to `totk.exe` is used, else the build-time path; a missing image stops the start with a message. | Save risk | | `romfs_index` | Path of `romfs-index.bin`, which `tools/romfs_index.py` wrote; the default is beside `totk.exe`. | The index is checked against the image by SHA-256 and size; a mismatch stops the start. | Caution | | `romfs_mmap` | `1` maps the RomFS image into memory instead of reading it with positional reads. | Changes how the image is read; the log reports when the mapped path is on. | Caution | @@ -138,6 +139,7 @@ Many rows below are developer tools that only act together with another setting | Setting | What it does | Effect of changing it | Safety | | --- | --- | --- | --- | +| `anv_vs_barrier` | A by-region barrier before each draw in a pass whose vertex shader reads a storage buffer. Off by default (`0`). Only Intel GPUs with Mesa's ANV driver on Linux need it: there such reads see stale data and campfire smoke and clouds are drawn as white or dark blobs, or the sky flashes white for single frames (#927). Set `1` to turn it on. | `1` costs about 5% of the frame rate on an Iris Xe and does nothing useful on other GPUs or on Windows; `0` leaves the one-frame glitches on ANV. | Safe | | `bind_inc` (default `0`) | `1` (or `on`) prepares a draw from what changed since the draw before (the bind ops mark the slots whose bytes they changed) instead of from the whole bound state; `check` prepares every draw as before, takes every decision of `on` beside it, logs each kind of difference once and counts them in a `bind_inc:` line every 300 frames; `0` or `off`: as before. `check` also counts what changed between draws in that line. | Less work per draw on the render thread; a change the marks missed would leave a stale descriptor, a wrong picture or a lost device, which `check` would show first. Off by default: with it on, a GTX 1050 Ti lost the device at one place, after the validation layer reported a descriptor pool reset while a command buffer still used its sets; the cause is not found yet. | Caution | | `block_views_3d` (default `0`) | `1` gives 3D block-compressed images block views too. | On some AMD cards a GPU write past the end of the image's memory loses the Vulkan device, and the game stops. | Risky | | `deswizzle` (default `auto`) | Where block-linear textures are deswizzled: `auto` or `gpu` uses a compute pass where the texture's storage is an imported pool and the CPU elsewhere, `cpu` always uses the CPU, `check` uses the GPU and also deswizzles every upload on the CPU and compares the two. | `cpu` brings back the long frames on entering new areas (the replay thread deswizzles every texture); `check` waits for the GPU at every upload and is for testing only. The log names the mode in use. | Caution | @@ -170,7 +172,9 @@ Many rows below are developer tools that only act together with another setting | `ub_overlay` (default `1`) | `0` copies each uniform update inside a pass into its buffer at once, ending the pass with a full barrier; `ab` alternates with the `ab` blocks. | With `0` scenes with many updated blocks (the terrain, the sky islands) take longer on the GPU; `TOTK_TRACE=perf` prints how many updates stayed in their pass. | Caution | | `ub_overlay_out` (default `1`) | `0` copies each uniform update between passes into its buffer at once, behind a full barrier of its own; `ab` alternates with the `ab` blocks. Needs `ub_overlay`. | With `0` a run of updates before a pass costs a full GPU barrier each; `TOTK_TRACE=perf` prints how many updates between passes were overlaid. | Caution | | `ubo_snapshot` (default `1`) | `0` binds live memory for uniform blocks; `ab` alternates with the `ab` blocks. | Without snapshots late draws read another object's matrix, so objects can be drawn in the wrong place. | Risky | +| `null_attach` (default `0`) | `1` gives the colour slots of a render pass that hold no target, below its last target, a dummy attachment (an `R8_UNORM` image covering the pass, writes masked off, loads and stores `DONT_CARE`) instead of a null image view; the pipelines name that format for those slots. A workaround to try on Intel's legacy Windows driver for 6th-10th generation graphics (HD 520, UHD 620, driver 101.21xx), which crashes inside `vkCmdBeginRendering` after the logo (#1343); untested there, and the crash dumps do not show that the empty slots are the cause. Also in `totk.ini.example`. | One or two dummy images per scene resolution (1.4 MiB at 1600x896, at most 24, freed when the device goes); pipelines with empty slots are built again once. | Caution | | `vk_no_float64` (default `0`) | `1` clears the 64-bit float feature, so the translator lowers FP64 to FP32. | Shaders change, so the shader cache entries for it are made again; precision of FP64 shaders drops. | Caution | +| `vk_no_host_import` (default `0`) | `1` leaves `VK_EXT_external_memory_host` off even when the GPU has it, so the game takes the path of a GPU without it: every CPU-visible pool gets shadow storage, as under Wine. For testing that path. | Shadow storage costs CPU copies before each submission and more memory than imports. | Caution | | `vk_ssbo_align` (default unset) | Power of two that storage buffer offsets are treated as needing, to test the unaligned path. | The translator and the draw code round storage offsets down to it; shaders are translated again. | Caution | | `vk_subgroup` (default `32`) | Subgroup size to pin where the driver allows it. | A value other than 32 changes what the translator is told about the GPU, and shaders are translated again. | Caution | | `volume_mask_bias` (default `1`) | `0` leaves the game's water volume mask draws (a volume's front faces tested LEQUAL without depth writes, blended ONE/ONE with reverse subtract) without the depth bias toward the viewer that `vk_pipeline.c` gives them; `ab` alternates with `TOTK_AB`. | Puddles and still water then flicker again where the volume's top face lies on the water surface; a test setting. | Caution | @@ -194,6 +198,7 @@ Many rows below are developer tools that only act together with another setting | `dlss_reactive` (default `0`) | `1` builds a reactive mask for DLSS where it ran. | Changes how DLSS blends moving areas; a test setting. | Caution | | `fsr3_debug` (default `0`) | With `scene_upscaler = fsr3`: `1` creates the FSR 3.1 context with the SDK's input checks, whose warnings go to the log (the first 32). | Adds checks to every FSR 3.1 dispatch and log lines. | Caution | | `fsr3_view` (default `0`) | With `scene_upscaler = fsr3`: `1` shows FSR 3.1's own debug view of its inputs and state in place of the picture. | The frame shows a debug image while it is set. | Caution | +| `fsr4_debug` (default `0`) | With `scene_upscaler = fsr4`: `1` creates the FSR 4 context with the AMD libraries' input checks, whose findings go to the log. | Adds checks to every FSR 4 dispatch and log lines. | 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 | @@ -208,7 +213,7 @@ Many rows below are developer tools that only act together with another setting | `mvprev_grow` (default `1`) | `0` keeps only three banks in the previous-frame tables. | Object motion that depends on the other banks is no longer tracked. | Caution | | `mvprev_skip` | Hex bank mask of banks left out of the previous-frame copy, replacing the default. | Different banks are tracked, which changes object motion. | Caution | | `mvprev_trust` | Hex bank mask of banks whose found previous-frame copy is taken without the check. | A copy that does not match is used anyway, which can give wrong motion. | Caution | -| `reflex` (default `off`) | `off`, `on`, or `boost`; enables NVIDIA Reflex Low Latency (`VK_NV_low_latency2`) to reduce system input latency. Read at start. | On NVIDIA GPUs supporting the extension, coordinates simulation and presentation cadence to lower latency, holding frames to the frame limit the pacer uses (`fps_limit`, the monitor's rate for `display`); `boost` keeps GPU clocks high in CPU-bound scenes. Has no effect on non-NVIDIA GPUs. | Safe | +| `reflex` (default `off`) | `off`, `auto`, `on`, or `boost`; reduces system input latency. `on` and `boost` enable NVIDIA Reflex Low Latency (`VK_NV_low_latency2`); `auto` enables Reflex, or AMD Anti-Lag 2 (`VK_AMD_anti_lag`, Mesa RADV and AMD's Windows driver) on a GPU without Reflex. Read at start. | Only one of the two runs; on a GPU with neither extension the setting does nothing. Both coordinate simulation and presentation so input reaches the screen sooner when the GPU is the limit, holding frames to the frame limit the pacer uses (`fps_limit`, the monitor's rate for `display`). `boost` also keeps NVIDIA GPU clocks high in CPU-bound scenes. | Safe | ## Scheduling and host @@ -245,6 +250,7 @@ These names are code patch sets built into the generated game code (`recomp/patc | `fixed_res_patch` (default `0`) | Patch set that holds the game's dynamic resolution at 100 percent (the scene tier). | The resolution code switches this set from `dynamic_res` (on at `0`); a manual value is replaced. | Unknown | | `freecam_patch` (default `0`) | Patch set of the hook in the camera component update behind the free camera (`freecam_pad`, `freecam_key`) on game 1.4.3; the *Free camera* row of the Controls tab. Read at start. | `1` puts the hook in the camera update: while the free camera is off it runs the game's own load and one compare. `0` runs the game's code as shipped: the combo and the key do nothing and the game gets the combo's buttons. | Safe | | `fov_patch` (default `0`) | Patch set that scales the camera's vertical view angle by the field-of-view setting. | The resolution code switches this set itself whenever the field of view is not 100 percent; a manual value is replaced. | Unknown | +| `lightning_fix` (default `1`) | Patch set on 1.2.1 and 1.4.3 (set `lightning`; 1.4.3 main+0x62b1fc, main+0x62b3d8, main+0x62b51c; 1.2.1 main+0xab8d50, main+0xab9014, main+0xab8f90): in a thunderstorm the world manager's lightning update runs once per frame and draws, each update, a random number for each of three fixed chances, 0.013333 for a distant bolt and 0.01 for a near strike and for the environment's lightning flag that near strikes also set (#1287). The set multiplies each chance by the frame ratio, at most 1, so above 30 fps a storm has as much lightning per second as at 30 fps; at 30 fps and below the chances are the game's own. Game 1.1.0 has no site and keeps the game's code. | `0` runs the game's code: the higher the frame rate, the more distant bolts and lightning flags. Counted on 1.4.3 in one storm (205 s, the reporter's save) with a local build that logs each draw that succeeds: distant bolts 22, 52 and 94 to 96 a minute at 30, 60 and 120 fps with `0`, and 26, 27 and 20 to 24 with `1`; the lightning flag 19, 34 and 64 to 80 a minute of the storm's lightning phase with `0`, 12 to 17 with `1`. Near strikes stayed at 14 to 18 per run at every rate with either value. On 1.2.1 counted from screenshots only (no logging build; a storm in Hyrule Field, one screenshot every 0.2 s, each counted bolt checked by eye): 19 screenshots with a distant bolt a minute at 30 fps, about 61 at 120 fps with `0`, 15 with `1`; the same count on 1.4.3 gives 25 to 26, 65 to 68 and 16 to 20. | Safe | | `mouse_direct_patch` (default `1`) | Patch set of the hooks in the game's camera code behind `mouse_mode = direct` on game 1.4.3. | `0` stops `mouse_mode = direct` from taking effect; other mouse modes are unaffected. | Safe | | `optref_guard` (default `1`) | Patch set that treats a negative value in the optional reference at object +0x6b0 (1.4.3 main+0x1bd01c0, 1.2.1 main+0x1622bec) as absent instead of loading through it (#1005). | `0` runs the game's code as shipped: the random crash reading `0xffffffffffffffff` after minutes to hours of play can return. | Risky | | `patch_output` (default `0`) | Patch set that makes the game use the configured output size for its swapchain and display configuration. | The resolution code switches this set whenever the output differs from the base size; a manual value is replaced. | Unknown | diff --git a/docs/tester-guide.md b/docs/tester-guide.md index 81198acd..514814ea 100644 --- a/docs/tester-guide.md +++ b/docs/tester-guide.md @@ -8,7 +8,8 @@ from it may be shared. - Windows 10 or later, an x86-64 CPU with SSE4.2 (AVX2/FMA recommended: they build the default, faster version), about 60 GB free. -- A GPU with Vulkan 1.3 and `VK_EXT_external_memory_host`, with a current driver. +- A GPU with Vulkan 1.3, with a current driver. `VK_EXT_external_memory_host` is recommended: without it the game + runs on shadow storage, which costs memory and frame rate. - *Tears of the Kingdom* base game (1.0.0) and the 1.1.0, 1.2.1 or 1.4.3 update, dumped from your own Switch as NSP or XCI. - `prod.keys` dumped from your own Switch. Never send it to anyone, and never paste it into a log or an issue. diff --git a/installer/cli.py b/installer/cli.py index a4106d30..7d00b3f0 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, for scene_upscaler = fsr4; the libraries decide which GPUs get FSR 4 (steps.py, Fsr). """ import argparse import signal @@ -51,6 +53,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 scene_upscaler = fsr4') 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 a2e2f5ce..b5021b19 100644 --- a/installer/gui.py +++ b/installer/gui.py @@ -38,8 +38,10 @@ except ImportError: from . import ini from . import layout as layouts from . import recent +from . import screens from .guilogic import (DONE, FAILED, PENDING, RUNNING, SKIPPED, UI_LANGUAGE_LABELS, UI_LANGUAGES, Catalog, Form, Model, - Process, amount, default_game_language, describe_event, parse_line, windows_ui_language) + Process, amount, default_game_language, describe_event, fsr_default, parse_line, + windows_ui_language) POLL_MS = 100 GLYPH = {PENDING: '\u25cb', RUNNING: '\u25b6', DONE: '\u2714', SKIPPED: '\u2013', FAILED: '\u2716'} @@ -114,6 +116,73 @@ def use_sun_valley(root, ui_font): return True +class ScrollArea(ttk.Frame): + """A screen's content scrolls while its action bar stays outside the viewport.""" + + def __init__(self, parent): + super().__init__(parent) + background = ttk.Style(parent).lookup('TFrame', 'background') or parent.winfo_toplevel().cget('background') + self.canvas = tk.Canvas(self, width=1, height=1, borderwidth=0, highlightthickness=0, background=background) + self.scrollbar = ttk.Scrollbar(self, orient='vertical', command=self.canvas.yview) + self.canvas.configure(yscrollcommand=self.scrollbar.set) + self.canvas.pack(side='left', fill='both', expand=True) + self.content = ttk.Frame(self.canvas) + self.window = self.canvas.create_window((0, 0), window=self.content, anchor='nw') + self.content.bind('', lambda _e: self.canvas.configure(scrollregion=self.canvas.bbox('all'))) + self.canvas.bind('', lambda e: self.canvas.itemconfigure(self.window, width=e.width)) + root = self.winfo_toplevel() + root.bind('', self.reveal_focus, add='+') + for sequence in ('',) + (('', '') if sys.platform.startswith('linux') else ()): + root.bind(sequence, self.wheel, add='+') + + def contains(self, widget): + return widget is self.canvas or str(widget).startswith(str(self.content) + '.') or widget is self.content + + def natural(self): + width = self.content.winfo_reqwidth() + if int(self.canvas.cget('width')) == width: + return False + self.canvas.configure(width=width) + return True + + def limit_height(self, height): + height = max(1, height) + scroll = height < self.content.winfo_reqheight() + changed = bool(self.scrollbar.winfo_manager()) != scroll + if changed: + if scroll: + self.scrollbar.pack(side='right', fill='y', before=self.canvas) + else: + self.scrollbar.pack_forget() + if int(self.canvas.cget('height')) != height: + self.canvas.configure(height=height) + changed = True + return changed + + def reveal_focus(self, event): + if not self.contains(event.widget) or event.widget is self.canvas: + return + top = event.widget.winfo_rooty() - self.content.winfo_rooty() + bottom = top + event.widget.winfo_height() + visible = self.canvas.canvasy(0) + height = self.canvas.winfo_height() + if top < visible: + self.canvas.yview_moveto(top / max(1, self.content.winfo_height())) + elif bottom > visible + height: + self.canvas.yview_moveto((bottom - height) / max(1, self.content.winfo_height())) + + def wheel(self, event): + if not self.contains(event.widget) or event.widget.winfo_class() in ('Text', 'Listbox', 'TCombobox'): + return + if self.canvas.yview() == (0.0, 1.0): + return + units = -1 if event.num == 4 else 1 if event.num == 5 else -int(event.delta / 120) + if not units and event.delta: + units = -1 if event.delta > 0 else 1 + self.canvas.yview_scroll(units, 'units') + return 'break' + + class App: def __init__(self, root, ui_lang, layout, run_args=None, rebuild=None): self.root, self.layout = root, layout @@ -180,6 +249,7 @@ class App: self.ui_box.pack(side='left') self.body = ttk.Frame(root, padding=PAD) self.body.pack(fill='both', expand=True) + self.scroll_areas = {} self.frames = {'form': self.build_form(), 'run': self.build_run(), 'finish': self.build_finish()} self.vars['lang'].set(self.lang_label(self.lang_code)) self.vars['dest'].trace_add('write', lambda *_: self.refresh_form()) @@ -267,13 +337,28 @@ class App: for), so a screen or language switch does not move the buttons sideways, and the height of the shown screen, so no screen carries the empty band of a taller one. Every text change that can add lines calls it again, or pack takes the missing height from the button bars. Without `shrink` the window only grows and a size the user - dragged it to stays; a screen or language switch and closing the details or the log shrink it to fit.""" + dragged it to stays; a screen or language switch and closing the details or the log shrink it to fit. A screen + taller than the display scrolls its content while its action bar remains outside the viewport.""" self.root.update_idletasks() + widths_changed = [area.natural() for area in self.scroll_areas.values()] + if any(widths_changed): + self.root.update_idletasks() widths = [f.winfo_reqwidth() for f in self.frames.values()] shown = self.frames[self.screen] if self.screen else max(self.frames.values(), key=lambda f: f.winfo_reqheight()) chrome = self.root.winfo_reqheight() - self.body.winfo_reqheight() # the title row above the body w = max(self.root.winfo_reqwidth(), max(widths) + 2 * PAD) h = chrome + shown.winfo_reqheight() + 2 * PAD + area = self.scroll_areas.get(self.screen) + if area: + h += area.content.winfo_reqheight() - area.canvas.winfo_reqheight() + # Leave room for window decorations and the desktop's panels. Content scrolls; the footer stays visible. + limit = max(1, self.root.winfo_screenheight() - dpi.px(80)) + if area: + changed = area.limit_height(area.content.winfo_reqheight() - max(0, h - limit)) + h = min(h, limit) + if changed: + self.root.update_idletasks() + w = max(w, shown.winfo_reqwidth() + 2 * PAD) # refresh_run calls it on every poll: leave the window alone while nothing grew if (w, h) == self.fitted and (not shrink or self.root.winfo_height() == h): return @@ -281,6 +366,12 @@ class App: self.root.minsize(w, h) self.root.geometry(f'{max(w, self.root.winfo_width())}x{h if shrink else max(h, self.root.winfo_height())}') + def scroll_content(self, parent, name): + area = ScrollArea(parent) + area.pack(fill='both', expand=True) + self.scroll_areas[name] = area + return area.content + def notice(self, parent): w = ttk.Label(parent, style='Notice.TLabel', wraplength=WRAP, justify='left') self.bind_text(w, 'text', 'ui.notice') @@ -310,9 +401,10 @@ class App: self.form_error.pack(side='bottom', anchor='w', pady=(dpi.px(4), 0)) self.update_hint = ttk.Label(f, style='Status.TLabel', wraplength=WRAP, justify='left') self.update_hint.pack(side='bottom', anchor='w', pady=(dpi.px(8), 0)) - self.form_intro = self.label(f, 'ui.intro', wraplength=WRAP, justify='left') + content = self.scroll_content(f, 'form') + self.form_intro = self.label(content, 'ui.intro', wraplength=WRAP, justify='left') self.form_intro.pack(anchor='w', pady=(0, dpi.px(4))) - grid = ttk.Frame(f) + grid = ttk.Frame(content) grid.pack(fill='x') grid.columnconfigure(1, weight=1) self.section(grid, 0, 'ui.section_files', dpi.px(6)) @@ -344,18 +436,25 @@ class App: # On by default and named with its source and licence: the player sees what is downloaded and can untick it. # The source and licence line is the first one under More details. self.dlss_var = tk.BooleanVar(value=True) - dlss = ttk.Checkbutton(f, variable=self.dlss_var) + dlss = ttk.Checkbutton(content, variable=self.dlss_var) self.bind_text(dlss, 'text', 'ui.dlss') dlss.pack(anchor='w', pady=(dpi.px(12), 0)) + # Ticked by default with an AMD display adapter only (guilogic.fsr_default); the player can tick it on any GPU. + # Its source and licence line follows DLSS's under More details. + self.fsr_var = tk.BooleanVar(value=fsr_default(screens.windows_adapter_names())) + fsr = ttk.Checkbutton(content, variable=self.fsr_var) + self.bind_text(fsr, 'text', 'ui.fsr') + fsr.pack(anchor='w', pady=(dpi.px(4), 0)) # The explanations stay out of the way until asked for: a link opens them under it - self.details_toggle = ttk.Label(f, style='Link.TLabel', cursor='hand2', takefocus=True) + self.details_toggle = ttk.Label(content, style='Link.TLabel', cursor='hand2', takefocus=True) self.bind_text(self.details_toggle, 'text', 'ui.more_details') for seq in ('', '', ''): self.details_toggle.bind(seq, lambda _e: self.toggle_details()) self.details_toggle.pack(anchor='w', pady=(dpi.px(8), 0)) - self.details = ttk.Frame(f) # packed after the link when open; no holder frame, as an emptied Tk frame keeps + self.details = ttk.Frame(content) # packed after the link when open; no holder frame, as an emptied Tk frame keeps # the height its last child gave it - for id in ('ui.dlss_help', 'ui.formats_help', 'ui.compressed_help', 'ui.firmware_help', 'ui.keys_private'): + for id in ('ui.dlss_help', 'ui.fsr_help', 'ui.formats_help', 'ui.compressed_help', 'ui.firmware_help', + 'ui.keys_private'): self.label(self.details, id, style='Muted.TLabel', wraplength=WRAP - dpi.px(16), justify='left').pack(anchor='w', pady=(dpi.px(6), 0)) self.details_open = False @@ -379,14 +478,15 @@ class App: self.cancel_button.pack(side='right') self.log_toggle = self.button(bar, 'ui.show_log', self.toggle_log) self.log_toggle.pack(side='left') - self.run_header = ttk.Label(f, font=(self.ui_font, 11, 'bold')) + content = self.scroll_content(f, 'run') + self.run_header = ttk.Label(content, font=(self.ui_font, 11, 'bold')) self.run_header.pack(anchor='w') self.step_rows = {} - self.steps_box = ttk.Frame(f) + self.steps_box = ttk.Frame(content) self.steps_box.pack(fill='x', pady=dpi.px(8)) - self.phase_label = ttk.Label(f, wraplength=WRAP, justify='left') + self.phase_label = ttk.Label(content, wraplength=WRAP, justify='left') self.phase_label.pack(anchor='w') - bar_holder = ttk.Frame(f) + bar_holder = ttk.Frame(content) bar_holder.pack(fill='x', pady=(dpi.px(4), dpi.px(6))) self.bar = ttk.Progressbar(bar_holder, mode='determinate', maximum=1000) self.bar.pack(fill='both', expand=True) @@ -396,11 +496,11 @@ class App: # holder follows it. bar_holder.pack_propagate(False) bar_holder.configure(height=dpi.px(22)) - self.space_label = ttk.Label(f, wraplength=WRAP, justify='left') + self.space_label = ttk.Label(content, wraplength=WRAP, justify='left') self.space_label.pack(anchor='w') - self.warn_label = ttk.Label(f, wraplength=WRAP, justify='left', foreground='#9a6700') + self.warn_label = ttk.Label(content, wraplength=WRAP, justify='left', foreground='#9a6700') self.warn_label.pack(anchor='w') - self.log_frame = ttk.Frame(f) + self.log_frame = ttk.Frame(content) self.log = tk.Text(self.log_frame, height=10, wrap='word', state='disabled', font=(self.mono_font, 9)) scroll = ttk.Scrollbar(self.log_frame, command=self.log.yview) self.log.configure(yscrollcommand=scroll.set) @@ -420,13 +520,14 @@ class App: self.back_button.pack(side='left') if self.rebuild: # a failed or cancelled rebuild: the game starts with the code it has self.button(bar, 'ui.start_game', self.start_game).pack(side='right', padx=(0, dpi.px(8))) - self.finish_title = ttk.Label(f, style='Title.TLabel', wraplength=WRAP, justify='left') + content = self.scroll_content(f, 'finish') + self.finish_title = ttk.Label(content, style='Title.TLabel', wraplength=WRAP, justify='left') self.finish_title.pack(anchor='w') - self.finish_text = ttk.Label(f, wraplength=WRAP, justify='left') + self.finish_text = ttk.Label(content, wraplength=WRAP, justify='left') self.finish_text.pack(anchor='w', pady=dpi.px(8)) - self.finish_steps = ttk.Frame(f) + self.finish_steps = ttk.Frame(content) self.finish_steps.pack(fill='x', pady=(0, dpi.px(8))) - self.finish_notice = self.notice(f) + self.finish_notice = self.notice(content) self.finish_notice.pack(fill='x', pady=(dpi.px(8), 0)) return f @@ -435,7 +536,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 @@ -711,7 +812,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 b91e892f..66a037d8 100644 --- a/installer/guilogic.py +++ b/installer/guilogic.py @@ -24,20 +24,20 @@ from . import state as statefile from .events import render TEXT = Path(__file__).resolve().parent / 'text' -UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans', 'de', 'fr', 'es', 'it', 'nl', 'ja', 'ko') +UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans', 'de', 'fr', 'es', 'it', 'nl', 'ja', 'ko', 'vi') # 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': '简体中文', 'de': 'Deutsch', 'fr': 'Français', 'es': 'Español', 'it': 'Italiano', 'nl': 'Nederlands', - 'ja': '日本語', 'ko': '한국어'} + 'ja': '日本語', 'ko': '한국어', 'vi': 'Tiếng Việt'} STEP_ORDER = ('check', 'kit', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'shapes', 'dlss', - 'cleanup') + '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_PT_BR = 0x0416 # Portuguese (Brazil), the whole LANGID: Portugal's Portuguese stays English # primary language id in a Windows LANGID -> window language, for the languages whose every region gets the same text. # Every Chinese gets Simplified Chinese: the setup has no Traditional Chinese text, as the in-game menu has none. PRIMARY_LANGS = {0x04: 'zh-Hans', 0x19: 'ru', 0x07: 'de', 0x0c: 'fr', 0x0a: 'es', 0x10: 'it', 0x13: 'nl', 0x11: 'ja', - 0x12: 'ko'} + 0x12: 'ko', 0x2a: 'vi'} # window language -> the game language the form starts with (default_game_language) GAME_LANGUAGE_FOR_UI = {'ru': 'ru', 'de': 'de', 'fr': 'fr', 'es': 'es', 'it': 'it', 'nl': 'nl', 'ja': 'ja'} @@ -142,6 +142,14 @@ def amount(cat, done, total, unit): # ---- the form ---------------------------------------------------------------------------------------------------- +def fsr_default(adapters): + """Whether the window ticks Download AMD FSR at start: only with an AMD display adapter among adapters (their + names, screens.windows_adapter_names). The step downloads on any GPU when ticked (steps.Fsr); on other GPUs, and + when no adapter could be listed, the box starts unticked, so a player without an AMD GPU never downloads AMD's + libraries (about 36 MB) without choosing to.""" + return any('AMD' in a.upper() or 'RADEON' in a.upper() for a in adapters) + + @dataclass class Form: base: str = '' @@ -151,6 +159,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.""" @@ -203,6 +212,8 @@ class Form: cmd.append('--verify') if self.dlss: cmd.append('--dlss') + if self.fsr: + cmd.append('--fsr') return cmd diff --git a/installer/hostcheck.c b/installer/hostcheck.c index d3099271..0433a874 100644 --- a/installer/hostcheck.c +++ b/installer/hostcheck.c @@ -57,9 +57,12 @@ static int x86_64_v3(void) { return (c & (1u << 5)) != 0; // LZCNT (ABM) } +// stdout is a pipe, so it is fully buffered: each part is flushed before the next call that can crash, and a probe +// that a Vulkan layer or driver kills still hands the installer what it found (installer/steps.py Check.probe_host). int main(void) { printf("{\"x86_64_v2\": %s, \"x86_64_v3\": %s, ", x86_64_v2() ? "true" : "false", x86_64_v3() ? "true" : "false"); + fflush(stdout); void *lib = open_lib(); PFN_vkGetInstanceProcAddr gipa = lib ? (PFN_vkGetInstanceProcAddr)lib_sym(lib, "vkGetInstanceProcAddr") : NULL; if (!gipa) { @@ -67,6 +70,7 @@ int main(void) { return 0; } printf("\"loader\": true, "); + fflush(stdout); PFN_vkCreateInstance create = (PFN_vkCreateInstance)gipa(NULL, "vkCreateInstance"); VkApplicationInfo app = {.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pApplicationName = "totk-install", .apiVersion = VK_API_VERSION_1_3}; diff --git a/installer/ini.py b/installer/ini.py index 5cad6f00..785e20df 100644 --- a/installer/ini.py +++ b/installer/ini.py @@ -1,7 +1,7 @@ """totk.ini: set the game language and keep everything else (keys and syntax as runtime/cfg.c reads them). A new file starts from totk.ini.example, whose lines are all commented defaults. The language goes into `lang` -(a Switch language code, runtime/ov_system.c): an active `lang = ...` line is rewritten in place, else the commented +(a Switch language code, runtime/ov_system.c): the last active `lang = ...` line is rewritten in place, else the commented `# lang = ...` line of the example is activated, else the line is added to [language] (created at the end if missing). Other lines, comments and line order stay as they are. """ @@ -32,8 +32,9 @@ def set_language(text, lang): """text with `lang = ` (an alias written as its canonical code); see the module docstring.""" lang = canonical_language(lang) lines = text.splitlines() - for i, line in enumerate(lines): - m = ACTIVE.match(line) + # runtime/cfg.c add gives the last non-empty value priority, regardless of section or the totk_ prefix. + for i in range(len(lines) - 1, -1, -1): + m = ACTIVE.match(lines[i]) if m: lines[i] = f'{m.group(1)}lang{m.group(2)}{lang}' return '\n'.join(lines) + '\n' @@ -53,10 +54,14 @@ def set_language(text, lang): def get_language(text): - for line in text.splitlines(): + for line in reversed(text.splitlines()): m = ACTIVE.match(line) if m: - return m.group(3) + value = m.group(3) + if len(value) >= 2 and value[0] == value[-1] == '"': + value = value[1:-1] + if value: # cfg.c add ignores empty values, including an empty quoted string + return value return None diff --git a/installer/launcher/launcher.c b/installer/launcher/launcher.c index b993c214..5ba7eaaa 100644 --- a/installer/launcher/launcher.c +++ b/installer/launcher/launcher.c @@ -28,6 +28,7 @@ static void fail(void) { LANG_DUTCH, LAUNCHER_TITLE_NL, LAUNCHER_PYTHON_MISSING_NL }, { LANG_JAPANESE, LAUNCHER_TITLE_JA, LAUNCHER_PYTHON_MISSING_JA }, { LANG_KOREAN, LAUNCHER_TITLE_KO, LAUNCHER_PYTHON_MISSING_KO }, + { LANG_VIETNAMESE, LAUNCHER_TITLE_VI, LAUNCHER_PYTHON_MISSING_VI }, { LANG_CHINESE, LAUNCHER_TITLE_ZH_HANS, LAUNCHER_PYTHON_MISSING_ZH_HANS }, }; LANGID ui = GetUserDefaultUILanguage(); diff --git a/installer/recent.py b/installer/recent.py index 5ebe75cd..375ee906 100644 --- a/installer/recent.py +++ b/installer/recent.py @@ -1,4 +1,4 @@ -"""The last install folder and source paths, in a per-user file, so an update, a reinstall or a switch to another game +r"""The last install folder and source paths, in a per-user file, so an update, a reinstall or a switch to another game version starts with the form filled in. {"format": 1, "dest": ..., "base": ..., "update": ..., "keys": ..., "firmware": ...} diff --git a/installer/screens.py b/installer/screens.py index 02f3ede6..8b96e349 100644 --- a/installer/screens.py +++ b/installer/screens.py @@ -94,6 +94,28 @@ def windows_displays(): return out +def windows_adapter_names(): + """The names of the display adapters Windows lists (EnumDisplayDevicesW, "AMD Radeon RX 9060 XT"), without + starting Vulkan; [] elsewhere or when the call fails. The setup window decides its defaults by them before the host + check has run.""" + if os.name != 'nt': + return [] + try: + user32 = ctypes.WinDLL('user32') + out, i = [], 0 + while i < 64: + dev = DISPLAY_DEVICEW() + dev.cb = ctypes.sizeof(dev) + if not user32.EnumDisplayDevicesW(None, i, ctypes.byref(dev), 0): + break + i += 1 + if dev.DeviceString and dev.DeviceString not in out: + out.append(dev.DeviceString) + return out + except (OSError, AttributeError, ValueError): + return [] + + XRANDR = re.compile(r'\sconnected\s+(?:primary\s+)?(\d+)x(\d+)\+') @@ -132,11 +154,16 @@ def displays(): # ---- totk.ini (runtime/cfg.c reads the same keys, in any section, with or without the totk_ prefix) def ini_value(text, name): + """The last nonempty value, with matching quotes removed, as runtime/cfg.c cfg_load and add read it.""" value = None for line in text.splitlines(): - m = re.match(rf'^\s*(?:totk_)?{name}\s*=\s*([^\s#;]*)', line, re.IGNORECASE) + m = re.match(rf'^\s*(?:totk_)?{re.escape(name)}\s*=(.*)$', line, re.IGNORECASE) if m: - value = m.group(1) + candidate = m.group(1).strip() + if len(candidate) >= 2 and candidate[0] == candidate[-1] == '"': + candidate = candidate[1:-1] + if candidate: + value = candidate return value diff --git a/installer/state.py b/installer/state.py index be264654..e1722504 100644 --- a/installer/state.py +++ b/installer/state.py @@ -36,10 +36,23 @@ def load(dest): data = json.loads(path.read_text(encoding='utf-8')) except (OSError, ValueError): raise StateError('state.unreadable', path) from None - if not isinstance(data, dict) or not isinstance(data.get('steps'), dict): + if not isinstance(data, dict): raise StateError('state.unreadable', path) - if data.get('format', 0) > FORMAT: + version = data.get('format', 0) + if type(version) is not int or version < 0: + raise StateError('state.unreadable', path) + if version > FORMAT: raise StateError('state.newer_format', path) + # The GUI and resume planner read these fields before running a step. A JSON value of the wrong type must take + # the same error path as unreadable JSON, rather than raising from their comparisons or dict lookups. + for name in ('release', 'lang', 'version'): + if name in data and not isinstance(data[name], str): + raise StateError('state.unreadable', path) + for name in ('steps', 'inputs'): + records = data.get(name, {} if name == 'inputs' else None) + if not isinstance(records, dict) or any(not isinstance(record, dict) for record in records.values()): + raise StateError('state.unreadable', path) + data.setdefault('inputs', {}) # older records may omit it; the extraction step expects a dictionary return data diff --git a/installer/steps.py b/installer/steps.py index 12abed07..09b36f12 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -1,5 +1,5 @@ -"""The eleven setup steps of docs/installer.md: check, kit, fonts, extract, lift, compile, prepare, pc_prompts, shapes, -dlss, cleanup. +"""The twelve setup steps of docs/installer.md: check, kit, 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-