mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 12:58:38 +00:00
d3d12-loader: the Series S budgets for -Lowest too, both or neither, and a test that they land
Review of 29016670a (KelboLive):
- The budgets were applied only for a pinned LEONIDA_RENDER_SCALE. -Lowest 1080 on Series S sets
LEONIDA_RENDER_SCALE_MIN to 1.0, and the title renders at or above it. The minimum path now applies them too.
- They are written by series_s_budgets through apply_all, so a build where one place differs keeps the console's
own pair instead of a raised pool alone.
- the_series_s_budgets_are_written_both_or_neither writes them into an image buffer:
- both are written at 1.0 and at 0.75, and neither at 2/3 or 0.5;
- neither is written when the heap's place holds other bytes.
With the helper made to write nothing, it fails.
- The game-step test has its doc comment back. The threshold test is named for both budgets.
- The README says -Lowest is covered.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -530,7 +530,8 @@ What to expect:
|
||||
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
|
||||
Series S, held (`-Resolution`) or the dynamic resolution's lowest
|
||||
(`-Lowest`), the loader gives both the other consoles' sizes, both or neither
|
||||
(`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
|
||||
|
||||
@ -203,11 +203,29 @@ const SERIES_S_TRANSIENT_HEAP: Patch<'static> = Patch {
|
||||
/// 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 {
|
||||
/// Whether a render scale needs [`SERIES_S_LARGER`]: one above Series S' own 2/3, pinned (`-Resolution`) or the
|
||||
/// lowest of the title's dynamic resolution (`-Lowest`), which it renders at or above.
|
||||
fn needs_series_s_larger(scale: f32) -> bool {
|
||||
scale > 2.0 / 3.0 + 1e-3
|
||||
}
|
||||
|
||||
/// Writes [`SERIES_S_LARGER`] into the image at `base` when `scale` needs it: both budgets or neither, so a build
|
||||
/// where one place differs keeps the console's own pair. Returns how many places were written.
|
||||
///
|
||||
/// # Safety
|
||||
/// As `disarm_watchdog`.
|
||||
unsafe fn series_s_budgets(base: usize, scale: f32) -> usize {
|
||||
if !needs_series_s_larger(scale) {
|
||||
return 0;
|
||||
}
|
||||
let pair: Vec<OwnedPatch> = SERIES_S_LARGER
|
||||
.iter()
|
||||
.map(|p| OwnedPatch { what: p.what, rva: p.rva, expect: p.expect.to_vec(), new: p.new.to_vec() })
|
||||
.collect();
|
||||
// SAFETY: forwarded from this function's contract.
|
||||
unsafe { apply_all(base, &pair) }
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
@ -464,12 +482,8 @@ pub(crate) unsafe fn resolution_levers(base: usize, hash: &blake3::Hash) -> usiz
|
||||
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) });
|
||||
}
|
||||
}
|
||||
// SAFETY: forwarded from this function's contract.
|
||||
applied += unsafe { series_s_budgets(base, scale) };
|
||||
}
|
||||
None => tracing::warn!(text, "{RENDER_SCALE_ENV} wants a number in 0.2..=1.0"),
|
||||
}
|
||||
@ -484,6 +498,9 @@ pub(crate) unsafe fn resolution_levers(base: usize, hash: &blake3::Hash) -> usiz
|
||||
applied += usize::from(done);
|
||||
tracing::info!(min, applied = done, "the title's own dynamic resolution: its lowest render scale set, the scale above it left to the title ({RENDER_SCALE_MIN_ENV})");
|
||||
}
|
||||
// The title renders at this scale or above, so Series S needs the same budgets as when pinned.
|
||||
// SAFETY: forwarded from this function's contract.
|
||||
applied += unsafe { series_s_budgets(base, min) };
|
||||
}
|
||||
None => tracing::warn!(text, "{RENDER_SCALE_MIN_ENV} wants a number in 0.2..=1.0"),
|
||||
}
|
||||
@ -709,16 +726,14 @@ 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.
|
||||
/// Series S' own scale and those below it keep the console's budgets; any scale above it gets the larger pair.
|
||||
#[test]
|
||||
fn only_a_scale_above_series_s_own_grows_its_target_pool() {
|
||||
fn only_a_scale_above_series_s_own_grows_its_budgets() {
|
||||
for scale in [0.3333, 0.5, 0.6, 0.6667, 2.0 / 3.0] {
|
||||
assert!(!needs_series_s_target_pool(scale), "{scale}");
|
||||
assert!(!needs_series_s_larger(scale), "{scale}");
|
||||
}
|
||||
for scale in [0.75, 0.8, 1.0] {
|
||||
assert!(needs_series_s_target_pool(scale), "{scale}");
|
||||
assert!(needs_series_s_larger(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);
|
||||
@ -728,6 +743,38 @@ mod tests {
|
||||
assert_eq!(pages(SERIES_S_TRANSIENT_HEAP.new), 0x2c60);
|
||||
}
|
||||
|
||||
/// The budgets land in an image: both at a scale above 2/3, neither at Series S' own, and neither when one
|
||||
/// place holds other bytes (an image of zeros with the two places written, as far as the pool's place).
|
||||
#[test]
|
||||
fn the_series_s_budgets_are_written_both_or_neither() {
|
||||
let image = || {
|
||||
let mut bytes = vec![0u8; SERIES_S_TARGET_POOL.rva + 8];
|
||||
for p in SERIES_S_LARGER {
|
||||
bytes[p.rva..p.rva + p.expect.len()].copy_from_slice(p.expect);
|
||||
}
|
||||
bytes
|
||||
};
|
||||
let at = |bytes: &[u8], p: &Patch<'_>| bytes[p.rva..p.rva + p.expect.len()].to_vec();
|
||||
for (scale, written) in [(1.0, 2), (0.75, 2), (0.6667, 0), (0.5, 0)] {
|
||||
let mut bytes = image();
|
||||
// SAFETY: the buffer holds every place written; the patches only change bytes the buffer owns.
|
||||
let done = unsafe { series_s_budgets(bytes.as_mut_ptr() as usize, scale) };
|
||||
assert_eq!(done, written, "{scale}");
|
||||
for p in SERIES_S_LARGER {
|
||||
assert_eq!(at(&bytes, p), if written == 2 { p.new } else { p.expect }, "{scale}: {}", p.what);
|
||||
}
|
||||
}
|
||||
// The heap's place holds other bytes: the pool is left as it was too.
|
||||
let mut bytes = image();
|
||||
let heap = SERIES_S_TRANSIENT_HEAP.rva;
|
||||
bytes[heap] = 0x90;
|
||||
// SAFETY: as above.
|
||||
assert_eq!(unsafe { series_s_budgets(bytes.as_mut_ptr() as usize, 1.0) }, 0);
|
||||
assert_eq!(at(&bytes, &SERIES_S_TARGET_POOL), SERIES_S_TARGET_POOL.expect);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[test]
|
||||
fn the_game_step_loads_point_at_the_ceiling_asked_for() {
|
||||
assert_eq!(parse_max_step(""), Some(None));
|
||||
|
||||
Reference in New Issue
Block a user