Skip to content

feat(oot): live output resolution up to the game's 2560x1440 swapchain - #1

Merged
Kolkka merged 1 commit into
Kolkka:feat/ootfrom
oxyp1e:oot/output-resolution
Nov 8, 2026
Merged

Kolkka merged 1 commit into
Kolkka:feat/ootfrom
oxyp1e:oot/output-resolution

Conversation

@oxyp1e

@oxyp1e oxyp1e commented Nov 8, 2026

Copy link
Copy Markdown

What

Live output resolution for Ocarina of Time, up to the game's own 2560x1440 swapchain. One commit on top of feat/oot (bd3e70e1).

The output size (layer render targets and the NVN crop) is DisplayConfig's base size cfg+0x10, written only by setBaseSize at main+0x1087f40. Two veneers, placed after the frame-step stub:

  • at setBaseSize's entry (original 29422408): every request takes the host's size;
  • in the per-frame cfg update at main+0x6502f8 (original 2941240b): calls setBaseSize when the request differs from the base.

The engine's own resize path (the one dock/undock uses: main+0x6549d0 → main+0x6531c0 → main+0x9cd030) then re-creates the targets, the crop follows, and the 3D scene follows the output every frame (still under the game's own dynamic resolution, 0.75 here). Both original words, the zero padding and the loader's parameter page are checked; any mismatch stops with runtime_fail.

  • Settings panel Resolution row, the resolution WxH input command and TOTK_OUTPUT_RES now work for OoT: 16:9, both sides multiples of 8, 640x360 up to 2560x1440; the panel only offers sizes that pass the same check (unit-tested; the final list was not checked on screen).
  • Default unchanged: the shipped 2048x1152. TOTK_OUTPUT_RES=0 skips the patch entirely (panel row shows fixed).
  • Aspect stays 16:9 (camera/UI aspect not analysed).
  • TOTK_OOT_DISPLAY_LOG=1 logs request vs. what setBaseSize was given; off by default.
  • runtime_output_size_valid is shared by the panel's choices and Custom input. Bananza's and Pokopia's acceptance rule is unchanged.

Analysis notes

  • setBaseSize writes a mode byte at cfg+0x18 from a table of standard sizes (1080p → 4, 1440p → 5; shipped 2048x1152 → 7). A search of every byte load at +0x18 and every route to cfg found no reader, and on its top tier the game itself outputs 1.0 × 2560x1440 (mode 5), so the natural value is kept.
  • Texture pool (DynamicTextureAllocatorMem) is a fixed 305 MiB from the heap table. Scene and layer targets come from it; a live resize frees the old layer targets before allocating. Resolution-dependent use scales 1.5625× from 2048x1152 to 2560x1440; no exhaustion seen. If it ever happens it fails immediately (null return), not gradually; growing the pool via the creation-arg memcpy at main+0xf2794c is mapped out but not needed so far.
  • Capped at 2560x1440 because that's the game's own swapchain (main+0x1202ee0); 4K would need that plus the pool.

How it was tested

  • Mac (Apple silicon, 24 GB, macOS 27, 5K display), game 1.0.0 (ExeFS main 7db9ddfd…), Kokiri Forest from a save: booted at 2560x1440 and switched live 2560x1440 ↔ 1920x1080 ↔ 960x540 repeatedly (earlier build) and 2560x1440 ↔ 1920x1080 (final build). Each request was taken by setBaseSize, the crop followed, no crash, ~20 min sessions. FPS at 1440p about the same as 2048x1152 (the game's dynamic resolution absorbs it).
  • Memory: system wired peaked 9.0 GB (final build, short session) and 13.5 GB (21 min, earlier build). That climb is host-side (it reached 11.9 GB at a steady 1440p before any switch; switches add no step). On a 16 GB Mac (12.3 GB guard) 1440p may trip the guard; the default stays 2048x1152.
  • make build/totk-native-oot, zero warnings. -fsyntax-only with the Makefile flags for GAME_DKB, GAME_POKOPIA, GAME_OOT (game_patches_ns2.c, input.c, frontend.m) and frontend.m for TotK default / V143. Preprocessed diff for Bananza and Pokopia shows no behaviour change. Bananza and Pokopia were not built or played (no dumps). iOS not built (OoT is Mac only; shared code compile-checked only).
  • python -m unittest tests.test_ns2_resolution tests.test_settings_panel tests.test_aspect tests.test_frame_lock: 12 OK. New tests run the real veneer words on stand-in setBaseSize/cfg-update stubs, and check runtime_output_size_valid per game.

Open

  • Whether the two setBaseSize callers (main+0x1087c68 display init, main+0x650600 per-frame update) can ever run concurrently: the veneer snapshots the request into one page slot. Believed single-threaded, not proven.

🤖 Generated with Claude Code

Ocarina of Time's output size (layer render targets and the NVN crop) is
DisplayConfig's base size, written only by setBaseSize at main+0x1087f40.
Two verified veneers redirect it to a host-chosen size: one at
setBaseSize's entry, one in the per-frame cfg update at main+0x6502f8 that
calls setBaseSize when the request changes, so the engine's own resize
path (the one dock/undock uses) re-creates the targets and the 3D scene
follows the output every frame. Both original words are checked, as is
the padding after the frame-step stub and the loader's parameter page.

The Resolution row in the settings panel, the "resolution WxH" input
command and TOTK_OUTPUT_RES now work for Ocarina of Time: 16:9, both
sides multiples of 8, from 640x360 up to the game's own 2560x1440
swapchain. The default stays the shipped 2048x1152 and TOTK_OUTPUT_RES=0
skips the patch. Aspect stays 16:9. TOTK_OOT_DISPLAY_LOG=1 logs request
vs. what setBaseSize was given (off by default).

runtime_output_size_valid is shared by the panel's choices and Custom
input; Bananza's and Pokopia's acceptance rule is unchanged.

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

Kolkka commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Tested on an M-series 16 GB Mac, game 1.0.0, Kokiri Forest: live 2048×1152 → 2560×1440 → 1920×1080 → 1280×720 → 640×360 → 2048×1152, all applied with a correct picture; invalid sizes rejected. About 14 s at 1440p, so long-session memory is still open.

@Kolkka
Kolkka merged commit 2311f0b into Kolkka:feat/oot Nov 8, 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.

2 participants