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

Open
github-bot wants to merge 5 commits from github-bot/gh-153 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:30 UTC · original
ubiquitarianism:old-pr/9885 → main · +245 −31 · 7 files · 5 commits · draft

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

**@⁠Andretuta** on GitHub · 2026-11-24 02:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/153) `ubiquitarianism:old-pr/9885` → `main` · +245 −31 · 7 files · 5 commits · draft > 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)
In 1.0.2.1 the game picks upscaler 7 (AMD's FFX upscaler) only on Series S
and 6 (its own) otherwise. The new option hooks that picker with the
result-override thunk (code_hooks.h), so a Series X configuration can
render through FSR via the PC upscaler shim. RVA 0x7E93F0 for 1.0.2.1:
a --dry-run redirects its 4 direct calls. docs/modding.md, ctest mods.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A mod can choose the upscaler ("use": "fsr" or "game") with the picker's
RVA for its executable version; --upscaler-picker still wins. FSR is only
applied with LEONIDA_FFX_PC=1, since without the PC upscaler shim the
game's FFX calls would reach the package's console DLL. ctest mods: 35.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/README.md lists modding.md; the README says how to turn
mods/fsr_series_x on. modding.md names the registry change by its PR
(#6990) instead of a file this branch doesn't have.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review by toeeshchaudhary on #7006: the --upscaler-picker parser (and the
--archetype-lookup one it copied) checked wcstoul's end pointer into a
temporary substr after it was destroyed. leonida::mods::parse_hook_option
parses "RVA" or "RVA,N" from the argument itself and refuses anything
after the last number; --view-mode-getter, --upscaler-picker and
--archetype-lookup use it (the archetype ARG is now refused unless 0 or 1,
where anything else silently meant 0). mods_test covers valid values and
trailing garbage.

JoaoPauluu: a hook that redirects no call logs "not hooked: no direct call
to it (wrong RVA for this executable?)" instead of "hooked", for all three.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	runtime/test/mods_test.cpp
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:46:36 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/src/main.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/153/head:github-bot/gh-153'
git switch 'github-bot/gh-153'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-153'
git switch 'github-bot/gh-153'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-153'
git switch 'github-bot/gh-153'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-153'
git switch 'main'
git merge --squash 'github-bot/gh-153'
git switch 'main'
git merge --ff-only 'github-bot/gh-153'
git switch 'main'
git merge 'github-bot/gh-153'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.