loader: opt-in RAGE 9 shadow/volumetric/tree/world-distance switches #114

Open
github-bot wants to merge 3 commits from github-bot/gh-113 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 12:47 UTC · original
SovietBearz0r:xmem-detail-switches → main · +7539 −474 · 58 files · 49 commits · draft

Add opt-in RAGE 9 force-value quality switches to the existing detail.rs patch pass (each off unless set): VICTORY_LOW_SHADOWS, VICTORY_SHADOW_CASCADES, VICTORY_SHADOW_DIST, VICTORY_LOW_VOLUMETRIC, VICTORY_TREE_TESS, VICTORY_ITER_TIER, VICTORY_WORLD_DIST_SCALE.

What

Ported from xmem PR #211 into main's crates/victory-loader/src/detail.rs, byte-checked through resolution::write and logged (detail: <what> (<value>) at title+<offset>: <Patched>):

  • LOW_SHADOWS 512/768/1024/1280/1536/2048 → GetShadowMapResolution at +0x1ce8bb0;
  • SHADOW_CASCADES 1–3 → store at +0x5705b63;
  • SHADOW_DIST low/min/1/on → both shadow-distance reads +0x5ad09fd/+0x5ad0a66;
  • LOW_VOLUMETRIC → 128 px / 7 mips at +0x1c9bea0;
  • TREE_TESS 0/off → mov cl,0 at +0x22436e9;
  • ITER_TIER 0/low → both tier reads at +0x2243767;
  • WORLD_DIST_SCALE 0.05–1.0 → scaled LOD table at +0x4fd06cb/+0x7453e24 (s=1.0 accepted).
    Three new pure parse/encode tests (every value set, encodings, displacement/NOP padding). Deliberate deviations: numeric shadow values only (xmem's word aliases dropped as ambiguous); SHADOW_DIST=0/off means off per our "off unless set" rule; the PR's VICTORY_SMALL_CULL widening and six switches already expressible through VICTORY_TITLE_QUALITY were left out.

Verification

  • cargo test -p victory-loader --lib -- --test-threads=1: 140 passed. (Parallel -p victory-loader runs hang in a pre-existing loader-lock deadlock between two unrelated tests, with or without this change — single-threaded is green.)
  • cargo check -p victory, cargo xtask policy, clippy on victory-loader (only main's pre-existing telemetry hex warnings): clean.
  • Needs in-game on 1.0.2.1: log should say patched (not Differs) per site; then A/B screenshots/draw counts for each switch. Hard-coded RVAs are byte-checked so a different build is a safe skip; WORLD_DIST_SCALE uses AVX (vshufps); if VICTORY_TITLE_QUALITY is also set, the force-value site wins for directional shadow quality.

Source: lobomfz/VIctory-xmem PR #211 (sites credited there to ToLIManl/VIctory-Hydra and HSgod/ps5-fpsunlocker-gta6).

**@⁠SovietBearz0r** on GitHub · 2026-12-05 12:47 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/113) `SovietBearz0r:xmem-detail-switches` → `main` · +7539 −474 · 58 files · 49 commits · draft Add opt-in RAGE 9 force-value quality switches to the existing `detail.rs` patch pass (each off unless set): `VICTORY_LOW_SHADOWS`, `VICTORY_SHADOW_CASCADES`, `VICTORY_SHADOW_DIST`, `VICTORY_LOW_VOLUMETRIC`, `VICTORY_TREE_TESS`, `VICTORY_ITER_TIER`, `VICTORY_WORLD_DIST_SCALE`. ## What Ported from xmem PR #211 into main's `crates/victory-loader/src/detail.rs`, byte-checked through `resolution::write` and logged (`detail: <what> (<value>) at title+<offset>: <Patched>`): - `LOW_SHADOWS` 512/768/1024/1280/1536/2048 → `GetShadowMapResolution` at `+0x1ce8bb0`; - `SHADOW_CASCADES` 1–3 → store at `+0x5705b63`; - `SHADOW_DIST` low/min/1/on → both shadow-distance reads `+0x5ad09fd`/`+0x5ad0a66`; - `LOW_VOLUMETRIC` → 128 px / 7 mips at `+0x1c9bea0`; - `TREE_TESS` 0/off → `mov cl,0` at `+0x22436e9`; - `ITER_TIER` 0/low → both tier reads at `+0x2243767`; - `WORLD_DIST_SCALE` 0.05–1.0 → scaled LOD table at `+0x4fd06cb`/`+0x7453e24` (`s=1.0` accepted). Three new pure parse/encode tests (every value set, encodings, displacement/NOP padding). Deliberate deviations: numeric shadow values only (xmem's word aliases dropped as ambiguous); `SHADOW_DIST=0/off` means off per our "off unless set" rule; the PR's `VICTORY_SMALL_CULL` widening and six switches already expressible through `VICTORY_TITLE_QUALITY` were left out. ## Verification - `cargo test -p victory-loader --lib -- --test-threads=1`: **140 passed**. (Parallel `-p victory-loader` runs hang in a pre-existing loader-lock deadlock between two unrelated tests, with or without this change — single-threaded is green.) - `cargo check -p victory`, `cargo xtask policy`, clippy on `victory-loader` (only main's pre-existing telemetry hex warnings): clean. - **Needs in-game on 1.0.2.1**: log should say `patched` (not `Differs`) per site; then A/B screenshots/draw counts for each switch. Hard-coded RVAs are byte-checked so a different build is a safe skip; `WORLD_DIST_SCALE` uses AVX (`vshufps`); if `VICTORY_TITLE_QUALITY` is also set, the force-value site wins for directional shadow quality. Source: lobomfz/VIctory-xmem PR #211 (sites credited there to ToLIManl/VIctory-Hydra and HSgod/ps5-fpsunlocker-gta6).
Port the seven force-value knobs of lobomfz/VIctory-xmem PR #211
(crates/victory-loader/src/detail.rs, GPL-3.0; head 95966c70) into the
detail.rs we already have: VICTORY_LOW_SHADOWS, VICTORY_SHADOW_CASCADES,
VICTORY_SHADOW_DIST, VICTORY_LOW_VOLUMETRIC, VICTORY_TREE_TESS,
VICTORY_ITER_TIER and VICTORY_WORLD_DIST_SCALE (1.0 accepted, as the
PR's own follow-up 62bb91e fixed).

They are applied in the same apply_asked pass as VICTORY_LOD_SCALE and
friends, each off without it, byte-checked before patching, said in the
log and on standard output when applied, and covered by pure parsing and
encoding tests. The other switches of that PR are left out: the ones our
VICTORY_TITLE_QUALITY editor already reaches (tree/volumetric/foliage
tiers, tessellation, shadow quality) are not duplicated, and only the
documented seven force-value knobs are in scope here.

The patch sites are credited in xmem to ToLIManl/VIctory-Hydra
(engine.rs, "Stage 14") and HSgod/ps5-fpsunlocker-gta6, verified against
game_scarlett_master.exe 1.0.2.1. Not run in game (GPU busy); CI gates
only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 12:50:23 +00:00
Author
Owner

@⁠ReTerryDavis on GitHub · 2026-12-05 17:38 UTC · original

Marking this as draft for now. This adds 7 raw-RVA opt-in env vars that haven't been verified in-game on 1.0.2.1 yet and heavily overlap existing VICTORY_TITLE_QUALITY / VICTORY_LOD_SCALE controls, plus a few concrete issues:

  • Inverted switch handling in asked_switch: VICTORY_TREE_TESS and VICTORY_ITER_TIER activate on 0/off, so passing =1 prints a bogus expected 0 or off error to stderr.
  • SUBSYSTEM_ITER_TIER (+0x2243767) zeroes [rsi+0x60], silently colliding with hairQuality in title_quality.rs.
  • world_dist_scale_code (+0x4fd06cb) mutates and broadcasts xmm0 where stock code preserved it — needs verification against 1.0.2.1 disassembly that xmm0 is dead past +0x4fd070c.
**@⁠ReTerryDavis** on GitHub · 2026-12-05 17:38 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/113#issuecomment-7442355134) Marking this as draft for now. This adds 7 raw-RVA opt-in env vars that haven't been verified in-game on 1.0.2.1 yet and heavily overlap existing `VICTORY_TITLE_QUALITY` / `VICTORY_LOD_SCALE` controls, plus a few concrete issues: - Inverted switch handling in `asked_switch`: `VICTORY_TREE_TESS` and `VICTORY_ITER_TIER` activate on `0`/`off`, so passing `=1` prints a bogus `expected 0 or off` error to stderr. - `SUBSYSTEM_ITER_TIER` (`+0x2243767`) zeroes `[rsi+0x60]`, silently colliding with `hairQuality` in `title_quality.rs`. - `world_dist_scale_code` (`+0x4fd06cb`) mutates and broadcasts `xmm0` where stock code preserved it — needs verification against 1.0.2.1 disassembly that `xmm0` is dead past `+0x4fd070c`.
- VICTORY_TREE_TESS and VICTORY_ITER_TIER are switches with no value now: 1/on/true/yes turns the patch on, 0/off/false/no (or unset) leaves the title's own. xmem's =0-for-on spelling is gone, so =1 no longer prints a bogus expected-0 error (unit-tested toggle).
- VICTORY_ITER_TIER is refused with a clear warning when VICTORY_TITLE_QUALITY asks for hairQuality: the site reads [rsi+0x60], that same settings member, and the two patches would fight over it. Moving the site needs disassembly this branch does not have; refusing is the safe side.
- world_dist_scale_code keeps xmm0: the factor is built in xmm1 and the table is the memory operand of the multiplies, so xmm0 is read and never written, as the title's code there keeps it. The replacement's bytes are pinned by test.
- In-game verification on 1.0.2.1 is still owed (all the switches, VICTORY_ITER_TIER in particular).
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 18:52 UTC · original

Fixed the parse/safety issues: VICTORY_TREE_TESS/VICTORY_ITER_TIER are true toggles now (1/on/true/yes enables; 0/off/false/no/unset leaves the title alone; the bogus "expected 0 or off" stderr is gone, truth-table tested). VICTORY_ITER_TIER now refuses with a clear warning when VICTORY_TITLE_QUALITY sets hairQuality, because its site reads [rsi+0x60], the same settings member (HAIR_QUALITY pinned by test) — I chose refusal over moving a byte-compared site without disassembly. world_dist_scale_code no longer writes xmm0: the scale² factor is built in xmm1 (which the title clobbers anyway), the table is a memory operand, and bytes are pinned by test. Staying draft: all seven switches still need 1.0.2.1 in-game verification, and whether a different instruction can carry ITER_TIER without touching [rsi+0x60] needs the title disassembly.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 18:52 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/113#issuecomment-7443511510) Fixed the parse/safety issues: `VICTORY_TREE_TESS`/`VICTORY_ITER_TIER` are true toggles now (`1/on/true/yes` enables; `0/off/false/no`/unset leaves the title alone; the bogus "expected 0 or off" stderr is gone, truth-table tested). `VICTORY_ITER_TIER` now **refuses** with a clear warning when `VICTORY_TITLE_QUALITY` sets `hairQuality`, because its site reads `[rsi+0x60]`, the same settings member (`HAIR_QUALITY` pinned by test) — I chose refusal over moving a byte-compared site without disassembly. `world_dist_scale_code` no longer writes `xmm0`: the scale² factor is built in `xmm1` (which the title clobbers anyway), the table is a memory operand, and bytes are pinned by test. Staying draft: all seven switches still need 1.0.2.1 in-game verification, and whether a different instruction can carry ITER_TIER without touching `[rsi+0x60]` needs the title disassembly.
Author
Owner

@⁠TrinityForever15 on GitHub · 2026-12-06 03:16 UTC · original

I ported these switches to a larp-based build and found a bug in VICTORY_WORLD_DIST_SCALE (world_dist_scale_code in crates/victory-loader/src/detail.rs). The last multiply is

vmulps xmm1, xmm1, xmm0   ; c5 f0 59 c8

It is a packed multiply, but the title only passes the input as a scalar in xmm0[0]. The code being replaced uses vmulss xmm1, xmm1, xmm0 for each of the three distances. Lanes 1 and 2 of xmm0 are 0.0 at that point, so LOD1 and LOD2 come out as 0. With the switch on, the open world falls to the lowest SLOD.

The fix I'm using: broadcast the scalar first, then multiply by a pre-scaled table:

vshufps xmm1, xmm0, xmm0, 0          ; c5 f8 c6 c8 00   (xmm1 = xmm0[0] x4)
movabs  rax, <table>                 ; 48 b8 imm64
vmulps  xmm1, xmm1, [rax]            ; c5 f0 59 08
mov     rax, [rdi]                   ; then the same vmovlps / vextractps stores

<table> is a 16-byte-aligned [t0²·s², t1²·s², t2²·s², 0.0], built once from the title's own table at WORLD_LOD_TABLE_RVA. It still clobbers only rax and xmm1. The unit tests that pin the current bytes (code[9..14] = vshufps xmm1, xmm1, xmm1, 0, code[30..34] = vmulps xmm1, xmm1, xmm0, and the count of that opcode) would need updating too.

I hit the original bug in play on an RX 6650 XT (Series S profile): the open world dropped to SLOD with the switch on. The fix above I verified by disassembly only. I haven't played with the switch on since the fix.

**@⁠TrinityForever15** on GitHub · 2026-12-06 03:16 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/113#issuecomment-7450565937) I ported these switches to a larp-based build and found a bug in `VICTORY_WORLD_DIST_SCALE` (`world_dist_scale_code` in `crates/victory-loader/src/detail.rs`). The last multiply is ``` vmulps xmm1, xmm1, xmm0 ; c5 f0 59 c8 ``` It is a packed multiply, but the title only passes the input as a scalar in `xmm0[0]`. The code being replaced uses `vmulss xmm1, xmm1, xmm0` for each of the three distances. Lanes 1 and 2 of `xmm0` are 0.0 at that point, so LOD1 and LOD2 come out as 0. With the switch on, the open world falls to the lowest SLOD. The fix I'm using: broadcast the scalar first, then multiply by a pre-scaled table: ``` vshufps xmm1, xmm0, xmm0, 0 ; c5 f8 c6 c8 00 (xmm1 = xmm0[0] x4) movabs rax, <table> ; 48 b8 imm64 vmulps xmm1, xmm1, [rax] ; c5 f0 59 08 mov rax, [rdi] ; then the same vmovlps / vextractps stores ``` `<table>` is a 16-byte-aligned `[t0²·s², t1²·s², t2²·s², 0.0]`, built once from the title's own table at `WORLD_LOD_TABLE_RVA`. It still clobbers only `rax` and `xmm1`. The unit tests that pin the current bytes (`code[9..14]` = `vshufps xmm1, xmm1, xmm1, 0`, `code[30..34]` = `vmulps xmm1, xmm1, xmm0`, and the count of that opcode) would need updating too. I hit the original bug in play on an RX 6650 XT (Series S profile): the open world dropped to SLOD with the switch on. The fix above I verified by disassembly only. I haven't played with the switch on since the fix.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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