gta6rt: --upscaler-picker RVA[,KIND] replaces the game's choice of upscaler (FSR on Series X) #153

Closed
Andretuta wants to merge 5 commits from upstream-pr/153 into main
Andretuta commented 2026-11-24 02:30:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:30:01Z.


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


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

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

Claimed in the coordination issue as: https://github.com/ItsNotRexed/Leonida/issues/6750#issuecomment-7105596665 (FSR in the Series X render path).

Depends on: #9883 (the title's FFX calls answered by the PC upscaler; with #9877, #9882) for FSR to actually run on a PC. Related: #9884 (the console type the title reads from the registry); this PR works without it.

In short

The game asks one question at startup: "which upscaler should I use?" It answers "FSR" only on a Series S (720p → 1080p) and "my own" on a Series X. This PR lets the runtime answer that question instead, so the game keeps its Series X resolution and settings but upscales with FSR. Nothing in the game file is changed: every call to that one function is redirected to a small thunk that returns "FSR". The FSR calls themselves then go to AMD's PC FSR through the upscaler shim (#9883).

How to turn it on: run with the PC upscaler shim (LEONIDA_FFX_PC=1 and LEONIDA_FFX_DIR), and either set "enabled": true in mods/fsr_series_x/mod.json or pass --upscaler-picker 7E93F0. Without LEONIDA_FFX_PC=1, FSR (kind 7) stays off either way and the log says why; another kind (e.g. ,6) needs no shim.

What and why

A static look at my own copy of the 1.0.2.1 executable (nothing executed; only names, counts and the RVA here):

  • The title's FFX calls (ffxCreateContext, ffxDestroyContext, ffxDispatch, ffxQuery; no ffxConfigure) all come from one class with a single static instance.
  • A short function returns an upscaler object by number: that instance for 7, another static for 6, null otherwise.
  • The picker passes it its number: 7 only when the console type is Series S (type 6, from the registry ConsoleMode, see #9884) and the FFX path is available; otherwise 6. The console type is tested in 70 places, but never inside the FFX class, so the class doesn't gate itself.

So a Series X configuration renders through the game's own upscaler, and FSR is tied to the Series S configuration (720p → 1080p).

The change

gta6rt --upscaler-picker RVA[,KIND] (hex RVA, decimal KIND, default 7) hooks the picker with the existing result-override thunk (code_hooks.h, as --view-mode-getter), so every pick returns KIND: the game keeps its Series X configuration and upscales through FFX, which #9883 serves with AMD's PC upscaler. leonida::mods::override_upscaler / upscaler_kind_slot in mods.h; docs/modding.md gets an "Upscaler" section with the 1.0.2.1 RVA (0x7E93F0) and how to find it in another version.

The setting (second commit): a mod's "upscaler" section ("use": "fsr" or "game", and "picker_rva") does the same without the command line; the last enabled mod with one decides and --upscaler-picker wins over it. mods/fsr_series_x ships with it, off by default. FSR is only applied with LEONIDA_FFX_PC=1: without the PC upscaler shim the game's FFX calls would reach the package's console DLL, so the runtime leaves the game's choice and logs why.

A menu to switch upscalers (an overlay, or later the game's own settings) and other backends (DLSS, XeSS through the same shim) are follow-ups once the game shows frames.

Review fixes (third commit): the hook options are parsed in place by leonida::mods::parse_hook_option (no pointer into a destroyed temporary, nothing allowed after the last number), shared by --upscaler-picker, --archetype-lookup and --view-mode-getter; the archetype ARG is now refused unless 0 or 1. A hook that redirects no direct call logs not hooked: no direct call to it (wrong RVA for this executable?) instead of "hooked".

Tested

Windows cross-build (clang-cl + xwin) under Wine 11, CachyOS:

  • ctest mods: 41 checks, 0 failures (the parser: RVA, RVA,KIND, a 0x prefix; refused: 7E93F0x, 7E93F0,6x, 7E93F0,, ,6, 0, a leading space or sign, RVA,256, an RVA past 32 bits). Earlier: 35 checks (new: no kind passes the game's choice through; RVA,7 makes every pick 7; the "upscaler" section parses fsr/game, refuses an unknown upscaler or a missing/bad RVA, and the last enabled mod decides).
  • --dry-run with mods/fsr_series_x enabled: without LEONIDA_FFX_PC it logs FSR upscaler not applied: it needs LEONIDA_FFX_PC=1; with it, the same 4 calls are redirected.
  • gta6rt --dry-run game_scarlett_master.exe --game-dir <my package> --upscaler-picker 7E93F0 (executable SHA-256 e95020b2…a08993, the one in #6715): [rt] mods: upscaler picker at RVA 0x7E93F0 hooked, upscaler 7: 4 direct call(s) redirected (three calls and a tail jump, as counted statically). The dry run executes no image code.
  • gta6rt --dry-run on the retail executable through the real command line: 7E93F0,7 and 7E93F0,6 hook 4 calls; 7E93F0x, 7E93F0,6x, 7E93F0,, --view-mode-getter 7E93F0,1 and --archetype-lookup 7E93F0,2 print usage (exit 2); 7E93F1 logs "not hooked: no direct call to it" for all three options.
  • Not tested: the effect in game. The title doesn't reach its first frame under gta6rt yet (RT-5), so FSR at the Series X resolution is unmeasured; the render size per quality mode is the FFX wrapper's own.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464957637 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/153). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:30:01Z. --- > Carried over from **old PR 9885** by `AwkGrep256` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9885`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `AwkGrep256`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Resubmitted unchanged: this was `#7006`, closed at the repository's move to the organisation (the members-only switch, 22:25–22:49 UTC) with no review comment; reopening it is refused. Same branch and head (`0b55cf08b`), which merges cleanly on `main` `7e39a81ea`. The test reports from other contributors are on `#7006`. Claimed in the coordination issue as: https://github.com/ItsNotRexed/Leonida/issues/6750#issuecomment-7105596665 (FSR in the Series X render path). Depends on: `#9883` (the title's FFX calls answered by the PC upscaler; with `#9877`, `#9882`) for FSR to actually run on a PC. Related: `#9884` (the console type the title reads from the registry); this PR works without it. ### In short The game asks one question at startup: "which upscaler should I use?" It answers "FSR" only on a Series S (720p → 1080p) and "my own" on a Series X. This PR lets the runtime answer that question instead, so the game keeps its Series X resolution and settings but upscales with FSR. Nothing in the game file is changed: every call to that one function is redirected to a small thunk that returns "FSR". The FSR calls themselves then go to AMD's PC FSR through the upscaler shim (`#9883`). How to turn it on: run with the PC upscaler shim (`LEONIDA_FFX_PC=1` and `LEONIDA_FFX_DIR`), and either set `"enabled": true` in `mods/fsr_series_x/mod.json` or pass `--upscaler-picker 7E93F0`. Without `LEONIDA_FFX_PC=1`, FSR (kind 7) stays off either way and the log says why; another kind (e.g. `,6`) needs no shim. ### What and why A static look at my own copy of the 1.0.2.1 executable (nothing executed; only names, counts and the RVA here): - The title's FFX calls (`ffxCreateContext`, `ffxDestroyContext`, `ffxDispatch`, `ffxQuery`; no `ffxConfigure`) all come from one class with a single static instance. - A short function returns an upscaler object by number: that instance for **7**, another static for **6**, null otherwise. - The **picker** passes it its number: 7 only when the console type is Series S (type 6, from the registry `ConsoleMode`, see `#9884`) and the FFX path is available; otherwise 6. The console type is tested in 70 places, but never inside the FFX class, so the class doesn't gate itself. So a Series X configuration renders through the game's own upscaler, and FSR is tied to the Series S configuration (720p → 1080p). ### The change `gta6rt --upscaler-picker RVA[,KIND]` (hex RVA, decimal KIND, default 7) hooks the picker with the existing result-override thunk (`code_hooks.h`, as `--view-mode-getter`), so every pick returns `KIND`: the game keeps its Series X configuration and upscales through FFX, which `#9883` serves with AMD's PC upscaler. `leonida::mods::override_upscaler` / `upscaler_kind_slot` in `mods.h`; `docs/modding.md` gets an "Upscaler" section with the 1.0.2.1 RVA (`0x7E93F0`) and how to find it in another version. The setting (second commit): a mod's `"upscaler"` section (`"use"`: `"fsr"` or `"game"`, and `"picker_rva"`) does the same without the command line; the last enabled mod with one decides and `--upscaler-picker` wins over it. `mods/fsr_series_x` ships with it, **off by default**. FSR is only applied with `LEONIDA_FFX_PC=1`: without the PC upscaler shim the game's FFX calls would reach the package's console DLL, so the runtime leaves the game's choice and logs why. A menu to switch upscalers (an overlay, or later the game's own settings) and other backends (DLSS, XeSS through the same shim) are follow-ups once the game shows frames. **Review fixes (third commit):** the hook options are parsed in place by `leonida::mods::parse_hook_option` (no pointer into a destroyed temporary, nothing allowed after the last number), shared by `--upscaler-picker`, `--archetype-lookup` and `--view-mode-getter`; the archetype `ARG` is now refused unless 0 or 1. A hook that redirects no direct call logs `not hooked: no direct call to it (wrong RVA for this executable?)` instead of "hooked". ### Tested Windows cross-build (clang-cl + xwin) under Wine 11, CachyOS: - ctest `mods`: 41 checks, 0 failures (the parser: `RVA`, `RVA,KIND`, a 0x prefix; refused: `7E93F0x`, `7E93F0,6x`, `7E93F0,`, `,6`, `0`, a leading space or sign, `RVA,256`, an RVA past 32 bits). Earlier: 35 checks (new: no kind passes the game's choice through; `RVA,7` makes every pick 7; the `"upscaler"` section parses `fsr`/`game`, refuses an unknown upscaler or a missing/bad RVA, and the last enabled mod decides). - `--dry-run` with `mods/fsr_series_x` enabled: without `LEONIDA_FFX_PC` it logs `FSR upscaler not applied: it needs LEONIDA_FFX_PC=1`; with it, the same 4 calls are redirected. - `gta6rt --dry-run game_scarlett_master.exe --game-dir <my package> --upscaler-picker 7E93F0` (executable SHA-256 `e95020b2…a08993`, the one in `#6715`): `[rt] mods: upscaler picker at RVA 0x7E93F0 hooked, upscaler 7: 4 direct call(s) redirected` (three calls and a tail jump, as counted statically). The dry run executes no image code. - `gta6rt --dry-run` on the retail executable through the real command line: `7E93F0,7` and `7E93F0,6` hook 4 calls; `7E93F0x`, `7E93F0,6x`, `7E93F0,`, `--view-mode-getter 7E93F0,1` and `--archetype-lookup 7E93F0,2` print usage (exit 2); `7E93F1` logs "not hooked: no direct call to it" for all three options. - Not tested: the effect in game. The title doesn't reach its first frame under `gta6rt` yet (RT-5), so FSR at the Series X resolution is unmeasured; the render size per quality mode is the FFX wrapper's own. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MoonEyes commented 2026-11-30 19:28:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T19:28:25Z.


This is not merge-ready: it remains a draft and mergeStateStatus is DIRTY; all current checks are cancelled. Its FSR path also depends on the shim stack from #151/#150/#145, which remains blocked. The description cites an old-repository claim and obsolete dependency numbers; please add the current coordination item and use current PR references, then rebase and obtain fresh CI before review. The in-game effect remains explicitly untested, so keep that limitation visible rather than treating the dry-run as end-to-end validation.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7289450029 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/153#issuecomment-7289450029). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T19:28:25Z. --- This is not merge-ready: it remains a draft and `mergeStateStatus` is `DIRTY`; all current checks are cancelled. Its FSR path also depends on the shim stack from #151/#150/#145, which remains blocked. The description cites an old-repository claim and obsolete dependency numbers; please add the current coordination item and use current PR references, then rebase and obtain fresh CI before review. The in-game effect remains explicitly untested, so keep that limitation visible rather than treating the dry-run as end-to-end validation.
aslan2142 commented 2026-12-01 17:20:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:20:05Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319132959 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/153#issuecomment-7319132959). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:20:05Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!153
No description provided.