d3d12-loader: Series S above 720p gets the other consoles' memory budgets (D3D12-SERIES-S-NATIVE-BUDGETS)

Series S at render scale 1.0 (1080p, `-SeriesS -Resolution 1080`, `play-S-1080p.ps1`) stopped the title at its own
breakpoint as soon as it started. The README listed it as "does not work yet". The title sizes two memory budgets per
console, both for Series S' own 2/3 scale, and at 1.0 each in turn is too small:

- The render-target pool, the third of nine pool sizes in the per-console table in .rdata: 1277 MiB on Series S,
  2199 MiB on the others. Its allocator treats a failed allocation as fatal, and a 1 MiB one failed.
- A heap counted in 64 KiB pages, `mov eax, 0x1290` then `cmovne` with 0x2c60: 297 MiB on Series S, 710 MiB on the
  others. A check compares a 432 MiB resource with it and stops at a breakpoint.

With a pinned render scale above 2/3, resolution_levers now writes the other consoles' sizes into both places. Only
Series S' row and its immediate change; the other consoles already hold such a scale. The retail-bytes test checks
both places and the other consoles' pool size.

RTX 3060, driver 621.40: Series S at 1080p ran five minutes into the world, rendering 1920x1080, at 11-22 fps, with
no crash. Before, it stopped about 8 s in, once at each budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alfredo Peres
2026-12-01 11:40:24 -03:00
parent 7f8bb90374
commit 29016670a0
2 changed files with 73 additions and 6 deletions

View File

@ -262,7 +262,7 @@ below.
Known faults left: the common room by its sunlit windows still goes beige and
hazy (sky light in the fog); smearing when the camera moves fast at half scale
(the title's own temporal upscaler); two orange glows on some corridor walls.
Render scale 1.0 on Series S has not been tested.
Render scale 1.0 on Series S runs since the loader gives two of its budgets the other consoles' sizes (below).
Also in, off by default:
@ -498,7 +498,7 @@ subtitles stay sharp either way. Series S outputs 1920x1080 and Series X
| Script | Console | World drawn at | Render scale | Tested on the RTX 5070 |
|---|---|---|---|---|
| `play-S-1080p.ps1` | Series S | 1920x1080 | 1.0 | **crashes at start** (the title stops at a breakpoint; also reported on an RTX 2080) |
| `play-S-1080p.ps1` | Series S | 1920x1080 | 1.0 | not yet; it crashed at start until the loader gave Series S larger budgets (below), and runs since on an RTX 3060 (11-22 fps in the world) |
| `play-S-720p.ps1` | Series S | 1280x720 | 0.667 | not yet |
| `play-S-540p.ps1` | Series S | 960x540 | 0.5 | yes: the default, about 18-22 fps |
| `play-S-480p.ps1` | Series S | 853x480 | 0.444 | not yet |
@ -524,9 +524,15 @@ What to expect:
- **Lower is softer and smears more.** The title's temporal upscaler rebuilds
detail from earlier frames. At low resolutions and low frame rates, fast
camera moves (driving, turning quickly) leave visible trails.
- **Series S at 1080p (render scale 1.0) does not work yet.** The title stops
at a breakpoint as soon as it starts, on a 12 GB card too, so it is not video
memory. Use 720p or lower on Series S.
- **Series S above 720p (render scale above 2/3) needs larger budgets.** The
title sizes two of its memory budgets per console, for Series S' own 720p:
its render-target pool (1277 MiB, 2199 on the other consoles) and a heap of
64 KiB pages (297 MiB, 710 on the others). At 1080p the first allocation that
does not fit stops the title at its own breakpoint as soon as it starts, on a
12 GB card too: it is not video memory. With a render scale above 2/3 on
Series S the loader gives both the other consoles' sizes
(`leonida-loader/src/hooks.rs`, `SERIES_S_LARGER`), and 1080p runs (RTX 3060,
2026-12-01: five minutes into the world, 1920x1080 rendered, 11-22 fps).
- Series S cannot go above 1080p: its output is 1080p, and the script says so
and stops if asked for more.
- **16 GB PCs: turned on for you, best with resizable BAR enabled.**

View File

@ -173,6 +173,41 @@ impl OwnedPatch {
}
}
/// Leonida: the title's memory pools come from a table of nine sizes per console (`.rdata`, the row at 0x6186250 for
/// Series S and the one 0x50 on for the other consoles, copied at start by the function at 0x1e1ced0). The third
/// is the pool whose allocator (`.data` 0x71c2808, made at 0x1e1d418) the render targets come from: 1277 MiB on
/// Series S, 2199 MiB on the others. A Series S render scale above its own 2/3 does not fit it: at 1.0 an
/// allocation of 1 MiB (64 KiB aligned) fails at the first pipelines and the allocator, which treats a failure as
/// fatal, stops the title at its breakpoint (0x2219650, called from 0x4fac40e). Given the other consoles' size, it
/// fits. With [`SERIES_S_TRANSIENT_HEAP`] too, Series S at 1080p ran five minutes into the world (RTX 3060,
/// 2026-12-01), where before both it stopped as soon as it started.
const SERIES_S_TARGET_POOL: Patch<'static> = Patch {
what: "Series S: the render-target pool as large as the other consoles'",
rva: 0x6186268,
expect: &[0x00, 0x00, 0xD0, 0x4F, 0x00, 0x00, 0x00, 0x00],
new: &[0x00, 0x00, 0x70, 0x89, 0x00, 0x00, 0x00, 0x00],
};
/// The second Series S budget such a scale outgrows: a heap counted in 64 KiB pages, 0x1290 (297 MiB) on Series S
/// and 0x2c60 (710 MiB) on the others (`mov eax, 0x1290` then a `cmovne` at 0x1d488ac, in the function at 0x1d488a0
/// that the start at 0x5b056a0 keeps in `.data` 0x75eaeb8). The check at 0x2473e83 compares a resource's size with it
/// and stops the title at the breakpoint at 0x2473e88 when it is larger: at scale 1.0 a size of 432 MiB, once the
/// pool above was large enough. Given the other consoles' count, it fits.
const SERIES_S_TRANSIENT_HEAP: Patch<'static> = Patch {
what: "Series S: the 64 KiB-page heap as large as the other consoles'",
rva: 0x1d488ac,
expect: &[0xB8, 0x90, 0x12, 0x00, 0x00],
new: &[0xB8, 0x60, 0x2C, 0x00, 0x00],
};
/// The Series S budgets a scale above its own 2/3 outgrows, given the other consoles' sizes.
const SERIES_S_LARGER: [&Patch<'static>; 2] = [&SERIES_S_TARGET_POOL, &SERIES_S_TRANSIENT_HEAP];
/// Whether a pinned render scale needs [`SERIES_S_LARGER`]: one above Series S' own 2/3.
fn needs_series_s_target_pool(scale: f32) -> bool {
scale > 2.0 / 3.0 + 1e-3
}
/// The upscaler choice: `mov eax, 6` (own upscaler) then `cmovne eax, ecx`
/// (FSR when the profile asks for it). NOPing the cmovne keeps 6.
const OWN_UPSCALER: Patch<'static> = Patch {
@ -428,6 +463,13 @@ pub(crate) unsafe fn resolution_levers(base: usize, hash: &blake3::Hash) -> usiz
// SAFETY: forwarded from this function's contract.
applied += usize::from(unsafe { apply(base, &p.borrowed()) });
}
// Only Series S' budgets change: the other consoles' hold such a scale already.
if needs_series_s_target_pool(scale) {
for p in SERIES_S_LARGER {
// SAFETY: forwarded from this function's contract.
applied += usize::from(unsafe { apply(base, p) });
}
}
}
None => tracing::warn!(text, "{RENDER_SCALE_ENV} wants a number in 0.2..=1.0"),
}
@ -646,9 +688,11 @@ mod tests {
let offset = s.file_offset as usize + rva - s.rva as usize;
&data[offset..offset + len]
};
for p in [&FSR_UPSCALER, &OWN_UPSCALER] {
for p in [&FSR_UPSCALER, &OWN_UPSCALER, &SERIES_S_TARGET_POOL, &SERIES_S_TRANSIENT_HEAP] {
assert_eq!(at(p.rva, p.expect.len()), p.expect, "{}", p.what);
}
// The other consoles' row: what the Series S pool is given.
assert_eq!(at(SERIES_S_TARGET_POOL.rva + 0x50, 8), SERIES_S_TARGET_POOL.new, "the other consoles' pool");
// The image's base does not matter to these: the vtable slot (a relocated pointer) is left out.
let scales = render_scale_patches(0, 0.5, true);
for p in output_patches(2560, 1440).iter().chain(scales.iter().filter(|p| p.rva != 0x6300ba8)) {
@ -667,6 +711,23 @@ mod tests {
/// The game step's loads are pointed from the title's 1/15 s at the constant asked for, the displacement
/// counted from the next instruction; the two constants are checked by bytes put back unchanged.
/// Series S' own scale and those below it keep the console's pool; any scale above it gets the larger one.
#[test]
fn only_a_scale_above_series_s_own_grows_its_target_pool() {
for scale in [0.3333, 0.5, 0.6, 0.6667, 2.0 / 3.0] {
assert!(!needs_series_s_target_pool(scale), "{scale}");
}
for scale in [0.75, 0.8, 1.0] {
assert!(needs_series_s_target_pool(scale), "{scale}");
}
assert_eq!(u64::from_le_bytes(SERIES_S_TARGET_POOL.expect.try_into().unwrap()), 1277 << 20);
assert_eq!(u64::from_le_bytes(SERIES_S_TARGET_POOL.new.try_into().unwrap()), 2199 << 20);
// The heap's page counts: 297 MiB on Series S, 710 MiB on the others.
let pages = |b: &[u8]| u32::from_le_bytes(b[1..5].try_into().unwrap()) as u64;
assert_eq!(pages(SERIES_S_TRANSIENT_HEAP.expect), 0x1290);
assert_eq!(pages(SERIES_S_TRANSIENT_HEAP.new), 0x2c60);
}
#[test]
fn the_game_step_loads_point_at_the_ceiling_asked_for() {
assert_eq!(parse_max_step(""), Some(None));