Skip to content

d3d12: leave FidelityFX maximum-size vtable patch off by default (D3D12-SERIESX-FSR-MAX-SCALED) - #2756

Merged
OreoFR merged 3 commits into
ProjectLeonida:mainfrom
IgorAntunes66:pr/seriesx-dlss-black-world
Dec 2, 2026
Merged

OreoFR merged 3 commits into
ProjectLeonida:mainfrom
IgorAntunes66:pr/seriesx-dlss-black-world

Conversation

@IgorAntunes66

@IgorAntunes66 IgorAntunes66 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-SERIESX-FSR-MAX-SCALED (#2570 (comment))

What and why

Fixes the black-world bug on Series X when upscaling through FidelityFX (LEONIDA_FSR_UPSCALER=1, DLSS or stretch) below render scale 1.0 (follow-up to ae217ceb in d3d12/docs/findings.md).

ender_scale_patches in d3d12/crates/leonida-loader/src/hooks.rs was unconditionally patching the FidelityFX upscaler's maximum-size vtable slot (x6300ba8, slot 11 -> slot 10's scaled-size function). When LEONIDA_RENDER_SCALE was below 1.0 on Series X, the title rendered the scene internally at the scaled size, ran fxDispatch to the output target, and then presented only the HUD over a completely black world.

This change leaves "render scale: FSR maximum = scaled size" off by default (kept opt-in via LEONIDA_FSR_MAX_SCALED=1 for diagnosis via parse_fsr_max_scaled), while preserving FSR_LOAD_S, FSR_LOAD_OTHER, and the title's own upscaler patches.

Follow-up kept out of this PR: removing the experimental warning and preserving the F1 menu's DLSS selection on Series X in d3d12/scripts/play-nvidia.ps1 can be proposed separately once verified across other output sizes (such as 3840x2160) and GPUs.

Tested

  • Unit tests (MEASURED): cargo test --locked -p leonida-loader (82 unit + 3 integration tests passed, including the new hooks::tests::the_fidelityfx_maximum_patch_is_left_out_by_default, which fails on main and passes here; covers parse_fsr_max_scaled for None, "0", and "1").
  • Before/after reproduction on the same save and camera framing (MEASURED, n=2 paired runs, diag build with diagnostics,dlss,mimalloc, Series X, -Dlss quality, -NoFrameGen, LEONIDA_OUTPUT=2560x1440):
    • Before (origin/main): patch "render scale: FSR maximum = scaled size" applied; DLSS created at 1706x960 -> 2560x1440 (quality=2); swapchain captures showed only the HUD over a completely black world (with 31 black-frame warnings).
    • After (this PR): patch "render scale: FSR maximum = scaled size" omitted; DLSS created and dispatched at 1706x960 -> 2560x1440 (quality=2); swapchain captures showed the full lit world rendered cleanly at the exact same framing (exitCode=0, no crash).
  • Asset policy check: diff touches only d3d12/crates/leonida-loader/src/hooks.rs (pure Rust source; no game data, keys, dumps, raw logs, or screenshots).

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (desktop, profile M), driver 621.40, Windows 11.

AI-assisted: yes (implementation: Gemini 4 Neon via Antigravity; independent separate reviewer agent: Gemini 4 Neon via Antigravity — approved).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled
    eeds rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — no translator change)

With LEONIDA_FSR_UPSCALER=1 and LEONIDA_RENDER_SCALE below 1.0 on Series X (DLSS or stretch), patching the FidelityFX upscaler's maximum-size vtable slot (0x6300ba8) to its scaled-size function caused the title to present only the HUD over a black world (investigated in 0ae217c). Leaving that patch off by default (opt-in via LEONIDA_FSR_MAX_SCALED=1) keeps the requested render scale while drawing and lighting the world at 1706x960 -> 2560x1440.
@KelboLive

Copy link
Copy Markdown
Contributor

Independent check on Windows (not the author), at 591bd23a7.

  • cargo test --locked -p leonida-loader --lib (shared warm target): 82 passed, 0 failed in 0.24 s.
  • hooks.rs only; no game run, so this covers compile + the loader crate's unit tests. The default-off behaviour of the FidelityFX maximum-size vtable patch is not exercised by the tests.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Rust 1.98.1 pinned.

AI-assisted: yes (opencode).

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flip itself is sound and the default is pinned: making it default-on fails exactly one test (hooks::tests::the_fidelityfx_maximum_patch_is_left_out_by_default, hooks.rs:625), the loader only writes that slot and the original function runs when off, and nothing else depends on 0x6300ba8. cargo test --locked -p leonida-loader is 82 + 2 + 1 passed, 0 failed here.

Two things must change before merge:

  1. The switch is undocumented. python -I tools/d3d12_switches.py --check d3d12/docs/switches.md is exit 0 on origin/main 86c30fcea and exit 1 on this head with missing from the page: LEONIDA_FSR_MAX_SCALED (the other six names are pre-existing base drift, gone after a rebase). Add a row: default off, only =1 turns it on (unlike LEONIDA_OWN_UPSCALER, which is presence-on), and when it applies (LEONIDA_RENDER_SCALE set and the own upscaler not forced).
  2. The gate is global while the evidence is one configuration. It applies whenever LEONIDA_RENDER_SCALE is set, so Series S' native FSR now loses the patch too, while the body measures one desktop GPU under the Series X profile (and "on Series X" there is a profile, not console hardware). Say what Series S does now, or measure it — the patch was introduced for that FSR path (193152d00).

Minor: only the parser is tested (None/"0"/"1" plus the flag into render_scale_patches); nothing drives the real env path in resolution_levers, and empty/other strings are untested, so the "unset means off" claim rests on a direct call rather than on the loader's own entry point.

TheStonedGamer added a commit to TheStonedGamer/mandy-fork that referenced this pull request Dec 2, 2026
- play-nvidia.ps1: a launcher switch only overrides the F1 menu's saved value
  when it changed since the last start (leonida-settings-cmdline.txt), so the
  menu's DLSS, render scale and frame generation stay between launches.
- play-nvidia.ps1: the menu's UPSCALER DLSS counts as asking for it on Series X,
  and it asks for the DLSS build.
- hooks.rs: the FidelityFX maximum-size patch is off by default
  (LEONIDA_FSR_MAX_SCALED=1 turns it on), from ProjectLeonida#2756: it
  left the world black on Series X with DLSS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@enlight3d

Copy link
Copy Markdown
Contributor

RUN (independent, in game): RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300). Head 591bd23 merged with git merge --no-ff onto main d741a9f and built with diagnostics,dlss,mimalloc (DLSS SDK v310.9.16 from the repository's script, target x86_64-pc-windows-msvc), against main d741a9f built the same way.

Red and green, off the game. The pull request's test does not compile on main (it calls the new API). The same assertion written with main's API fails there for the stated reason (default patches include the FSR maximum slot) and passes on the merge. cargo test -p leonida-loader on the merge: 86 of 86 pass. Two things not caused by this change: tests/load_probe.rs::loads_binds_and_calls_probe fails the same way on main here (the probe DLL is built with this machine's default GNU toolchain), and console_insn::tests::a_clzero_loop_becomes_plain_stores is flaky on main too.

In game. Series X profile, -Dlss <mode> -NoFrameGen, output 2560x1440 (LEONIDA_OUTPUT), standing at the save, the same warm data folder, a warm-up run per build first, then 600 s measured with nothing else running; captures at 120 and 300 s kept locally.

Build DLSS FSR maximum patch World Frame median / p90 Card busy
main quality, 1706x960 to 2560x1440 applied not lit: the HUD over a dark background at 120 and 300 s 32.0 / 36.5 ms 32.6 ms
this pull request quality, 1706x960 to 2560x1440 left out lit, in the cut scene at 120 s and in play at 300 s 32.7 / 37.4 ms 33.2 ms
this pull request balanced, 1536x864 to 2560x1440 left out lit 30.5 / 35.1 ms 31.0 ms

Verdict: PASS. On this card, with DLSS on the Series X profile, the change turns the dark world into a lit one, for 0.7 ms more than the dark frame.

AI-assisted: Claude Code (Claude Opus 5.5)

@enlight3d

Copy link
Copy Markdown
Contributor

Addendum to my RUN above, the output size it had not covered yet: the same merge, Series X, -Dlss quality -NoFrameGen with a 3840x2160 output (DLSS 2560x1440 to 3840x2160), the same warm data folder, 600 s measured. The world is lit at 120 s (cut scene) and 300 s (in play); frame median 44.1 ms, p90 49.0 ms, card busy 44.6 ms a frame; card memory at most 17.0 GB; no device loss, no "black frame" warning. So on this card the change holds at both output sizes and both modes tried (quality and balanced at 2560x1440, quality at 3840x2160).

@OreoFR

OreoFR commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR (RUN, AI-assisted: oreofr-agent): head 591bd23a71b6df6ed8b7f50fe073fef628e869d7 merged into current main 8422def759cda12c89f918438eeb8d53dd5972a6 (clean merge).

Red / green in game: RTX 4070 Laptop 8 GB, driver 621.40, Windows 11. Series X, DLSS quality, no frame generation, same data and pipelines for both runs.

Tests: cargo test -p leonida-loader on the merged tree: 93 passed, 0 failed.

This agrees with enlighted's 3090 result above: same fix on two cards.

Safe to merge into main?

  1. Merges cleanly into current main: yes.
  2. CI: not run yet. The two workflow runs (CI, No Game Data) are waiting for a maintainer's approval (first-time contributor).
  3. Off by default: the patch is now off by default, which is the fix.
  4. Repo checks (loader tests): green locally.
  5. Scope: one file, d3d12/crates/leonida-loader/src/hooks.rs.

Ready once a maintainer approves the CI runs and they are green.

@OreoFR

OreoFR commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Merging (oreofr-agent, with OreoFR's written OK as maintainer): head 591bd23a71b6df6ed8b7f50fe073fef628e869d7 merged into current main 8422def759cda12c89f918438eeb8d53dd5972a6 with no conflicts. CI green on the head. Checked in game on the RTX 4070 Laptop (comment above) and on enlighted's 3090: the world is lit in Series X with DLSS. Going into the merge queue with #2986.

@OreoFR
OreoFR added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 2, 2026
OreoFR and others added 2 commits December 2, 2026 06:30
The merge queue's tests found the page out of date once this branch met main.
Regenerated with tools/d3d12_switches.py after merging main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OreoFR

OreoFR commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

The merge queue took this out: on the merge with main, tests/test_d3d12_switches.py fails with d3d12/docs/switches.md is out of date ... missing from the page: LEONIDA_FSR_MAX_SCALED. The page lists every LEONIDA_* name in the code, and this PR adds one.

Fix: merge main, then run python -I tools/d3d12_switches.py --out d3d12/docs/switches.md and commit the page (3 lines added, 2 removed). With that, python -I tests/test_d3d12_switches.py passes here (20/20). Once it is pushed, the PR goes back into the queue.

@OreoFR

OreoFR commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Merging again (oreofr-agent, with OreoFR's written OK): head 5b005f8bb9bae6588e867d511ff395250b0d1595 = the verified 591bd23a7 + main 8422def75 merged in + d3d12/docs/switches.md regenerated (the page the queue's tests found out of date). No code change since the in-game check. CI green on this head; back into the merge queue.

@OreoFR
OreoFR added this pull request to the merge queue Dec 2, 2026
Merged via the queue into ProjectLeonida:main with commit f37c4a8 Dec 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants