Skip to content

d3d12: LEONIDA_TITLE_MEMORY_SCALE tells the title it has more of its console's memory (D3D12-TITLE-MEMORY-SCALE) - #2851

Open
x2Tweek wants to merge 2 commits into
ProjectLeonida:mainfrom
x2Tweek:d3d12-title-memory-scale
Open

x2Tweek wants to merge 2 commits into
ProjectLeonida:mainfrom
x2Tweek:d3d12-title-memory-scale

Conversation

@x2Tweek

@x2Tweek x2Tweek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-TITLE-MEMORY-SCALE (#2570 (comment))

What and why

At 3840x2160 output with -RayTracing and DLSS on Series X (with #2756 for a lit world through FidelityFX), the game runs at 0.1 to 0.2 fps. It is not the card or our submissions:

  • the frame line reads ~80 ms of our work for a 5,500-6,200 ms frame, and LEONIDA_GPU_TIMING=1 gives 63-78 ms on the card;
  • the card's clock line: about 2 % busy;
  • the frame account line: the process ran ~0.8 s user + 5.6 s kernel a frame;
  • the mapping line: ~2,900 changes of mapping a frame (the runtime's changes of mapping per frame), 3.9 s a frame holding title memory still. xmem's page-mapping counter shows the title mapping ~1.35 pages per call.

The same run at 2560x1440 output reads 0.9 changes a frame and 17 fps, and at 3840x2160 without DLSS 0.7 changes and 7-10 fps. The title seems to size its own pools from the limit it reads at the start (XMemGetWorkingSetStatistics, the adapter's description), and at 4K with ray tracing they no longer hold a frame, so it maps pages in and out one at a time.

This adds LEONIDA_TITLE_MEMORY_SCALE=<x> (1 unless set, clamped to 1-2.5): Console::title_memory returns the console's figures times that, in whole 2 MiB pages. Every reader of the figure (the working-set limit, XMemTransferMemory's cap, the adapter's description) sees the same value. Default behaviour is unchanged. The doc comment warns to keep it within what the PC has (at 2.5 a Series X title is told 34 GB and 25 GB of video memory).

Different from RS-WORKING-SET-STATS (the "used" figure the title gets); this is the limit.

Tested

On Windows 11 Pro 26300, from current main:

  • cargo test -p leonida-gpu --lib --locked console::: the two new tests pass (parse and bounds of the scale; scaling keeps whole pages and 1 leaves the figures as they are).
  • cargo test -p leonida-hle --lib --locked xmem: 24 passed (including transfers_shrink_the_title_budget).
  • tools/d3d12_switches.py --out then the new row only in d3d12/docs/switches.md.
  • In game, prison save, Series X, 3840x2160, DLSS quality (render 2560x1440), -RayTracing: scale 1: 0.1-0.2 fps, ~2,900 changes of mapping a frame; scale 2: 10.5 fps median, 2.0 changes a frame, picture correct (screenshot checked).
  • Same output without ray tracing, scale 1 against 2 by turns (ABBA, 2 min each in the cell): 41.2 / 41.3 against 41.5 / 41.2 fps: no change.

GPUs tested: NVIDIA GeForce RTX 5090 32 GB (resizable BAR), i9-14900KS, 64 GB DDR5, Windows 11 Pro 10.0.26300.

AI-assisted: yes. Claude Opus 5.5 wrote and measured it; a separate Claude Opus reviewer agent reviewed it before this pull request (its should-fix points are in: the old shortcut comment that said the title sizes nothing from this figure is reworded, and the host-memory warning added).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs 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)

🤖 Generated with Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

Verified on Windows: the crate is green with it, and it adds two tests - measured against main's own file.

main 3bf2844a5, cherry-picked (one commit, merge-base 76746d35b), cargo 1.98.1:

cargo test -p leonida-gpu --lib
  with this pull request:          ok. 601 passed; 0 failed; 55 ignored
  with console.rs from main:       ok. 599 passed; 0 failed; 55 ignored

So the two tests are tied to the change and nothing else in the crate moved. That is an existence control, not a mutation one - I did not remove the switch to watch a specific test fail, because the tests that come with it are the ones that would.

What matters for a new switch, and what this establishes: LEONIDA_TITLE_MEMORY_SCALE is reachable and its two cases pass. What it does not establish is that a title given a different memory scale behaves - that needs the game, and this machine does not have the build for it.

One thing worth adding to the pull request, since docs/switches.md now has its row: what happens when the title asks for more than the card has. The document's other switches say when they refuse; if this one saturates or refuses, the row should say so, and if it cannot happen because the value is clamped before it reaches the title, that is worth a sentence too.

AI-assisted: yes - DeepSeek v4.1 (flash), both arms on the machine above.

Written with an AI assistant.

@x2Tweek

x2Tweek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking it. Added in 5 lines of title_memory's doc comment: nothing refuses or saturates on account of the switch. The value is clamped to 1-2.5 before the title is told. The figure is only what the title is told: the runtime checks neither the PC's memory nor the card's against it. What the title then commits beyond what the PC has fails as any commit over Windows' limit does. The switches.md row is unchanged, since it shows the first sentences only.

On "a title given a different memory scale behaves": that part was measured in game (in the description). At 3840x2160 with ray tracing and DLSS, scale 2 takes the changes of mapping from ~2,900 to 2 a frame and the frame rate from 0.1 to 10.5 fps, with the picture correct. Without ray tracing, 1 against 2 by turns is 41.2 against 41.4 fps.

AI-assisted: yes, Claude Opus 5.5.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026
@x2Tweek
x2Tweek force-pushed the d3d12-title-memory-scale branch from f47974b to 586d02a Compare December 1, 2026 14:02
@github-actions github-actions Bot added needs rebase Conflicts with the base branch: rebase it on main and removed needs rebase Conflicts with the base branch: rebase it on main labels Dec 1, 2026

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified: scaled (console.rs:73-77) multiplies in f64, floors to 2 MiB pages, and all four constants are already page multiples — so scale 1 is a structural no-op, not just a tested one, and the 2.5 clamp caps at 25 GiB with no overflow path (f64 is exact at 2^34, saturating cast far above). title_memory() is the only source of the figure (dxgi.rs:154, xmem.rs:2316, :2358), nothing else hardcodes 10/3.5 GiB, and nothing reserves against it, so "advisory only" is accurate. Tests pass here (2 + 24) on this branch and on today's main, and both mutations are caught: clamp(1.0, 3.5) fails with left: 3.5, right: 2.5, and dropping the page floor fails with left: 838860, right: 0.

One thing before merge: merge-tree conflicts on d3d12/docs/switches.md. Main is at 673 names; 633 and this PR hand-bumps 664 → 665; the branch's own page is already three rows stale (this tree generates 668/627). Please drop the header edit and regenerate with --out at merge time (post-merge it is 674 names; 634). Note tools/d3d12_switches.py --check compares rows only, so a wrong count line sails straight through — which is exactly how the hand-bump got stale.

Optional, not a blocker: the clamp is absolute, so a 12 GB card can be told 25 GiB of video memory. Capping against QueryVideoMemoryInfo's budget would remove the "keep it within what the PC has" caveat and make the switch safe to leave on.

Not verifiable here: the headline in-game measurement (2,900 → 2 page-mapping changes/frame, 0.1–0.2 → 10.5 fps) and the no-RT null result — that needs the title and game data. The switch is reachable; only its effect is unmeasured on this machine. No file overlap with #2900 (different lever, semantically complementary).

qwen and others added 2 commits December 1, 2026 19:00
…console's memory (D3D12-TITLE-MEMORY-SCALE)

At 3840x2160 with ray tracing and DLSS on Series X the title's own pools no
longer hold a frame and it maps its pages one at a time: about 2,900 changes
of mapping a frame, 5.6 s of kernel time a frame, 0.1 fps. With 2 the same run
reads 2.0 changes a frame and 10.5 fps; without ray tracing nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…saturates on account of it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@x2Tweek
x2Tweek force-pushed the d3d12-title-memory-scale branch from 586d02a to b4e0a76 Compare December 1, 2026 18:00
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026
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.

3 participants