Skip to content

widescreen: support narrow landscape Unlocked aspect ratio (#474) - #504

Merged
mamcjr merged 1 commit into
mamcjr:mainfrom
Propinbo:feat/fullscreen-narrow
Nov 20, 2026
Merged

mamcjr merged 1 commit into
mamcjr:mainfrom
Propinbo:feat/fullscreen-narrow

Conversation

@Propinbo

@Propinbo Propinbo commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses #474 by enabling full-height Unlocked aspect rendering on narrow landscape displays (9/16 <= shape < 1, such as 16:10 tablets, 3:2, 4:3, 1:1, and unfolded foldables) while leaving portrait screens (dw < dh), 16:9, 20:9 ultrawide, Original aspect mode, and unhooked game versions (!reshape_allowed) unchanged.

Default behavior & rollback: Selecting Unlocked in Video settings automatically applies Vert+ narrow-landscape framing on narrow landscape displays (16:10, 4:3, etc.); switching Aspect back to Original restores stock 16:9 letterboxing immediately (LARECOMP_NARROW_HOR_MINUS=1 and LARECOMP_NO_SCOPE_BARS=1 remain available as env fallbacks).

Changes

  • Output & shape policy (runtime/nvn/output_scale.c, runtime/nvn/vulkan/device.c):
    • Reshapes narrow landscape windows (shape in [9/16, 0.995) when dw >= dh, or explicit LARECOMP_WIDE_TEST >= 9/16) while keeping portrait (dw < dh), [0.995, 1.005] deadband, Original mode, and unhooked versions (!reshape_allowed) at 16:9 letterbox.
    • Keeps [0.995, 1.005] deadband and 9/16 portrait boundary identical across output_scale.c and device.c, guards non-positive/non-finite dimensions, and parses env overrides once.
  • Camera, zero-creep FOV preservation, HUD & crop state (runtime/hle/widescreen.c):
    • Expands vertical FOV via Vert+ (tan_new = tan(orig_fovy / 2) / shape), leaving p[2] (mAngle) untouched while storing orig_fovy alongside scaled_{sin,cos,tan,aspect} checked by trig_scaled_match() and a same_nf stack-reuse guard. Because mAngle is preserved and trig_scaled_match() recognizes already-scaled projection entries (updating near/far without rescaling), repeated frames, camera blends, zooms, and paraglider transitions cannot compound-scale or creep FPS/FOV.
    • Replaces the 64-entry FIFO camera table with a 256-slot LRU table using C11 _Atomic state, single-snapshot readers, dynamic near/far tolerance, address-reuse invalidation, full mAspect restoration across dynamic resizes (narrow <-> 16:9 / portrait / ultrawide), lock-free steady-state rt_persp_aspect(), and RT_ON_RESET(widescreen_reset).
    • Adapts HUD vertical anchoring (widescreen_hud_anchor()) for top/bottom strips (y >= 260 && (x < -120 || x > 290) so multi-row hearts don't split), isolates far-left Rune/D-pad/Champion columns (y >= 170 && x < -460) without moving interior 3D enemy HP bars, and exposes widescreen_cropped() so Title and Sheikah Scope use symmetric 16:9 cropping (LARECOMP_NO_SCOPE_BARS=1 opt-out).
  • Vulkan UI, covers, bands & map (runtime/nvn/vulkan/exec.c):
    • Scales UI projections vertically, preserves condensed (!fixed) text proportions, skips the draw_() fminf viewport box on narrow ui_layout draws, and adapts nn::ui2d full-screen covers, blurred backdrops, and loading-screen top/bottom color bands using cb3[33] (w, h, left, top) bounds with finiteness, pane size, and off-screen guards.
    • Adapts map terrain/markers only inside menus when uncropped, and gates widescreen_band_seen() on !widescreen_in_menu() so HUD anchors react immediately on menu close.
  • Tests (tools/test_fullscreen_narrow.py, tools/test_rt_load_upload.c):
    • Adds host unit & negative-control harness (-Wall -Wextra -Werror, 0 warnings) covering output_scale.c, device.c, widescreen.c, exec.c, 16:9/20:9 regressions, 60-frame FOV zero-creep verification, dynamic resizes, 1:1/4:3 stack reuse, 300-camera LRU, PROT_NONE 64-byte text UBO OOB guard, tall_ui viewport bypass, g_wide_backdrop, --wide-test, and 10 --negative-control modes.
    • Adds the 4 widescreen_* link stubs referenced by exec.c in tools/test_rt_load_upload.c (tools/patches.py, runtime/gamelib.h, and .gitignore remain untouched).

Rollback / Zero-Overhead Guarantee

  • Original aspect mode (and non-narrow 16:9 / 20:9 / portrait surfaces) bypasses narrow-landscape projection/UI adaptation; setting Aspect back to Original restores stock 16:9 letterboxing. LARECOMP_NARROW_HOR_MINUS=1 and LARECOMP_NO_SCOPE_BARS=1 provide env fallbacks for Vert+ and 16:9 scope cropping.

Isolated On-Device Verification (Exact v0.4.8-beta Commit 186ea04)

Environment: Galaxy Tab S11 (SM-X730), Android 16, Mali-G925-Immortalis MC12 (vendor 0x13b5, device 0xd8300010, driver-id 9, v1.r49p1-03bet0.f8a98b506b89b21c80a508d70abfcb3f), BOTW 1.9.0, upstream base 2b71a10 (v0.4.8-beta), commit 186ea04 (built from identical tree 6668c01, debug APK 9c4c071600e3), native 2560x1600 (16:10), USB-powered (plugged: 2, no off-charger power claims made).

Verbatim startup & runtime log proof (Unlocked, LARECOMP_LOG_ASPECT=1):

[vk-cap] gpu Mali-G925-Immortalis MC12 vendor 0x13b5 device 0xd8300010 api 1.3.278 driver-id 9 name Mali-G925-Immortalis MC12 info v1.r49p1-03bet0.f8a98b506b89b21c80a508d70abfcb3f
[vk] swapchain: surface 2560x1600 transform 0x1, window 2560x1600, present mode 1, images 5-80
[widescreen] frame 0: window 2560 x 1600
[widescreen] projection 33ffff440: aspect 1.6000 fovy 40.0 -> 44.0 deg (mAngle preserved)

Official 30 FPS benchmark.c (Unlocked 16:10 Vert+, warmup_s=8, calm_s=2, window_s=6, 181 frames/scene)

Scene Config FPS 1% low Frame p50 / p99 GPU p50 / p95 RT p50 / p95 Headroom p50
plateau Unlocked (16:10 Vert+, 186ea04) 30.00 29.52 33.34 / 33.85 ms 26.67 / 33.64 ms 17.73 / 20.43 ms 6.66 ms
zora-plaza Unlocked (16:10 Vert+, 186ea04) 30.00 29.57 33.34 / 33.78 ms 27.56 / 33.49 ms 17.49 / 21.30 ms 5.77 ms

(For visual comparison against Original 16:9 letterbox, baseline Original captures from 25ebfb6 (30.00 fps) are shown alongside exact v0.4.8-beta commit 186ea04 Unlocked captures below.)

Visual Comparison (SM-X730 2560x1600)

Scene Original (16:9 letterbox baseline) Unlocked (16:10 Vert+, 186ea04)
Great Plateau plateau original plateau unlocked
Zora's Domain zora original zora unlocked

Additional Unit & Build Checks (186ea04)

  • Host/WSL (test_fullscreen_narrow.py, -Wall -Wextra -Werror): PASS, including --wide-test -0.5, 0.5, 0.5625, 0.75, 0.996, 1.25, inf and 10/10 --negative-control detections (camera, ui, anchor, map, crop, band, crop_title, oob_guard, tall_ui, backdrop); WSL -fsanitize=thread passed on 25ebfb6 (0 races).
  • Host NDK r30 Python suites: test_vulkan_compat.py (16), test_vulkan_startup.py (33), test_shader_cache.py (17), test_soft_linear.py (23 C + 3 SPIR-V + 203 math), test_gpu_timing_trace.py (8), test_command_snapshot.py, test_pipeline_cache_save.py: PASS.
  • Android Bionic (SM-X730, tools/test_android_runtime.ps1): 7/7 PASS; :app:assembleDebug --no-daemon BUILD SUCCESSFUL.

Tested vs Untested GPU Matrix

Target Status Notes
ARM Mali-G925 (SM-X730, r49p1, 2560x1600 16:10) Tested on hardware Exact v0.4.8-beta commit 186ea04: Unlocked benchmark + (mAngle preserved) logs + screenshots + Bionic 7/7
4:3 / 3:2 / 1:1 / 20:9 / -0.5..inf shapes Host + --wide-test verified Covered in test_fullscreen_narrow.py (incl. 60-frame zero-creep and 1:1 stack reuse)
Adreno (Turnip / Qualcomm stock), Mali < r49, unfolded foldables, Desktop Untested on physical hardware Guarded by unit tests & reshape_allowed / aspect bounds; Original and 16:9/20:9 logic unchanged

@mamcjr

mamcjr commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks! I tested it on the POCO with LARECOMP_WIDE_TEST=0.9 and 0.75: the world is right (Vert+, the HUD in the corners). I still need to check the map, the inventory with the 3D Link, the scope and the FOV transitions (bow, scope, paraglider), so I'll hold it until then. Two notes: it isn't opt-in (every 16:10 tablet and 4:3 screen gets Vert+ instead of bars, with Original as the way back), which is fine but should be in the PR text; and it rewrites the camera's stored fovy/sin/cos/tan, not only its aspect. If the game derives a new fovy from the current one (zoom, paraglider, cutscene blends), please make sure it can't creep.

Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 20, 2026
Enable full-height unlocked rendering on narrow landscape displays (9/16 <= shape < 1, such as 16:10, 3:2, 4:3, 1:1, and unfolded foldables) while keeping portrait (dw < dh), 16:9, and ultrawide (> 1) behavior unchanged.

- Output/aspect reshaping (runtime/nvn/output_scale.c, runtime/nvn/vulkan/device.c): accept narrow landscape ratios in [9/16, 0.995) when dw >= dh (or explicit LARECOMP_WIDE_TEST >= 9/16), keep [0.995, 1.005] deadband and portrait guard consistent between both files, and sanitize env overrides once.
- Camera/HUD state (runtime/hle/widescreen.c): expand 3D perspective vertically via Vert+ (or Hor- with LARECOMP_NARROW_HOR_MINUS=1), preserve mAngle untouched while tracking orig_fovy and scaled sin/cos/tan/aspect across frames to prevent FOV creep during camera blends, maintain seen projections in a 256-entry LRU with C11 atomics and RT_ON_RESET cleanup, restore aspect cleanly on dynamic resize, adapt UI projection and HUD vertical/strip anchors without splitting upper heart rows or shifting interior 3D enemy HP bars, and apply symmetric 16:9 vertical crop on Title and Sheikah Scope.
- Vulkan UI/cover/band adaptation (runtime/nvn/vulkan/exec.c): adapt map terrain and full-screen fades/backdrops/top-bottom cover bands using nn::ui2d cb3[33] (w, h, left, top) layout bounds with finiteness and off-screen guards, adapt condensed text, and gate draw_() UI viewport box skipping to narrow UI layouts.
- Tests (tools/test_fullscreen_narrow.py, tools/test_rt_load_upload.c): add host unit/negative-control test suite (-Wall -Wextra -Werror, 10 negative controls, 60-frame FOV creep check, tall_ui/backdrop tests) and required widescreen_* link stubs for Android Bionic unit builds.
@Propinbo
Propinbo force-pushed the feat/fullscreen-narrow branch from 25ebfb6 to 186ea04 Compare November 20, 2026 14:17
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 20, 2026
@Propinbo

Copy link
Copy Markdown
Contributor Author

Updated in 186ea04 (rebased onto v0.4.8-beta 2b71a10):

  1. PR text: Called out upfront that Unlocked applies narrow-landscape Vert+ automatically on 16:10 / 3:2 / 4:3 / 1:1 / foldables, with Original as the immediate rollback (LARECOMP_NARROW_HOR_MINUS=1 and LARECOMP_NO_SCOPE_BARS=1 remain env fallbacks).
  2. Zero fovy creep guarantee (runtime/hle/widescreen.c): rt_persp_update() now preserves p[2] (mAngle) unmodified and stores orig_fovy alongside scaled_{sin,cos,tan,aspect}, checked via trig_scaled_match() and a same_nf stack-reuse guard so blends, zooms, paraglider, and fixed-angle slots update near/far without ever compound-scaling. Added a 60-frame creep test and 1:1/4:3 stack-reuse check to tools/test_fullscreen_narrow.py (10/10 negative controls pass under -Wall -Wextra -Werror).
  3. Updated SM-X730 (Mali-G925 r49p1, 2560x1600, BOTW 1.9.0, 186ea04): Logs confirm (mAngle preserved); benchmark.c 30 FPS stays locked (30.00 fps, 1% low 29.52 Plateau / 29.57 Zora), updated Plateau & Zora screenshots are linked in the PR description, and Bionic 7/7 passes.

Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 20, 2026
@mamcjr
mamcjr merged commit 5df9dd9 into mamcjr:main Nov 20, 2026
@mamcjr

mamcjr commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks for the creep guard and the test. On the POCO with LARECOMP_WIDE_TEST=0.9 and 0.75 (all three PRs together, 1.9.0): the world is Vert+ with the HUD in the corners, the map fills the narrow window with its markers on their places, the inventory fits with the 3D Link undistorted, bow aiming and the scope look right (the scope's vertical lines are there at 16:9 too), and nothing crashed. I didn't test the paraglider. Merged, thanks!

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