Make the dynamic resolution toggle work on game version 1.1.0

The menu exposed dynamic_res on 1.1.0, but its patch table had no fixres
set, so disabling it left the engine's 80/90/100 percent tiers active.
Patch the scale returned by the controller's common epilogue, matching
the existing 1.2.1 and 1.4.3 implementation. The configured render scale
remains the maximum size, and enabling dynamic resolution restores the
original controller live.

Extend the 1.1.0 differential patch tests across dynamic tiers and both
switch states, checking register, SIMD and flag preservation. All 51
sites and 889 spin back-edges match local ExeFS; 720 native/Unicorn cases
pass. All five runtime probes pass. Live off/on/off testing shows native
3440x1440, lower tiers when enabled, and 3440x1440 again when disabled.
This commit is contained in:
Marjaperse committed 2026-11-16 21:07:02 +02:00
1 parent f85058070e
commit 9d66735e73
4 files changed
+18 -6

No files matched your search

+5
View File
@@ -103,6 +103,11 @@ set pooloff TOTK_POOL_OFFSET_PATCH 1
site pooloff main 9b93a8 93407f22 2a1903e2
site pooloff main 9b93c4 8b39c101 8b394101
# Fixed scene tier: the 1.1.0 controller (main+0xce8d74, 1.2.1 main+0xcc26f4) returns its scale through w23 in
# the shared epilogue. res_dynres_live enables this set when dynamic_res is off, preserving the configured render_scale.
set fixres TOTK_FIXED_RES_PATCH 0
site fixres main ce9280 2a1703e9 52a7f009 # mov w9, w23 -> mov w9, #0x3f800000 (1.0f)
# Sun shadow map: the size rounded here is used for width (+0x3d8), height (+0x3f8) and viewport together.
# runtime/resolution.c shadow_init supplies the fixed size at page +92; the default remains the game's size.
site shadow main d0760c 11001d6b @page:x11 b9405d6b 11001d6b
+1 -1
View File
@@ -648,7 +648,7 @@ void res_fov_live(void) {
rt_log("resolution: field of view %d%% of the game's", pct);
}
// TOTK_DYNAMIC_RES = 0 holds the game's dynamic resolution at 100 % (recomp/patches-v121.txt and patches-v143.txt,
// TOTK_DYNAMIC_RES = 0 holds the game's dynamic resolution at 100 % (patches-v110.txt, patches-v121.txt and patches-v143.txt,
// set fixres), so the scene renders at the size render_scale chose. The game picks its tier (100, 90 or 80 %) mostly
// from a fixed cost model made for the Switch: one term grows with the object counts, one with (scene width / 1600)
// squared. The GPU time it also measures (two NVN report timestamps, a frame apart) only lowers that prediction when the
+11 -4
View File
@@ -30,6 +30,7 @@ SITES = [
('pooloff', 0x9b93a8, 2, 'offset'), ('pooloff', 0x9b93c4, 1, 'source'),
('shadow', 0xd0760c, 11, 'shadow'),
*[('cascade', a, 8, 'cascade') for a in (0x1157fb8, 0x1158040, 0x11580c8, 0x115814c)],
('fixres', 0xce9280, 9, 'fixed'),
]
@@ -74,7 +75,7 @@ def main():
words.append((orig, repl))
build = ROOT / 'build'
build.mkdir(exist_ok=True)
groups = {ratio: ([], []) for ratio in (1.0, 0.5, 0.25)}
groups = {ratio: ([], []) for ratio in (1.0, 0.9, 0.8, 0.5, 0.25)}
page = bytearray(0x1000)
# Distinct fields reveal an accidental load from the neighboring page slot.
for off, value in ((0, 0.5), (4, 1 / 60), (56, 21 / 9), (60, 1.2),
@@ -92,7 +93,7 @@ def main():
for k, (name, off, target, kind) in enumerate(SITES):
pc = base + off
for enabled in (0, 1):
for ratio in (1.0, 0.5, 0.25):
for ratio in groups:
for offset in (0, 0x7fffffff, 0x80000000, 0xffffffff):
mem = bytearray(initial)
struct.pack_into('<f', mem, 0x2008, ratio)
@@ -106,6 +107,8 @@ def main():
x = [0x1234567800000000 + i for i in range(31)]
for i in (8, 19, 20, 23, 27):
x[i] = BUF + 0x2000
if kind == 'fixed':
x[23] = 0xabcdef0000000000 | int.from_bytes(struct.pack('<f', ratio), 'little')
x[25], x[30] = offset, enabled
v = [(0x123456789abcdef << 32) | int.from_bytes(struct.pack('<f', 2.0), 'little')] * 32
v[1] = int.from_bytes(struct.pack('<f', 4.0), 'little')
@@ -129,12 +132,16 @@ def main():
elif kind == 'cascade':
slot = (64, 68, 72, 76)[(0x1157fb8, 0x1158040, 0x11580c8, 0x115814c).index(off)]
assert ex[target] == struct.unpack_from('<I', page, slot)[0]
elif kind == 'fixed':
assert ex[target] == 0x3f800000
# The stack save must preserve the complete x10, not just its lower word.
if name in ('aspect', 'fov'):
assert ex[10] == x[10]
allowed_x = {target} if kind in ('offset', 'source', 'shadow', 'cascade') else {9} if kind == 'map' else set()
elif kind == 'fixed':
assert ex[target] == x[23] & 0xffffffff
allowed_x = {target} if kind in ('offset', 'source', 'shadow', 'cascade', 'fixed') else {9} if kind == 'map' else set()
# Integer destinations do not authorize writes to the same-numbered SIMD register.
allowed_v = set() if kind in ('offset', 'source', 'shadow', 'cascade') else {0, 1} if kind == 'map' else {target}
allowed_v = set() if kind in ('offset', 'source', 'shadow', 'cascade', 'fixed') else {0, 1} if kind == 'map' else {target}
if enabled and kind in ('map', 'aim', 'gyro'):
allowed_v |= {16}
if kind == 'map':
+1 -1
View File
@@ -207,7 +207,7 @@
# render_scale = game
# Dynamic resolution: 1 lets the game lower the scene to 90 or 80 % of that size, 0 keeps it at 100 %. The game decides
# by a cost estimate made for the Switch, which grows with the scene's width and ignores how fast your GPU is: a
# scene wider than about 3000 pixels can drop to 80 % on any GPU. 1 is the default. 1.2.1 and 1.4.3. Changes in
# scene wider than about 3000 pixels can drop to 80 % on any GPU. 1 is the default. 1.1.0, 1.2.1 and 1.4.3. Changes in
# the menu take effect at once.
# dynamic_res = 1
# Scaling to the window when it is larger than the game resolution: fsr (AMD FSR 1) or bilinear, and FSR's sharpening