Repository navigation
Conversation
77eb948 to
c997121
Compare
a0fc1e3 to
0781016
Compare
6066d4b to
1bba1a4
Compare
75b0d21 to
6bcf057
Compare
…ed by the build's rewriter table A stub in a profile's patches.py (an entry in FRAME_STEP) can replace the game's own output size with the host's. The build then names itself in main's rewriter table: the stub sets ctx.keys (OUTPUT_W / OUTPUT_H, the game's own size), patch_nso.py writes them as rows of the fixups table, and the loader reads them into module_t (out_w / out_h). dm_fps_state_apply writes DM_OUTPUT_SIZE (WxH from 640x360 to 7680x4320, 1080p, 1440p or 4k) to the state page at +0x40 (u64 width | height << 32) and +0x48 (float width) only for such a build, and refuses it with a red line for any other, so no other game's state page is touched and no game's size is in the host. The state page the loader checks grows from 0x40 to 0x50 bytes. Names and form are those of draft PR seedds#76 (Breath of the Wild above 60 fps and 1080p), whose general part this is without its variable frame step, render buffer pool and view sizes, so seedds#76 can rebase onto it. Checked: main of Breath of the Wild 1.9.0 (the one build here with frame-step stubs), Mario Kart 8 Deluxe 4.0.0 and Super Smash Bros. Ultimate 13.0.5 rewrites byte-identically to upstream (patched main, cuts, fixups, gates, obs and sites; only build_src.sha256 differs, the hash of the rewriter's sources); the host unit tests pass with Hades's, Breath of the Wild's and Super Mario Bros. Wonder's profiles; the Mac host builds. Not checked: Tears of the Kingdom, Age of Calamity and Paper Mario: The Thousand-Year Door (their NSPs are not here; their stubs set no keys, and the larger state page bound only moves an assert that still holds within the page)
…ed by the build's rewriter table A stub in a profile's patches.py (an entry in FRAME_STEP) can replace the game's own output size with the host's. The build then names itself in main's rewriter table: the stub sets ctx.keys (OUTPUT_W / OUTPUT_H, the game's own size), patch_nso.py writes them as rows of the fixups table, and the loader reads them into module_t (out_w / out_h). dm_fps_state_apply writes DM_OUTPUT_SIZE (WxH from 640x360 to 7680x4320, 1080p, 1440p or 4k) to the state page at +0x40 (u64 width | height << 32) and +0x48 (float width) only for such a build, and refuses it with a red line for any other, so no other game's state page is touched and no game's size is in the host. The state page the loader checks grows from 0x40 to 0x50 bytes. Names and form are those of draft PR seedds#76 (Breath of the Wild above 60 fps and 1080p), whose general part this is without its variable frame step, render buffer pool and view sizes, so seedds#76 can rebase onto it. Checked: main of Breath of the Wild 1.9.0 (the one build here with frame-step stubs), Mario Kart 8 Deluxe 4.0.0 and Super Smash Bros. Ultimate 13.0.5 rewrites byte-identically to upstream (patched main, cuts, fixups, gates, obs and sites; only build_src.sha256 differs, the hash of the rewriter's sources); the host unit tests pass with Hades's, Breath of the Wild's and Super Mario Bros. Wonder's profiles; the Mac host builds. Not checked: Tears of the Kingdom, Age of Calamity and Paper Mario: The Thousand-Year Door (their NSPs are not here; their stubs set no keys, and the larger state page bound only moves an assert that still holds within the page)
…e frame, the 1/240 s floor kept in real time (review of seedds#76) - After a cutscene or a prerendered movie the variable step started from the last variable frame's start, so the first frame stepped the whole time the whole-vsync frames had stepped already (8.333 ms at 120, then 50 ms after a second of them). vstep_off now resets it, and the first frame after the reset takes one frame at the cap. - VFR::updateInterval's stub (main+0x151d484) read the host's step at state +0x50 in both of a frame's calls, and the host writes it on the presenting thread, which can come between them. The setWaitVsyncInterval stub (main+0x11269b8, once a frame in the main loop) now latches it at +0x54, which the VFR stub reads, as the whole-vsync step is latched through the setter. - The floor of 1/240 s raised short intervals: at 240 on a 360 Hz screen the display link's virtual ticks lie 2.78 and 5.56 ms apart in turn, and the game ran at 1.17 of real time. The time the floor adds is now carried into the next steps (bounded by the longest step), so game time keeps real time; the longest step (1.5) still slows the game down, as on the Switch. The step's arithmetic moves into nvn_fstep.h (nvn_vstep_next / nvn_vstep_reset), so t_fstep checks it: steady 120, 120 on 144 Hz and 240 on 360 Hz at 1.000 of real time, one frame at the cap after a second of whole-vsync frames, at most 1.5 for a 60 ms frame (57 checks). The variable step and the render buffer pool grown with the render scale are entries in docs/reference/frame-rate.md and memory.md, linked from Breath of the Wild's note; the symptom index is regenerated. The rewritten main's two stubs were checked by disassembly.
…n's menu-repeat stub (main+0xeb0f88), which seedds#76 no longer patches itself
|
@v0lumehi stacked the iOS gate onto botw-uncap as you suggested: v0lumehi#2. One loader change (the ceiling is what fits a 6 GB reservation, so BotW gets 3.0 on iOS too) plus the two doc lines. Checked on an iPad Pro M4 at 1.40 with the pool doubled. |
d4544df to
ecba067
Compare
…e frame, the 1/240 s floor kept in real time (review of seedds#76) - After a cutscene or a prerendered movie the variable step started from the last variable frame's start, so the first frame stepped the whole time the whole-vsync frames had stepped already (8.333 ms at 120, then 50 ms after a second of them). vstep_off now resets it, and the first frame after the reset takes one frame at the cap. - VFR::updateInterval's stub (main+0x151d484) read the host's step at state +0x50 in both of a frame's calls, and the host writes it on the presenting thread, which can come between them. The setWaitVsyncInterval stub (main+0x11269b8, once a frame in the main loop) now latches it at +0x54, which the VFR stub reads, as the whole-vsync step is latched through the setter. - The floor of 1/240 s raised short intervals: at 240 on a 360 Hz screen the display link's virtual ticks lie 2.78 and 5.56 ms apart in turn, and the game ran at 1.17 of real time. The time the floor adds is now carried into the next steps (bounded by the longest step), so game time keeps real time; the longest step (1.5) still slows the game down, as on the Switch. The step's arithmetic moves into nvn_fstep.h (nvn_vstep_next / nvn_vstep_reset), so t_fstep checks it: steady 120, 120 on 144 Hz and 240 on 360 Hz at 1.000 of real time, one frame at the cap after a second of whole-vsync frames, at most 1.5 for a 60 ms frame (57 checks). The variable step and the render buffer pool grown with the render scale are entries in docs/reference/frame-rate.md and memory.md, linked from Breath of the Wild's note; the symptom index is regenerated. The rewritten main's two stubs were checked by disassembly.
…n's menu-repeat stub (main+0xeb0f88), which seedds#76 no longer patches itself
…ants in the host Builds tell the loader which further stubs they have through main's rewriter table (ctx.keys of the stubs in the profile's patches.py): VAR_STEP, RENDER_POOL and the base sizes VIEW_W / VIEW_H / OUTPUT_W / OUTPUT_H. The loader writes the state page fields beyond +0x40 only for such a build, so AoC's +0x28 and TOTK's +0x8 are never touched and no heap size or base width of one game is in the host. The page grows to 0x60 bytes. Breath of the Wild's stubs are in its patches.py; its main rewrites byte-identically to the previous patch_nso.py version of this change. - Variable frame step (DM_FPS_TARGET 61 to 240, refused on a build without VAR_STEP): each frame the host publishes the time the previous one took as the VFR's frame ratio (state +0x50, main+0x151d484); the VFR override and prerendered movies keep the whole-vsync step. The display link runs at the cap (mode 4, with virtual ticks on a screen whose rate is not a multiple of it; no screen mode switch). Steps have no floor at the cap: at 120 on a 144 Hz screen a floor of 1/120 s ran the game at 1.12 of real time. - Interval-stepped logic: the layout system's animation step (menus, HUD; main+0x1280ec8) and a fade (main+0x125f114) take the VFR's frame ratio in place of max(interval, 1); menus and the HUD ran at twice the speed at 120. Held buttons count the ratio (main+0xeb0f88): the inventory cursor repeated at twice the speed at 60 already. The physics step gets a ratio of at least 0.5 (main+0x128106c), three substeps, where two at 120 blew ragdolls apart. Sites from MacNativeGames PR seedds#103, checked by disassembly. - Above 1080p (render scale up to 3.0, Mac only): the render buffer pool grows by the factor's square (main+0x106d328), the application pool, alias region and the game's fixed heaps by what it adds plus 64 MB (state +0x58: the stubs add it to the game's own sizes), and above 1.2 the output takes the views' size. - The iOS launcher keeps 30 / 60: above 60 is not yet run on an iPhone (DM_FPS_TARGET in env.txt reaches it). Mac (M2 Max, 144 Hz screen): 119.5 fps at 2560x1440 at the title and in the menus at 1.000 of real time, menus and the inventory at normal speed; in the open world about 84 fps at 1440p and 74 at 4K with PR seedds#62's implementation of the same step (two physics substeps a frame at 120, three here; not measured again); at the profile's 60 fps 1.000 of real time. Red lines: BufferInitialize past the end of a pool when the inventory opens, on main too; MemoryPoolInitialize without storage only at render scale 1.6, as with the first implementation (PR seedds#62). TOTK, AoC and Paper Mario: their stubs are unchanged and their tables get no new rows (not run here). The graphics tests that compile nvn_mtl.m and hle_nvn.c in one translation unit rename nvn_mtl.m's weak nvn_var_fps, as they do nvn_game_fps. dm/host/tests/t_heap_size.c and t_svc_memory.c, which compile hle_svc.c on their own, define dm_mem_extra (0: no render buffer pool grown), as loader.c does in the host. On cae5ec2's memory layout: the extra goes into the alias size its boundary check (mem_init_once) validates as well as the layout, RESERVE and APP_POOL as before; the heap budget and the map limit take APP_POOL, so they include it.
…e frame, the 1/240 s floor kept in real time (review of seedds#76) - After a cutscene or a prerendered movie the variable step started from the last variable frame's start, so the first frame stepped the whole time the whole-vsync frames had stepped already (8.333 ms at 120, then 50 ms after a second of them). vstep_off now resets it, and the first frame after the reset takes one frame at the cap. - VFR::updateInterval's stub (main+0x151d484) read the host's step at state +0x50 in both of a frame's calls, and the host writes it on the presenting thread, which can come between them. The setWaitVsyncInterval stub (main+0x11269b8, once a frame in the main loop) now latches it at +0x54, which the VFR stub reads, as the whole-vsync step is latched through the setter. - The floor of 1/240 s raised short intervals: at 240 on a 360 Hz screen the display link's virtual ticks lie 2.78 and 5.56 ms apart in turn, and the game ran at 1.17 of real time. The time the floor adds is now carried into the next steps (bounded by the longest step), so game time keeps real time; the longest step (1.5) still slows the game down, as on the Switch. The step's arithmetic moves into nvn_fstep.h (nvn_vstep_next / nvn_vstep_reset), so t_fstep checks it: steady 120, 120 on 144 Hz and 240 on 360 Hz at 1.000 of real time, one frame at the cap after a second of whole-vsync frames, at most 1.5 for a 60 ms frame (57 checks). The variable step and the render buffer pool grown with the render scale are entries in docs/reference/frame-rate.md and memory.md, linked from Breath of the Wild's note; the symptom index is regenerated. The rewritten main's two stubs were checked by disassembly.
…tl.m's occlusion slots use: the graphics tests that build nvn_mtl.m and hle_nvn.c as one translation unit (t_linear_readback and others) failed to compile (CI's build check on 1b37c0f). Checked: every gfx test builds, t_fstep (57) and t_present_snap (13) pass
…n's menu-repeat stub (main+0xeb0f88), which seedds#76 no longer patches itself
…g_link_rate The test from seedds#324 includes nvn_mtl.m and hle_nvn.c together, so it renames nvn_mtl.m's weak nvn_var_fps as the other tests do, and sets g_link_rate beside g_link_mode, as link_range does: the wait now counts ticks from the link's rate, which also covers a variable step's cap.
0043 carries seedds/nxnative#76 on the pin. 0044 makes the Mac launcher list offer 120 fps and a render scale up to 2.4 for a build that has the new stubs. The iPhone list stays at 30 / 60. Refs #287.
0043 carries seedds/nxnative#76 on the pin. 0044 makes the Mac launcher list offer 120 fps and a render scale up to 2.4 for a build that has the new stubs. The iPhone list stays at 30 / 60. Refs #287.
|
I refreshed the separate native-camera widescreen work onto current main and opened draft #817 for scope/shared-state ABI review. It uses desired/acknowledged camera ratios at +0x40/+0x44, which intersects this proposal's layout; the two must not be combined without agreeing allocations. I have not opened a competing FPS PR. A separate local BOTW real-time uncapping implementation preserves host movie activity and game-owned vsync override precedence; happy to contribute a focused timing correction here after the shared-state contract is agreed. No new FPS or iPhone gain is claimed from the current refresh. |
|
One wall we hit on 1.9.0 that I can't find in this PR: at a 2560x1440 output the swapchain's pool didn't fit. With that plus the pool and the two heap sizes (the same sites as yours), 1.9.0 holds 60 at 2560x1440 and 3840x2160 on an M5 Max, headless on the Great Plateau and through 39 minutes of my own play at 4K fullscreen. At 4K that needs the GPU clock kept up: left alone, macOS ran it at about 717 MHz for 13 ms frames, with little margin. |
This picks up the parts of #62 that were not taken, reworked along the lines of your review. Stable 60 fps came first: on the Mac with #134 (merged) and #87, and on an iPhone 17 Pro Max with the PRs listed in #142. This PR is what lets the game run above 60 fps and above 1080p at all; the work that makes 120 fps steady (less GPU work per pass, cheaper encoding, CPU / GPU overlap) comes in separate PRs, tracked in #142, so this one no longer waits for them.
Breath of the Wild above 60 fps and above 1080p, with no game's constants in the host
Your points on #62, one by one:
ctx.keysof the stubs in the profile'spatches.py, a new field of the frame-step context:VAR_STEP,RENDER_POOL,VIEW_W/VIEW_H,OUTPUT_W/OUTPUT_H), the same wayRENDER_SCALEworks for the launcher. The loader writes the new state page fields (all from +0x40 on) only for such a build.DM_FPS_TARGETabove 60 is refused on any build withoutVAR_STEP, and AoC's +0x28 and TOTK's +0x8 are never touched.main+0x1280ec8) and a fade (main+0x125f114) step bymax(interval, 1) × 0.5, not by the VFR's frame ratio. Both now take the ratio (+0x3c), which is the same value at whole vsyncs and in cutscenes. Two more interval-stepped sites are covered as well: held buttons count 1.0 a frame (main+0xeb0f88, so the inventory cursor already repeated at twice the speed at 60 fps), and the physics step runsround(6 × ratio)substeps (two at 120 fps, where ragdolls blew apart). The physics step now gets at least 0.5, which means three substeps. These sites were found by MacNativeGames (PR Two guest-memory reclaim layers for NVN: pool page renew and static packaged-texture source reclaim #103) and checked here by disassembly.link_rangealready does for 60.DM_FPS_TARGETinenv.txtreaches it for testing).Results on an M2 Max with a 144 Hz screen: 119.5 fps at 2560×1440 at the title and in the menus, at 1.000 of real time, with menus and inventory at normal speed. In the open world the step is the same as #62's, which ran about 84 fps at 1440p and 74 at 4K on this machine. I haven't measured it again here; this version runs three physics substeps a frame at 120 instead of two. At the profile's 60 fps: 1.000 of real time. TOTK, AoC and Paper Mario were not run (I don't have them). Their stubs are unchanged and their tables get no new rows.
t_nvn102/102.Also noticed
dm/gfx/tools/dmsh_xlate_bin/dmsh_xlateis arm64-only again since bb585cd (it was universal for #54).Rebased onto f4f0a85 (the patch split): Breath of the Wild's new stubs are in
dm/games/01007EF00011E000/patches.py,patch_nso.pyonly gains the 0x60-byte state page,ctx.keysand their rows in the fixups table. Its main rewrites byte-identically to this PR's previous version (patched image, fixups, cuts, sites, gates, obs);dm/tools/testspass.Rebased onto 2006d5e. Main replaced the
GENERALIZElist withBINDING. Breath of the Wild's frame-step and render-pool stubs are classified there now. Indm/host/loader.cand thefps_targetrow ofdm/games/README.mdI kept main's Unreal rows and added this PR's rows next to them. Main has no frame cap or render scale above 1.0 of its own, so nothing in this PR became a duplicate.