mirror of
https://github.com/seedds/nxnative.git
synced 2026-11-23 11:39:42 -10:00
EA SPORTS FC 27: profile and note (Frostbite, 60 fps); c2 handle arrays over the whole table
The port (1.8d.310c, SDK 22.2.0, Frostbite 2025.1.2, NVN in a run-time NRO), Mac: menus and a Classic Match. - Rewriter: two patch areas for a text longer than a branch reaches (185.6 MB). - Shaders: CompiledBytecode resources read from Frostbite superbundles (frostbite.py); shader_key_skip for the renderer's control-block cache. - Host: vi::CreateLayer with LayerCreationSettings, builder storage getters, Map of a CPU_NO_ACCESS pool returns NULL, depth-plane copies between depth formats, the SDK 22 node-area cut. 60 fps: hle_fpslock finds Frostbite's SimulationTimeSettings by name in main's reflection data (ForceSimRate / MaxSimFps, any build) and writes FIFA's frame regulator on 1.8d.310c; present_interval display. Match clock at the 30 fps rate; a build without the regulator row keeps 30 fps at the right speed. Bound handles are the driver's 32-bit words: bind_handles keeps the low 32 bits (separate textures bound with bit 32 set read as sampler ID 4096). Chain fbf5a565dd44 (with the chain changes before it): arrays of c2 handles have one element per handle word (301, Program.cs C2HandleWords) instead of 32 clamped; c2_array decodes handle type 1 with its separate sampler word (soff), ORed in by the replay; a computed index into c2 is fillable (the replay fills the handle tables whole). Every game's shaders need a rebuild.
This commit is contained in:
1 parent
ed7c473b67
commit
682fdd2672
49 files changed
+12145
-107
No files matched your search
@@ -242,7 +242,7 @@ Under a game, "60 fps with 1.2.0" means it runs at 60 fps (30 on the Switch) wit
|
||||
<tr>
|
||||
<td align="center" valign="top" width="33%"><img src="docs/images/well-dweller.jpg" width="256" alt="Well Dweller"><br><small><b><a href="dm/games/0100217023F6C000/README.md">Well Dweller</a></b></small></td>
|
||||
<td align="center" valign="top" width="33%"><img src="docs/images/need-for-speed-hot-pursuit-remastered.jpg" width="256" alt="Need for Speed: Hot Pursuit Remastered"><br><small><b><a href="dm/games/010029B0118E8000/README.md">Need for Speed: Hot Pursuit Remastered</a></b></small></td>
|
||||
<td></td>
|
||||
<td align="center" valign="top" width="33%"><img src="docs/images/ea-sports-fc-27.jpg" width="256" alt="EA SPORTS FC 27"><br><small><b><a href="dm/games/0100C49025D3E000/README.md">EA SPORTS FC 27</a></b><br>60 fps with 1.8d.310c</small></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of gallery -->
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# EA SPORTS FC 27 (`0100C49025D3E000`)
|
||||
|
||||
Update 1.8d.310c (v393216), SDK 22.2.0, on NVN (API 55.15). **Frostbite** 2025.1.2 (`Info_Nx_retail.BuildSettings`): its data in superbundles (`.toc` tables, `.cas` files, Oodle Leviathan), its NVN renderer in an NRO the game loads at run time, `Engine.Render.Core2.PlatformNvn.nro` (with its symbol file `.nrs` beside it in the RomFS). Modules `main` (185.6 MB of text) and `sdk`; the NRO is collected from the RomFS and rewritten like them.
|
||||
|
||||
On the Mac (2026-10-29): the accessibility settings, the EA SPORTS and FC 27 logos, the title, the offline notice (no EA servers), the user agreement, the favourite-team setup, the main menu over its 3D training ground, Kick Off, and a Classic Match (Atlanta United v Orlando City at Mercedes-Benz Stadium): the stadium and crowd, the pre-match presentation (tifo, coaches, line-ups), kick-off, and the first half and into the second (67 minutes of match time) played with the pad (passing, shooting, a goal for Orlando, a corner, the in-game tactics tutorial). The game runs at 30 fps on the Switch; here menus and the match run at 60 ([Frame rate](#frame-rate)): frame time p50 16.7 ms, the match clock at its 30 fps rate. Resident memory stays at about 3.5 GB, GPU allocated 1.9 GB.
|
||||
|
||||
## What it needs
|
||||
|
||||
| Setting | Where | Why |
|
||||
|---|---|---|
|
||||
| 7 GB block with a 5.25 GB alias region: `mem_reserve 0x1c0000000`, `mem_alias 0x150000000`, `mem_stack 0x10000000`, `app_pool 0xCD500000` | [`game.tsv`](game.tsv) | Frostbite reserves its arenas as address regions ([Memory](#memory)); the heap region keeps the 1.25 GB the heap check measured (`main` asks for a 1.19 GB heap) |
|
||||
| `sys_resource 0x600000` | `game.tsv` | the NPDM declares 6 MB of system resource: virtual address memory |
|
||||
| `shader_key_skip 0x7d0+0x18` | `game.tsv` | the renderer's control-block cache ([Shaders](#shaders)) |
|
||||
| `shader_groups /Data/=data /Patch/=patch` | `game.tsv` | the shaders are in the base data's and the update's cas files |
|
||||
| [`dual_want.tsv`](dual_want.tsv) | profile | the six pixel shaders a match blends with their output 1 as the second source (dual-source blending), noted with `DM_NVN_DUAL_WANT` |
|
||||
| `fps_target 60`, `present_interval display` | `game.tsv` | 60 fps: the host sets Frostbite's simulation rate and the game's frame regulator ([Frame rate](#frame-rate)); the game's present interval 2 is ignored |
|
||||
| the node-area cut on `sdk` `fed212d6…` | [`dm/tools/sdk_patches.py`](../../tools/sdk_patches.py) | SDK 22's AddressRegionManager takes 1 GB of the alias region as its node area ([The SDK's address-region node area](../../../docs/reference/memory.md#the-sdks-address-region-node-area)); registered for this build, and the SDK-wide rule now covers SDK 22 |
|
||||
|
||||
## Files
|
||||
|
||||
- RomFS: 197 files, 31.8 GB, nearly all in `Data/NX` (the base game's superbundles and 18 install chunks of cas files) and `Patch/NX` (the update's); `Data/layout.toc` names the install chunks, `Data/initfs_NX` is encrypted (the game decrypts it). 83,325 bundles in all. `Scripts/BootIni/MemoryInit.ini` sets the engine's arenas; `oo2tex.key` is Oodle Texture's.
|
||||
- The save is one container written through `save commit` lines; the game asks the accessibility settings on every start so far.
|
||||
|
||||
## Shaders
|
||||
|
||||
- **Current:** 7,873 shaders (1,520 vertex, 3,131 pixel, 3,222 compute) from the 10,401 `CompiledBytecode` resources of the bundles: [CompiledBytecode resources in Frostbite superbundles](../../../docs/reference/shaders.md#compiledbytecode-resources-in-frostbite-superbundles). The split decodes them with the game's own Oodle in the Mac host in about 30 s. All translate and compile for the Mac.
|
||||
- **The control-block cache:** `fb::ShaderPlatformDataNvn` (renderer NRO) copies each shader's code into its pool and keeps one copy of each control section in a cache keyed by a hash that leaves out GLSLC's compile information (`s_controlBlockCacheMutex`), so a program gets the control section of the first shader with the same rest: at run time +0x7d0..+0x7e7 name another shader. Without `shader_key_skip`, 10 of the first menus' programs were not in the map (their code areas were the files', their control sections another resource's); with it the 10,342 keys are 7,873 shaders ([Control sections shared among shaders that differ only in their compile information](../../../docs/reference/shaders.md#control-sections-shared-among-shaders-that-differ-only-in-their-compile-information)).
|
||||
- **Open:** the resources name no vertex / pixel pairs (Frostbite pairs them in its pipeline data), so there is no pipeline prebuild list; the prewarm list (`pso_manifest.tsv`) is empty.
|
||||
- **Resolved:** `dc446d7f52c14ea6` (pixel; `[RED] … B binding fp_t2d_cb196610_10570000 has no resolved slot number`), met in a match, did not load. Its loop over separate texture slots i = 1, 2, … reads each handle word at c2 byte 0x168 + 8i and samples an array of c2 handles at element 45 + i (the handle's byte offset ÷ 8), with one separate sampler word (c2 byte 0x570) ORed into every handle; the translator's 32-element array clamped every index to 31, the build did not decode the sampler word, and it refused the loop's own read of each handle word at a computed c2 index → [Arrays of c2 handles cover the whole table, with a separate sampler word](../../../docs/reference/shaders.md#arrays-of-c2-handles-cover-the-whole-table-with-a-separate-sampler-word).
|
||||
- **Open:** five shaders have a binding whose slot the build does not decode, and the translator leaves out seven (two with a bindless `texture2D` whose handle source it cannot find, four with `PrmtI`, one with `AtomCas`); none was met in the menus or a match.
|
||||
|
||||
## Memory
|
||||
|
||||
- Frostbite's `VirtualAlloc` (`main+0x17f9884`, `VirtualAlloc_Posix.cpp`) reserves each arena of `MemoryInit.ini` as an address region: 264 regions, 2.8 GB, in its first minute, three of them 512 MB, while it maps 0.7 GB. With the SDK's 1 GB node area they ran past the 4.38 GB alias region within seconds (`Couldn't reserve memory of size: 536870912 …`, then a deliberate store to address 0 at `main+0x17f98c4`). With the node-area cut they reach alias +3.5 GB at the title, +3.75 GB in the menus +4.25 GB 23 minutes into a match and +4.50 GB at 67 minutes (1.3 GB mapped) in a 4.75 GB alias region, hence the 5.25 GB one. Late in that match 655 live regions held 3.05 GB but spanned 4.52 GB: 1.41 GB lay in 654 gaps, nearly one after each region, as the SDK's AddressRegionManager placed them (open: whether the mark levels off over a whole match).
|
||||
- Measured with a Switch-sized alias region (`DM_ALIAS_SIZE=0x1000000000`, `DM_REGIONS`).
|
||||
|
||||
## Frame rate
|
||||
|
||||
- **Current:** 60 fps in the menus and a Classic Match (1.8d.310c, Mac): frame time p50 16.66 ms, p95 18.2 ms; the match clock went 02:40 → 04:00 → 05:20 at 10.3 s steps, as at 30 fps (01:20 → 02:39). `fps_target 30` runs the game's own 30.
|
||||
- **What sets 30 on the Switch:** three things, each needed. Frostbite's `SimulationTimeSettings` (`ForceSimRate` 30, `MaxSimFps` 30) caps the simulation's ticks; the game's frame regulator, an object at `[main+0xda20e38]` whose tick (`main+0x99ea580`) waits 1 / `[+0x8]` s from the last frame (the constructor sets 60.0 at `main+0x99e80c8`), gets 30.0 in `[+0x8]` and `[+0x10]` from `main+0x5d501c0` whenever `GameRenderSettings.Enable` is 1, a constant of this build; and `BaseDisplaySettings.PresentInterval` is 2.
|
||||
- **What the host does:** the simulation settings are found by name in `main`'s reflection data, on any build ([Frostbite's simulation rate, found by name](../../../docs/reference/frame-rate.md#frostbites-simulation-rate-found-by-name)); the regulator is a build-gated row of `hle_fpslock.c` (the game sets 30 again at some screen changes; the host writes 60 back); `present_interval display` ignores the interval. Only the simulation and the regulator at 60 together give 60 at the right speed: the regulator and present interval alone gave 60 frames a second with the match clock at half speed (3.65 game seconds a second); the simulation at 60 with the regulator at 30 (a build without the row) gives 30 fps at the right speed.
|
||||
- **Not needed:** `GameplayFeatures.DeltaTicks` (4.0; it becomes the int at `main+0xd10b6d8` that sets the gameplay rate `60 / DeltaTicks` at `[regulator]+0x1e54c`) stays as the game sets it. Forcing that int to 1 instead crashed the match at kick-off (`main+0x4ccd66c`).
|
||||
- **Open:** a new build needs the regulator row carried over (`nso_fnmap.py`, then check `main+0x5d501c0` and the regulator's global by disassembly): `main` has unwind entries for only 405 functions, so a function-matched cut cannot follow it. Until then such a build runs at 30 fps at the right speed.
|
||||
|
||||
## On the Mac
|
||||
|
||||
- After the NSP script's `--platform mac` build, its printed command runs the game; the work folder's `run/boot.sh <log> [secs] [VAR=…]` runs a renamed copy of the host (`build/fchost`); `run/ctl.sh "snap NAME" "A" "wait 3" …` drives a run started with `DM_CTL=<work>/run/ctl.txt DM_PRESENT_LINK=0`.
|
||||
- First start: the accessibility settings are up about 15 s after start. A (Continue), A (skip the logo), A (Let's Play!), A (OK on the offline notice), A (Continue on the user agreement), A, A, A (country, league, club of the favourite team), then the main menu; B closes its welcome panel, Down four times selects Kick Off.
|
||||
- With that save (the work folder's `run/save`): the title is up about 20 s after start; A, A (title, offline notice), Down four times and A (Kick Off), A (Classic Match), A (Start Match), A (the difficulty notice), about 45 s of loading, then hold A (`A~2.5`) twice to skip the presentation. The left stick moves, A passes, B shoots.
|
||||
|
||||
## Found on this game
|
||||
|
||||
General changes first needed here; each applies to every game on the same path:
|
||||
|
||||
- **Resolved: a text longer than a branch reaches** (185.6 MB): the rewriter splits the patch area in two → [Two patch areas for a text longer than a branch reaches](../../../docs/reference/rewriter.md#two-patch-areas-for-a-text-longer-than-a-branch-reaches).
|
||||
- **Resolved: no shader container found** → [CompiledBytecode resources in Frostbite superbundles](../../../docs/reference/shaders.md#compiledbytecode-resources-in-frostbite-superbundles) (`dm/gfx/tools/frostbite.py`).
|
||||
- **Resolved: `vi::CreateLayer` with `LayerCreationSettings` (SDK 22)** → [`vi::CreateLayer` with `LayerCreationSettings` (SDK 22)](../../../docs/reference/services.md#vicreatelayer-with-layercreationsettings-sdk-22).
|
||||
- **Resolved: builder storage getters** (`nvnTextureBuilderGetMemoryOffset`, `…GetRawStorageClass`) → [Builder storage getters](../../../docs/reference/nvn-objects.md#builder-storage-getters).
|
||||
- **Resolved: the SDK 22 node area** → [The SDK's address-region node area](../../../docs/reference/memory.md#the-sdks-address-region-node-area).
|
||||
- **Resolved: a depth plane copied into a depth-only texture** → [Depth plane copies between depth formats](../../../docs/reference/rendering.md#depth-plane-copies-between-depth-formats).
|
||||
- **Resolved: 30 fps** (the simulation rate) → [Frostbite's simulation rate, found by name](../../../docs/reference/frame-rate.md#frostbites-simulation-rate-found-by-name).
|
||||
- **Resolved: a shader with an array of c2 handles and a separate sampler word** (its lights) → [Arrays of c2 handles cover the whole table, with a separate sampler word](../../../docs/reference/shaders.md#arrays-of-c2-handles-cover-the-whole-table-with-a-separate-sampler-word).
|
||||
- **Resolved: `[RED] sampler ID 4096 not registered`** at the title, separate textures bound with bit 32 set → [Bound handles are the driver's 32-bit words](../../../docs/reference/nvn-objects.md#bound-handles-are-the-drivers-32-bit-words).
|
||||
- **Resolved: a copy to address 0 at the match load**, `nvnBufferMap` of a GPU-only buffer → [`Map` of a pool without CPU access returns NULL](../../../docs/reference/nvn-objects.md#map-of-a-pool-without-cpu-access-returns-null).
|
||||
|
||||
## Open
|
||||
|
||||
- **iPhone:** not built or tested. The 7 GB block is more than the 5 GB proven on a phone without the extended-virtual-addressing entitlement, so the game's arenas likely need less address space there (open: whether its command line or `MemoryInit.ini` can size them).
|
||||
- **Gameplay:** a whole match, its result screens, other modes (Career, Ultimate Team offline parts, Tournaments), other stadiums and weather, local multiplayer and other languages are untested.
|
||||
- Online play needs EA's servers: offline only.
|
||||
@@ -0,0 +1 @@
|
||||
# generated
|
||||
|
@@ -0,0 +1,7 @@
|
||||
# Pixel shaders a pipeline blends with their output 1 as the second source (dual-source blending): dmsh_build.py gives each a dual-source entry point (fs_dual). Rows: shader key, noted by the host with DM_NVN_DUAL_WANT
|
||||
0d34c6ac020eb776
|
||||
2f8cf470efdd0618
|
||||
488191a1b35d5c20
|
||||
8c3a58176b62918e
|
||||
ae1e490686acc612
|
||||
eb182b85889234f4
|
||||
|
@@ -0,0 +1,46 @@
|
||||
# EA SPORTS FC 27 (Frostbite 2025.1.2), SDK 22.2.0, NVN in the renderer NRO Engine.Render.Core2.PlatformNvn.nro.
|
||||
# Started from the NSP script's provisional profile; the memory layout is measured on the Mac (README.md, Memory).
|
||||
|
||||
# ---- Identity ----
|
||||
title_id 0100C49025D3E000
|
||||
program_id 0100C49025D3E000
|
||||
|
||||
# ---- App ----
|
||||
name EA SPORTS FC 27
|
||||
ipa EaSportsFc27.ipa
|
||||
app_category public.app-category.sports-games
|
||||
|
||||
# ---- Versions ----
|
||||
build v393216 1.8d.310c main=a48c0de3bc353efa0e4d359bde05ef24 sdk=fed212d6e0963706f9f4b16ea5d65879
|
||||
package v393216
|
||||
shader_versions v393216
|
||||
|
||||
# ---- Files ----
|
||||
# every module main imports from (the renderer NRO is loaded at run time, nro_collect.py)
|
||||
modules main sdk
|
||||
romfs_marker Data/NX/superbundlelayout/installpackage_05/cas_01.cas
|
||||
zip_store .cas:.nrs:.metallib
|
||||
|
||||
# ---- Memory ----
|
||||
# The NPDM declares 6 MB of system resource (virtual address memory) and main sets a heap of 1.19 GB (a 1.25 GB heap region, the heap check). Frostbite's VirtualAlloc reserves its
|
||||
# arenas as address regions, 264 of them and 2.8 GB in its first minute while it maps 0.7 GB: after the 62 MB node area they reach alias +3.5 GB at the title and +4.5 GB
|
||||
# 67 minutes into a match, so the alias region is 5.25 GB in a 7 GB block (README.md, Memory; more than the 5 GB proven on an iPhone)
|
||||
mem_reserve 0x1c0000000
|
||||
mem_alias 0x150000000
|
||||
mem_stack 0x10000000
|
||||
app_pool 0xCD500000
|
||||
# the NPDM declares 6 MB of system resource
|
||||
sys_resource 0x600000
|
||||
|
||||
# ---- Shader split ----
|
||||
shader_groups /Data/=data /Patch/=patch
|
||||
shader_note EA SPORTS FC 27 shaders: Frostbite CompiledBytecode resources (frostbite.py)
|
||||
# The renderer keeps one copy of each control section by a hash that leaves out GLSLC's compile information (+0x7d0..+0x7e7) and hands later shaders the first one, so at run time
|
||||
# those bytes name another shader (README.md, Shaders)
|
||||
shader_key_skip 0x7d0+0x18
|
||||
|
||||
# ---- Frame rate ----
|
||||
# 60 fps as on the game's other platforms: the host sets Frostbite's simulation rate (SimulationTimeSettings, found by name) and, on 1.8d.310c, the game's frame regulator to the
|
||||
# target (hle_fpslock.c); the game asks for present interval 2, which display pacing ignores (README.md, Frame rate). 30 runs the game's own 30
|
||||
fps_target 60
|
||||
present_interval display
|
||||
|
@@ -0,0 +1,2 @@
|
||||
# Prewarm seed list (shipped in the app, next to shader_map.tsv). Rows: S<TAB>shader key<TAB>stage / R<TAB>render pipeline key (pso_skey hex) / C<TAB>compute shader key.
|
||||
# Provisional profile: empty until recorded on the Mac (DM_PSO_MANIFEST=off DM_PSO_RECORD).
|
||||
|
@@ -0,0 +1 @@
|
||||
# kind: evidence supplemental vertex / pixel shader pairs (BAHS program variations and legacy Unity pass-input covers) for vertex output padding and the pipeline prebuild (generated by dm/gfx/tools/shader_split.py, do not edit): vertex key <TAB> pixel key
|
||||
|
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
# kind: evidence control-section key conflict rulings: empty
|
||||
dm_ctl_sha16 chosen_pc class candidates records
|
||||
|
@@ -0,0 +1 @@
|
||||
# kind: evidence vertex / pixel shader pairs within BNSH variations (generated by dm/gfx/tools/shader_split.py, do not edit): vertex key <TAB> pixel key
|
||||
|
+2
-1
@@ -77,6 +77,7 @@ One row per profile; the notes are each profile's `README.md`.
|
||||
| [Donkey Kong Country: Tropical Freeze](0100C1F0051B6000/README.md) | `0100C1F0051B6000` | 1.0.2 | 4.4.0 | Retro Studios' engine | NVN |
|
||||
| [DRAGON QUEST VII Reimagined](0100A9D01C446000/README.md) | `0100A9D01C446000` | 1.2.0 | 19.3.1 | Unreal Engine 4.27 | NVN |
|
||||
| [DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition](01006C300E9F0000/README.md) | `01006C300E9F0000` | 1.0.4 | 7.3.2 | Unreal Engine 4.18 | NVN |
|
||||
| [EA SPORTS FC 27](0100C49025D3E000/README.md) | `0100C49025D3E000` | 1.8d.310c | 22.2.0 | Frostbite 2025.1.2 (its NVN renderer in an NRO) | NVN |
|
||||
| [FINAL FANTASY CRYSTAL CHRONICLES Remastered Edition](0100CE4010AAC000/README.md) | `0100CE4010AAC000` | 1.0.3 | 8.2.1 | Unity 2018.4.2f1 IL2CPP, FMOD | NVN |
|
||||
| [FINAL FANTASY RESONANCE](0100606026F12000/README.md) | `0100606026F12000` | 1.0.1 | 20.5.17 | Unreal Engine 5.6.1 | NVN |
|
||||
| [FINAL FANTASY RESONANCE, Asian release](0100B8A026F14000/README.md) | `0100B8A026F14000` | 1.0.1 | 20.5.17 | Unreal Engine 5.6.1 | NVN |
|
||||
@@ -180,7 +181,7 @@ One row per profile; the notes are each profile's `README.md`.
|
||||
| `present_snap` | `on` / `off` (the default): present snapshots by default (`nvn_mtl.m` `mtl_snap_on`, a ring of 2 host textures): each present is copied and the game's swapchain texture is free at once, so the GPU does not idle between frames ([Present snapshots](../../docs/reference/frame-rate.md#present-snapshots-the-games-swapchain-texture-free-at-once)). A setting the game was tested with: the iOS launcher's **Frame buffering** defaults to it, and `DM_PRESENT_SNAP` / `Documents/env.txt` override it. Breath of the Wild sets it on |
|
||||
| `pso_mtl4` | `on` / `off` (the default): on iOS, render pipelines through MTL4Compiler by default, with the pipeline archive, the prepare step, the hybrid pipelines and the prebuild (on by default on the Mac; `DM_PSO_MTL4=1` / `0` overrides). A setting the game was tested with on an iPhone. It also gives the app the [pipeline archive made offline](../../docs/development.md#the-pipeline-archive-made-offline) (`build_ipa.sh` builds it for `g18p` unless `DM_PSO_GPUS` says otherwise; without the key, none) and the pulling libraries (`_bp`). Breath of the Wild sets it on |
|
||||
| `enc_thread` | `on` / `off` (the default): on the Mac, Metal encoding on its own thread by default, as on iOS for every game (`nvn_rec.h` `rec_on`; `DM_NVN_ENC_THREAD=1` / `0` and the launcher's Encode thread override it). For a game that waits on its fence every frame, whose submit thread would otherwise also encode before the wait: Need for Speed: Hot Pursuit Remastered's 60 fps frame took 18.1 ms with encoding on the submit thread and 16.7 on its own |
|
||||
| `fps_target` | Frame rate cap of the rewriter's frame step, for builds that have one (`FRAME_STEP` in the profile's `patches.py`: Tears of the Kingdom 1.4.3, Breath of the Wild 1.9.0, Hyrule Warriors: Age of Calamity 1.3.0, Paper Mario: The Thousand-Year Door 1.0.1, ASTRAL CHAIN 1.0.1), or the engine's own frame limit the host writes into game memory (`hle_fpslock.c`: Monster Hunter Rise 16.0.2, which also needs `present_interval display`; Octopath Traveler 0 1.0.5, Unreal's `t.MaxFPS` and `rhi.SyncInterval`, so the game asks for present interval 1 itself; Luigi's Mansion 3 1.4.0, its frame limiter's milliseconds per frame, with `present_interval display`; Pokémon Brilliant Diamond 1.3.0, Unity's integer `Application.targetFrameRate`, also with `present_interval display`). `0` (the default): the game's own step. `30` / `60`: the host decides each frame's step in whole vsyncs and keeps the frame on screen that long (`hle_nvn.c` `fstep_tick`, `nvn_fstep.h`): 1 at a 60 cap, 2 when 60 does not hold or at a 30 cap (and while a prerendered movie plays), plus one vsync while the game is behind real time after a late frame. Presents follow that hold instead of the interval the game sets. `DM_FPS_TARGET` overrides it, also from `Documents/env.txt`; the log line `frame step: game time … of real time` checks the game's speed |
|
||||
| `fps_target` | Frame rate cap of the rewriter's frame step, for builds that have one (`FRAME_STEP` in the profile's `patches.py`: Tears of the Kingdom 1.4.3, Breath of the Wild 1.9.0, Hyrule Warriors: Age of Calamity 1.3.0, Paper Mario: The Thousand-Year Door 1.0.1, ASTRAL CHAIN 1.0.1), or the engine's own frame limit the host writes into game memory (`hle_fpslock.c`: Monster Hunter Rise 16.0.2, which also needs `present_interval display`; Octopath Traveler 0 1.0.5, Unreal's `t.MaxFPS` and `rhi.SyncInterval`, so the game asks for present interval 1 itself; Luigi's Mansion 3 1.4.0, its frame limiter's milliseconds per frame, with `present_interval display`; Pokémon Brilliant Diamond 1.3.0, Unity's integer `Application.targetFrameRate`, also with `present_interval display`; EA SPORTS FC 27, Frostbite's simulation rate, found by name on any build, and on 1.8d.310c its frame regulator, also with `present_interval display`). `0` (the default): the game's own step. `30` / `60`: the host decides each frame's step in whole vsyncs and keeps the frame on screen that long (`hle_nvn.c` `fstep_tick`, `nvn_fstep.h`): 1 at a 60 cap, 2 when 60 does not hold or at a 30 cap (and while a prerendered movie plays), plus one vsync while the game is behind real time after a late frame. Presents follow that hold instead of the interval the game sets. `DM_FPS_TARGET` overrides it, also from `Documents/env.txt`; the log line `frame step: game time … of real time` checks the game's speed |
|
||||
| `fps_hold` | `on` (the default): with `fps_target`, three late frames in a row raise the hold above the cap's vsyncs (30 or 20 fps), and steady frames that fit try the lower hold again. `off`: frames are never held longer than the cap's vsyncs; each is shown as soon as it is ready. For a game whose updates do not wait for the presents and step by the cap whatever the hold (Age of Calamity): there the hold only paces the screen. `DM_FPS_HOLD=on` / `off` overrides it, also from `Documents/env.txt` Paper Mario: The Thousand-Year Door sets it off too: its frame waits for three render worker threads, and holding frames left them idle, so a frame cost more the longer the hold (the hold stuck at 3 vsyncs, 20 fps, on a loaded Mac; 32–58 fps without holds) |
|
||||
| `ue_texture_pool` | Unreal Engine games: megabytes of the texture streaming pool (`r.Streaming.PoolSize`) the host raises the game's own to, on the Mac (`hle_uecvar.c`, which finds the variable by its name): past its pool the streamer drops the top mips of what is in view, and the Switch's pool is small (DRAGON QUEST VII Reimagined: 200 MB, 1000 on Windows). `0` (the default): the game's own pool. A larger value the game sets, or −1, stays. `DM_UE_TEXTURE_POOL` overrides it; on iOS only that switch turns it on (`Documents/env.txt`). An improvement over the Switch, not a fix: [Unreal's texture streaming pool](../../docs/reference/rendering.md#unreals-texture-streaming-pool) |
|
||||
| `core_preempt` | `on` / `off` (the default): additionally check higher-priority runnable threads pinned to the caller's core after every thread SVC (`hle_thread.c`). `DM_PREEMPT=0` / `1` overrides it. Wake-triggered same-core handoffs apply to every game with either setting and wait until the threads the wake made runnable block, with no wall-clock cap. Metroid Dread no longer needs this key or its movie request-ring gates; see [Same-core wake handoffs](../../docs/reference/threads.md#same-core-wake-handoffs) |
|
||||
|
||||
@@ -210,12 +210,13 @@ def nro_modules(exefs, nros, modules, hooks=None):
|
||||
|
||||
|
||||
# ---- Shader sources: decided from the game files at every build, not kept in the profile (scripts/build_ipa_from_nsp.py; shader_split.py reads what those steps write) ----
|
||||
def shader_sources(imports, glsl_src, glslc_mods, spirv, unreal_paks, trinity_packs=0, legacy_paks=0, gl_names=0, gl_src=0, gl_files=0, oodle_pkz=0, nro_imports=frozenset(), oodle_gfpak=0, oodle_ue3=0):
|
||||
def shader_sources(imports, glsl_src, glslc_mods, spirv, unreal_paks, trinity_packs=0, legacy_paks=0, gl_names=0, gl_src=0, gl_files=0, oodle_pkz=0, nro_imports=frozenset(), oodle_gfpak=0, oodle_ue3=0, frostbite=False):
|
||||
"""{name: (value, reason)}: graphics (vulkan when main imports Vulkan functions and not nvnBootstrapLoader; gl when it imports eglCreateWindowSurface and names glShaderSource, so it compiles
|
||||
GLSL through OpenGL (gl_names: how often main has that name; Absolum imports the same EGL functions for SDL3 but renders with NVN and names no GL function); else nvn; vkGetInstanceProcAddr
|
||||
alone is SDL's Vulkan loader, which Balatro's LÖVE links and never uses), vk_capture (a Vulkan game without SPIR-V files generates its shaders at run time), gl_capture (an OpenGL game with no
|
||||
GLSL source where gl_shaders.py looks, gl_src strings in main and gl_files files in the RomFS: it puts its shaders together at run time, LÖVE from its Lua), glslc_capture (main holds GLSL sources and calls glslcCompile in a module the game loads: it compiles some shaders at run time), ue_decode (Unreal paks keep the shaders Oodle-compressed
|
||||
in their shader code archives, which only the game's own Oodle decodes), oodle_packs (Trinity packs, oodle_pkz PlatinumGames PKZ archives, oodle_gfpak Game Freak GFPAK archives with Oodle Kraken entries or oodle_ue3 Unreal Engine 3 packages with Oodle chunks:
|
||||
in their shader code archives, which only the game's own Oodle decodes), oodle_packs (Trinity packs, oodle_pkz PlatinumGames PKZ archives, oodle_gfpak Game Freak GFPAK archives with Oodle Kraken entries, oodle_ue3 Unreal Engine 3 packages with Oodle chunks
|
||||
or frostbite Frostbite superbundles, whose cas files are Oodle Leviathan:
|
||||
Oodle-compressed file by file, which the shader split decodes with the game's own decoder in the Mac host's tool mode), ue_legacy (Unreal paks whose shaders are inline in the cooked packages:
|
||||
legacy paks, version 4, which the shader split reads through the game's own decoder the same way, and version 11 paks without shader code archives, Zlib, read by uepak.py itself).
|
||||
unreal_paks counts the paks with shader code archives, legacy_paks those with inline shaders (uepak.inline_shaders). Checked against every profile: Hades and Super Mario Galaxy Vulkan, Galaxy alone with no SPIR-V file, Three Houses alone compiling
|
||||
@@ -237,7 +238,8 @@ def shader_sources(imports, glsl_src, glslc_mods, spirv, unreal_paks, trinity_pa
|
||||
f'the NROs the game loads call glslcCompile in {", ".join(glslc_mods)}: shaders compiled at run time (Portal), captured by booting it on the Mac' if nro_glslc and not (glsl_src and 'glslcCompile' in imports) else
|
||||
f'main holds {glsl_src} GLSL sources and calls glslcCompile in {", ".join(glslc_mods) or "no module it loads"}: shaders compiled at run time (Fire Emblem: Three Houses), captured by booting it on the Mac'),
|
||||
'ue_decode': (not vulkan and not gl and bool(unreal_paks), f'{unreal_paks} Unreal pak(s): the shaders are Oodle-compressed in their shader code archives (Octopath Traveler 0), decoded by booting the game on the Mac'),
|
||||
'oodle_packs': (not vulkan and not gl and bool(trinity_packs or oodle_pkz or oodle_gfpak or oodle_ue3), (f'{trinity_packs} Trinity pack file(s) (ONEPACK, arc/data.trpfs: Pokémon Legends: Z-A)' if trinity_packs else
|
||||
'oodle_packs': (not vulkan and not gl and bool(trinity_packs or oodle_pkz or oodle_gfpak or oodle_ue3 or frostbite), (f'{trinity_packs} Trinity pack file(s) (ONEPACK, arc/data.trpfs: Pokémon Legends: Z-A)' if trinity_packs else
|
||||
'Frostbite superbundles (Data/layout.toc, cas files: EA SPORTS FC 27), the shaders in their CompiledBytecode resources' if frostbite else
|
||||
f'{oodle_pkz} PlatinumGames PKZ archive(s) with Oodle Kraken entries (Bayonetta 3)' if oodle_pkz else
|
||||
f'{oodle_gfpak} Game Freak GFPAK archive(s) with Oodle Kraken entries (Pokémon Legends: Arceus)' if oodle_gfpak else
|
||||
f'{oodle_ue3} Unreal Engine 3 package(s) with Oodle-compressed chunks (Batman: Arkham Knight, its combined shader cache among them)') + ', Oodle-compressed: the shader split decodes them with the game\'s own decoder in the Mac host (dm/host/hle_oodle.c DM_OODLE_SERVE)'),
|
||||
@@ -303,8 +305,9 @@ def build_sources(exefs, romfs, modules):
|
||||
if 0 < i and i + 16 <= len(h):
|
||||
nb = (struct.unpack_from('<I', h, i + 12)[0] + max(struct.unpack_from('<I', h, i + 4)[0], 1) - 1) // max(struct.unpack_from('<I', h, i + 4)[0], 1)
|
||||
oodle_ue3 += h[i + 16 + 8 * nb:i + 17 + 8 * nb] == b'\x8c'
|
||||
import frostbite # Frostbite's superbundles (EA SPORTS FC 27): every item of the cas files is Oodle Leviathan, decoded with the game's own decoder
|
||||
return shader_sources(imports, glsl_src, glslc_mods, spirv, len(uepak.unreal_paks(str(romfs), inline=False)), trinity, len(uepak.unreal_paks(str(romfs), inline=True)), gl_names, gl_src, gl_files, oodle_pkz, nro_imp,
|
||||
oodle_gfpak=oodle_gfpak, oodle_ue3=oodle_ue3)
|
||||
oodle_gfpak=oodle_gfpak, oodle_ue3=oodle_ue3, frostbite=frostbite.is_frostbite(str(romfs)))
|
||||
|
||||
|
||||
def va_heap(sysres, imports): # virtual address memory (an NPDM system resource) and a heap: the alias / heap split is a starting point the heap check corrects (Wonder, Tears of the Kingdom; Engage's pool is its own measurement)
|
||||
|
||||
@@ -23,6 +23,12 @@ HLE_FORCE("_ZN2nn2vi11CreateLayerEPPNS0_5LayerEPNS0_7DisplayEii", "create layer
|
||||
if (w > 0 && h > 0 && w < 0x10000 && h < 0x10000) g_layer_wh = (uint32_t)w | (uint32_t)h << 16;
|
||||
return RES_OK;
|
||||
}
|
||||
// SDK 22's overload with a LayerCreationSettings, which its constructor LayerCreationSettings(int w, int h) fills as {w, h, 2} (sdk+0x4526a0 in EA SPORTS FC 27; the SDK's own
|
||||
// constructor runs). The SDK's CreateLayer goes to am::GetSelfController(), which the host never made (SIGSEGV at the load from it, sdk+0x44ea94)
|
||||
HLE_FORCE("_ZN2nn2vi11CreateLayerEPPNS0_5LayerEPNS0_7DisplayEPKNS0_21LayerCreationSettingsE", "create layer from creation settings (SDK 22); the host returns a static object",
|
||||
Result, h_vi_CreateLayerSettings, void **out, void *disp, const int32_t *settings) {
|
||||
return h_vi_CreateLayerWH(out, disp, settings ? settings[0] : 0, settings ? settings[1] : 0);
|
||||
}
|
||||
HLE_FORCE("_ZN2nn2vi15GetNativeWindowEPPvPNS0_5LayerE", "native window handle, passed to the NVN window builder; the host returns a static object", Result, h_vi_GetNative, void **out, void *layer) {
|
||||
(void)layer; *out = &g_native; return RES_OK;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Generated file (dm/gfx/tools/dmsh_chain.py --header): the B shader library translation chain version this source tree expects (default options), one for every game;
|
||||
// the host loads only <library dir>/b-<V>/. Run dmsh_chain.py --header after changing the chain's tools and commit this file with the change
|
||||
#define DMSH_CHAIN "a76212ee4af0"
|
||||
#define DMSH_CHAIN "fbf5a565dd44"
|
||||
+19
-3
@@ -509,6 +509,9 @@ NVN(nvnTextureCompare, NVNboolean, const NVNtexture *a, const NVNtexture *b) {
|
||||
}
|
||||
// No prototype in the header; call sites such as main 0x174899c compare the return value with 1 and set some status bit 0x100 if not equal. Meaning unverified; return 1 for now
|
||||
NVN_NOPROTO(nvnTextureGetRawStorageClass, int, const NVNtexture *t) { (void)t; return 1; }
|
||||
// The class a texture from this builder would report, so the two agree: EA SPORTS FC 27's Frostbite renderer asks the builder (the class names the page kind a virtual pool maps,
|
||||
// NVNmappingRequest.storageClass, which the host's virtual pools do not distinguish)
|
||||
NVN_NOPROTO(nvnTextureBuilderGetRawStorageClass, int, const NVNtextureBuilder *b) { (void)b; return 1; }
|
||||
#define VW(v) ((view_t *)(v))
|
||||
NVN(nvnTextureViewSetDefaults, void, NVNtextureView *v) { memset(v, 0, sizeof(view_t)); }
|
||||
NVN(nvnTextureViewSetLevels, void, NVNtextureView *v, int base, int n) { VW(v)->set_levels = 1; VW(v)->base_level = base; VW(v)->nlevels = n; }
|
||||
@@ -1001,7 +1004,10 @@ NVN(nvnCommandBufferBindStorageBuffers, void, NVNcommandBuffer *c, NVNshaderStag
|
||||
}
|
||||
static p_bind_handles *bind_handles(NVNcommandBuffer *c, int op, int st, int first, int n, const uint64_t *h) {
|
||||
if (n < 0 || n > 32) { LOG("[RED] bind handle count %d", n); return NULL; }
|
||||
p_bind_handles *r = RECN(c, op, p_bind_handles, h, n); r->stage = st; r->first = first; r->n = n; r->defer = 0; r->src = 0; memcpy(r->h, h, 8 * n);
|
||||
p_bind_handles *r = RECN(c, op, p_bind_handles, h, n); r->stage = st; r->first = first; r->n = n; r->defer = 0; r->src = 0;
|
||||
// The driver writes each handle into the c2 table as a 32-bit word (texture ID in bits 0-19, sampler ID in bits 20-31), so the GPU never sees the upper half of the 64-bit handle.
|
||||
// EA SPORTS FC 27 binds separate textures with bit 32 set (0x1000001d1): read whole, its sampler ID was 4096, beyond any pool, where the GPU reads sampler 0
|
||||
for (int i = 0; i < n; i++) r->h[i] = (uint32_t)h[i];
|
||||
{ // this command buffer may have bound a pool other than the first: move its IDs to that pool's part of the table (handle: texture ID in bits 0-19, sampler ID from bit 20)
|
||||
int tb = CB(c)->tex_base, sb = CB(c)->samp_base;
|
||||
for (int i = 0; i < n && (tb || sb); i++) {
|
||||
@@ -1963,7 +1969,10 @@ NVN(nvnBufferInitialize, NVNboolean, NVNbuffer *buf, const NVNbufferBuilder *b)
|
||||
NVN(nvnBufferFinalize, void, NVNbuffer *buf) { ((buf_t *)buf)->magic = 0; }
|
||||
NVN(nvnBufferSetDebugLabel, void, NVNbuffer *buf, const char *s) { (void)buf; (void)s; }
|
||||
NVN(nvnBufferGetAddress, NVNbufferAddress, const NVNbuffer *buf) { return (NVNbufferAddress)(BF(buf)->pool->mem + BF(buf)->off); }
|
||||
NVN(nvnBufferMap, void *, const NVNbuffer *buf) { return BF(buf)->pool->mem + BF(buf)->off; }
|
||||
// A buffer or pool the CPU has no access to (NVN_MEMORY_POOL_FLAGS_CPU_NO_ACCESS) maps to NULL, as in NVN, though the host's storage is CPU memory: EA SPORTS FC 27's Frostbite
|
||||
// renderer takes a buffer's GPU address as GetAddress + (its data pointer − Map), with a null data pointer for such a buffer (OpcodeCopySubresource), so a real pointer made the
|
||||
// copy's destination address 0 (FATAL buffer copy address is in no memory pool)
|
||||
NVN(nvnBufferMap, void *, const NVNbuffer *buf) { return BF(buf)->pool->flags & NVN_MEMORY_POOL_FLAGS_CPU_NO_ACCESS ? NULL : BF(buf)->pool->mem + BF(buf)->off; }
|
||||
NVN(nvnBufferGetSize, size_t, const NVNbuffer *buf) { return (size_t)BF(buf)->size; }
|
||||
NVN(nvnBufferGetMemoryPool, NVNmemoryPool *, const NVNbuffer *buf) { return (NVNmemoryPool *)BF(buf)->pool; }
|
||||
NVN(nvnBufferGetMemoryOffset, ptrdiff_t, const NVNbuffer *buf) { return (ptrdiff_t)BF(buf)->off; }
|
||||
@@ -1972,7 +1981,7 @@ NVN(nvnBufferInvalidateMappedRange, void, const NVNbuffer *buf, ptrdiff_t off, s
|
||||
|
||||
// Memory pool queries
|
||||
NVN(nvnMemoryPoolGetFlags, NVNmemoryPoolFlags, const NVNmemoryPool *p) { return (NVNmemoryPoolFlags)((const pool_t *)p)->flags; }
|
||||
NVN(nvnMemoryPoolMap, void *, const NVNmemoryPool *p) { return ((const pool_t *)p)->mem; }
|
||||
NVN(nvnMemoryPoolMap, void *, const NVNmemoryPool *p) { return ((const pool_t *)p)->flags & NVN_MEMORY_POOL_FLAGS_CPU_NO_ACCESS ? NULL : ((const pool_t *)p)->mem; } // NULL without CPU access (nvnBufferMap)
|
||||
NVN(nvnMemoryPoolGetSize, size_t, const NVNmemoryPool *p) { return (size_t)((const pool_t *)p)->size; }
|
||||
NVN(nvnMemoryPoolInvalidateMappedRange, void, const NVNmemoryPool *p, ptrdiff_t off, size_t n) { (void)p; (void)off; (void)n; }
|
||||
NVN(nvnMemoryPoolSetDebugLabel, void, NVNmemoryPool *p, const char *s) { (void)p; (void)s; }
|
||||
@@ -2226,6 +2235,13 @@ NVN(nvnMultisampleStateGetSampleLocationsGridEnable, NVNboolean, const NVNmultis
|
||||
// Builder and pool queries
|
||||
NVN(nvnBufferBuilderGetSize, size_t, const NVNbufferBuilder *b) { return (size_t)((const buf_builder_t *)b)->size; }
|
||||
NVN(nvnBufferBuilderGetMemoryOffset, ptrdiff_t, const NVNbufferBuilder *b) { return (ptrdiff_t)((const buf_builder_t *)b)->off; }
|
||||
// The storage set with SetStorage (EA SPORTS FC 27's Frostbite renderer reads it back from its texture builders before it initializes the textures). The pool getters return the
|
||||
// pool's address, as nvnTextureGetMemoryPool does; the header the prototypes come from declares the builders' by value, so they get no signature check
|
||||
NVN_NOPROTO(nvnBufferBuilderGetMemoryPool, NVNmemoryPool *, const NVNbufferBuilder *b) { return (NVNmemoryPool *)((const buf_builder_t *)b)->pool; }
|
||||
NVN_NOPROTO(nvnTextureBuilderGetMemoryPool, NVNmemoryPool *, const NVNtextureBuilder *b) { return (NVNmemoryPool *)((const tex_builder_t *)b)->pool; }
|
||||
NVN(nvnTextureBuilderGetMemoryOffset, ptrdiff_t, const NVNtextureBuilder *b) { return (ptrdiff_t)((const tex_builder_t *)b)->off; }
|
||||
NVN_NOPROTO(nvnEventBuilderGetMemoryPool, NVNmemoryPool *, const NVNeventBuilder *b) { return (NVNmemoryPool *)((const ev_builder_t *)b)->pool; }
|
||||
NVN_NOPROTO(nvnEventBuilderGetMemoryOffset, int64_t, const NVNeventBuilder *b) { return ((const ev_builder_t *)b)->off; }
|
||||
NVN(nvnTextureBuilderGetTarget, NVNtextureTarget, const NVNtextureBuilder *b) { return (NVNtextureTarget)((const tex_builder_t *)b)->d.target; }
|
||||
NVN(nvnTextureBuilderGetWidth, int, const NVNtextureBuilder *b) { return (int)((const tex_builder_t *)b)->d.width; }
|
||||
NVN(nvnTextureBuilderGetHeight, int, const NVNtextureBuilder *b) { return (int)((const tex_builder_t *)b)->d.height; }
|
||||
|
||||
+31
-6
@@ -976,6 +976,9 @@ static inline void enc_b_end(id e) { m4_end(e); }
|
||||
static inline void enc_b_copy_buffer(id e, id<MTLBuffer> s, NSUInteger so, id<MTLBuffer> d, NSUInteger doff, NSUInteger n) { [e copyFromBuffer:s sourceOffset:so toBuffer:d destinationOffset:doff size:n]; }
|
||||
static inline void enc_b_copy_buffer_texture(id e, id<MTLBuffer> s, NSUInteger so, NSUInteger row, NSUInteger img, MTLSize z, id<MTLTexture> d, NSUInteger sl, NSUInteger lv, MTLOrigin o) { [e copyFromBuffer:s sourceOffset:so sourceBytesPerRow:row sourceBytesPerImage:img sourceSize:z toTexture:d destinationSlice:sl destinationLevel:lv destinationOrigin:o]; }
|
||||
static inline void enc_b_copy_texture_buffer(id e, id<MTLTexture> s, NSUInteger sl, NSUInteger lv, MTLOrigin o, MTLSize z, id<MTLBuffer> d, NSUInteger doff, NSUInteger row, NSUInteger img) { [e copyFromTexture:s sourceSlice:sl sourceLevel:lv sourceOrigin:o sourceSize:z toBuffer:d destinationOffset:doff destinationBytesPerRow:row destinationBytesPerImage:img]; }
|
||||
// The same with a blit option: one plane of a combined depth / stencil texture (MTLBlitOptionDepthFromDepthStencil)
|
||||
static inline void enc_b_copy_buffer_texture_opt(id e, id<MTLBuffer> s, NSUInteger so, NSUInteger row, NSUInteger img, MTLSize z, id<MTLTexture> d, NSUInteger sl, NSUInteger lv, MTLOrigin o, MTLBlitOption opt) { [e copyFromBuffer:s sourceOffset:so sourceBytesPerRow:row sourceBytesPerImage:img sourceSize:z toTexture:d destinationSlice:sl destinationLevel:lv destinationOrigin:o options:opt]; }
|
||||
static inline void enc_b_copy_texture_buffer_opt(id e, id<MTLTexture> s, NSUInteger sl, NSUInteger lv, MTLOrigin o, MTLSize z, id<MTLBuffer> d, NSUInteger doff, NSUInteger row, NSUInteger img, MTLBlitOption opt) { [e copyFromTexture:s sourceSlice:sl sourceLevel:lv sourceOrigin:o sourceSize:z toBuffer:d destinationOffset:doff destinationBytesPerRow:row destinationBytesPerImage:img options:opt]; }
|
||||
static inline void enc_b_copy_texture(id e, id<MTLTexture> s, NSUInteger sl, NSUInteger lv, MTLOrigin so, MTLSize z, id<MTLTexture> d, NSUInteger dl, NSUInteger dv, MTLOrigin doo) { [e copyFromTexture:s sourceSlice:sl sourceLevel:lv sourceOrigin:so sourceSize:z toTexture:d destinationSlice:dl destinationLevel:dv destinationOrigin:doo]; }
|
||||
static void blit_note(void); // Per-pass dump: a copy / buffer update ended the render pass (defined after PD)
|
||||
// Ordering inside the copy encoder: Metal 4 does not order copies / fills within one encoder (no automatic hazard tracking); an operation reading or writing a range an earlier one wrote needs an intra-encoder barrier.
|
||||
@@ -1586,7 +1589,7 @@ void mtl_drain(void) { present_drop_for_suspend(); mtl_present_flush(); snap_dra
|
||||
|
||||
// ================= Render replay =================
|
||||
#include "../../host/front.h"
|
||||
static int g_red_once[132];
|
||||
static int g_red_once[133];
|
||||
#define RED_ONCE(k, ...) do { if (!g_red_once[k]++) MLOG("[RED] " __VA_ARGS__); } while (0)
|
||||
// NVN vertex streams 0–15 → Metal vertex buffer slots: 0–13 go to 16–29 (30 is the constant fallback buffer), 14 and 15 to 14 and 15. Metal has only the 31 slots 0–30; translated shaders use only buffer(0) (the argument buffer),
|
||||
// and the host's own vertex functions read no vertex buffers. 13 Sentinels uses stream 15, and the old 16 + stream went out of range (Metal assertion: buffer index (31) must be < 31)
|
||||
@@ -4569,6 +4572,7 @@ static struct {
|
||||
static uint64_t c2_handle(int stage, unsigned b) {
|
||||
if (b >= DMSH_C2_TEX && b < DMSH_C2_SEPTEX && !((b - DMSH_C2_TEX) % DMSH_C2_ROW)) return tex_slot_h(S.tex[stage], S.img[stage], (b - DMSH_C2_TEX) / DMSH_C2_ROW);
|
||||
if (b >= DMSH_C2_SEPTEX && b < DMSH_C2_SAMP && !((b - DMSH_C2_SEPTEX) % DMSH_C2_ROW)) return S.tex[stage][NVN_SEPTEX_SLOT0 + (b - DMSH_C2_SEPTEX) / DMSH_C2_ROW];
|
||||
if (b >= DMSH_C2_SAMP && b < DMSH_C2_SAMP + DMSH_C2_ROW * DMSH_C2_SEP_SLOTS && !((b - DMSH_C2_SAMP) % DMSH_C2_ROW)) return S.samp[stage][(b - DMSH_C2_SAMP) / DMSH_C2_ROW];
|
||||
return 0;
|
||||
}
|
||||
// A deferred inline update changes what the draws after it read through the uniform bindings it overlaps (they get a shadow): the argument blocks of those stages are encoded again.
|
||||
@@ -6932,21 +6936,22 @@ static int encode_args_(id<MTLCommandEncoder> en, NvShader *sh, int nvn_stage, i
|
||||
USE(pb, MTLResourceUsageRead);
|
||||
if (bl) PD("B %llu st%d %s pool base %d", g_stat_pass, nvn_stage, b->kind == NVN_RB_SAMPP ? "sampler" : "texture", b->kind == NVN_RB_SAMPP ? S.samp_base : S.tex_base);
|
||||
} else if (b->kind == NVN_RB_TEXA) { // an array of the driver table's handles that the shader indexes at run time (nvn_refl.h): element k = the texture of the c2 word at off + 8k
|
||||
uint64_t real = 0;
|
||||
uint64_t real = 0; // (elements past 63 are not in the log's mask)
|
||||
for (int k = 0; k < b->n; k++) {
|
||||
int tid = (int)(c2_handle(nvn_stage, b->off + 8u * k) & 0xfffff);
|
||||
int tid = (int)(c2_handle(nvn_stage, b->off + 8u * k) & 0xfffff); // a separate sampler word ORed in (soff) holds only a sampler ID
|
||||
void *tv = NULL; uint64_t trid = tid ? tex_fast_rid(tid, &tv) : 0; __unsafe_unretained id<MTLTexture> t = (__bridge id<MTLTexture>)tv;
|
||||
if (t && t.textureType != (MTLTextureType)b->dtt) { uint64_t r2 = 0; id<MTLTexture> v = tex_fit_elem(tid, t, (MTLTextureType)b->dtt, &r2); t = v; trid = v ? r2 : 0; } // an element the shader does not pick here may be another kind
|
||||
if (!t) { t = dummy_tex(b->dtt, b->dpf); trid = g_dummy_tex_rid[b->dtt & 7][b->dpf & 3]; } else real |= 1ull << k;
|
||||
if (!t) { t = dummy_tex(b->dtt, b->dpf); trid = g_dummy_tex_rid[b->dtt & 7][b->dpf & 3]; } else if (k < 64) real |= 1ull << k;
|
||||
if (bl && tid) PD("B %llu st%d texa [%d] tid=%d %s", g_stat_pass, nvn_stage, k, tid, tv ? "real" : "dummy");
|
||||
if (b->dtt == (uint8_t)MTLTextureTypeTextureBuffer) t = tbuf_shadow(t, &trid); // see tbuf_shadow
|
||||
slots[aid + k] = trid;
|
||||
USE(t, MTLResourceUsageRead);
|
||||
}
|
||||
if (!(sh->logged & 8)) { sh->logged |= 8; static int nlog; if (nlog++ < 32) MLOG("shader %s (stage %d): an array of %d driver-table handles from c2 byte %#x, elements %#llx hold textures", sh->key, nvn_stage, b->n, b->off, (unsigned long long)real); }
|
||||
} else if (b->kind == NVN_RB_SAMPA) { // its samplers: element k = the sampler of the combined handle at c2 byte off + 8k
|
||||
} else if (b->kind == NVN_RB_SAMPA) { // its samplers: element k = the sampler of the handle at c2 byte off + 8k, ORed with the separate sampler word at soff (handle type 1) as the GPU does
|
||||
uint64_t sw = b->soff ? c2_handle(nvn_stage, b->soff) : 0;
|
||||
for (int k = 0; k < b->n; k++) {
|
||||
int sid = (int)(c2_handle(nvn_stage, b->off + 8u * k) >> 20);
|
||||
int sid = (int)((c2_handle(nvn_stage, b->off + 8u * k) | sw) >> 20);
|
||||
__unsafe_unretained id<MTLSamplerState> ss = sid ? (__bridge id<MTLSamplerState>)samp_fast(sid) : nil;
|
||||
slots[aid + k] = sid && sid < g_nsreg && g_srid[sid] ? g_srid[sid] : dummy_samp_rid();
|
||||
USE(ss ? ss : dummy_samp(), MTLResourceUsageRead);
|
||||
@@ -10071,6 +10076,26 @@ static void copy_t2t(const p_copy_t2t *c) {
|
||||
if (rb) mirror_readback(c->dst, d, dl, dz0, &c->dr, "texture", 0);
|
||||
return;
|
||||
}
|
||||
// The depth plane of a depth-stencil texture into a depth-only one, or back (EA SPORTS FC 27's Frostbite copies its 1920x1080 Depth32Float_Stencil8 target into a Depth32Float
|
||||
// texture): a blit copies only between equal formats, so the 32-bit float depth goes through a buffer, taken from and written to the combined texture's depth plane
|
||||
if (!s3 && !d3 && c->sr.width == c->dr.width && c->sr.height == c->dr.height && (c->sr.depth ? c->sr.depth : 1) == 1 && (c->dr.depth ? c->dr.depth : 1) == 1
|
||||
&& !(c->flags & ~NVN_COPY_FLAGS_ENGINE_2D_BIT & ~NVN_COPY_FLAGS_LINEAR_FILTER_BIT) && s.sampleCount == 1 && d.sampleCount == 1
|
||||
&& ((s.pixelFormat == MTLPixelFormatDepth32Float_Stencil8 && d.pixelFormat == MTLPixelFormatDepth32Float) || (s.pixelFormat == MTLPixelFormatDepth32Float && d.pixelFormat == MTLPixelFormatDepth32Float_Stencil8))) {
|
||||
static id<MTLBuffer> plane; // kept from copy to copy, replaced (deferred) by a larger one
|
||||
NSUInteger row = (NSUInteger)c->sr.width * 4, img = row * (NSUInteger)c->sr.height;
|
||||
if (!plane || plane.length < img) {
|
||||
if (plane) defer_obj_release(plane);
|
||||
plane = [g_dev newBufferWithLength:img options:MTLResourceStorageModePrivate];
|
||||
if (!plane) { RED_ONCE(132, "depth plane copy: cannot create a %#lx-byte staging buffer", (unsigned long)img); return; }
|
||||
res_add(plane);
|
||||
}
|
||||
MTLBlitOption so = s.pixelFormat == MTLPixelFormatDepth32Float_Stencil8 ? MTLBlitOptionDepthFromDepthStencil : MTLBlitOptionNone, dop = d.pixelFormat == MTLPixelFormatDepth32Float_Stencil8 ? MTLBlitOptionDepthFromDepthStencil : MTLBlitOptionNone;
|
||||
enc_b_copy_texture_buffer_opt(blit(), s, sz0, sl, MTLOriginMake(c->sr.xoffset, c->sr.yoffset, 0), MTLSizeMake(c->sr.width, c->sr.height, 1), plane, 0, row, img, so);
|
||||
enc_b_copy_buffer_texture_opt(blit(), plane, 0, row, img, MTLSizeMake(c->sr.width, c->sr.height, 1), d, dz0, dl, MTLOriginMake(c->dr.xoffset, c->dr.yoffset, 0), dop);
|
||||
static int once; if (!once++) MLOG("depth plane copy: %dx%d Metal format %lu → %lu through a staging buffer", c->sr.width, c->sr.height, (unsigned long)s.pixelFormat, (unsigned long)d.pixelFormat);
|
||||
if (rb) mirror_readback(c->dst, d, dl, dz0, &c->dr, "texture", 0);
|
||||
return;
|
||||
}
|
||||
if (c->sr.width != c->dr.width || c->sr.height != c->dr.height || (c->sr.depth ? c->sr.depth : 1) != (c->dr.depth ? c->dr.depth : 1) || (c->flags & ~NVN_COPY_FLAGS_ENGINE_2D_BIT & ~NVN_COPY_FLAGS_LINEAR_FILTER_BIT)
|
||||
|| s.pixelFormat != d.pixelFormat || s3 != d3) {
|
||||
RED_ONCE(33, "texture→texture copy case not implemented: %dx%dx%d→%dx%dx%d flags %#x format %lu→%lu 3D %d→%d", c->sr.width, c->sr.height, c->sr.depth, c->dr.width, c->dr.height, c->dr.depth,
|
||||
|
||||
@@ -23,7 +23,7 @@ enum { NVN_CT_FLOAT = 0, NVN_CT_UINT, NVN_CT_INT };
|
||||
// (UiMM_WorldMap3D) has a pixel shader with 30 textures, 30 samplers, 3 uniform buffers and the c1 / support / driver segments, 66 in all, which the old limit of 64 refused
|
||||
// (the traveler selection drew its map black)
|
||||
#define NVN_REFL_MAXB 96
|
||||
#define NVN_REFL_MAXARG 192 // argument buffer entries of one shader (an array binding takes n of them)
|
||||
#define NVN_REFL_MAXARG 768 // argument buffer entries of one shader (an array binding takes n of them; a c2 handle array 301, with its samplers 602)
|
||||
#define NVN_REFL_MAXV 32
|
||||
|
||||
typedef struct {
|
||||
@@ -31,7 +31,8 @@ typedef struct {
|
||||
uint8_t dtt, dpf; // Dummy texture when the texture slot is unbound: MTLTextureType value, pixel class
|
||||
uint16_t reg, aid; // D3D register number, index within the argument buffer
|
||||
uint16_t off; // TEXU / SAMPU: byte offset of the handle within the uniform buffer; SBUFU: of the 64-bit storage buffer address
|
||||
uint8_t n; // TEXD / SAMPD, and TEXU / SAMPU arrays (element k = the handle at byte 8k of the uniform buffer): array length (argument buffer entries aid .. aid + n - 1)
|
||||
uint16_t n; // TEXD / SAMPD, TEXA / SAMPA, and TEXU / SAMPU arrays (element k = the handle at byte 8k of the uniform buffer): array length (argument buffer entries aid .. aid + n - 1)
|
||||
uint16_t soff; // TEXA / SAMPA: c2 byte of a separate sampler word ORed into every element's handle (handle type 1), 0 = none
|
||||
uint8_t f1d; // TEX: read by 1D integer fetches as 2D rows of 16384 texels (dmsh_build.py "fetch1d"): a buffer texture here is bound as such rows (nvn_mtl.m tbuf_as_2d)
|
||||
uint8_t atom; // IMG: the shader runs image atomics on it (dmsh_build.py "atomic"): the texture must allow Metal's texture atomics (nvn_mtl.m dummy_img_atomic)
|
||||
} nvn_rbind;
|
||||
|
||||
@@ -71,8 +71,10 @@ int nvn_refl_from_json(NSDictionary *j, nvn_refl *o, char *err, int errlen) {
|
||||
else if ([k isEqualToString:@DMSH_KIND_TEX_POOL]) { r->kind = NVN_RB_TEXP; dummy_kind(b[@"elem"], &r->dtt, &r->dpf); o->bindless = o->pool = 1; }
|
||||
else if ([k isEqualToString:@DMSH_KIND_SAMP_POOL]) { r->kind = NVN_RB_SAMPP; o->bindless = o->pool = 1; }
|
||||
else if ([k isEqualToString:@DMSH_KIND_TEX_C2A] || [k isEqualToString:@DMSH_KIND_SAMP_C2A]) { // an array of the driver table's handles (nvn_refl.h TEXA / SAMPA)
|
||||
if (n < 1 || n > 32) FAIL("B binding %s: array of %d", nm.UTF8String, n);
|
||||
r->kind = [k isEqualToString:@DMSH_KIND_TEX_C2A] ? NVN_RB_TEXA : NVN_RB_SAMPA; r->n = (uint8_t)n; r->off = (uint16_t)[b[@"off"] intValue];
|
||||
int words = (DMSH_C2_SAMP + DMSH_C2_ROW * DMSH_C2_SEP_SLOTS) / DMSH_C2_ROW, soff = [b[@"soff"] intValue]; // one element per c2 handle word (Program.cs C2HandleWords)
|
||||
if (n < 1 || n > words) FAIL("B binding %s: array of %d", nm.UTF8String, n);
|
||||
if (soff < 0 || soff % DMSH_C2_ROW || soff >= DMSH_C2_SAMP + DMSH_C2_ROW * DMSH_C2_SEP_SLOTS) FAIL("B binding %s: sampler word at c2 byte %#x", nm.UTF8String, soff);
|
||||
r->kind = [k isEqualToString:@DMSH_KIND_TEX_C2A] ? NVN_RB_TEXA : NVN_RB_SAMPA; r->n = (uint16_t)n; r->off = (uint16_t)[b[@"off"] intValue]; r->soff = (uint16_t)soff;
|
||||
if (r->kind == NVN_RB_TEXA) dummy_kind(el, &r->dtt, &r->dpf);
|
||||
}
|
||||
else if ([k isEqualToString:@DMSH_KIND_IMG]) { r->kind = NVN_RB_IMG; dummy_kind(b[@"msl_type"], &r->dtt, &r->dpf); // rw: the shader writes it (access::write / read_write; a load-only view of the slot is not)
|
||||
|
||||
@@ -16,7 +16,8 @@ def builder_reflection():
|
||||
tree = ast.parse((TOOLS / 'dmsh_build.py').read_text())
|
||||
names = {'reflect', 'decode_tex', 'decode_ubo_tex', 'const_sampler', 'c2_array'}
|
||||
selected = [n for n in tree.body if (isinstance(n, ast.FunctionDef) and n.name in names)
|
||||
or (isinstance(n, ast.Assign) and any(isinstance(t, ast.Name) and t.id == 'SSBO' for t in n.targets))]
|
||||
or (isinstance(n, ast.Assign) and any(isinstance(t, ast.Name) and t.id == 'SSBO' for t in n.targets))
|
||||
or (isinstance(n, ast.Assign) and any(isinstance(t, ast.Tuple) and any(isinstance(e, ast.Name) and e.id == 'TEX_BASE' for e in t.elts) for t in n.targets))]
|
||||
ns = {'re': re, 'dmsh_geometry': dmsh_geometry, 'abi': dmsh_abi}
|
||||
exec(compile(ast.Module(body=selected, type_ignores=[]), str(TOOLS / 'dmsh_build.py'), 'exec'), ns)
|
||||
return ns['reflect']
|
||||
@@ -60,5 +61,46 @@ class StorageBuffers(unittest.TestCase):
|
||||
self.assertIsNone(bindings('hs', [0x410], [1])[0]['reg'])
|
||||
|
||||
|
||||
class DriverTableArrays(unittest.TestCase):
|
||||
def reflect(self, members):
|
||||
source = 'struct spvDescriptorSetBuffer0\n{\n' + ''.join(f' {t} {n} [[id({i})]];\n' for t, n, i in members) + '};\n'
|
||||
return REFLECT('synthetic', 'ps', source, {'sbufs': []})
|
||||
|
||||
def test_combined_handles(self): # Luigi's Mansion 3's shadow cascades: element k = the handle at c2 byte 8k
|
||||
got = self.reflect([('array<texture2d_array<float>, 301>', 'fp_t2das_cb2_0', 0), ('array<sampler, 301>', 'fp_t2das_cb2_0Smplr', 301)])
|
||||
self.assertEqual([(b['kind'], b['off'], b.get('soff')) for b in got], [('tex_c2a', 0, None), ('samp_c2a', 0, None)])
|
||||
|
||||
def test_one_separate_sampler_word(self): # EA SPORTS FC 27's lights: texture words from c2 byte 0, the sampler word at c2 byte 0x570 ORed into each
|
||||
got = self.reflect([('array<texture2d<float>, 301>', 'fp_t2d_cb196610_10570000', 0), ('array<sampler, 301>', 'fp_t2d_cb196610_10570000Smplr', 301)])
|
||||
self.assertEqual([(b['kind'], b['off'], b.get('soff')) for b in got], [('tex_c2a', 0, 0x570), ('samp_c2a', 0, 0x570)])
|
||||
|
||||
def test_sampler_word_in_another_buffer_is_not_a_driver_table_array(self): # the sampler word in c3 (slots 0x40002): not this form
|
||||
got = self.reflect([('array<texture2d<float>, 301>', 'fp_t2d_cb262146_10570000', 0)])
|
||||
self.assertNotEqual(got[0]['kind'], 'tex_c2a')
|
||||
|
||||
|
||||
def builder_unfillable():
|
||||
tree = ast.parse((TOOLS / 'dmsh_build.py').read_text())
|
||||
keep = lambda n: (isinstance(n, ast.FunctionDef) and n.name in ('drv_reads', 'unfillable')) or (isinstance(n, ast.Assign) and any(
|
||||
(isinstance(t, ast.Name) and t.id in ('SSBO', 'DRV_FILL')) or (isinstance(t, ast.Tuple) and any(isinstance(e, ast.Name) and e.id == 'TEX_BASE' for e in t.elts)) for t in n.targets))
|
||||
ns = {'re': re, 'abi': dmsh_abi}
|
||||
exec(compile(ast.Module(body=[n for n in tree.body if keep(n)], type_ignores=[]), str(TOOLS / 'dmsh_build.py'), 'exec'), ns)
|
||||
return lambda src: ns['unfillable'](ns['drv_reads'](src))
|
||||
|
||||
|
||||
UNFILLABLE = builder_unfillable()
|
||||
|
||||
|
||||
class DriverReads(unittest.TestCase):
|
||||
def test_computed_c2_index_reads_the_filled_tables(self): # EA SPORTS FC 27's lights: (*spvDescriptorSet0.fp_c2)._m0[int(_237)][_239]
|
||||
self.assertEqual(UNFILLABLE('float _241 = (*spvDescriptorSet0.fp_c2)._m0[int(_237)][_239];'), [])
|
||||
|
||||
def test_computed_c0_index_is_refused(self):
|
||||
self.assertEqual(UNFILLABLE('float x = (*spvDescriptorSet0.fp_c0)._m0[int(_5)].x;'), ['c0 dynamic index'])
|
||||
|
||||
def test_c2_word_outside_the_tables_is_refused(self):
|
||||
self.assertEqual(UNFILLABLE('float x = (*spvDescriptorSet0.fp_c2)._m0[0].x;'), ['c2+0x0'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,119 @@
|
||||
"""frostbite.py on a synthetic Frostbite RomFS: layout.toc's install chunks, a superbundle toc whose one bundle has a CompiledBytecode resource and a texture, the bundle manifest in a cas file,
|
||||
the item's blocks (stored and through a decoder) and the VNVN record's code area and control section."""
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
|
||||
import frostbite as fb
|
||||
|
||||
CHUNK = 0xA3A00DE1 # installpackage_00's persistentIndex in EA SPORTS FC 27
|
||||
|
||||
|
||||
def leb(n):
|
||||
out = bytearray()
|
||||
while True:
|
||||
b = n & 0x7f; n >>= 7
|
||||
out.append(b | (0x80 if n else 0))
|
||||
if not n: return bytes(out)
|
||||
|
||||
|
||||
def dbo(kind, name, body): # one DbObject value: a type byte with bit 7 for an unnamed one, its name, its body
|
||||
return bytes([kind | (0x80 if name is None else 0)]) + (b'' if name is None else name.encode() + b'\0') + body
|
||||
|
||||
|
||||
def dbo_obj(name, items, kind=2): body = b''.join(items) + b'\0'; return dbo(kind, name, leb(len(body)) + body)
|
||||
def dbo_str(name, s): b = s.encode() + b'\0'; return dbo(7, name, leb(len(b)) + b)
|
||||
def dbo_i32(name, v): return dbo(8, name, struct.pack('<i', v))
|
||||
|
||||
|
||||
def toc_file(body): return fb.TOC_MAGIC + bytes(fb.TOC_BODY - 4) + body
|
||||
|
||||
|
||||
def block(data, codec=0, stored=None): # an item block: stored bytes as they are, or what a decoder is given
|
||||
s = data if stored is None else stored
|
||||
return struct.pack('>IBBH', len(data), codec, 0x70 | len(s) >> 16, len(s) & 0xffff) + s
|
||||
|
||||
|
||||
def vnvn(code, ctl): # a CompiledBytecode resource: a 0x20-byte header, then the VNVN record (version 9, one register mapping in the first list)
|
||||
head = b'VNVN' + struct.pack('<IHHI', 0, 9, 0, 0) + b'\0' + struct.pack('<H', 1) + bytes(4) + struct.pack('<HHHH', 0, 0, 0, 0)
|
||||
co = len(head) + 24; ko = co + len(code)
|
||||
rec = head + struct.pack('<4IQ', co, len(code), ko, len(ctl), 0) + code + ctl
|
||||
return bytes([5, 0, 8, 0]) + bytes(0x1c) + rec
|
||||
|
||||
|
||||
def manifest(res): # res: [(name, size, type)] → the manifest as the cas file stores it
|
||||
names = b''; offs = []
|
||||
for n, _, _ in res: offs.append(len(names)); names += n.encode() + b'\0'
|
||||
tot = len(res); body_head = 0x20 + 20 * tot + 8 * tot + 4 * tot + 24 * tot
|
||||
hdr = struct.pack('<8I', fb.BUNDLE_MAGIC, tot, 0, tot, 0, body_head, 0, 0) + bytes(20 * tot)
|
||||
hdr += b''.join(struct.pack('<II', o, s) for o, (_, s, _) in zip(offs, res)) + b''.join(struct.pack('<I', t) for _, _, t in res) + bytes(24 * tot) + names
|
||||
return struct.pack('>I', len(hdr)) + hdr
|
||||
|
||||
|
||||
class FrostbiteTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory(); r = Path(self.tmp.name)
|
||||
self.code = struct.pack('<I', 0x12345678) + bytes(0x60)
|
||||
self.ctl = bytes.fromhex('34127698') + bytes(0x87c); self.ctl = self.ctl[:0x704] + struct.pack('<I', len(self.code)) + self.ctl[0x708:]
|
||||
self.shader = vnvn(self.code, self.ctl); tex = b'texture data'
|
||||
res = [('shaders/bytecode/0001', len(self.shader), fb.COMPILED_BYTECODE), ('textures/a', len(tex), fb.name_hash('Texture'))]
|
||||
man = manifest(res); items = [block(self.shader), block(tex)]
|
||||
cas = man + b''.join(items)
|
||||
(r / 'Data/NX/superbundlelayout/installpackage_00').mkdir(parents=True)
|
||||
(r / 'Data/NX/superbundlelayout/installpackage_00/cas_01.cas').write_bytes(cas)
|
||||
chunks = dbo_obj('installChunks', [dbo_obj(None, [dbo_str('name', 'superbundlelayout/installpackage_00'), dbo_str('installBundle', ''),
|
||||
dbo_i32('persistentIndex', CHUNK - (1 << 32))])], kind=1)
|
||||
(r / 'Data/layout.toc').write_bytes(toc_file(dbo_obj(None, [dbo_obj('installManifest', [chunks])])))
|
||||
cid = bytes([0, 0]) + struct.pack('>IH', CHUNK, 1)
|
||||
ents = [(len(man), 0)] + [(len(i), len(man) + sum(len(x) for x in items[:k])) for k, i in enumerate(items)]
|
||||
n = len(ents); data = struct.pack('>9I', 0, 0, 0x24 + 8 + 8 * n, n, 0x24, 0x24, 0x24, 0, n) + cid
|
||||
for size, off in ents: data += struct.pack('>II', off, size)
|
||||
data += bytes([0x84] + [0] * (n - 1))
|
||||
body = struct.pack('>24I', 0, 0x60, 1, *([0] * 21)) + struct.pack('>IIQ', 0, 0x40000000 | len(data), 0x70) + data
|
||||
(r / 'Data/NX/test.toc').write_bytes(toc_file(body))
|
||||
self.root, self.items, self.man = str(r), items, man
|
||||
|
||||
def tearDown(self): self.tmp.cleanup()
|
||||
|
||||
def test_name_hash(self):
|
||||
self.assertEqual(fb.COMPILED_BYTECODE, 0x0e2b02f7)
|
||||
self.assertEqual(fb.name_hash('Texture'), 0x6bde20ba)
|
||||
self.assertEqual(fb.name_hash('ShaderBlockDepotResource'), 0x73312045)
|
||||
|
||||
def test_resources_of_a_type(self):
|
||||
self.assertTrue(fb.is_frostbite(self.root))
|
||||
res = fb.resources(self.root, fb.COMPILED_BYTECODE)
|
||||
self.assertEqual(list(res.values()), [(len(self.shader), 'shaders/bytecode/0001')])
|
||||
(cas, off, stored), = res
|
||||
self.assertTrue(cas.endswith('installpackage_00/cas_01.cas'))
|
||||
self.assertEqual((off, stored), (len(self.man), len(self.items[0])))
|
||||
|
||||
def test_read_and_nvn_shader(self):
|
||||
(cas, off, stored), (size, _) = next(iter(fb.resources(self.root, fb.COMPILED_BYTECODE).items()))
|
||||
d = Path(cas).read_bytes()
|
||||
b = fb.read(d, off, stored, size, None)
|
||||
self.assertEqual(b, self.shader)
|
||||
self.assertEqual(fb.nvn_shader(b), (self.code, self.ctl))
|
||||
|
||||
def test_decoded_blocks(self): # codec 0x19 goes to the decoder with the block's raw size
|
||||
data = b'0123456789' * 10
|
||||
d = block(data[:60], 0x19, b'A' * 7) + block(data[60:])
|
||||
seen = []
|
||||
def decode(comp, n): seen.append((comp, n)); return data[:n]
|
||||
self.assertEqual(fb.read(d, 0, len(d), len(data), decode), data)
|
||||
self.assertEqual(seen, [(b'A' * 7, 60)])
|
||||
|
||||
def test_damaged_items(self):
|
||||
d = block(b'abc')
|
||||
with self.assertRaises(ValueError): fb.read(d, 0, len(d), 4, None) # decodes to 3, not 4
|
||||
bad = d[:5] + b'\x60' + d[6:] # the 0x70 marker broken
|
||||
with self.assertRaises(ValueError): fb.read(bad, 0, len(bad), 3, None)
|
||||
with self.assertRaises(ValueError): fb.read(block(b'abc', 0x22), 0, 11, 3, None) # an unknown codec
|
||||
self.assertIsNone(fb.nvn_shader(b'not a shader' * 4))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -547,13 +547,17 @@ def decode_ubo_tex(name):
|
||||
return (tb - 3, o0 * 4), (('id', o1) if ty == 3 else (sb - 3, o1 * 4) if ty else (tb - 3, o0 * 4))
|
||||
|
||||
def c2_array(name, ty):
|
||||
"""An array of combined handles in the driver table c2 that the shader indexes at run time (Ryujinx's texture array from a buffer, here bank 2: <stage>_t<type>_cb2_<handle>, declared
|
||||
array<element, n>; the index is the handle's byte offset ÷ 8). Luigi's Mansion 3: 586 pixel shaders sample their shadow cascades from array<texture2d_array<float>, 32> fp_t2das_cb2_0,
|
||||
the index (0x80 + a cascade offset) ÷ 8. → the c2 byte offset of element 0 (element k = the handle at that offset + 8k), or None"""
|
||||
m = re.fullmatch(r'[a-z]+_t\w*?_cb2_([0-9A-F]+)', name[:-5] if name.endswith('Smplr') else name)
|
||||
"""An array of handles in the driver table c2 that the shader indexes at run time (Ryujinx's texture array from a buffer, here bank 2: <stage>_t<type>_cb<slots>_<handle>, declared
|
||||
array<element, n>, one element per c2 handle word; the index is the handle's byte offset ÷ 8). Luigi's Mansion 3: 586 pixel shaders sample their shadow cascades from
|
||||
array<texture2d_array<float>, n> fp_t2das_cb2_0, the index (0x80 + a cascade offset) ÷ 8. Handle type 1 ORs one fixed separate sampler word into every element's handle:
|
||||
EA SPORTS FC 27's lights, fp_t2d_cb196610_10570000 (texture words from c2 byte 0, the sampler word at c2 byte 0x570), indexed by separate texture i at element 45 + i.
|
||||
→ (the c2 byte offset of element 0 (element k = the handle at that offset + 8k), the c2 byte offset of the sampler word or None), or None"""
|
||||
m = re.fullmatch(r'[a-z]+_t\w*?_cb(\d+)_([0-9A-F]+)', name[:-5] if name.endswith('Smplr') else name)
|
||||
if not m or not ty.startswith('array<'): return None
|
||||
h = int(m.group(1), 16)
|
||||
return (h & 0x3fff) * 4 if h >> 28 == 0 else None
|
||||
slots, h = int(m.group(1)), int(m.group(2), 16)
|
||||
if h >> 28 == 0 and slots == 2: return (h & 0x3fff) * 4, None
|
||||
if h >> 28 == 1 and slots & 0xffff == 2 and (slots >> 16) - 1 == 2: return (h & 0x3fff) * 4, ((h >> 14) & 0x3fff) * 4
|
||||
return None
|
||||
|
||||
POOL_MIN = 33 # arrays at least this long are pools: Program.cs sizes Ryujinx's handle fallback by the pools, the vendored BindlessElimination keeps 32-entry slot arrays (NvnSlotArrayLength)
|
||||
|
||||
@@ -627,7 +631,8 @@ def reflect(key, stage, msl, res):
|
||||
elif 'texture_buffer' in ty: e.update(kind=abi.KIND_UNKNOWN) # bindless typed buffer: not implemented in the replay layer
|
||||
else: e.update(kind=abi.KIND_TEX_UBO, reg=ut[0], off=ut[1])
|
||||
elif c2_array(nm, ty) is not None: # an array of the driver table's handles (c2_array): the replay fills element k from the slot whose c2 word is at off + 8k
|
||||
e.update(kind=abi.KIND_SAMP_C2A if nm.endswith('Smplr') else abi.KIND_TEX_C2A, off=c2_array(nm, ty))
|
||||
off, soff = c2_array(nm, ty)
|
||||
e.update(kind=abi.KIND_SAMP_C2A if nm.endswith('Smplr') else abi.KIND_TEX_C2A, off=off, **({'soff': soff} if soff is not None else {}))
|
||||
elif nm.endswith('Smplr'): # handle type 0 = texture and sampler combined in one handle: the sampler index is taken from the high bits of that texture slot's handle
|
||||
t, s, ty = decode_tex(nm[:-5]); e.update(kind=abi.KIND_SAMP_ID, reg=const_sampler(nm[:-5])) if ty == 3 else e.update(kind=abi.KIND_SAMP, reg=s) if ty else e.update(kind=abi.KIND_SAMP_TEX, reg=t)
|
||||
else:
|
||||
@@ -674,7 +679,9 @@ def drv_reads(src):
|
||||
def unfillable(dr):
|
||||
bad = []
|
||||
for bank, d in dr.items():
|
||||
if d['dynamic']: bad.append(f'c{bank} dynamic index')
|
||||
# a computed index into c2 reads one of its handle tables, which the replay layer fills whole (nvn_mtl.m DRV2: EA SPORTS FC 27's lights read the separate texture words
|
||||
# at 0x168 + 8i to test each light's handle); c0 is filled only in its tables and words above, so a computed index there may read what the replay does not write
|
||||
if d['dynamic'] and bank == '0': bad.append(f'c{bank} dynamic index')
|
||||
for o in d['vec4_offsets']:
|
||||
# a read is a 16-byte row: overlapping any table is enough (Engage reads the c2+0x160 row for texture slot 0 at 0x168 in it)
|
||||
if not any(o < b and a < o + 16 for a, b in DRV_FILL[int(bank)]): bad.append(f'c{bank}+{o:#x}')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Translation chain tool fingerprints (written by tool_lock.py --update-lock; regenerate after changing tools and commit it)
|
||||
dmsh_xlate.dll 66510135b31711af
|
||||
dmsh_xlate.dll 2fc5a8d958a43afd
|
||||
Ryujinx.Graphics.Shader.dll dea593d38ebb2ae6
|
||||
Ryujinx.Common.dll 9d72afeb44b3096e
|
||||
xlate_source 748af7f9c36b9c49
|
||||
xlate_source 29e80b8c166d2f81
|
||||
spirv-cross e37945d8e441d34d
|
||||
metal_macosx Apple metal version 32023.921 (metalfe-32023.921.6)
|
||||
metal_iphoneos Apple metal version 32023.921 (metalfe-32023.921.6)
|
||||
@@ -25,6 +25,9 @@ static class SwshXlate
|
||||
// NVN's handle tables in c[2], byte offsets, 8 bytes per slot (one layout in every game, see dm/gfx/tools/dmsh_build.py): combined textures 0x20 + 8 r, images 0x120 + 8 r (8 slots),
|
||||
// separate textures 0x168 + 8 r (slot 128 + r), separate samplers 0x568 + 8 r
|
||||
const int TexBase = 0x20, ImgBase = 0x120, ImgSlots = 8, SepTexBase = 0x168, SepTexSlot0 = 128, SampBase = 0x568;
|
||||
// Handle words in c[2]: one every 8 bytes up to the end of the separate sampler table (128 slots), 301 in all. An array of c[2] handles the shader indexes at run time (Ryujinx's
|
||||
// texture array from a buffer, BindlessToArray: the index is the handle's byte offset ÷ 8) has one element per word, so any word the shader computes is in it
|
||||
const int C2HandleWords = (SampBase + 8 * 128) / 8;
|
||||
|
||||
sealed class Accessor : IGpuAccessor
|
||||
{
|
||||
@@ -54,7 +57,9 @@ static class SwshXlate
|
||||
// A texture read whose handle the translator cannot trace to one slot indexes the texture and sampler pools by the handle's IDs (20 and 12 bits); dmsh_build.py turns these
|
||||
// arrays into pointers to the pools the replay keeps (pool_arrays), with a run-time bound, so the lengths are the whole ID ranges
|
||||
public int QuerySamplerArrayLengthFromPool() => 1 << 12;
|
||||
public int QueryTextureArrayLengthFromBuffer(int slot) => 32;
|
||||
// c[2]: every handle word (C2HandleWords). EA SPORTS FC 27's lights index separate texture i as element 45 + i (c2 byte 0x168 + 8 i), which 32 elements clamped to element 31.
|
||||
// Other buffers (the game's own uniform buffers, read through the handles' byte offsets as well) keep 32
|
||||
public int QueryTextureArrayLengthFromBuffer(int slot) => slot == 2 ? C2HandleWords : 32;
|
||||
public int QueryTextureArrayLengthFromPool() => 1 << 20;
|
||||
|
||||
string Get(string table, int slot) => _job[table] is JsonObject t && t[slot.ToString()] is JsonNode n ? (n is JsonObject o ? (string)o["type"] : (string)n) : null;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,189 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Frostbite's game data on the Switch (EA SPORTS FC 27, Frostbite 2025.1.2): the superbundle tables (.toc), the bundle manifests and the compressed data in the cas files, and the
|
||||
NVN shaders of its CompiledBytecode resources. Used by shader_split.py (frostbite_jobs, frostbite_shaders) and dm/games/profile_guess.py (is_frostbite).
|
||||
|
||||
The RomFS holds Data/ (the base data) and Patch/ (the update's), each with NX/<superbundle>.toc files and NX/superbundlelayout/<install chunk>/cas_NN.cas files, and Data/layout.toc,
|
||||
whose installManifest names the install chunks. Every .toc starts with the magic 00 D1 CE 01, a signature and padding; its body is at +0x22c. Data/initfs_NX is encrypted (the game decrypts
|
||||
it); nothing here needs it.
|
||||
· layout.toc's body is a DbObject (dbobject): installManifest.installChunks lists {name 'superbundlelayout/<name>', the folder under NX/, persistentIndex}, which the cas ids name
|
||||
(installBundle is the same path under NX/, empty for two install chunks with no bundles of their own).
|
||||
· A superbundle .toc's body (big-endian): u32 offsets and counts, relative to the body: +4 bundle table, +8 bundle count, +0x14 chunk count, +0x18 chunk table. A bundle is
|
||||
{u32 name, u32 0x40000000 | data size, u64 data offset}; its data is {u32 0, 0, flag offset, entry count, entry offset, …}, then the entries, then one flag byte per entry: an entry is
|
||||
{u32 offset, u32 stored size} in a cas file, preceded by an 8-byte cas id when its flag has bit 7 set (the first one always). A cas id is {u8 0, u8 1 = Patch / 0 = Data,
|
||||
u32 the install chunk's persistentIndex, u16 the cas file's number}. Entry 0 is the bundle's manifest, the others its items in the manifest's order (ebx, res, chunks).
|
||||
A chunk is {cas id, u32 offset, u32 stored size}, 16 bytes.
|
||||
· A manifest is stored as it is: u32 big-endian length, then (little-endian) the magic 0x9D798ED6, total count, ebx count, res count, chunk count, string offset (from the magic),
|
||||
meta offset, meta size, a SHA-1 per item, then the ebx {u32 name, u32 size}, the res {u32 name, u32 size}, the res types (u32 each, name_hash of the type's name), 16 bytes of meta and
|
||||
a u64 id per res, the chunks {16-byte GUID, u32 logical offset, u32 logical size}, the names.
|
||||
· An item's stored data is a run of blocks: {u32 big-endian size (low 24 bits), u8 codec, u8 0x70 | bits 16..19 of the stored size, u16 big-endian stored size bits 0..15} and the
|
||||
stored bytes. Codec 0 is stored as it is, 0x19 Oodle (Leviathan, 8C 0C), which only the game's own decoder reads (shader_split.py oodle). Blocks hold at most 256 KB.
|
||||
· A CompiledBytecode resource (shaders/bytecode/<guid>) is a 0x20-byte header (u8 5, u8 stage: 0 vertex, 1 pixel, 5 compute; …) and a VNVN record, fb::NvnCustomShaderData
|
||||
(Engine.Render.Core2.PlatformNvn.nro, NvnCustomShaderData::read): 'VNVN', u32 size, u16 version (9), …, a byte from version 3 on, four lists of register mappings {u16 count, 4 bytes
|
||||
each}, one list {u16 count, 8 bytes each}, then {u32 code offset, u32 code length, u32 control offset, u32 control length, u64 GPU code bits}, offsets from the record. The code area and
|
||||
control section are NVN's own (compiled offline); 10,401 of them in FC 27 1.8d.310c, 7,084 graphics and 3,317 compute."""
|
||||
import os, struct, sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../tools'))
|
||||
from romfs import os, open, mmap
|
||||
|
||||
TOC_MAGIC, TOC_BODY = bytes.fromhex('00d1ce01'), 0x22c
|
||||
BUNDLE_MAGIC = 0x9D798ED6
|
||||
|
||||
|
||||
def name_hash(name):
|
||||
"""Frostbite's hash of a type name (res types): djb2 with xor over the lower-case name; name_hash('CompiledBytecode') = 0x0e2b02f7, 'Texture' 0x6bde20ba, 'MeshSet' 0x49b156d4"""
|
||||
h = 5381
|
||||
for c in name.lower().encode(): h = (h * 33 ^ c) & 0xffffffff
|
||||
return h
|
||||
|
||||
|
||||
COMPILED_BYTECODE = name_hash('CompiledBytecode')
|
||||
|
||||
|
||||
def is_frostbite(romfs):
|
||||
"""The RomFS is Frostbite's: Data/layout.toc with the toc magic"""
|
||||
p = os.path.join(romfs, 'Data', 'layout.toc')
|
||||
if not os.path.exists(p): return False
|
||||
with open(p, 'rb') as f: return f.read(4) == TOC_MAGIC
|
||||
|
||||
|
||||
def _leb(d, p):
|
||||
v = s = 0
|
||||
while True:
|
||||
if p >= len(d): raise ValueError('DbObject: a length runs past the end')
|
||||
b = d[p]; p += 1; v |= (b & 0x7f) << s; s += 7
|
||||
if not b & 0x80: return v, p
|
||||
|
||||
|
||||
def dbobject(d, p):
|
||||
"""One DbObject value at p → ((name or None, value), next offset). A type byte (bit 7 clear: a NUL-terminated name follows; low 5 bits the kind: 1 list, 2 object, 6 bool, 7 string,
|
||||
8 int32, 9 int64, 0xb float, 0xc double, 0xf GUID, 0x10 SHA-1, 0x13 blob), lists and objects with a LEB128 length and ending in a 0 byte"""
|
||||
t = d[p]; p += 1; name = None
|
||||
if not t & 0x80:
|
||||
e = d.index(b'\0', p); name = d[p:e].decode(errors='replace'); p = e + 1
|
||||
k = t & 0x1f
|
||||
if k in (1, 2):
|
||||
n, p = _leb(d, p); end = p + n; items = []
|
||||
while p < end and d[p]: it, p = dbobject(d, p); items.append(it)
|
||||
return (name, dict(items) if k == 2 else [v for _, v in items]), end
|
||||
if k == 7: n, p = _leb(d, p); return (name, d[p:p + n - 1].decode(errors='replace')), p + n
|
||||
if k == 19: n, p = _leb(d, p); return (name, bytes(d[p:p + n])), p + n
|
||||
fixed = {6: ('<?', 1), 8: ('<i', 4), 9: ('<q', 8), 0xb: ('<f', 4), 0xc: ('<d', 8)}
|
||||
if k in fixed: return (name, struct.unpack_from(fixed[k][0], d, p)[0]), p + fixed[k][1]
|
||||
if k in (0xf, 0x10): n = 16 if k == 0xf else 20; return (name, bytes(d[p:p + n])), p + n
|
||||
raise ValueError(f'DbObject: type {t:#x} at {p - 1:#x} is not known')
|
||||
|
||||
|
||||
def _read(p):
|
||||
with open(p, 'rb') as f: return f.read()
|
||||
|
||||
|
||||
def install_chunks(romfs):
|
||||
"""{persistentIndex (u32): the install chunk's folder under NX/, 'superbundlelayout/<name>'} from Data/layout.toc"""
|
||||
d = _read(os.path.join(romfs, 'Data', 'layout.toc'))
|
||||
(_, lay), _ = dbobject(d, TOC_BODY)
|
||||
if not isinstance(lay, dict) or 'installManifest' not in lay: raise ValueError('Data/layout.toc: no installManifest')
|
||||
return {c['persistentIndex'] & 0xffffffff: c['name'] for c in lay['installManifest']['installChunks']}
|
||||
|
||||
|
||||
def tocs(romfs):
|
||||
"""The superbundle tables of Data/ and Patch/ (Patch/ holds the update's bundles and chunks, which name Patch/ cas files)"""
|
||||
out = []
|
||||
for top in ('Data', 'Patch'):
|
||||
for dp, _, fs in os.walk(os.path.join(romfs, top, 'NX')):
|
||||
out += [os.path.join(dp, f) for f in sorted(fs) if f.endswith('.toc')]
|
||||
return out
|
||||
|
||||
|
||||
def toc_bundles(d, what='toc'):
|
||||
"""[[(cas id, offset, stored size), …] per bundle] of a superbundle .toc (entry 0 the manifest); [] for a toc without a body"""
|
||||
if d[:4] != TOC_MAGIC: raise ValueError(f'{what}: not a Frostbite toc (magic {bytes(d[:4]).hex()})')
|
||||
if len(d) < TOC_BODY + 0x20: return []
|
||||
B = TOC_BODY; bo, nb = struct.unpack_from('>II', d, B + 4)
|
||||
out = []
|
||||
for i in range(nb):
|
||||
_, sz, off = struct.unpack_from('>IIQ', d, B + bo + 16 * i)
|
||||
s = B + off; end = s + (sz & 0xffffff)
|
||||
if end > len(d): raise ValueError(f'{what}: bundle {i}\'s data runs past the end')
|
||||
fo, n, p = struct.unpack_from('>III', d, s + 8)
|
||||
p += s; fo += s; cas, ents = None, []
|
||||
if fo + n > end: raise ValueError(f'{what}: bundle {i}\'s flags run past its data')
|
||||
for k in range(n):
|
||||
if d[fo + k] & 0x80 or cas is None: cas = bytes(d[p:p + 8]); p += 8
|
||||
ents.append((cas,) + struct.unpack_from('>II', d, p)); p += 8
|
||||
if p != fo: raise ValueError(f'{what}: bundle {i}\'s entries end at {p - s:#x}, its flags start at {fo - s:#x}')
|
||||
out.append(ents)
|
||||
return out
|
||||
|
||||
|
||||
def cas_path(romfs, cid, chunks):
|
||||
"""The cas file a cas id names"""
|
||||
pi, n = struct.unpack_from('>IH', cid, 2)
|
||||
if pi not in chunks: raise ValueError(f'cas id {cid.hex()}: no install chunk has persistentIndex {pi:#x}')
|
||||
return os.path.join(romfs, 'Patch' if cid[1] else 'Data', 'NX', chunks[pi], f'cas_{n:02d}.cas')
|
||||
|
||||
|
||||
def manifest(d, off):
|
||||
"""A bundle manifest at off in a cas file → (manifest length, [(ebx name, size)], [(res name, size, type)], [(chunk GUID, logical offset, logical size)])"""
|
||||
hl = struct.unpack_from('>I', d, off)[0]; magic, tot, ne, nr, nc, so = struct.unpack_from('<6I', d, off + 4)
|
||||
if magic != BUNDLE_MAGIC: raise ValueError(f'no bundle manifest at {off:#x} (magic {magic:#x})')
|
||||
if ne + nr + nc != tot: raise ValueError(f'bundle manifest at {off:#x}: {ne} + {nr} + {nc} items, not the {tot} it counts')
|
||||
h = off + 4; p = h + 0x20 + 20 * tot
|
||||
ebx = [struct.unpack_from('<II', d, p + 8 * i) for i in range(ne)]; p += 8 * ne
|
||||
res = [struct.unpack_from('<II', d, p + 8 * i) for i in range(nr)]; p += 8 * nr
|
||||
types = struct.unpack_from(f'<{nr}I', d, p); p += 4 * nr + 24 * nr
|
||||
ch = [struct.unpack_from('<16sII', d, p + 24 * i) for i in range(nc)]
|
||||
def name(o):
|
||||
a = h + so + o; e = d.find(b'\0', a, h + hl)
|
||||
if e < 0: raise ValueError(f'bundle manifest at {off:#x}: a name at {a - off:#x} runs past the manifest')
|
||||
return bytes(d[a:e]).decode(errors='replace')
|
||||
return hl + 4, [(name(a), s) for a, s in ebx], [(name(a), s, t) for (a, s), t in zip(res, types)], [(g, lo, ls) for g, lo, ls in ch]
|
||||
|
||||
|
||||
def resources(romfs, rtype):
|
||||
"""Every res of type rtype (a name_hash) the bundles of every superbundle hold → {(cas path, offset, stored size): (size, name)}, each stored copy once. Data/ and Patch/ are read
|
||||
alike: a shader's key is its content, so a base copy the update replaced only adds a shader the game no longer uses"""
|
||||
chunks, maps, out = install_chunks(romfs), {}, {}
|
||||
def view(p):
|
||||
if p not in maps:
|
||||
with open(p, 'rb') as f: maps[p] = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
||||
return maps[p]
|
||||
try:
|
||||
for t in tocs(romfs):
|
||||
for ents in toc_bundles(_read(t), t):
|
||||
cid, off, size = ents[0]
|
||||
mlen, ebx, res, ch = manifest(view(cas_path(romfs, cid, chunks)), off)
|
||||
if mlen != size: raise ValueError(f'{t}: a bundle manifest of {mlen:#x} bytes, the toc says {size:#x}')
|
||||
if len(ebx) + len(res) + len(ch) != len(ents) - 1: raise ValueError(f'{t}: a bundle of {len(ebx) + len(res) + len(ch)} items with {len(ents) - 1} entries')
|
||||
for (nm, sz, ty), (c, o, s) in zip(res, ents[1 + len(ebx):]):
|
||||
if ty == rtype: out[(cas_path(romfs, c, chunks), o, s)] = (sz, nm)
|
||||
finally:
|
||||
for m in maps.values(): m.close()
|
||||
return out
|
||||
|
||||
|
||||
def read(d, off, stored, size, decode):
|
||||
"""An item's data: its blocks at off (stored bytes in all) decoded; decode(compressed, size) is the game's Oodle"""
|
||||
o, end, out = off, off + stored, bytearray()
|
||||
while o < end:
|
||||
if o + 8 > end: raise ValueError(f'a block header at {o:#x} runs past the item')
|
||||
n, codec, cs = struct.unpack_from('>IBB', d, o)[0] & 0xffffff, d[o + 4], d[o + 5]
|
||||
c = (cs & 0xf) << 16 | struct.unpack_from('>H', d, o + 6)[0]
|
||||
if cs & 0xf0 != 0x70 or o + 8 + c > end: raise ValueError(f'a damaged block at {o:#x} ({bytes(d[o:o + 8]).hex()})')
|
||||
blk = d[o + 8:o + 8 + c]
|
||||
if codec == 0: out += blk
|
||||
elif codec == 0x19: out += decode(bytes(blk), n)
|
||||
else: raise ValueError(f'block at {o:#x}: codec {codec:#x} is not known')
|
||||
o += 8 + c
|
||||
if len(out) != size: raise ValueError(f'item at {off:#x}: {len(out):#x} bytes decoded, not {size:#x}')
|
||||
return bytes(out)
|
||||
|
||||
|
||||
def nvn_shader(b):
|
||||
"""A CompiledBytecode resource → (code area, control section), or None when it holds no VNVN record"""
|
||||
if len(b) < 0x24 or b[0x20:0x24] != b'VNVN': return None
|
||||
r = 0x20; v = struct.unpack_from('<H', b, r + 8)[0]; p = r + (0x11 if v >= 3 else 0x10)
|
||||
for _ in range(4): p += 2 + 4 * struct.unpack_from('<H', b, p)[0]
|
||||
p += 2 + 8 * struct.unpack_from('<H', b, p)[0]
|
||||
co, cl, ko, kl = struct.unpack_from('<4I', b, p)
|
||||
if r + co + cl > len(b) or r + ko + kl > len(b): raise ValueError(f'VNVN record: code {co:#x}+{cl:#x} or control {ko:#x}+{kl:#x} outside its {len(b) - r:#x} bytes')
|
||||
return b[r + co:r + co + cl], b[r + ko:r + ko + kl]
|
||||
@@ -39,6 +39,8 @@
|
||||
# and of the startup material archive LZSS-compressed in main, see rfrm_shaders and retro_main_forms
|
||||
# · BERG (Snowdrop, Mario + Rabbids Sparks of Hope): shader objects in the individually zstd-compressed records of its SDF data slices, see snowdrop_shaders
|
||||
# · bnd2 (Criterion's Bundle 2, Need for Speed: Hot Pursuit Remastered): whole GLSLC outputs in the zlib resources of SHADERS.BNDL, see bnd2_resources and bnd2_shaders
|
||||
# · Frostbite (EA SPORTS FC 27): the CompiledBytecode resources of the bundles its superbundle tables (.toc) list, in its cas files (Oodle Leviathan, decoded by the game's own decoder in the
|
||||
# Mac host), each a VNVN record with one code area and control section (frostbite.py), see frostbite_jobs and frostbite_shaders
|
||||
# · Unreal Engine 3 (Batman: Arkham Knight): shader records in its global shader cache (BMSG) and in the packages (the combined shader cache), whose compressed chunks are Oodle blocks decoded by the game's own decoder in the Mac host, see ue3_body and ue3_shaders
|
||||
# Code area: 0x30 header + (graphics) 0x50 SPH + instructions; header magic 0x12345678 for graphics, 0x12345679 for compute. The control section starts with 0x98761234, +0x704 = code area length,
|
||||
# +0x700 = start of the c1 constant segment within the code area; for compute +0x748 thread group xyz (u32 ×3), +0x754 shared memory bytes (checked one by one against PC reflection on D2R's 22 compute shaders).
|
||||
@@ -1587,6 +1589,43 @@ def trpfs_jobs(files, parts=64):
|
||||
taken |= {p, p[:-1] + 'd'}
|
||||
return jobs, taken
|
||||
|
||||
FB_CAS = 'Frostbite cas'
|
||||
def frostbite_jobs(files, parts=64):
|
||||
"""Frostbite (EA SPORTS FC 27): its shaders are the CompiledBytecode resources of the bundles (frostbite.resources), stored in the cas files. → ([(cas path, rel, (FB_CAS, ((offset,
|
||||
stored size, size, name), …))), …] in about equal stored sizes, the paths taken: every .toc and .cas file, which hold nothing a loose scan reads (31.8 GB in FC 27)"""
|
||||
import frostbite
|
||||
roots = {p[:-len('Data/layout.toc')] for p, _ in files if p.endswith(os.sep + os.path.join('Data', 'layout.toc'))}
|
||||
jobs, taken = [], set()
|
||||
for root in sorted(roots):
|
||||
if not frostbite.is_frostbite(root): continue
|
||||
res = frostbite.resources(root, frostbite.COMPILED_BYTECODE)
|
||||
rel_of = {p: r for p, r in files if p.startswith(root)}
|
||||
taken |= {p for p in rel_of if p.endswith(('.toc', '.cas'))}
|
||||
by_cas = collections.defaultdict(list)
|
||||
for (cas, off, stored), (size, name) in res.items(): by_cas[cas].append((off, stored, size, name))
|
||||
step = sum(stored for (_, _, stored) in res) / parts
|
||||
for cas in sorted(by_cas):
|
||||
cur, size_ = [], 0
|
||||
for e in sorted(by_cas[cas]):
|
||||
cur.append(e); size_ += e[1]
|
||||
if size_ >= step: jobs.append((cas, rel_of[cas], (FB_CAS, tuple(cur)))); cur, size_ = [], 0
|
||||
if cur: jobs.append((cas, rel_of[cas], (FB_CAS, tuple(cur))))
|
||||
return jobs, taken
|
||||
|
||||
def frostbite_shaders(path, rel, ents, out):
|
||||
"""A range of one cas file's CompiledBytecode resources (frostbite_jobs), each decoded with the game's Oodle and read as one shader (frostbite.nvn_shader). Labels: /<cas>#<resource name>"""
|
||||
import frostbite
|
||||
from romfs import mmap
|
||||
with open(path, 'rb') as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as d:
|
||||
for off, stored, size, name in ents:
|
||||
label = f'/{rel}#{name}'
|
||||
sh = frostbite.nvn_shader(frostbite.read(d, off, stored, size, oodle))
|
||||
if sh is None: print(f'[RED] {label}: a CompiledBytecode resource without a VNVN record; left out', flush=True); continue
|
||||
code, ctl = sh; st = glslc_stage(ctl, code)
|
||||
why = check(label, st, ctl, code) if st else 'no stage in the code area header'
|
||||
if why: print(f'[RED] {label}: {why}; left out', flush=True); continue
|
||||
out.append((label, st, ctl, code))
|
||||
|
||||
def smash_arc_jobs(files, parts=128):
|
||||
"""Super Smash Bros. Ultimate's data.arc (17.6 GB, smash_arc.py): the game's current files, in ranges of about equal stored size. → ([(path, rel, entries), …], the paths taken)"""
|
||||
import smash_arc
|
||||
@@ -2338,6 +2377,9 @@ def scan_file_in(args):
|
||||
if len(args) > 2 and args[2][0] == UE_LEGACY: # files of a legacy Unreal pak (ue_legacy_jobs)
|
||||
ue_legacy_shaders(path, rel, args[2][1], found)
|
||||
return rel, uniq_keys(found), var_pairs(found), trees
|
||||
if len(args) > 2 and args[2][0] == FB_CAS: # CompiledBytecode resources of a Frostbite cas file (frostbite_jobs)
|
||||
frostbite_shaders(path, rel, args[2][1], found)
|
||||
return rel, uniq_keys(found), var_pairs(found), trees
|
||||
if len(args) > 2 and head[:4] == PKZL: # entries of a PlatinumGames PKZ (pkz_jobs)
|
||||
pkz_shaders(path, rel, args[2], found)
|
||||
return rel, uniq_keys(found), var_pairs(found), trees
|
||||
@@ -2506,8 +2548,9 @@ def main():
|
||||
ck_jobs, cpks = cpk_jobs(files) # Bayonetta 2's CRI CPK archives (CRILAYLA entries)
|
||||
zp_jobs, zips = zip_jobs(files) # Portal's game.zip (Deflate members)
|
||||
ah_jobs, arhs = arh_jobs(files) # Monolith's ARH1/ARD archives and embedded XBC1/HCPS programs
|
||||
big += pak_jobs + tr_jobs + ue_jobs + bd_jobs + arc_jobs + pz_jobs + ck_jobs + zp_jobs + ah_jobs
|
||||
files = [(p, r) for p, r in files if not linkdata_jobs(p, r) and p not in paks and p not in trp and p not in uep and p not in bdts and p not in arcs and p not in pkzs and p not in cpks and p not in zips and p not in arhs]
|
||||
fb_jobs, fbs = frostbite_jobs(files) # EA SPORTS FC 27's Frostbite bundles, Oodle Leviathan decoded by the game's own decoder in the Mac host
|
||||
big += pak_jobs + tr_jobs + ue_jobs + bd_jobs + arc_jobs + pz_jobs + ck_jobs + zp_jobs + ah_jobs + fb_jobs
|
||||
files = [(p, r) for p, r in files if not linkdata_jobs(p, r) and p not in paks and p not in trp and p not in uep and p not in bdts and p not in arcs and p not in pkzs and p not in cpks and p not in zips and p not in arhs and p not in fbs]
|
||||
with cf.ProcessPoolExecutor(J, initializer=_pool_init, initargs=(common, {}, zdicts)) as ex:
|
||||
n = len(big) + len(files)
|
||||
results += pooled(ex, big, n) + pooled(ex, files, n, len(big), chunk=16)
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef struct {
|
||||
uint64_t fps_state_off; // frame step state page (patch_nso.py FRAME_STEP: Tears of the Kingdom 1.4.3 and Breath of the Wild 1.9.0 main); 0 = none
|
||||
int64_t patch_off; // patch area relative to the base; negative = before the base (image too large, see patch_nso.py FAR), and size does not include it
|
||||
uint64_t image_size, file_image_len, patch_len; // only with the patch area before the base: whole image (with bss and key page), length of the image part of the file, patch area length
|
||||
uint64_t back_off, back_len; // a second patch area after the image (patch_nso.py TWO: a text longer than a B reaches), inside size; 0 = none
|
||||
char build_id[33]; // First 16 bytes of the NSO build ID (hex); empty for older build outputs
|
||||
unsigned key_idx[4]; // key page index of each thread slot (K18, KTLS, KTLR, KGATE)
|
||||
const Elf64_Dyn *dyn;
|
||||
|
||||
+95
-5
@@ -4,8 +4,8 @@
|
||||
#include "hle.h"
|
||||
#include <mach/mach.h>
|
||||
|
||||
// What a field holds: the frame rate as a float or int32, vsyncs per frame (60 / frame rate) as an int32, or the frame time in milliseconds as a float. Copies: consecutive copies of the value
|
||||
// (Unreal keeps one for the game thread, one for the render thread). A row with no pointer (ptr_off 0) has its field at main + field: a constant in main's read-only data, which the loader
|
||||
// What a field holds: the frame rate as a float, double or int32, vsyncs per frame (60 / frame rate) as an int32, or the frame time in milliseconds as a float. Copies: consecutive copies of the
|
||||
// value (Unreal keeps one for the game thread, one for the render thread). A row with no pointer (ptr_off 0) has its field at main + field: a constant in main's read-only data, which the loader
|
||||
// leaves writable (the image's data block on iOS too, loader.c map_image).
|
||||
// At 60 a frame time gets MS_MARGIN less than the vsync: such a limiter counts from the frame's start, and the work after it (the GPU fence wait, the next frame's start) adds to the
|
||||
// period, so frames at exactly 16.667 ms came 0.11 ms late each on the Mac (59.6 fps, every 150th frame shown two vsyncs). Slightly shorter, the host's present pacing sets the pace
|
||||
@@ -13,7 +13,7 @@
|
||||
// frame for two, so a shorter time showed some frames for one (30.4 fps); 30 writes the game's own 33.333 ms
|
||||
// Also: a frame time in ticks as a uint32 (scale / frame rate: 19,200,000 for the Switch's 19.2 MHz system tick), a frame step in seconds as a float (1 / frame rate), and a mode
|
||||
// switch an engine reads before it takes those fields at all (written 1 at any target)
|
||||
enum { FPS_F32, VSYNCS_I32, MS_F32, FPS_I32, TICKS_U32, SECS_F32, MODE_U32 };
|
||||
enum { FPS_F32, VSYNCS_I32, MS_F32, FPS_I32, TICKS_U32, SECS_F32, MODE_U32, FPS_F64 };
|
||||
#define MS_MARGIN 0.5f
|
||||
static float ms_want(int fps) { return 1000.0f / (float)fps - (fps == 60 ? MS_MARGIN : 0); }
|
||||
static const struct { const char *build, *what; uint64_t ptr_off; uint32_t field; uint8_t kind, copies; uint32_t scale; } k_locks[] = {
|
||||
@@ -71,6 +71,12 @@ static const struct { const char *build, *what; uint64_t ptr_off; uint32_t field
|
||||
{ "799d1061182c1302e08e706b84ce76e5", "Criterion frame ticks / 10", 0xed96a8, 0x28, TICKS_U32, 1, 1920000 },
|
||||
{ "799d1061182c1302e08e706b84ce76e5", "Criterion 2D game step", 0xeffc60, 0x30, SECS_F32, 1, 0 },
|
||||
{ "799d1061182c1302e08e706b84ce76e5", "Criterion 3D game step", 0xeffc60, 0x50, SECS_F32, 1, 0 },
|
||||
// EA SPORTS FC 27 1.8d.310c: the game's frame regulator, an object at [main+0xda20e38] (its constructor, main+0x99e80c8, sets 60.0). Its tick (main+0x99ea580) waits until
|
||||
// 1 / [+0x8] seconds have passed since the last frame; [+0x10] is the rate it reports. main+0x5d501c0 sets both to 30.0 whenever GameRenderSettings.Enable is 1 (fmov v1.2d, #30.0;
|
||||
// stur q1, [x9, #8]), a constant of the Switch build, so it is written here. The simulation's own rate is Frostbite's SimulationTimeSettings, set below by name: on a build without
|
||||
// this row the game keeps 30 fps at the right speed (the simulation at 60 and the regulator at 30: match clock as at 30). The game asks for present interval 2
|
||||
// (BaseDisplaySettings.PresentInterval), which the profile's present_interval display ignores
|
||||
{ "a48c0de3bc353efa0e4d359bde05ef24", "FIFA frame regulator", 0xda20e38, 0x8, FPS_F64, 2, 0 },
|
||||
};
|
||||
#define NLOCKS ((int)(sizeof k_locks / sizeof k_locks[0]))
|
||||
|
||||
@@ -131,6 +137,77 @@ static void dynamic_resolution_tick(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Frostbite's simulation rate, found by name (no fixed addresses, so it holds across a game's updates). Frostbite reflects its settings classes: a class record (its name, then at
|
||||
// +0x40 its field list) and per field a record of 0x20 bytes (name, hash, offset at +0x10, type). SimulationTimeSettings' ForceSimRate (int32) and MaxSimFps (float) cap the
|
||||
// simulation's ticks a second: 30 in EA SPORTS FC 27, whose frames then cannot go faster than 30 whatever paces them. A static constructor registers the class: it stores the record's
|
||||
// address into its type info (adrp / add of the record, then str into the type info just made by adrp / add), and the code that reads the settings asks the settings registry for the
|
||||
// instance with that type info in x1 and a cache word in x2 (adrp / add each, then bl), which keeps the instance's address. The instance holds its type info at +8, which checks the cache.
|
||||
// Both fields are written each frame they differ (the game may load its settings again), like the frame limits above
|
||||
static struct { int n; uint8_t *base; uint64_t ti, cache[8]; int ncache; uint32_t off_rate, off_max; } fb;
|
||||
static int fb_name_at(uint8_t *base, uint64_t size, uint64_t p, const char *want) { // p, a relocated pointer, points into the module at the string want
|
||||
uint64_t b = (uint64_t)(uintptr_t)base; size_t n = strlen(want);
|
||||
return p >= b && p - b + n + 1 <= size && !memcmp((const void *)(uintptr_t)p, want, n + 1);
|
||||
}
|
||||
static int64_t fb_pair(const uint32_t *t, uint64_t i, int reg) { // the target of adrp / add into reg at words i, i + 1, or -1 (module offsets: the text sits at offset 0)
|
||||
uint32_t w = t[i], x = t[i + 1];
|
||||
if ((w & 0x9F000000u) != 0x90000000u || (int)(w & 31) != reg || (x & 0xFFC00000u) != 0x91000000u || (x & 31) != (uint32_t)reg || ((x >> 5) & 31) != (uint32_t)reg) return -1;
|
||||
int64_t imm = (int64_t)(((w >> 29) & 3) | (((w >> 5) & 0x7FFFF) << 2)); if (imm & (1 << 20)) imm -= 1 << 21;
|
||||
return (int64_t)((i * 4) & ~0xfffull) + imm * 4096 + ((x >> 10) & 0xfff);
|
||||
}
|
||||
static void fb_find(void) {
|
||||
module_t *m = NULL; for (int i = 0; i < g_nmod; i++) if (!strcmp(g_mod[i].name, "main")) m = &g_mod[i];
|
||||
if (!m || !m->text_end || !m->ro_off || m->ro_off >= m->size) return;
|
||||
static const char cls[] = "SimulationTimeSettings";
|
||||
uint8_t *base = m->base, *ro = base + m->ro_off; uint64_t size = m->back_off ? m->back_off : m->size, b = (uint64_t)(uintptr_t)base;
|
||||
const uint8_t *s = memmem(ro, (size_t)(size - m->ro_off), "\0SimulationTimeSettings\0", sizeof cls + 1); if (!s) return; // not Frostbite
|
||||
uint64_t name = (uint64_t)(uintptr_t)(s + 1), rec = 0;
|
||||
for (uint64_t o = (m->ro_off + 7) & ~7ull; o + 0x48 <= size && !rec; o += 8) {
|
||||
if (*(uint64_t *)(base + o) != name) continue;
|
||||
uint64_t fl = *(uint64_t *)(base + o + 0x40); if (fl < b || fl - b + 0x20 > size) continue;
|
||||
for (uint64_t f = fl - b; f + 0x20 <= size; f += 0x20) { // the field list ends where a name stops being one
|
||||
uint64_t fn = *(uint64_t *)(base + f); if (fn < b || fn - b >= size) break;
|
||||
uint32_t off = *(uint32_t *)(base + f + 0x10);
|
||||
if (fb_name_at(base, size, fn, "ForceSimRate")) fb.off_rate = off;
|
||||
else if (fb_name_at(base, size, fn, "MaxSimFps")) fb.off_max = off;
|
||||
}
|
||||
if (fb.off_rate && fb.off_max) rec = o;
|
||||
}
|
||||
if (!rec) { LOG("[RED] main: Frostbite's %s found, but not its ForceSimRate and MaxSimFps fields; leaving the simulation rate", cls); return; }
|
||||
const uint32_t *t = (const uint32_t *)base; uint64_t nw = m->text_end / 4;
|
||||
for (uint64_t i = 0; i + 3 < nw && !fb.ti; i++) { // the registration: adrp / add xR = record, str xR, [xT] with xT = the type info from an adrp / add just before
|
||||
int r = (int)(t[i] & 31); if (fb_pair(t, i, r) != (int64_t)rec) continue;
|
||||
uint32_t st = t[i + 2]; if ((st & 0xFFFFFC00u) != 0xF9000000u || (int)(st & 31) != r) continue; // str xR, [xT] (no offset)
|
||||
int xt = (int)((st >> 5) & 31);
|
||||
for (uint64_t k = i >= 6 ? i - 6 : 0; k < i; k++) { int64_t ti = fb_pair(t, k, xt); if (ti > 0) fb.ti = (uint64_t)ti; }
|
||||
}
|
||||
if (!fb.ti) { LOG("[RED] main: Frostbite's %s: its type info was not found; leaving the simulation rate", cls); return; }
|
||||
for (uint64_t i = 8; i + 12 < nw && fb.ncache < 8; i++) { // the readers: adrp / add x1 = type info, adrp / add x2 = cache word, near each other before a bl
|
||||
if (fb_pair(t, i, 1) != (int64_t)fb.ti) continue;
|
||||
for (uint64_t k = i - 8; k < i + 10; k++) {
|
||||
int64_t c = fb_pair(t, k, 2); if (c <= 0 || (uint64_t)c + 8 > m->size) continue;
|
||||
int known = 0; for (int j = 0; j < fb.ncache; j++) known |= fb.cache[j] == (uint64_t)c;
|
||||
if (!known) fb.cache[fb.ncache++] = (uint64_t)c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fb.ncache) { LOG("[RED] main: Frostbite's %s: no settings lookup found; leaving the simulation rate", cls); return; }
|
||||
fb.base = base; fb.n = 1;
|
||||
LOG("main: Frostbite %s at main+%#llx (ForceSimRate +%#x, MaxSimFps +%#x), type info main+%#llx, %d instance caches", cls, (unsigned long long)rec, fb.off_rate, fb.off_max,
|
||||
(unsigned long long)fb.ti, fb.ncache);
|
||||
}
|
||||
static void fb_tick(int target, const char *src) {
|
||||
static int nlog; uint64_t ti = (uint64_t)(uintptr_t)(fb.base + fb.ti);
|
||||
for (int j = 0; j < fb.ncache; j++) {
|
||||
uint64_t inst = 0, tinfo = 0; int32_t rate; float max;
|
||||
if (!rd((uint64_t)(uintptr_t)(fb.base + fb.cache[j]), &inst, sizeof inst) || !inst || !rd(inst + 8, &tinfo, sizeof tinfo) || tinfo != ti) continue; // not made yet, or another word
|
||||
if (!rd(inst + fb.off_rate, &rate, sizeof rate) || !rd(inst + fb.off_max, &max, sizeof max)) return;
|
||||
if (rate != target) { int32_t *p = (int32_t *)(uintptr_t)(inst + fb.off_rate); dm_guest_write_prepare(p, sizeof *p); __atomic_store_n(p, target, __ATOMIC_RELAXED); }
|
||||
if (max != (float)target) { float w = (float)target, *p = (float *)(uintptr_t)(inst + fb.off_max); dm_guest_write_prepare(p, sizeof *p); __atomic_store_n((uint32_t *)p, *(uint32_t *)&w, __ATOMIC_RELAXED); }
|
||||
if ((rate != target || max != (float)target) && nlog < 8) { nlog++; LOG("main: Frostbite simulation rate ForceSimRate %d, MaxSimFps %g → %d (%s)", rate, max, target, src); }
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void dm_fps_lock_tick(void) {
|
||||
dynamic_resolution_tick(); // separate from the FPS cap
|
||||
static int state = -2, rows[NLOCKS], nrow, nlog[NLOCKS], target, nier; static uint8_t *base; static const char *src; static uint32_t display;
|
||||
@@ -142,10 +219,11 @@ void dm_fps_lock_tick(void) {
|
||||
for (int k = 0; k < (int)(sizeof k_nier_dr / sizeof *k_nier_dr); k++) if (!strcmp(g_mod[i].build_id, k_nier_dr[k].build)) { base = g_mod[i].base; nier = 2; display = k_nier_dr[k].display; }
|
||||
for (int k = 0; k < NLOCKS; k++) if (!strcmp(g_mod[i].build_id, k_locks[k].build)) { rows[nrow++] = k; base = g_mod[i].base; }
|
||||
}
|
||||
if (!nrow && !nier) return;
|
||||
fb_find(); if (!nrow && !nier && !fb.n) return;
|
||||
const char *e = getenv("DM_FPS_TARGET"); int t = e ? atoi(e) : DM_GAME_FPS_TARGET; src = e ? "DM_FPS_TARGET" : "game profile fps_target";
|
||||
if (t != 0 && t != 30 && t != 60) { LOG("[RED] DM_FPS_TARGET=%s: must be 0, 30 or 60; leaving the game's frame limit", e); t = 0; }
|
||||
if (!t) { for (int r = 0; r < nrow; r++) LOG("main: %s left as the game sets it (%s)", k_locks[rows[r]].what, src); if (nier) LOG("main: NieR frame interval left as the game sets it (%s)", src); return; }
|
||||
if (!t) { for (int r = 0; r < nrow; r++) LOG("main: %s left as the game sets it (%s)", k_locks[rows[r]].what, src); if (nier) LOG("main: NieR frame interval left as the game sets it (%s)", src);
|
||||
if (fb.n) LOG("main: Frostbite simulation rate left as the game sets it (%s)", src); return; }
|
||||
target = t; state = 0;
|
||||
}
|
||||
if (nier == 1) {
|
||||
@@ -191,9 +269,21 @@ void dm_fps_lock_tick(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fb.n) fb_tick(target, src);
|
||||
for (int r = 0; r < nrow; r++) {
|
||||
int k = rows[r]; uint64_t obj = (uint64_t)(uintptr_t)base;
|
||||
if (k_locks[k].ptr_off && (!rd((uint64_t)(uintptr_t)(base + k_locks[k].ptr_off), &obj, sizeof obj) || !obj)) continue; // not created yet
|
||||
if (k_locks[k].kind == FPS_F64) {
|
||||
for (int c = 0; c < k_locks[k].copies; c++) {
|
||||
uint64_t a = obj + k_locks[k].field + 8 * (uint64_t)c; double cur, want = target;
|
||||
if (!rd(a, &cur, sizeof cur)) break;
|
||||
if (cur == want || !(cur >= 10 && cur <= 120)) continue; // already set, or not set yet
|
||||
double *p = (double *)(uintptr_t)a;
|
||||
dm_guest_write_prepare(p, sizeof *p); __atomic_store_n((uint64_t *)p, *(uint64_t *)&want, __ATOMIC_RELAXED);
|
||||
if (nlog[k] < 8) { nlog[k]++; LOG("main: %s%s %g → %d fps (%s)", k_locks[k].what, k_locks[k].copies > 1 ? (c ? " (reported rate)" : " (target)") : "", cur, target, src); }
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (int c = 0; c < k_locks[k].copies; c++) {
|
||||
uint64_t a = obj + k_locks[k].field + 4 * (uint64_t)c; uint32_t cur, want; char was[16];
|
||||
if (!rd(a, &cur, sizeof cur)) break;
|
||||
|
||||
+6
-4
@@ -77,7 +77,7 @@ static size_t image_bytes(void) { size_t n = 0; for (int i = 0; i < g_nmod; i++)
|
||||
// and the heap it opens = pool − 64 MB − 1.75 GB virtual address memory − 1 MB = 0x5be00000, as on hardware); Metroid Dread's main has about 1.8 GB of bss, the engine's static heap, which the Switch counts as used;
|
||||
// without it the game asks for pool − 64 MB = 3.15 GB of heap
|
||||
// Like image_bytes, exclude NROs: their buffers already belong to the game's heap. Counting every offline-mapped NRO's bss made FFX/X-2's used memory exceed its pool before any LoadModule.
|
||||
static size_t big_bss_bytes(void) { size_t n = 0; for (int i = 0; i < g_nmod; i++) if (!g_mod[i].nro && g_mod[i].patch_off < 0) n += g_mod[i].size - g_mod[i].file_image_len; return n; }
|
||||
static size_t big_bss_bytes(void) { size_t n = 0; for (int i = 0; i < g_nmod; i++) if (!g_mod[i].nro && g_mod[i].patch_off < 0) n += g_mod[i].size - g_mod[i].back_len - g_mod[i].file_image_len; return n; }
|
||||
|
||||
// For memory accounting (memstat.m): the range of the whole guest address space block (base = NULL when not initialized)
|
||||
void svc_guest_range(uint8_t **base, size_t *size) { *base = g_as; *size = g_reserve; }
|
||||
@@ -208,6 +208,7 @@ static void module_readonly_run(uint64_t off, uint64_t start, uint64_t end,
|
||||
static void module_data_query(const module_t *m, uint64_t off, uint64_t *lo, uint64_t *hi, uint64_t *perm) {
|
||||
module_readonly_run(off, 0, (m->text_end + 0x3fff) & ~UINT64_C(0x3fff), lo, hi, perm);
|
||||
if (m->patch_off > 0) module_readonly_run(off, (uint64_t)m->patch_off & ~UINT64_C(0x3fff), m->size, lo, hi, perm);
|
||||
if (m->back_len) module_readonly_run(off, m->back_off, m->back_off + m->back_len, lo, hi, perm);
|
||||
module_readonly_run(off, m->key_page_off, m->key_page_off + m->key_page_size, lo, hi, perm);
|
||||
}
|
||||
static int map_source_backed(uint64_t src, uint64_t size) {
|
||||
@@ -220,7 +221,7 @@ static int map_source_backed(uint64_t src, uint64_t size) {
|
||||
// Active NRO data is valid backing too (FFX/X-2's launcher allocates thread stacks from its bss). Deactivation below checks borrowers under this same lock before reload can restore it.
|
||||
if (!m || !m->loaded || !memory_contains((uintptr_t)m->base, m->size, src, size)) return 0;
|
||||
uint64_t lo = m->data_off ? m->data_off : (m->ro_off ? m->ro_off : m->text_end);
|
||||
uint64_t hi = m->patch_off > 0 ? (uint64_t)m->patch_off : m->size;
|
||||
uint64_t hi = m->patch_off > 0 ? (uint64_t)m->patch_off : m->back_len ? m->back_off : m->size;
|
||||
uint64_t off = src - (uintptr_t)m->base, perm = 3;
|
||||
module_data_query(m, off, &lo, &hi, &perm);
|
||||
return perm == 3 && hi >= lo && memory_contains(lo, hi - lo, off, size);
|
||||
@@ -513,9 +514,10 @@ uint64_t svc_dispatch(int num, uint64_t *regs, uint64_t orig_addr) {
|
||||
// The SDK's C++ exception unwinding (nn::ro::detail::GetExceptionInfo) walks back from the PC over "Code+RX" regions to find the module start, forward over Code then CodeData to find its end, then reads MOD0 at the module start for .eh_frame_hdr.
|
||||
// Previously "the 4 KiB page around it, Code+RX" was reported: the backward walk ran on into other memory, found no MOD0 and aborted (Engage's IL2CPP throws a C++ exception for every managed exception).
|
||||
// The rewriter's patch area is reported as CodeData+RX: modules sit back to back in the host, and an executable patch area reported as Code+RX would merge the previous module into the backward walk
|
||||
// Modules with the patch area before the base (patch_off < 0): the patch area is reported alone as CodeData+RX, and data and bss run to the end of the image
|
||||
// Modules with the patch area before the base (patch_off < 0): the patch area is reported alone as CodeData+RX, and data and bss run to the end of the image, or to a back patch area
|
||||
// (patch_nso.py TWO), which is reported as CodeData+RX like a patch area after the image
|
||||
module_t *mm = module_of(a); uint64_t off = (uint64_t)(a - mm->base), mb = (uint64_t)mm->base;
|
||||
uint64_t ro = mm->ro_off ? mm->ro_off : mm->text_end, da = mm->data_off ? mm->data_off : ro, pa = mm->patch_off > 0 ? (uint64_t)mm->patch_off : mm->size;
|
||||
uint64_t ro = mm->ro_off ? mm->ro_off : mm->text_end, da = mm->data_off ? mm->data_off : ro, pa = mm->patch_off > 0 ? (uint64_t)mm->patch_off : mm->back_len ? mm->back_off : mm->size;
|
||||
if (a < mm->base) { base = mb + mm->patch_off; size = mm->patch_len; state = 4/*CodeData*/; perm = 5; }
|
||||
else if (off < ro) { base = mb; size = ro; state = 3/*Code*/; perm = 5; }
|
||||
else if (off < da) { base = mb + ro; size = da - ro; state = 3/*Code*/; perm = 1; }
|
||||
|
||||
+19
-4
@@ -194,6 +194,8 @@ static void read_layout(module_t *m, const char *dir) {
|
||||
if (!strcmp(key, "PATCH_OFF")) m->patch_off = strtoll(line + 2 + strlen(key), NULL, 16); // may be negative (patch area before the base)
|
||||
else if (!strcmp(key, "IMAGE_SIZE")) m->image_size = v;
|
||||
else if (!strcmp(key, "FILE_IMAGE_LEN")) m->file_image_len = v;
|
||||
else if (!strcmp(key, "BACK_OFF")) m->back_off = v;
|
||||
else if (!strcmp(key, "BACK_LEN")) m->back_len = v;
|
||||
else if (!strcmp(key, "KEY_PAGE_OFF")) m->key_page_off = v;
|
||||
else if (!strcmp(key, "KEY_PAGE_SIZE")) m->key_page_size = v;
|
||||
else if (!strcmp(key, "TEXT_END")) m->text_end = v;
|
||||
@@ -213,6 +215,9 @@ static void read_layout(module_t *m, const char *dir) {
|
||||
die("%s: the output comes from an old rewriter; rewrite the modules again with dm/tools/patch_nso.py", path);
|
||||
if (m->patch_off < 0 && (!m->image_size || !m->file_image_len || m->file_image_len % 0x4000 || m->patch_off % 0x4000 || m->key_page_off + m->key_page_size > m->image_size))
|
||||
die("%s: patch area before the base, but IMAGE_SIZE / FILE_IMAGE_LEN missing or wrong", path);
|
||||
if ((m->back_off || m->back_len) && (m->patch_off >= 0 || !m->back_len || m->back_off % 0x4000 || m->back_len % 0x4000 || m->back_off < m->key_page_off + m->key_page_size
|
||||
|| m->back_off + m->back_len != m->image_size))
|
||||
die("%s: back patch area, but BACK_OFF / BACK_LEN missing or wrong", path);
|
||||
}
|
||||
|
||||
// Frame step state (the page after the key page, read-write; layout in patch_nso.py FRAME_STEP): the rewriter's stubs step the game by the host's whole vsyncs capped at this
|
||||
@@ -535,6 +540,12 @@ static void map_image(module_t *m, const char *dir) {
|
||||
if (m->nro) { if (!nro_pieces(m->name, &x0, &z0, &w, &zw, &x1, &z1)) die("NRO %s: not in the embedded NRO table (__DATA,__dm_nro_tab)", m->name); }
|
||||
else { x0 = getsectiondata(IMAGE_MH, "__TEXT", sx0, &z0); w = getsectiondata(IMAGE_MH, dm, "__img", &zw); x1 = getsectiondata(IMAGE_MH, "__TEXT", sx1, &z1); }
|
||||
if (!x0 || !w || !x1) die("embedded sections %s / %s / %s missing", sx0, dm, sx1);
|
||||
// The back patch area (patch_nso.py TWO) is a fourth section, __dm<name>x2; NROs never have one (nro_pieces holds three pieces)
|
||||
unsigned long z2 = 0; const uint8_t *x2 = NULL;
|
||||
if (m->back_len) {
|
||||
char sx2[17]; snprintf(sx2, sizeof sx2, "__dm%sx2", m->name);
|
||||
if (m->nro || !(x2 = getsectiondata(IMAGE_MH, "__TEXT", sx2, &z2)) || z2 != m->back_len || ((uintptr_t)x2 & 0x3FFF)) die("embedded back patch area %s missing or wrong", sx2);
|
||||
}
|
||||
// Patch area before the base (patch_off < 0): W ends at the end of data (FILE_IMAGE_LEN); bss and the key page are zero pages from vm_allocate and are not in the executable
|
||||
int front = m->patch_off < 0;
|
||||
if (z0 + zw != (front ? m->file_image_len : (uint64_t)m->patch_off) || (z0 & 0x3FFF) || (zw & 0x3FFF) || (z1 & 0x3FFF) || ((uintptr_t)x0 & 0x3FFF) || ((uintptr_t)w & 0x3FFF) || ((uintptr_t)x1 & 0x3FFF))
|
||||
@@ -550,6 +561,7 @@ static void map_image(module_t *m, const char *dir) {
|
||||
// A module with nothing to rewrite has an empty patch area (87 of Super Smash Bros. Ultimate's 98 NROs: no x18, SVC or TLS register use); vm_remap refuses 0 bytes
|
||||
// (KERN_INVALID_ARGUMENT), which stopped the app at launch on an iPhone at the first such NRO (found in PR #94)
|
||||
if (z1) remap_at(m, base + m->patch_off, x1, z1, FALSE, VM_PROT_READ | VM_PROT_EXECUTE);
|
||||
if (z2) remap_at(m, base + m->back_off, x2, z2, FALSE, VM_PROT_READ | VM_PROT_EXECUTE);
|
||||
m->base = (uint8_t *)base; install_key_page(m);
|
||||
}
|
||||
#else
|
||||
@@ -569,14 +581,17 @@ static void map_image(module_t *m, const char *dir) {
|
||||
size_t sz; uint8_t *raw = slurp(path, &sz);
|
||||
if (m->patch_off < 0) {
|
||||
// Patch area before the base: file = the first part of the image (text + ro + data) + patch area; bss and the key page are anonymous zero pages. The gap from the patch area's end to the base is left inaccessible (PROT_NONE)
|
||||
uint64_t pre = (uint64_t)-m->patch_off, fl = m->file_image_len;
|
||||
if (sz < fl) die("%s is shorter than FILE_IMAGE_LEN %#llx", path, (unsigned long long)fl);
|
||||
m->size = m->image_size; m->patch_len = (sz - fl + 0x3FFF) & ~0x3FFFull;
|
||||
// With a back patch area (patch_nso.py TWO) the file ends with it, BACK_LEN bytes, copied to BACK_OFF in the image
|
||||
uint64_t pre = (uint64_t)-m->patch_off, fl = m->file_image_len, bl = m->back_len;
|
||||
if (sz < fl + bl) die("%s is shorter than FILE_IMAGE_LEN %#llx + BACK_LEN %#llx", path, (unsigned long long)fl, (unsigned long long)bl);
|
||||
m->size = m->image_size; m->patch_len = (sz - bl - fl + 0x3FFF) & ~0x3FFFull;
|
||||
if (m->patch_len > pre) die("%s patch area of %#llx bytes does not fit in the %#llx before the base", path, (unsigned long long)m->patch_len, (unsigned long long)pre);
|
||||
uint8_t *a = mmap(NULL, pre + m->size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
if (a == MAP_FAILED) die("%s mmap %#llx", m->name, (unsigned long long)(pre + m->size));
|
||||
m->base = a + pre;
|
||||
memcpy(m->base, raw, fl); memcpy(a, raw + fl, sz - fl); free(raw); install_key_page(m);
|
||||
memcpy(m->base, raw, fl); memcpy(a, raw + fl, sz - bl - fl); if (bl) memcpy(m->base + m->back_off, raw + sz - bl, bl);
|
||||
free(raw); install_key_page(m);
|
||||
if (bl && mprotect(m->base + m->back_off, bl, PROT_READ | PROT_EXEC)) die("%s mprotect back patch", m->name);
|
||||
uint64_t rx = (m->text_end + 0x3FFF) & ~0x3FFFull;
|
||||
if (mprotect(m->base, rx, PROT_READ | PROT_EXEC)) die("%s mprotect text", m->name);
|
||||
if (mprotect(a, m->patch_len, PROT_READ | PROT_EXEC)) die("%s mprotect patch", m->name);
|
||||
|
||||
@@ -10,7 +10,31 @@ static module_t test_modules[1];
|
||||
module_t *g_mod = test_modules;
|
||||
int g_nmod;
|
||||
static int writes;
|
||||
void dm_guest_write_prepare(void *p, size_t n) { (void)p; assert(n == 4); writes++; }
|
||||
void dm_guest_write_prepare(void *p, size_t n) { (void)p; assert(n == 4 || n == 8); writes++; }
|
||||
|
||||
// adrp / add of a module offset into register r, at word i of the text (module offsets: the text at 0)
|
||||
static void adrp_add(uint32_t *t, uint32_t i, int r, uint64_t target) {
|
||||
int64_t imm = (int64_t)((target & ~0xfffull) - ((i * 4ull) & ~0xfffull)) >> 12;
|
||||
t[i] = 0x90000000u | (uint32_t)(imm & 3) << 29 | (uint32_t)((imm >> 2) & 0x7ffff) << 5 | (uint32_t)r;
|
||||
t[i + 1] = 0x91000000u | (uint32_t)(target & 0xfff) << 10 | (uint32_t)r << 5 | (uint32_t)r;
|
||||
}
|
||||
// A Frostbite main in miniature: the class name and field names in read-only data, the class record and its field list, the static constructor's registration of the
|
||||
// type info and a reader's settings lookup in the text, the instance cache word and the instance
|
||||
static uint8_t *frostbite(uint8_t *base, uint8_t *inst) {
|
||||
g_mod[0].text_end = 0x1000; g_mod[0].ro_off = 0x2000; g_mod[0].size = 0x13000000;
|
||||
uint64_t b = (uint64_t)(uintptr_t)base, rec = 0x3008, fields = 0x3100, ti = 0x40000, cache = 0x41000;
|
||||
memcpy(base + 0x2000, "\0SimulationTimeSettingsX\0SimulationTimeSettings\0ForceSimRate\0MaxSimFps", 72);
|
||||
*(uint64_t *)(base + 0x3000) = b + 0x2001; // a record of another class whose name starts the same
|
||||
*(uint64_t *)(base + rec) = b + 0x2019; *(uint64_t *)(base + rec + 0x40) = b + fields;
|
||||
*(uint64_t *)(base + fields) = b + 0x203d; *(uint32_t *)(base + fields + 0x10) = 0x34;
|
||||
*(uint64_t *)(base + fields + 0x20) = b + 0x2030; *(uint32_t *)(base + fields + 0x30) = 0x38;
|
||||
uint32_t *t = (uint32_t *)base;
|
||||
adrp_add(t, 100, 19, ti); adrp_add(t, 102, 8, rec); t[104] = 0xF9000000u | 19 << 5 | 8; // str x8, [x19]
|
||||
adrp_add(t, 200, 2, 0x42000); // another word in x2 well before the lookup
|
||||
adrp_add(t, 220, 1, ti); adrp_add(t, 222, 2, cache); t[224] = 0x94000000u; // bl
|
||||
*(uint64_t *)(inst + 8) = b + ti; *(uint64_t *)(base + cache) = (uint64_t)(uintptr_t)inst;
|
||||
return inst;
|
||||
}
|
||||
|
||||
static void check(int which) {
|
||||
size_t len = 0x13000000;
|
||||
@@ -37,6 +61,15 @@ static void check(int which) {
|
||||
*(uintptr_t *)(base + 0x7b32690 + 0x10) = (uintptr_t)(object + 16);
|
||||
f = (float *)object; f[0] = f[1] = 30;
|
||||
sync = (int32_t *)(object + 16); sync[0] = sync[1] = 2;
|
||||
} else if (which == 14) {
|
||||
strcpy(g_mod[0].build_id, "a48c0de3bc353efa0e4d359bde05ef24");
|
||||
*(uintptr_t *)(base + 0xda20e38) = (uintptr_t)object;
|
||||
double *d = (double *)(object + 8); d[0] = d[1] = 30;
|
||||
} else if (which == 15 || which == 16) {
|
||||
strcpy(g_mod[0].build_id, "0123456789abcdef0123456789abcdef");
|
||||
frostbite(base, object);
|
||||
*(float *)(object + 0x34) = 30; *(int32_t *)(object + 0x38) = 30;
|
||||
if (which == 16) *(uint64_t *)(object + 8) = 0; // the cache word holds something else
|
||||
} else if (which >= 9) {
|
||||
strcpy(g_mod[0].build_id, "b7f965b9d7227db8e29f04e84ea7331b");
|
||||
if (which == 12) g_mod[0].build_id[31] = '0';
|
||||
@@ -61,6 +94,12 @@ static void check(int which) {
|
||||
sync[0] = sync[1] = 2; dm_fps_lock_tick();
|
||||
assert(sync[0] == 1 && sync[1] == 1 && writes == 4);
|
||||
} else if (which == 10) assert(sync[0] == 2 && sync[1] == 2 && writes == 2);
|
||||
else if (which == 14) { double *d = (double *)(object + 8); assert(d[0] == 60 && d[1] == 60 && writes == 2); }
|
||||
else if (which == 15) {
|
||||
assert(*(float *)(object + 0x34) == 60 && *(int32_t *)(object + 0x38) == 60 && writes == 2);
|
||||
dm_fps_lock_tick(); assert(writes == 2);
|
||||
*(int32_t *)(object + 0x38) = 30; dm_fps_lock_tick(); assert(*(int32_t *)(object + 0x38) == 60 && writes == 3);
|
||||
} else if (which == 16) assert(*(float *)(object + 0x34) == 30 && *(int32_t *)(object + 0x38) == 30 && writes == 0);
|
||||
else if (which == 13) {
|
||||
assert(sync[0] == 2 && sync[1] == 2 && writes == 0);
|
||||
*(uintptr_t *)(base + 0x8adca10 + 0x10) = (uintptr_t)object;
|
||||
@@ -73,7 +112,7 @@ static void check(int which) {
|
||||
|
||||
int main(void) {
|
||||
// Each process starts the production one-time initialization with a fresh build and target.
|
||||
for (int i = 0; i < 14; i++) {
|
||||
for (int i = 0; i < 17; i++) {
|
||||
pid_t p = fork(); assert(p >= 0);
|
||||
if (!p) { check(i); _exit(0); }
|
||||
int status; assert(waitpid(p, &status, 0) == p); assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
|
||||
|
||||
@@ -245,6 +245,29 @@ static void module_sources(void) {
|
||||
g_nmod = 0; memset(g_mod, 0, sizeof test_modules); assert(!munmap(b, 0x20000));
|
||||
}
|
||||
|
||||
// A module with the patch area before the base and a second one after the image (patch_nso.py TWO, EA SPORTS FC 27's 185.6 MB of text): data and bss end at the back area,
|
||||
// which is reported as CodeData+RX and is no mapping source, like a patch area after the image
|
||||
static void module_back_patch(void) {
|
||||
uint8_t *a = mmap(NULL, 0x30000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0), *b = a + 0x8000;
|
||||
assert(a != MAP_FAILED);
|
||||
g_mod[0] = (module_t){.base=b, .size=0x28000, .text_end=0x2800, .ro_off=0x2800, .data_off=0x3000, .patch_off=-0x8000, .patch_len=0x4000, .image_size=0x28000,
|
||||
.file_image_len=0x4000, .key_page_off=0x10000, .key_page_size=0x4000, .back_off=0x20000, .back_len=0x8000, .loaded=1};
|
||||
g_nmod = 1;
|
||||
assert(!mprotect(b, 0x4000, PROT_READ));
|
||||
assert(!mprotect(b + 0x10000, 0x4000, PROT_READ));
|
||||
assert(!mprotect(b + 0x20000, 0x8000, PROT_READ));
|
||||
expect((uintptr_t)b - 0x8000, (uintptr_t)b - 0x8000, 0x4000, 4, 0, 5);
|
||||
expect((uintptr_t)b + 0x4000, (uintptr_t)b + 0x4000, 0xc000, 4, 0, 3);
|
||||
expect((uintptr_t)b + 0x14000, (uintptr_t)b + 0x14000, 0xc000, 4, 0, 3);
|
||||
expect((uintptr_t)b + 0x20000, (uintptr_t)b + 0x20000, 0x8000, 4, 0, 5);
|
||||
expect((uintptr_t)b + 0x27000, (uintptr_t)b + 0x20000, 0x8000, 4, 0, 5);
|
||||
assert(map(stack, (uintptr_t)b + 0x1f000, 2 * P) == BAD);
|
||||
assert(map(stack, (uintptr_t)b + 0x20000, P) == BAD);
|
||||
assert(!map(stack, (uintptr_t)b + 0x14000, P));
|
||||
assert(!unmap(stack, (uintptr_t)b + 0x14000, P));
|
||||
g_nmod = 0; memset(g_mod, 0, sizeof test_modules); assert(!munmap(a, 0x30000));
|
||||
}
|
||||
|
||||
// Apple has no pthread_barrier. The gate makes races deterministic at entry,
|
||||
// without assumptions about which operation wins the memory-state lock.
|
||||
typedef struct { pthread_mutex_t mu; pthread_cond_t cv; unsigned waiting; } gate;
|
||||
@@ -465,7 +488,7 @@ int main(int argc, char **argv) {
|
||||
for (unsigned i = 0; i < 8; ++i) assert(!pthread_create(&threads[i], NULL, init_worker, &addresses[i]));
|
||||
for (unsigned i = 0; i < 8; ++i) { assert(!pthread_join(threads[i], NULL)); assert(addresses[i] == addresses[0]); }
|
||||
alias = addresses[0]; stack = info(I_StackAddr); heap = info(I_HeapAddr);
|
||||
lazy_commit(); alias_lifecycle(); ownership(); module_sources(); failures(); concurrency(); fragmented_queries();
|
||||
lazy_commit(); alias_lifecycle(); ownership(); module_sources(); module_back_patch(); failures(); concurrency(); fragmented_queries();
|
||||
guest_helper();
|
||||
if (!DM_GAME_MEM_MAP_LIMIT) metadata_limit();
|
||||
#ifdef TEST_REAL_DIRTY
|
||||
@@ -479,6 +502,9 @@ int main(int argc, char **argv) {
|
||||
g_mod[1] = (module_t){.size=0x160000000, .file_image_len=0x100000, .patch_off=-0x2000000, .nro=1};
|
||||
assert(info(I_UsedMem) == DM_GAME_MEM_USED + 0xff00000);
|
||||
assert(info(I_UsedNonSys) == DM_GAME_MEM_USED + 0xff00000);
|
||||
g_mod[0].back_len = 0x40000; // a back patch area (patch_nso.py TWO) is code from the file, not bss
|
||||
assert(info(I_UsedMem) == DM_GAME_MEM_USED + 0xfec0000);
|
||||
g_mod[0].back_len = 0;
|
||||
assert(image_bytes() == 0x10000000);
|
||||
g_nmod = 0;
|
||||
free(g_alias_bits); free(g_alias_exposed); assert(!munmap(g_as, RESERVE));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# __TEXT,__dm<name>x0 original text: [0, round16K(TEXT_END)) (includes part of the first ro page, read-only)
|
||||
# __DM<name>W,__img RW segment: [round16K(TEXT_END), PATCH_OFF), rest of ro + data + bss (relocations land only here)
|
||||
# __TEXT,__dm<name>x1 patch area: [PATCH_OFF, round16K(end of file))
|
||||
# __TEXT,__dm<name>x2 only with a back patch area (patch_nso.py TWO, a text longer than a B reaches): the last BACK_LEN bytes of the file, mapped at BACK_OFF
|
||||
# Modules with the patch area before the base (negative PATCH_OFF, see patch_nso.py FAR): W is [round16K(TEXT_END), FILE_IMAGE_LEN), x1 is the patch area after FILE_IMAGE_LEN in the file; bss and the key page are not in the executable
|
||||
# The three pieces are not adjacent in the executable; at run time the loader (loader.c iOS branch) reserves one contiguous address range and vm_remaps them back at their original relative positions (code pages share the signed pages, W is copy-on-write),
|
||||
# so the run-time layout is byte-identical to the original image: PC-relative addressing between original code and data, relative jumps in the patch area, and the host's "base + original offset" references all need no change.
|
||||
@@ -14,16 +15,16 @@ import os, sys
|
||||
out, dst, names = sys.argv[1], sys.argv[2], sys.argv[3:]
|
||||
PG = 0x4000
|
||||
def r16(x): return (x + PG - 1) & ~(PG - 1)
|
||||
def pieces(n): # the module's (x0, W, x1) as (file start, end)
|
||||
def pieces(n): # the module's (x0, W, x1[, x2]) as (file start, end)
|
||||
hdr = dict(l[2:].split() for l in open(f'{out}/{n}.fixups.tsv'))
|
||||
te, po = int(hdr['TEXT_END'], 16), int(hdr['PATCH_OFF'], 16)
|
||||
ko, ks = int(hdr['KEY_PAGE_OFF'], 16), int(hdr['KEY_PAGE_SIZE'], 16)
|
||||
bin_ = os.path.abspath(f'{out}/{n}.patched.bin'); sz = os.path.getsize(bin_)
|
||||
a, end = r16(te), r16(sz)
|
||||
if po < 0: # patch area before the base (patch_nso.py FAR): W ends at the end of data, the loader supplies zero pages for bss and the key page; in the file the patch area follows at FILE_IMAGE_LEN
|
||||
fl = int(hdr['FILE_IMAGE_LEN'], 16)
|
||||
assert fl % PG == 0 and a <= fl and ko % PG == 0 and ks == PG and ko >= fl
|
||||
return bin_, sz, ((0, a), (a, fl), (fl, end))
|
||||
fl, bl = int(hdr['FILE_IMAGE_LEN'], 16), int(hdr.get('BACK_LEN', '0'), 16)
|
||||
assert fl % PG == 0 and a <= fl and ko % PG == 0 and ks == PG and ko >= fl and bl % PG == 0 and (not bl or sz % PG == 0)
|
||||
return bin_, sz, ((0, a), (a, fl), (fl, end - bl)) + (((end - bl, end),) if bl else ())
|
||||
assert po % PG == 0 and a <= ko and ko + ks <= po and ko % PG == 0 and ks == PG
|
||||
return bin_, sz, ((0, a), (a, po), (po, end))
|
||||
def place(asm, bin_, sz, lo, hi): # one piece, 16K aligned at both ends (vm_remap takes whole pages)
|
||||
@@ -35,7 +36,7 @@ asm = ['// Generated by dm/ios/tools/gen_embed.py; do not edit']
|
||||
flags = []
|
||||
for n in names:
|
||||
bin_, sz, parts = pieces(n)
|
||||
for sect, (lo, hi) in zip((f'__TEXT,__dm{n}x0', f'__DM{n}W,__img', f'__TEXT,__dm{n}x1'), parts):
|
||||
for sect, (lo, hi) in zip((f'__TEXT,__dm{n}x0', f'__DM{n}W,__img', f'__TEXT,__dm{n}x1', f'__TEXT,__dm{n}x2'), parts):
|
||||
assert all(len(x) <= 16 for x in sect.split(','))
|
||||
asm.append(f' .section {sect}'); place(asm, bin_, sz, lo, hi)
|
||||
flags.append(f'-Wl,-segprot,__DM{n}W,rw,rw')
|
||||
@@ -47,6 +48,7 @@ if nros:
|
||||
asm.append(f' .section {sect}')
|
||||
for k, n in enumerate(nros):
|
||||
bin_, sz, parts = pieces(n); lo, hi = parts[i]
|
||||
assert len(parts) == 3, f'NRO {n} has a back patch area, which the packed NRO sections do not hold'
|
||||
if i == 0: rows.append([n])
|
||||
rows[k] += [at[i], hi - lo]; at[i] += hi - lo
|
||||
place(asm, bin_, sz, lo, hi)
|
||||
|
||||
+34
-12
@@ -11,7 +11,7 @@
|
||||
# Function-matched cuts (MATCH_CUTS of the selected game's patches.py): unknown builds only, unique complete-function and direct-callee fingerprints, then original-byte assertions
|
||||
# Registered observation gates (OBS of the patch files, restricted by build ID): one instruction at the entry is replaced with "enter the host observation callback → execute the original instruction → jump back", so diagnostics modify zero code at runtime; listed in <name>.obs.tsv
|
||||
# The key page only stores "actual key number × 8" at the end of the data segment, and patch code fetches thread slots indirectly through the key page: the loader may use any key number.
|
||||
# Output: <name>.patched.bin (key page and patch area appended after the image at PATCH_OFF; when that would start beyond 112 MB the patch area sits before the base, see FAR), <name>.fixups.tsv (layout and key page index header), <name>.gates.tsv, <name>.sites.tsv, <name>.cuts.tsv, <name>.obs.tsv
|
||||
# Output: <name>.patched.bin (key page and patch area appended after the image at PATCH_OFF; when that would start beyond 112 MB the patch area sits before the base, see FAR; a text longer than a B reaches adds a second one after the image, see TWO), <name>.fixups.tsv (layout and key page index header), <name>.gates.tsv, <name>.sites.tsv, <name>.cuts.tsv, <name>.obs.tsv
|
||||
import struct, re, sys, os, glob, types, importlib.util
|
||||
from itertools import combinations
|
||||
from capstone import *
|
||||
@@ -33,7 +33,14 @@ FAR, FRONT = NEAR_PATCH_OFF > 0x7000000, 0x2000000
|
||||
# order, so the last site's stub ends up about as far from it as the text is long. The first pass tries the gap that keeps every site in reach; when the patch area does not fit there
|
||||
# (Monster Hunter Rise: 3.6 MB), the rewriter runs again with exactly the size it needs (DM_PATCH_FRONT, set only by that rerun) and B() checks every branch
|
||||
BIG_TEXT = FAR and MOD.text_end + FRONT > 0x8000000 - 0x10000
|
||||
if BIG_TEXT: FRONT = int(os.environ.get('DM_PATCH_FRONT', '0'), 0) or (0x8000000 - 0x10000 - MOD.text_end) & ~0xFFFF
|
||||
# A text segment longer than the reach itself (EA SPORTS FC 27: 185.6 MB of text in main) leaves no gap before the base from which a B reaches its end, so the patch area is split in
|
||||
# two (TWO): the front area before the base takes the sites below SPLIT, the back area right after the image (after bss, the key page and the frame step page, at BACK_OFF) takes
|
||||
# the others. A site's stubs, and their branches back to it, stay in the area it belongs to; SPLIT keeps 1 MB of margin for a stub's exits past its site (a window's targets, a
|
||||
# switch's cases). The front area starts at 16 MB; when its sites need more, the rewriter runs again with exactly that size (DM_PATCH_FRONT), and B() checks every branch
|
||||
TWO = BIG_TEXT and MOD.text_end > 0x8000000 - 0x10000
|
||||
if TWO: FRONT = int(os.environ.get('DM_PATCH_FRONT', '0'), 0) or 0x1000000
|
||||
elif BIG_TEXT: FRONT = int(os.environ.get('DM_PATCH_FRONT', '0'), 0) or (0x8000000 - 0x10000 - MOD.text_end) & ~0xFFFF
|
||||
SPLIT = 0x8000000 - FRONT - 0x100000 if TWO else None
|
||||
IMG = MOD.image
|
||||
if not FAR: IMG.extend(bytes(bss))
|
||||
TEXT_END = MOD.text_end
|
||||
@@ -42,10 +49,12 @@ if FAR:
|
||||
FILE_IMAGE_LEN = (len(IMG) + 0x3FFF) & ~0x3FFF
|
||||
KEY_PAGE_OFF = (len(IMG) + bss + 0x3FFF) & ~0x3FFF
|
||||
IMAGE_SIZE, PATCH_OFF = KEY_PAGE_OFF + 0x4000, -FRONT
|
||||
BACK_OFF = (KEY_PAGE_OFF + 0x8000 + 0xFFFF) & ~0xFFFF if TWO else 0 # after the key page and the frame step page FRAME_STEP may take
|
||||
else:
|
||||
KEY_PAGE_OFF = (len(IMG) + 0x3FFF) & ~0x3FFF
|
||||
IMG.extend(bytes(0x4000))
|
||||
PATCH_OFF = (len(IMG) + 0xFFFF) & ~0xFFFF
|
||||
IMAGE_SIZE = BACK_OFF = 0 # only the layout with the patch area before the base has them
|
||||
|
||||
# ---- Registered patches of particular builds, keyed by NSO build ID: dm/tools/sdk_patches.py (Nintendo SDK module builds, which several games can ship) and dm/games/<id>/patches.py
|
||||
# (a game's own modules: its profile's builds). Every file is loaded, whatever the game, so a module gets the patches of its build wherever it comes from; a build ID claimed twice stops the rewrite.
|
||||
@@ -129,8 +138,13 @@ KEY_INDEX = {k: i for i, k in enumerate(('K18', 'KTLS', 'KTLR', 'KGATE'))}
|
||||
|
||||
md = Cs(CS_ARCH_ARM64, CS_MODE_ARM); md.detail = True
|
||||
patch = bytearray(); fix = []; gates = []; stats = {}
|
||||
patch_front, patch_back, PATCH_BASE = patch, bytearray(), PATCH_OFF # the area emit() writes into and its offset: the front one unless TWO puts a site in the back one
|
||||
def use_area(a):
|
||||
"""Emit what follows into the patch area that reaches the code at offset a (TWO: the back area from SPLIT on)"""
|
||||
global patch, PATCH_BASE
|
||||
patch, PATCH_BASE = (patch_back, BACK_OFF) if TWO and a >= SPLIT else (patch_front, PATCH_OFF)
|
||||
def stat(k): stats[k] = stats.get(k, 0) + 1
|
||||
def here(): return PATCH_OFF + len(patch)
|
||||
def here(): return PATCH_BASE + len(patch)
|
||||
def emit(w, kind=None):
|
||||
if kind: fix.append((len(patch), kind))
|
||||
patch.extend(struct.pack('<I', w & 0xFFFFFFFF))
|
||||
@@ -1036,11 +1050,12 @@ if far_into: # functions analysed in pieces (pieces above): their far b / bl,
|
||||
|
||||
def put_branch(at, to): struct.pack_into('<I', IMG, at, B(at, to))
|
||||
for wseg in windows:
|
||||
st, lo, hi = site_window(wseg); stat('window'); put_branch(lo, st)
|
||||
use_area(wseg[0].address); st, lo, hi = site_window(wseg); stat('window'); put_branch(lo, st)
|
||||
for parts in retries:
|
||||
st = site_retry_window(parts); stat('retry_window'); put_branch(parts[0][0][0].address, st)
|
||||
use_area(parts[0][0][0].address); st = site_retry_window(parts); stat('retry_window'); put_branch(parts[0][0][0].address, st)
|
||||
for a in sorted(kinds):
|
||||
if a in done: continue
|
||||
use_area(a)
|
||||
k, arg = kinds[a]
|
||||
ins = dis(struct.unpack_from('<I', IMG, a)[0], a)
|
||||
if k == 'x18':
|
||||
@@ -1091,7 +1106,7 @@ for off, oid, ow, why in obs:
|
||||
after_bl = off >= 4 and struct.unpack_from('<I', IMG, off - 4)[0] >> 26 == 0x25
|
||||
assert off in set(starts) or after_bl or scratch_dead(off), f'observation gate neither at a function entry, after a bl nor before a call with x9–x17 unread {off:#x}'
|
||||
assert off < TEXT_END and off not in kinds and not any(lo <= off < hi for wseg in windows for lo, hi in [(wseg[0].address, wseg[-1].address + 4)]), f'observation gate conflicts with a rewrite site {off:#x}'
|
||||
put_branch(off, site_obs(off, oid, w)); stat('obs')
|
||||
use_area(off); put_branch(off, site_obs(off, oid, w)); stat('obs')
|
||||
|
||||
# ---- Address regions (every module that defines the SDK's VammManager: sdk) ----
|
||||
# Three observation gates, found by the SDK's own symbols in any build, let the host keep the table of address regions (hle_svc.c "Address regions"): the alias region space each takes,
|
||||
@@ -1133,7 +1148,7 @@ def stdalloc_gates():
|
||||
out.append((off, OBS_STDALLOC_INIT, f'{struct.unpack_from("<I", IMG, off)[0]:08x}', f'StandardAllocator::Initialize(void *, size_t{", bool" if name.endswith("b") else ""}) entry: the size in x2, capped when the address in x1 is null'))
|
||||
return out
|
||||
region_obs += stdalloc_gates()
|
||||
for off, oid, ow, why in region_obs: put_branch(off, site_obs(off, oid, int(ow, 16))); stat('obs')
|
||||
for off, oid, ow, why in region_obs: use_area(off); put_branch(off, site_obs(off, oid, int(ow, 16))); stat('obs')
|
||||
obs += region_obs
|
||||
|
||||
# ---- Frame step in whole vsyncs (the mains whose patch file has FRAME_STEP: The Legend of Zelda: Tears of the Kingdom 1.4.3, Breath of the Wild 1.9.0, Hyrule Warriors: Age of Calamity 1.3.0,
|
||||
@@ -1168,7 +1183,7 @@ if BUILD_ID in FRAME_STEP and NAME == 'main':
|
||||
for i, w in enumerate(words): struct.pack_into('<I', IMG, off + 4 * i, w)
|
||||
cuts.append((off, old.hex(), bytes(IMG[off:off + 4 * len(words)]).hex(), why)); stat('frame_step')
|
||||
if FS_STATE_OFF: # the build's stubs (FRAME_STEP of its patches.py)
|
||||
fs = types.SimpleNamespace(here=here, emit=emit, site=fs_site, put=fs_put, state=FS_STATE_OFF, render_scale=0)
|
||||
use_area(0); fs = types.SimpleNamespace(here=here, emit=emit, site=fs_site, put=fs_put, state=FS_STATE_OFF, render_scale=0)
|
||||
FRAME_STEP[BUILD_ID](fs); RENDER_SCALE = fs.render_scale
|
||||
|
||||
# ---- Spin waits (every module) ----
|
||||
@@ -1410,7 +1425,7 @@ def spin_region1(T, bes, ban, stores):
|
||||
return {'T': T, 'R': sorted(R), 'nodes': nodes, 'valid': valid}
|
||||
def spin_emit(g):
|
||||
T, R, nodes, valid = g['T'], g['R'], g['nodes'], g['valid']
|
||||
cpy, fixes, tramp = {}, [], {}
|
||||
use_area(T); cpy, fixes, tramp = {}, [], {}
|
||||
for i, a in enumerate(R):
|
||||
n = nodes[a]; cpy[a] = here(); x = n['ins'][0]
|
||||
if n['kind'] == 'rmw':
|
||||
@@ -1438,7 +1453,7 @@ def spin_emit(g):
|
||||
if t not in tramp: tramp[t] = here(); emit(B(here(), t))
|
||||
return tramp[t]
|
||||
for idx, x, info in fixes:
|
||||
pc = PATCH_OFF + idx
|
||||
pc = PATCH_BASE + idx
|
||||
if x is None: w = B(pc, cpy.get(info, info))
|
||||
elif isinstance(info, tuple): w = spin_rebranch(x, pc, out(info[1]))
|
||||
elif info is not None: w = spin_rebranch(x, pc, cpy[info])
|
||||
@@ -1460,12 +1475,18 @@ if os.environ.get('DM_SPIN_LIST'):
|
||||
|
||||
os.makedirs(outdir, exist_ok=True)
|
||||
P = lambda ext: os.path.join(outdir, f'{NAME}.{ext}')
|
||||
if FAR: # patch area before the base: file = text + ro + data (padded to 16K) + patch area
|
||||
patch = patch_front
|
||||
BACK_LEN = (len(patch_back) + 0x3FFF) & ~0x3FFF
|
||||
if FAR: # patch area before the base: file = text + ro + data (padded to 16K) + patch area (TWO: the front area padded to 16K, then the back area, padded to 16K)
|
||||
if BIG_TEXT and len(patch) > FRONT - 0x4000 and 'DM_PATCH_FRONT' not in os.environ:
|
||||
need = (len(patch) + 0x4000 + 0xFFFF) & ~0xFFFF
|
||||
print(f'{NAME}: patch area of {len(patch):#x} bytes does not fit in {FRONT:#x} before the base; rewriting again with {need:#x}', flush=True)
|
||||
os.execve(sys.executable, [sys.executable] + sys.argv, dict(os.environ, DM_PATCH_FRONT=hex(need)))
|
||||
assert len(patch) <= FRONT - 0x4000, f'patch area of {len(patch):#x} bytes does not fit in the {FRONT:#x} before the base'
|
||||
if TWO:
|
||||
assert IMAGE_SIZE <= BACK_OFF, 'back patch area overlaps the key page or the frame step page'
|
||||
IMAGE_SIZE = BACK_OFF + BACK_LEN
|
||||
patch = patch + bytearray(-len(patch) & 0x3FFF) + patch_back + bytearray(BACK_LEN - len(patch_back))
|
||||
open(P('patched.bin'), 'wb').write(IMG + bytearray(FILE_IMAGE_LEN - len(IMG)) + patch)
|
||||
else:
|
||||
open(P('patched.bin'), 'wb').write(IMG + bytearray(PATCH_OFF - len(IMG)) + patch)
|
||||
@@ -1475,6 +1496,7 @@ with open(os.path.join(outdir, 'build_src.sha256'), 'w') as f: # the same for
|
||||
with open(P('fixups.tsv'), 'w') as f:
|
||||
f.write(f'# PATCH_OFF\t{PATCH_OFF:#x}\n# KEY_PAGE_OFF\t{KEY_PAGE_OFF:#x}\n# KEY_PAGE_SIZE\t0x4000\n# TEXT_END\t{TEXT_END:#x}\n# RO_OFF\t{RO_OFF:#x}\n# DATA_OFF\t{DATA_OFF:#x}\n')
|
||||
if FAR: f.write(f'# IMAGE_SIZE\t{IMAGE_SIZE:#x}\n# FILE_IMAGE_LEN\t{FILE_IMAGE_LEN:#x}\n') # patch area before the base (negative PATCH_OFF): whole image size, length of the image part of the file
|
||||
if TWO: f.write(f'# BACK_OFF\t{BACK_OFF:#x}\n# BACK_LEN\t{BACK_LEN:#x}\n') # the back patch area (TWO): its offset in the image, and its length, the last bytes of the file
|
||||
for k in KEY_INDEX: f.write(f'# KEY_{k}_IDX\t{KEY_INDEX[k]}\n')
|
||||
if FS_STATE_OFF: f.write(f'# FPS_STATE_OFF\t{FS_STATE_OFF:#x}\n') # frame step state page (FRAME_STEP): the loader writes the target fps there
|
||||
if RENDER_SCALE: f.write('# RENDER_SCALE\t1\n') # a render-scale stub reads state +0x10 (the loader ignores the key; dm/games/settings.py offers the setting by it)
|
||||
@@ -1498,5 +1520,5 @@ with open(P('cuts.tsv'), 'w') as f:
|
||||
with open(P('obs.tsv'), 'w') as f:
|
||||
f.write(f'# BUILD_ID\t{BUILD_ID}\n')
|
||||
for off, oid, ow, why in obs: f.write(f'{off:#x}\t{oid}\t{ow}\t{why}\n')
|
||||
print(NAME, stats, 'cuts', len(cuts), 'obs', len(obs), 'patch', len(patch), 'PATCH_OFF', hex(PATCH_OFF), 'slot_refs', len(fix), 'gates', len(gates))
|
||||
print(NAME, stats, 'cuts', len(cuts), 'obs', len(obs), 'patch', len(patch_front) + len(patch_back), 'PATCH_OFF', hex(PATCH_OFF), *(('BACK_OFF', hex(BACK_OFF), 'back', len(patch_back)) if TWO else ()), 'slot_refs', len(fix), 'gates', len(gates))
|
||||
if DATA_BLOCKS: print(NAME, 'data blocks left alone:', ', '.join(f'{s:#x}..{e:#x}' for s, e in DATA_BLOCKS))
|
||||
@@ -80,6 +80,13 @@ CUTS = {
|
||||
(0x1423fc, '08fca752', '087ca052', 'AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000'),
|
||||
(0x142468, '09fca752', '097ca052', 'AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000'),
|
||||
],
|
||||
# EA SPORTS FC 27 1.8d.310c (v393216) sdk (SDK 22.2.0, also Well Dweller's, which has no virtual address memory): the same node area cut, the SDK-wide rule's implementation 6 (the
|
||||
# constructor at sdk+0x14def0), registered because the profile was brought up on this build. Frostbite's VirtualAlloc reserves 264 regions, 2.8 GB, in its first minute
|
||||
# (main+0x17f9884, AllocateAddressRegion), which the 1 GB node area pushed past the alias region. Region placement aligns only to 64 KB or 2 MB (sdk+0x14e060), as SDK 20
|
||||
'fed212d6e0963706f9f4b16ea5d65879': [
|
||||
(0x14df00, '08fca752', '087ca052', 'AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000'),
|
||||
(0x14df6c, '09fca752', '097ca052', 'AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000'),
|
||||
],
|
||||
# Paper Mario: The Origami King 1.0.1 (v65536) sdk (SDK 8.3.1): the SDK-wide rules' cuts (node area and alignment implementation 1, the constructor at sdk+0xc96e0), registered because the
|
||||
# profile was brought up on this build. nninitStartup initializes a StandardAllocator over 62 GB with virtual address memory (the region returns to main+0x5c05ac); the host's cap gives it
|
||||
# 4.06 GB, which fits the 4.375 GB alias region only after the 62 MB node area and with 32 MB alignment. Blasphemous 1.0.8 ships this build too; it has no virtual address memory
|
||||
@@ -290,6 +297,8 @@ MATCH_CUTS = {'sdk': [
|
||||
'3549234b3e27a013791bbd834b5ff7dd501a5826c4216c80961bd996eef556ea'], 0x10, '08fca752', '087ca052', 0xa4, '09fca752', '097ca052'),
|
||||
# SDK 19.3.11 (Pokémon Legends: Z-A), 19.3.13 (Octopath Traveler 0), 20.5.19 (BALL x PIT), 20.5.22 (Tears of the Kingdom)
|
||||
node(244, ['b02f0514e2cc25a65261ec23cefa9a1fe7b244b3db741f183deb334935541eee'], 0x10, '08fca752', '087ca052', 0x7c, '09fca752', '097ca052'),
|
||||
# SDK 22.2.0 (EA SPORTS FC 27, Well Dweller): the SDK 19 / 20 constructor, instruction for instruction up to its cold path, which gives each failing result its own abort (32 bytes more)
|
||||
node(276, ['8960fe237061c387226a3775daf750a646dd0ee12eccf3d1340248683a6a7d78'], 0x10, '08fca752', '087ca052', 0x7c, '09fca752', '097ca052'),
|
||||
# SDK 7.3.2 (DRAGON QUEST XI S), 8.2.1 (Super Smash Bros. Ultimate), 8.3.1 (Paper Mario: The Origami King), 10.4.1 (Advance Wars 1+2), 10.4.8 (Pikmin 4)
|
||||
align(352, ['006abd214d94c93386735550cee4fe7708bc1f0d1812663123cfa3b9611f1533', '42167e4d3c710e11937e45a9e420fdd0ed9a410386c17da4d1d896b847d3b0d6'], 0x6c, 'ea030232'),
|
||||
# SDK 11.4.0 (Pokémon Legends: Arceus, Kirby and the Forgotten Land): the next rule's size classes with 8 more bytes of body; the 4 GB StandardAllocator region of Arceus's nninitStartup
|
||||
|
||||
@@ -124,6 +124,10 @@ class Host(unittest.TestCase):
|
||||
(REPO / 'dm/gfx/tools/dmsh_xlate/Program.cs').read_text())
|
||||
assert m, 'Program.cs c2 layout line not found'
|
||||
self.assertEqual([int(x, 0) for x in m.groups()], [abi.C2_TEX, abi.C2_IMG, abi.C2_IMG_SLOTS, abi.C2_SEPTEX, abi.SEPTEX_SLOT0, abi.C2_SAMP])
|
||||
m = re.search(r'const int C2HandleWords = \(SampBase \+ 8 \* (\d+)\) / 8;', (REPO / 'dm/gfx/tools/dmsh_xlate/Program.cs').read_text())
|
||||
assert m, 'Program.cs C2HandleWords line not found'
|
||||
self.assertEqual(int(m.group(1)), abi.C2_SEP_SLOTS)
|
||||
self.assertEqual(abi.C2_ROW, 8)
|
||||
|
||||
|
||||
class Ratchet(unittest.TestCase):
|
||||
|
||||
+102
-39
@@ -9,29 +9,30 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
| [ASTRAL CHAIN](#astral-chain) | 0 | 0 | 112 | 0 | 0 | yes |
|
||||
| [Batman: Arkham Knight](#batman-arkham-knight) | 8 | 0 | 0 | 0 | 1 | yes |
|
||||
| [DARK SOULS: REMASTERED](#dark-souls-remastered) | 2 | 0 | 0 | 0 | 0 | yes |
|
||||
| [DRAGON QUEST VII Reimagined](#dragon-quest-vii-reimagined) | 1 | 1 | 0 | 0 | 3 | yes |
|
||||
| [DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition](#dragon-quest-xi-s-echoes-of-an-elusive-age--definitive-edition) | 0 | 0 | 0 | 0 | 2 | |
|
||||
| [DRAGON QUEST VII Reimagined](#dragon-quest-vii-reimagined) | 1 | 1 | 0 | 0 | 7 | yes |
|
||||
| [DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition](#dragon-quest-xi-s-echoes-of-an-elusive-age--definitive-edition) | 0 | 0 | 0 | 0 | 6 | |
|
||||
| [EA SPORTS FC 27](#ea-sports-fc-27) | 0 | 0 | 0 | 0 | 3 | |
|
||||
| [FINAL FANTASY CRYSTAL CHRONICLES Remastered Edition](#final-fantasy-crystal-chronicles-remastered-edition) | 8 | 0 | 0 | 0 | 0 | yes |
|
||||
| [FINAL FANTASY RESONANCE](#final-fantasy-resonance) | 1 | 0 | 0 | 0 | 3 | yes |
|
||||
| [FINAL FANTASY RESONANCE (Asian release)](#final-fantasy-resonance-asian-release) | 1 | 0 | 0 | 0 | 2 | yes |
|
||||
| [FINAL FANTASY RESONANCE](#final-fantasy-resonance) | 1 | 0 | 0 | 0 | 7 | yes |
|
||||
| [FINAL FANTASY RESONANCE (Asian release)](#final-fantasy-resonance-asian-release) | 1 | 0 | 0 | 0 | 4 | yes |
|
||||
| [FINAL FANTASY TACTICS - The Ivalice Chronicles](#final-fantasy-tactics---the-ivalice-chronicles) | 2 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Fire Emblem Engage](#fire-emblem-engage) | 1 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Fire Emblem: Three Houses](#fire-emblem-three-houses) | 12 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Hyrule Warriors: Age of Calamity](#hyrule-warriors-age-of-calamity) | 0 | 0 | 3 | 0 | 0 | yes |
|
||||
| [Luigi's Mansion 3](#luigis-mansion-3) | 0 | 0 | 0 | 0 | 1 | |
|
||||
| [Luigi's Mansion 3](#luigis-mansion-3) | 0 | 0 | 0 | 0 | 3 | |
|
||||
| [Mario + Rabbids Kingdom Battle](#mario--rabbids-kingdom-battle) | 6 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Mario + Rabbids® Sparks of Hope](#mario--rabbids-sparks-of-hope) | 7 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Monster Hunter Rise](#monster-hunter-rise) | 0 | 0 | 0 | 0 | 1 | |
|
||||
| [Need For Speed™ Hot Pursuit Remastered](#need-for-speed-hot-pursuit-remastered) | 1 | 0 | 0 | 0 | 5 | yes |
|
||||
| [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](#nierautomata-the-end-of-yorha-edition-010056b015fe8000) | 8 | 0 | 0 | 0 | 1 | yes |
|
||||
| [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](#nierautomata-the-end-of-yorha-edition-0100b8e016f76000) | 8 | 0 | 0 | 0 | 1 | yes |
|
||||
| [OCTOPATH TRAVELER 0](#octopath-traveler-0) | 1 | 0 | 0 | 0 | 3 | yes |
|
||||
| [OCTOPATH TRAVELER II](#octopath-traveler-ii) | 1 | 1 | 0 | 0 | 3 | yes |
|
||||
| [Monster Hunter Rise](#monster-hunter-rise) | 0 | 0 | 0 | 0 | 3 | |
|
||||
| [Need For Speed™ Hot Pursuit Remastered](#need-for-speed-hot-pursuit-remastered) | 1 | 0 | 0 | 0 | 15 | yes |
|
||||
| [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](#nierautomata-the-end-of-yorha-edition-010056b015fe8000) | 8 | 0 | 0 | 0 | 3 | yes |
|
||||
| [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](#nierautomata-the-end-of-yorha-edition-0100b8e016f76000) | 8 | 0 | 0 | 0 | 3 | yes |
|
||||
| [OCTOPATH TRAVELER 0](#octopath-traveler-0) | 1 | 0 | 0 | 0 | 7 | yes |
|
||||
| [OCTOPATH TRAVELER II](#octopath-traveler-ii) | 1 | 1 | 0 | 0 | 7 | yes |
|
||||
| [Paper Mario: The Thousand-Year Door](#paper-mario-the-thousand-year-door) | 1 | 0 | 1 | 0 | 0 | yes |
|
||||
| [Pikmin 4](#pikmin-4) | 3 | 1 | 0 | 0 | 1 | yes |
|
||||
| [Pokémon Brilliant Diamond](#pokémon-brilliant-diamond) | 0 | 0 | 0 | 0 | 1 | |
|
||||
| [Pokémon Brilliant Diamond](#pokémon-brilliant-diamond) | 0 | 0 | 0 | 0 | 3 | |
|
||||
| [Pokémon Scarlet](#pokémon-scarlet) | 1 | 0 | 0 | 0 | 0 | yes |
|
||||
| [SHIN MEGAMI TENSEI V: Vengeance](#shin-megami-tensei-v-vengeance) | 1 | 1 | 0 | 0 | 3 | yes |
|
||||
| [SHIN MEGAMI TENSEI V: Vengeance](#shin-megami-tensei-v-vengeance) | 1 | 1 | 0 | 0 | 7 | yes |
|
||||
| [Subnautica](#subnautica) | 1 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Subnautica: Below Zero](#subnautica-below-zero) | 1 | 0 | 0 | 0 | 0 | yes |
|
||||
| [Super Smash Bros. Ultimate](#super-smash-bros-ultimate) | 11 | 0 | 0 | 1 | 0 | yes |
|
||||
@@ -206,6 +207,10 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- gate 21 at `+0x32758e4`: GCreateMalloc: the allocator object is in x19, before it is used: the host puts its vtable in; orig mov x0, x19
|
||||
- host [hle_fpslock.c:43](../../dm/host/hle_fpslock.c#L43): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:44](../../dm/host/hle_fpslock.c#L44): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:43](../../dm/host/hle_fpslock.c#L43): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:44](../../dm/host/hle_fpslock.c#L44): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:43](../../dm/host/hle_fpslock.c#L43): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:44](../../dm/host/hle_fpslock.c#L44): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_uemalloc.c:42](../../dm/host/hle_uemalloc.c#L42): Unreal's allocator on a host malloc zone
|
||||
|
||||
### DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition
|
||||
@@ -215,6 +220,19 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- **1.0.4 `main`** `1719aabf…`
|
||||
- host [hle_fpslock.c:38](../../dm/host/hle_fpslock.c#L38): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:39](../../dm/host/hle_fpslock.c#L39): engine frame limit set to fps_target: Unreal nvn.SyncInterval
|
||||
- host [hle_fpslock.c:38](../../dm/host/hle_fpslock.c#L38): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:39](../../dm/host/hle_fpslock.c#L39): engine frame limit set to fps_target: Unreal nvn.SyncInterval
|
||||
- host [hle_fpslock.c:38](../../dm/host/hle_fpslock.c#L38): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:39](../../dm/host/hle_fpslock.c#L39): engine frame limit set to fps_target: Unreal nvn.SyncInterval
|
||||
|
||||
### EA SPORTS FC 27
|
||||
|
||||
[EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md), `0100C49025D3E000`.
|
||||
|
||||
- **1.8d.310c `main`** `a48c0de3…`
|
||||
- host [hle_fpslock.c:79](../../dm/host/hle_fpslock.c#L79): engine frame limit set to fps_target: FIFA frame regulator
|
||||
- host [hle_fpslock.c:79](../../dm/host/hle_fpslock.c#L79): engine frame limit set to fps_target: FIFA frame regulator
|
||||
- host [hle_fpslock.c:79](../../dm/host/hle_fpslock.c#L79): engine frame limit set to fps_target: FIFA frame regulator
|
||||
|
||||
### FINAL FANTASY CRYSTAL CHRONICLES Remastered Edition
|
||||
|
||||
@@ -242,6 +260,10 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- cut `+0x137f0`: nninitStartup: bl 0xae770 (FMallocBinned3 constructor, 38 GB of address space) → nop; the host allocator is in the object already (hle_uemalloc.c)
|
||||
- host [hle_fpslock.c:47](../../dm/host/hle_fpslock.c#L47): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:48](../../dm/host/hle_fpslock.c#L48): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:47](../../dm/host/hle_fpslock.c#L47): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:48](../../dm/host/hle_fpslock.c#L48): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:47](../../dm/host/hle_fpslock.c#L47): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:48](../../dm/host/hle_fpslock.c#L48): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_uemalloc.c:53](../../dm/host/hle_uemalloc.c#L53): Unreal's allocator on a host malloc zone
|
||||
|
||||
### FINAL FANTASY RESONANCE (Asian release)
|
||||
@@ -253,6 +275,8 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- **1.0.1 `main`** `b7f965b9…` ([patches.py:7](../../dm/games/0100B8A026F14000/patches.py#L7))
|
||||
- cut `+0x137f0`: nninitStartup: bl 0xae770 (FMallocBinned3 constructor, 38 GB of address space) → nop; the host allocator is in the object already (hle_uemalloc.c)
|
||||
- host [hle_fpslock.c:50](../../dm/host/hle_fpslock.c#L50): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:50](../../dm/host/hle_fpslock.c#L50): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:50](../../dm/host/hle_fpslock.c#L50): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_uemalloc.c:55](../../dm/host/hle_uemalloc.c#L55): Unreal's allocator on a host malloc zone
|
||||
|
||||
### FINAL FANTASY TACTICS - The Ivalice Chronicles
|
||||
@@ -311,6 +335,8 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
|
||||
- **1.4.0 `main`** `79e5950f…`
|
||||
- host [hle_fpslock.c:64](../../dm/host/hle_fpslock.c#L64): engine frame limit set to fps_target: NLG frame limiter target
|
||||
- host [hle_fpslock.c:64](../../dm/host/hle_fpslock.c#L64): engine frame limit set to fps_target: NLG frame limiter target
|
||||
- host [hle_fpslock.c:64](../../dm/host/hle_fpslock.c#L64): engine frame limit set to fps_target: NLG frame limiter target
|
||||
|
||||
### Mario + Rabbids Kingdom Battle
|
||||
|
||||
@@ -347,6 +373,8 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
|
||||
- **16.0.2 `main`** `c9a3dd77…`
|
||||
- host [hle_fpslock.c:27](../../dm/host/hle_fpslock.c#L27): engine frame limit set to fps_target: RE Engine frame limit
|
||||
- host [hle_fpslock.c:27](../../dm/host/hle_fpslock.c#L27): engine frame limit set to fps_target: RE Engine frame limit
|
||||
- host [hle_fpslock.c:27](../../dm/host/hle_fpslock.c#L27): engine frame limit set to fps_target: RE Engine frame limit
|
||||
|
||||
### Need For Speed™ Hot Pursuit Remastered
|
||||
|
||||
@@ -361,6 +389,16 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- host [hle_fpslock.c:71](../../dm/host/hle_fpslock.c#L71): engine frame limit set to fps_target: Criterion frame ticks / 10
|
||||
- host [hle_fpslock.c:72](../../dm/host/hle_fpslock.c#L72): engine frame limit set to fps_target: Criterion 2D game step
|
||||
- host [hle_fpslock.c:73](../../dm/host/hle_fpslock.c#L73): engine frame limit set to fps_target: Criterion 3D game step
|
||||
- host [hle_fpslock.c:69](../../dm/host/hle_fpslock.c#L69): engine frame limit set to fps_target: Criterion 60 fps mode
|
||||
- host [hle_fpslock.c:70](../../dm/host/hle_fpslock.c#L70): engine frame limit set to fps_target: Criterion frame ticks
|
||||
- host [hle_fpslock.c:71](../../dm/host/hle_fpslock.c#L71): engine frame limit set to fps_target: Criterion frame ticks / 10
|
||||
- host [hle_fpslock.c:72](../../dm/host/hle_fpslock.c#L72): engine frame limit set to fps_target: Criterion 2D game step
|
||||
- host [hle_fpslock.c:73](../../dm/host/hle_fpslock.c#L73): engine frame limit set to fps_target: Criterion 3D game step
|
||||
- host [hle_fpslock.c:69](../../dm/host/hle_fpslock.c#L69): engine frame limit set to fps_target: Criterion 60 fps mode
|
||||
- host [hle_fpslock.c:70](../../dm/host/hle_fpslock.c#L70): engine frame limit set to fps_target: Criterion frame ticks
|
||||
- host [hle_fpslock.c:71](../../dm/host/hle_fpslock.c#L71): engine frame limit set to fps_target: Criterion frame ticks / 10
|
||||
- host [hle_fpslock.c:72](../../dm/host/hle_fpslock.c#L72): engine frame limit set to fps_target: Criterion 2D game step
|
||||
- host [hle_fpslock.c:73](../../dm/host/hle_fpslock.c#L73): engine frame limit set to fps_target: Criterion 3D game step
|
||||
|
||||
### NieR:Automata The End of YoRHa Edition (010056B015FE8000)
|
||||
|
||||
@@ -378,7 +416,9 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- cut `+0x9bf4d4`: dynamic resolution: optimal frame cost 32.01 -> 16.005 ms at 60 fps (second load)
|
||||
- cut `+0x9bf4f8`: dynamic resolution: good frame cost 30 -> 15 ms at 60 fps
|
||||
- launcher capabilities: DYNAMIC_RESOLUTION
|
||||
- host [hle_fpslock.c:89](../../dm/host/hle_fpslock.c#L89): frame interval and dynamic-resolution floor
|
||||
- host [hle_fpslock.c:95](../../dm/host/hle_fpslock.c#L95): frame interval and dynamic-resolution floor
|
||||
- host [hle_fpslock.c:95](../../dm/host/hle_fpslock.c#L95): frame interval and dynamic-resolution floor
|
||||
- host [hle_fpslock.c:95](../../dm/host/hle_fpslock.c#L95): frame interval and dynamic-resolution floor
|
||||
|
||||
### NieR:Automata The End of YoRHa Edition (0100B8E016F76000)
|
||||
|
||||
@@ -396,7 +436,9 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- cut `+0x9c08e8`: dynamic resolution lower bound follows the selected preset
|
||||
- cut `+0x9c08f4`: dynamic resolution lower bound follows the selected preset
|
||||
- launcher capabilities: DYNAMIC_RESOLUTION
|
||||
- host [hle_fpslock.c:90](../../dm/host/hle_fpslock.c#L90): frame interval and dynamic-resolution floor
|
||||
- host [hle_fpslock.c:96](../../dm/host/hle_fpslock.c#L96): frame interval and dynamic-resolution floor
|
||||
- host [hle_fpslock.c:96](../../dm/host/hle_fpslock.c#L96): frame interval and dynamic-resolution floor
|
||||
- host [hle_fpslock.c:96](../../dm/host/hle_fpslock.c#L96): frame interval and dynamic-resolution floor
|
||||
|
||||
### OCTOPATH TRAVELER 0
|
||||
|
||||
@@ -408,6 +450,10 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- cut `+0x12e40`: nninitStartup: bl 0x9f480 (FMallocBinned3 constructor, 37 GB of address space) → nop; the host allocator is in the object already (hle_uemalloc.c)
|
||||
- host [hle_fpslock.c:33](../../dm/host/hle_fpslock.c#L33): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:34](../../dm/host/hle_fpslock.c#L34): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:33](../../dm/host/hle_fpslock.c#L33): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:34](../../dm/host/hle_fpslock.c#L34): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:33](../../dm/host/hle_fpslock.c#L33): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:34](../../dm/host/hle_fpslock.c#L34): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_uemalloc.c:40](../../dm/host/hle_uemalloc.c#L40): Unreal's allocator on a host malloc zone
|
||||
|
||||
### OCTOPATH TRAVELER II
|
||||
@@ -421,6 +467,10 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- gate 21 at `+0xbecc0c`: GCreateMalloc: the allocator object is in x19, before it is used: the host puts its vtable in; orig mov x0, x19
|
||||
- host [hle_fpslock.c:54](../../dm/host/hle_fpslock.c#L54): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:55](../../dm/host/hle_fpslock.c#L55): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:54](../../dm/host/hle_fpslock.c#L54): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:55](../../dm/host/hle_fpslock.c#L55): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:54](../../dm/host/hle_fpslock.c#L54): engine frame limit set to fps_target: Unreal t.MaxFPS
|
||||
- host [hle_fpslock.c:55](../../dm/host/hle_fpslock.c#L55): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_uemalloc.c:48](../../dm/host/hle_uemalloc.c#L48): Unreal's allocator on a host malloc zone
|
||||
|
||||
### Paper Mario: The Thousand-Year Door
|
||||
@@ -452,6 +502,8 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
|
||||
- **1.3.0 `main`** `94ceae32…`
|
||||
- host [hle_fpslock.c:22](../../dm/host/hle_fpslock.c#L22): engine frame limit set to fps_target: Unity targetFrameRate
|
||||
- host [hle_fpslock.c:22](../../dm/host/hle_fpslock.c#L22): engine frame limit set to fps_target: Unity targetFrameRate
|
||||
- host [hle_fpslock.c:22](../../dm/host/hle_fpslock.c#L22): engine frame limit set to fps_target: Unity targetFrameRate
|
||||
|
||||
### Pokémon Scarlet
|
||||
|
||||
@@ -473,6 +525,10 @@ Every piece of code that runs for one game and not the others: the rewriter's pa
|
||||
- gate 21 at `+0x1f2f644`: GCreateMalloc: x19 is the allocator object; install the host vtable before use; orig mov x0, x19
|
||||
- host [hle_fpslock.c:59](../../dm/host/hle_fpslock.c#L59): engine frame limit set to fps_target: Unreal Project.FrameRateLimit
|
||||
- host [hle_fpslock.c:60](../../dm/host/hle_fpslock.c#L60): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:59](../../dm/host/hle_fpslock.c#L59): engine frame limit set to fps_target: Unreal Project.FrameRateLimit
|
||||
- host [hle_fpslock.c:60](../../dm/host/hle_fpslock.c#L60): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_fpslock.c:59](../../dm/host/hle_fpslock.c#L59): engine frame limit set to fps_target: Unreal Project.FrameRateLimit
|
||||
- host [hle_fpslock.c:60](../../dm/host/hle_fpslock.c#L60): engine frame limit set to fps_target: Unreal rhi.SyncInterval
|
||||
- host [hle_uemalloc.c:51](../../dm/host/hle_uemalloc.c#L51): Unreal's allocator on a host malloc zone
|
||||
|
||||
### Subnautica
|
||||
@@ -623,75 +679,78 @@ Cuts of Nintendo SDK `sdk` builds ([sdk_patches.py](../../dm/tools/sdk_patches.p
|
||||
- **sdk** `871fb219…` ([sdk_patches.py:79](../../dm/tools/sdk_patches.py#L79)): Cult of the Lamb 1.5.28
|
||||
- cut `+0x1423fc`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x142468`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `86a2afd8…` ([sdk_patches.py:87](../../dm/tools/sdk_patches.py#L87)): Blasphemous 1.0.8, Paper Mario: The Origami King 1.0.1
|
||||
- **sdk** `fed212d6…` ([sdk_patches.py:86](../../dm/tools/sdk_patches.py#L86)): EA SPORTS FC 27 1.8d.310c, Well Dweller 1.0.0
|
||||
- cut `+0x14df00`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x14df6c`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `86a2afd8…` ([sdk_patches.py:94](../../dm/tools/sdk_patches.py#L94)): Blasphemous 1.0.8, Paper Mario: The Origami King 1.0.1
|
||||
- cut `+0xc96f0`: AddressRegionManager constructor: node area limit orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0xc9790`: AddressRegionManager constructor: length of the node area registered as an occupied region orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0xc98fc`: AllocateAddressRegion: alignment of regions of 1 GB and more orr w10,wzr,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `2aef2cff…` ([sdk_patches.py:95](../../dm/tools/sdk_patches.py#L95)): Batman: Arkham Knight 1.0.5, Persona 4 Golden 1.0.2
|
||||
- **sdk** `2aef2cff…` ([sdk_patches.py:102](../../dm/tools/sdk_patches.py#L102)): Batman: Arkham Knight 1.0.5, Persona 4 Golden 1.0.2
|
||||
- cut `+0x12d8b0`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x12d94c`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `9c73fb73…` ([sdk_patches.py:102](../../dm/tools/sdk_patches.py#L102)): Patrick's Parabox 1.0.1
|
||||
- **sdk** `9c73fb73…` ([sdk_patches.py:109](../../dm/tools/sdk_patches.py#L109)): Patrick's Parabox 1.0.1
|
||||
- cut `+0x37c3b0`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x37c44c`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `3644a676…` ([sdk_patches.py:118](../../dm/tools/sdk_patches.py#L118)): AI: THE SOMNIUM FILES - nirvanA Initiative 1.0.2, Pokémon Scarlet 1.0.0, Subnautica 1.23.83358, Subnautica: Below Zero 1.23.55063
|
||||
- **sdk** `3644a676…` ([sdk_patches.py:125](../../dm/tools/sdk_patches.py#L125)): AI: THE SOMNIUM FILES - nirvanA Initiative 1.0.2, Pokémon Scarlet 1.0.0, Subnautica 1.23.83358, Subnautica: Below Zero 1.23.55063
|
||||
- cut `+0x37c140`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x37c1dc`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x37c334`: AllocateAddressRegion: alignment of regions from 32 MB to 1 GB mov w11,#0x2000000 → mov w11,#0x200000 (2 MB, as SDK 20)
|
||||
- cut `+0x37c33c`: AllocateAddressRegion: alignment of regions of 1 GB and more mov w10,#0x40000000 → mov w10,#0x200000 (2 MB, as SDK 20)
|
||||
- cut `+0x37c340`: AllocateAddressRegion: alignment of regions from 4 MB to 32 MB mov w8,#0x400000 → mov w8,#0x200000 (2 MB, as SDK 20)
|
||||
- **sdk** `43211771…` ([sdk_patches.py:132](../../dm/tools/sdk_patches.py#L132)): Mario + Rabbids® Sparks of Hope 1.6.2225577
|
||||
- **sdk** `43211771…` ([sdk_patches.py:139](../../dm/tools/sdk_patches.py#L139)): Mario + Rabbids® Sparks of Hope 1.6.2225577
|
||||
- cut `+0x37c140`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x37c1dc`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x37c33c`: AllocateAddressRegion: alignment of regions of 1 GB and more mov w10,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `df7a3960…` ([sdk_patches.py:139](../../dm/tools/sdk_patches.py#L139)): Pokémon Legends: Z-A 2.0.2
|
||||
- **sdk** `df7a3960…` ([sdk_patches.py:146](../../dm/tools/sdk_patches.py#L146)): Pokémon Legends: Z-A 2.0.2
|
||||
- cut `+0x1423fc`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x142468`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `e01950c5…` ([sdk_patches.py:147](../../dm/tools/sdk_patches.py#L147)): Hollow Knight: Silksong 1.0.30000
|
||||
- **sdk** `e01950c5…` ([sdk_patches.py:154](../../dm/tools/sdk_patches.py#L154)): Hollow Knight: Silksong 1.0.30000
|
||||
- cut `+0x145bfc`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x145c68`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `574284b4…` ([sdk_patches.py:157](../../dm/tools/sdk_patches.py#L157)): The Legend of Zelda: Breath of the Wild 1.9.0, The Legend of Zelda: Tears of the Kingdom 1.4.3
|
||||
- **sdk** `574284b4…` ([sdk_patches.py:164](../../dm/tools/sdk_patches.py#L164)): The Legend of Zelda: Breath of the Wild 1.9.0, The Legend of Zelda: Tears of the Kingdom 1.4.3
|
||||
- cut `+0x145d0c`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x145d78`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `8bfebccd…` ([sdk_patches.py:163](../../dm/tools/sdk_patches.py#L163)): BALL x PIT 1.293
|
||||
- **sdk** `8bfebccd…` ([sdk_patches.py:170](../../dm/tools/sdk_patches.py#L170)): BALL x PIT 1.293
|
||||
- cut `+0x145d0c`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x145d78`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `60751516…` ([sdk_patches.py:170](../../dm/tools/sdk_patches.py#L170)): Donkey Kong Country Returns HD 1.1.0, Monster Train 2 1.1.1, Super Mario Galaxy 1.3.1, Super Mario Galaxy 2 1.4.0
|
||||
- **sdk** `60751516…` ([sdk_patches.py:177](../../dm/tools/sdk_patches.py#L177)): Donkey Kong Country Returns HD 1.1.0, Monster Train 2 1.1.1, Super Mario Galaxy 1.3.1, Super Mario Galaxy 2 1.4.0
|
||||
- cut `+0x13be4c`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x13bee0`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `f118ae1c…` ([sdk_patches.py:179](../../dm/tools/sdk_patches.py#L179)): Absolum 1.1.1, Absolum 1.1.2, Balatro 1.1.3
|
||||
- **sdk** `f118ae1c…` ([sdk_patches.py:186](../../dm/tools/sdk_patches.py#L186)): Absolum 1.1.1, Absolum 1.1.2, Balatro 1.1.3
|
||||
- cut `+0x13be4c`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x13bee0`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x13c03c`: AllocateAddressRegion: alignment of regions of 1 GB and more mov w10,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `86188952…` ([sdk_patches.py:187](../../dm/tools/sdk_patches.py#L187)): Blasphemous 2 1.0.8, Celeste 1.4.1.1, Paper Mario: The Thousand-Year Door 1.0.1, SHIN MEGAMI TENSEI V: Vengeance 1.0.3
|
||||
- **sdk** `86188952…` ([sdk_patches.py:194](../../dm/tools/sdk_patches.py#L194)): Blasphemous 2 1.0.8, Celeste 1.4.1.1, Paper Mario: The Thousand-Year Door 1.0.1, SHIN MEGAMI TENSEI V: Vengeance 1.0.3
|
||||
- cut `+0x12e0f0`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x12e184`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x12e2e0`: AllocateAddressRegion: alignment of regions of 1 GB and more mov w10,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `0023a1b0…` ([sdk_patches.py:194](../../dm/tools/sdk_patches.py#L194)): FINAL FANTASY RESONANCE (Asian release) 1.0.1, FINAL FANTASY RESONANCE 1.0.1, STEINS;GATE RE:BOOT 1.0.3
|
||||
- **sdk** `0023a1b0…` ([sdk_patches.py:201](../../dm/tools/sdk_patches.py#L201)): FINAL FANTASY RESONANCE (Asian release) 1.0.1, FINAL FANTASY RESONANCE 1.0.1, STEINS;GATE RE:BOOT 1.0.3
|
||||
- cut `+0x145cbc`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x145d28`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `145dde94…` ([sdk_patches.py:199](../../dm/tools/sdk_patches.py#L199)): DRAGON QUEST VII Reimagined 1.2.0
|
||||
- **sdk** `145dde94…` ([sdk_patches.py:206](../../dm/tools/sdk_patches.py#L206)): DRAGON QUEST VII Reimagined 1.2.0
|
||||
- cut `+0x1423fc`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x142468`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `fcf93a41…` ([sdk_patches.py:208](../../dm/tools/sdk_patches.py#L208)): DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition 1.0.4, Luigi's Mansion 3 1.4.0, Pokémon Shield 1.3.2, Pokémon Sword 1.3.2, Raging Loop 1.0.0, Super Mario Odyssey 1.4.1
|
||||
- **sdk** `fcf93a41…` ([sdk_patches.py:215](../../dm/tools/sdk_patches.py#L215)): DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition 1.0.4, Luigi's Mansion 3 1.4.0, Pokémon Shield 1.3.2, Pokémon Sword 1.3.2, Raging Loop 1.0.0, Super Mario Odyssey 1.4.1
|
||||
- cut `+0x32c460`: AddressRegionManager constructor: node area limit orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x32c500`: AddressRegionManager constructor: length of the node area registered as an occupied region orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x32c66c`: AllocateAddressRegion: alignment of regions of 1 GB and more orr w10,wzr,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `5fd4f531…` ([sdk_patches.py:217](../../dm/tools/sdk_patches.py#L217)): Catherine: Full Body 1.0.1a, FINAL FANTASY CRYSTAL CHRONICLES Remastered Edition 1.0.3, Super Smash Bros. Ultimate 13.0.5
|
||||
- **sdk** `5fd4f531…` ([sdk_patches.py:224](../../dm/tools/sdk_patches.py#L224)): Catherine: Full Body 1.0.1a, FINAL FANTASY CRYSTAL CHRONICLES Remastered Edition 1.0.3, Super Smash Bros. Ultimate 13.0.5
|
||||
- cut `+0x336b50`: AddressRegionManager constructor: node area limit orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x336bf0`: AddressRegionManager constructor: length of the node area registered as an occupied region orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x336d5c`: AllocateAddressRegion: alignment of regions of 1 GB and more orr w10,wzr,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `d9add76f…` ([sdk_patches.py:227](../../dm/tools/sdk_patches.py#L227)): Advance Wars 1+2: Re-Boot Camp 1.0.0, Need For Speed™ Hot Pursuit Remastered 1.0.3, The Great Ace Attorney Chronicles 1.0.0
|
||||
- **sdk** `d9add76f…` ([sdk_patches.py:234](../../dm/tools/sdk_patches.py#L234)): Advance Wars 1+2: Re-Boot Camp 1.0.0, Need For Speed™ Hot Pursuit Remastered 1.0.3, The Great Ace Attorney Chronicles 1.0.0
|
||||
- cut `+0x340ea0`: AddressRegionManager constructor: node area limit orr w8,wzr,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x340f3c`: AddressRegionManager constructor: length of the node area registered as an occupied region orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x34109c`: AllocateAddressRegion: alignment of regions of 1 GB and more orr w10,wzr,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `30a1e87b…` ([sdk_patches.py:235](../../dm/tools/sdk_patches.py#L235)): Pikmin 4 1.1.1
|
||||
- **sdk** `30a1e87b…` ([sdk_patches.py:242](../../dm/tools/sdk_patches.py#L242)): Pikmin 4 1.1.1
|
||||
- cut `+0x340ea0`: AddressRegionManager constructor: node area limit orr w8,wzr,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x340f3c`: AddressRegionManager constructor: length of the node area registered as an occupied region orr w9,wzr,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- cut `+0x34109c`: AllocateAddressRegion: alignment of regions of 1 GB and more orr w10,wzr,#0x40000000 → mov w10,#0x2000000 (32 MB, as from 32 MB up)
|
||||
- **sdk** `7bba185a…` ([sdk_patches.py:243](../../dm/tools/sdk_patches.py#L243)): OCTOPATH TRAVELER 0 1.0.5
|
||||
- **sdk** `7bba185a…` ([sdk_patches.py:250](../../dm/tools/sdk_patches.py#L250)): OCTOPATH TRAVELER 0 1.0.5
|
||||
- cut `+0x1423fc`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x142468`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
- **sdk** `5bcf525f…` ([sdk_patches.py:250](../../dm/tools/sdk_patches.py#L250)): OCTOPATH TRAVELER II 1.1.1
|
||||
- **sdk** `5bcf525f…` ([sdk_patches.py:257](../../dm/tools/sdk_patches.py#L257)): OCTOPATH TRAVELER II 1.1.1
|
||||
- cut `+0x346190`: AddressRegionManager constructor: node area limit mov w8,#0x3fe00000 → mov w8,#0x3e00000
|
||||
- cut `+0x34622c`: AddressRegionManager constructor: length of the node area registered as an occupied region mov w9,#0x3fe00000 → mov w9,#0x3e00000
|
||||
|
||||
@@ -704,6 +763,7 @@ Applied to the `sdk` of any build without CUTS whose profile was not brought up
|
||||
- node area 1 GB → 62 MB: SDK 11.4.3 (Pokémon Brilliant Diamond), 12.3.2 (OCTOPATH TRAVELER II), 12.3.9 (Xenoblade Chronicles 3), 13.3.5 (Mario + Rabbids Sparks of Hope)
|
||||
- node area 1 GB → 62 MB: SDK 15.3.2 (Paper Mario: The Thousand-Year Door), 16.2.0 (Sea of Stars), 16.2.4 (Brain Memory Training Academy), 17.5.3 (Ace Attorney Investigations Collection), 18.3.2 (Absolum), 18.3.5 (Super Mario Galaxy)
|
||||
- node area 1 GB → 62 MB: SDK 19.3.11 (Pokémon Legends: Z-A), 19.3.13 (Octopath Traveler 0), 20.5.19 (BALL x PIT), 20.5.22 (Tears of the Kingdom)
|
||||
- node area 1 GB → 62 MB: SDK 22.2.0 (EA SPORTS FC 27, Well Dweller): the SDK 19 / 20 constructor, instruction for instruction up to its cold path, which gives each failing result its own abort (32 bytes more)
|
||||
- regions of 1 GB and more aligned to 32 MB: SDK 7.3.2 (DRAGON QUEST XI S), 8.2.1 (Super Smash Bros. Ultimate), 8.3.1 (Paper Mario: The Origami King), 10.4.1 (Advance Wars 1+2), 10.4.8 (Pikmin 4)
|
||||
- regions of 1 GB and more aligned to 32 MB: SDK 11.4.0 (Pokémon Legends: Arceus, Kirby and the Forgotten Land): the next rule's size classes with 8 more bytes of body; the 4 GB StandardAllocator region of Arceus's nninitStartup (the host's cap) fits after the 62 MB node area only with it
|
||||
- regions of 1 GB and more aligned to 32 MB: SDK 12.3.9 (Xenoblade Chronicles 3), 13.3.5 (Mario + Rabbids Sparks of Hope), 15.3.2 (Paper Mario: The Thousand-Year Door)
|
||||
@@ -713,11 +773,13 @@ Applied to the `sdk` of any build without CUTS whose profile was not brought up
|
||||
|
||||
Dead code unless such a build is run; a candidate for removal, or for a build row in its profile.
|
||||
|
||||
- `992787e2…`: [hle_fpslock.c:141](../../dm/host/hle_fpslock.c#L141): build check (a build no profile registers)
|
||||
- `992787e2…`: [hle_fpslock.c:218](../../dm/host/hle_fpslock.c#L218): build check (a build no profile registers)
|
||||
- `992787e2…`: [hle_fpslock.c:218](../../dm/host/hle_fpslock.c#L218): build check (a build no profile registers)
|
||||
- `992787e2…`: [hle_fpslock.c:218](../../dm/host/hle_fpslock.c#L218): build check (a build no profile registers)
|
||||
|
||||
## Translator rules keyed by a shader's code
|
||||
|
||||
- [Program.cs:220](../../dm/gfx/tools/dmsh_xlate/Program.cs#L220): Tears of the Kingdom 1.4.3 visibility counter (one vertex shader, exact code SHA-256 below)
|
||||
- [Program.cs:225](../../dm/gfx/tools/dmsh_xlate/Program.cs#L225): Tears of the Kingdom 1.4.3 visibility counter (one vertex shader, exact code SHA-256 below)
|
||||
|
||||
## Profile switches
|
||||
|
||||
@@ -730,6 +792,7 @@ Profile keys (`game.tsv`) whose value changes what the host does, set away from
|
||||
| `present_snap on` | [The Legend of Zelda: Breath of the Wild](../../dm/games/01007EF00011E000/README.md) |
|
||||
| `pso_mtl4 on` | [The Legend of Zelda: Breath of the Wild](../../dm/games/01007EF00011E000/README.md) |
|
||||
| `shader_key_skip 0x770+0x78` | [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md) |
|
||||
| `shader_key_skip 0x7d0+0x18` | [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) |
|
||||
| `stdalloc_cap 0xa0000000` | [Absolum](../../dm/games/0100A83022A22000/README.md) |
|
||||
| `ue_texture_pool 1000` | [DRAGON QUEST VII Reimagined](../../dm/games/0100A9D01C446000/README.md) |
|
||||
| `vconv_range on` | [Hyrule Warriors: Age of Calamity](../../dm/games/01002B00111A2000/README.md) |
|
||||
@@ -744,7 +807,7 @@ Profile keys (`game.tsv`) whose value changes what the host does, set away from
|
||||
| `alloc_big_align on` | [13 Sentinels: Aegis Rim](../../dm/games/01003FC01670C000/README.md), [13 Sentinels: Aegis Rim (Asia)](../../dm/games/01008D7016438000/README.md), [13 Sentinels: Aegis Rim (Japan)](../../dm/games/010045C014650000/README.md), [Unicorn Overlord](../../dm/games/010069401ADB8000/README.md), [Unicorn Overlord (Asia)](../../dm/games/010054B01AD92000/README.md) |
|
||||
| `feedback_snap (shader keys)` | [Captain Toad: Treasure Tracker](../../dm/games/01009BF0072D4000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [Paper Mario: The Origami King](../../dm/games/0100A3900C3E2000/README.md), [Super Mario 3D World + Bowser's Fury](../../dm/games/010028600EBDA000/README.md), [Super Mario Bros. Wonder](../../dm/games/010015100B514000/README.md) |
|
||||
| `op_mode handheld` | [Balatro](../../dm/games/0100CD801CE5E000/README.md), [Big Brain Academy: Brain vs. Brain](../../dm/games/0100620012D6E000/README.md), [Captain Toad: Treasure Tracker](../../dm/games/01009BF0072D4000/README.md), [Rhythm Heaven Groove](../../dm/games/0100D9F01D474000/README.md), [Super Mario Galaxy](../../dm/games/010099C022B96000/README.md), [Super Mario Galaxy 2](../../dm/games/0100FD8022DAA000/README.md), [Taiko Risshiden V DX](../../dm/games/0100346017304000/README.md) |
|
||||
| `present_interval display` | [Luigi's Mansion 3](../../dm/games/0100DCA0064A6000/README.md), [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md), [Monster Train 2](../../dm/games/010051701FB46000/README.md), [Need For Speed™ Hot Pursuit Remastered](../../dm/games/010029B0118E8000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [Pokémon Brilliant Diamond](../../dm/games/0100000011D90000/README.md) |
|
||||
| `present_interval display` | [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md), [Luigi's Mansion 3](../../dm/games/0100DCA0064A6000/README.md), [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md), [Monster Train 2](../../dm/games/010051701FB46000/README.md), [Need For Speed™ Hot Pursuit Remastered](../../dm/games/010029B0118E8000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [Pokémon Brilliant Diamond](../../dm/games/0100000011D90000/README.md) |
|
||||
| `tex_dirty_upload on` | [FINAL FANTASY TACTICS - The Ivalice Chronicles](../../dm/games/010038B015560000/README.md), [Ghost Trick: Phantom Detective](../../dm/games/010029B018432000/README.md), [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [OCTOPATH TRAVELER](../../dm/games/010057D006492000/README.md), [The Great Ace Attorney Chronicles](../../dm/games/010036E00FB20000/README.md), [The Legend of Zelda: Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md), [Yoshi's Crafted World](../../dm/games/01006000040C2000/README.md) |
|
||||
| `tex_flush_upload on` | [FINAL FANTASY TACTICS - The Ivalice Chronicles](../../dm/games/010038B015560000/README.md), [Ghost Trick: Phantom Detective](../../dm/games/010029B018432000/README.md), [Hyrule Warriors: Age of Calamity](../../dm/games/01002B00111A2000/README.md), [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [OCTOPATH TRAVELER](../../dm/games/010057D006492000/README.md), [The Great Ace Attorney Chronicles](../../dm/games/010036E00FB20000/README.md), [The Legend of Zelda: Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md), [Yoshi's Crafted World](../../dm/games/01006000040C2000/README.md) |
|
||||
| `fps_target 60` | [ASTRAL CHAIN](../../dm/games/01007300020FA000/README.md), [DRAGON QUEST VII Reimagined](../../dm/games/0100A9D01C446000/README.md), [DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition](../../dm/games/01006C300E9F0000/README.md), [FINAL FANTASY RESONANCE](../../dm/games/0100606026F12000/README.md), [FINAL FANTASY RESONANCE (Asian release)](../../dm/games/0100B8A026F14000/README.md), [Hyrule Warriors: Age of Calamity](../../dm/games/01002B00111A2000/README.md), [Luigi's Mansion 3](../../dm/games/0100DCA0064A6000/README.md), [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md), [Need For Speed™ Hot Pursuit Remastered](../../dm/games/010029B0118E8000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [OCTOPATH TRAVELER 0](../../dm/games/01005270232F2000/README.md), [OCTOPATH TRAVELER II](../../dm/games/0100A3501946E000/README.md), [Paper Mario: The Thousand-Year Door](../../dm/games/0100ECD018EBE000/README.md), [Pokémon Brilliant Diamond](../../dm/games/0100000011D90000/README.md), [SHIN MEGAMI TENSEI V: Vengeance](../../dm/games/010069C01AB82000/README.md), [The Legend of Zelda: Breath of the Wild](../../dm/games/01007EF00011E000/README.md), [The Legend of Zelda: Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md) |
|
||||
| `fps_target 60` | [ASTRAL CHAIN](../../dm/games/01007300020FA000/README.md), [DRAGON QUEST VII Reimagined](../../dm/games/0100A9D01C446000/README.md), [DRAGON QUEST XI S: Echoes of an Elusive Age – Definitive Edition](../../dm/games/01006C300E9F0000/README.md), [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md), [FINAL FANTASY RESONANCE](../../dm/games/0100606026F12000/README.md), [FINAL FANTASY RESONANCE (Asian release)](../../dm/games/0100B8A026F14000/README.md), [Hyrule Warriors: Age of Calamity](../../dm/games/01002B00111A2000/README.md), [Luigi's Mansion 3](../../dm/games/0100DCA0064A6000/README.md), [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md), [Need For Speed™ Hot Pursuit Remastered](../../dm/games/010029B0118E8000/README.md), [NieR:Automata The End of YoRHa Edition (010056B015FE8000)](../../dm/games/010056B015FE8000/README.md), [NieR:Automata The End of YoRHa Edition (0100B8E016F76000)](../../dm/games/0100B8E016F76000/README.md), [OCTOPATH TRAVELER 0](../../dm/games/01005270232F2000/README.md), [OCTOPATH TRAVELER II](../../dm/games/0100A3501946E000/README.md), [Paper Mario: The Thousand-Year Door](../../dm/games/0100ECD018EBE000/README.md), [Pokémon Brilliant Diamond](../../dm/games/0100000011D90000/README.md), [SHIN MEGAMI TENSEI V: Vengeance](../../dm/games/010069C01AB82000/README.md), [The Legend of Zelda: Breath of the Wild](../../dm/games/01007EF00011E000/README.md), [The Legend of Zelda: Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md) |
|
||||
@@ -46,6 +46,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- `B()` range assertion in `patch_nso.py` (`site_plain`), only for one module. → [Patch area before the module base for a large bss](../reference/rewriter.md#patch-area-before-the-module-base-for-a-large-bss)
|
||||
- `frame step state page` assertion when a `FRAME_STEP` profile is added to a module with a large BSS. → [Frame-step state with a front patch area](../reference/rewriter.md#frame-step-state-with-a-front-patch-area)
|
||||
- `B()` range assertion, then `patch area of … bytes does not fit in the … before the base`. → [Patch area right before the base for a long text](../reference/rewriter.md#patch-area-right-before-the-base-for-a-long-text)
|
||||
- `main: patch area of 0x6b9d38 bytes does not fit in -0x39c0000 before the base; rewriting again with 0x6c0000`, then a `B()` range assertion in `site_window`: the gap before the base came out negative. → [Two patch areas for a text longer than a branch reaches](../reference/rewriter.md#two-patch-areas-for-a-text-longer-than-a-branch-reaches)
|
||||
- `observation gate neither at a function entry nor after a bl`; `observation gate neither at a function entry, after a bl nor before a call` on an epilogue. → [Observation gates where x9–x17 are dead](../reference/rewriter.md#observation-gates-where-x9x17-are-dead)
|
||||
- `jump table <addr>` assertion on an ordinary byte table near the start of the text (`adr x18; ldrb w0,[x17,x16]; add x18,x18,x0,lsl #2; br x18`). → [Code before the first unwind entry is one function](../reference/rewriter.md#code-before-the-first-unwind-entry-is-one-function)
|
||||
- the rewrite never finishes, the Mac swaps, the rewriter's footprint reaches 100 GB. → [Long functions analysed in pieces](../reference/rewriter.md#long-functions-analysed-in-pieces)
|
||||
@@ -177,6 +178,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- the hunter's name box stays empty, then stays open with the name in it (Monster Hunter Rise, character creation). → [Inline keyboard text callbacks and `Calc` states](../reference/services.md#inline-keyboard-text-callbacks-and-calc-states)
|
||||
- `CRASH sig=10` at a heap address, called from `main+0x6bca160` right after the name was entered (Monster Hunter Rise); crash in `lmem::AllocateFromExpHeap` under `ngc::ProfanityFilter::MaskProfanityWordsInText` right after the character name is entered (DARK SOULS: REMASTERED); filter methods among the undefined imports with no hook, found from the import list before they were met (The Great Ace Attorney Chronicles). → [`nn::ngc::ProfanityFilter` vtable and by-name overloads](../reference/services.md#nnngcprofanityfilter-vtable-and-by-name-overloads)
|
||||
- SIGSEGV in `vi::CreateLayer(Layer**, Display*, int, int)` (`sdk+0x3f9bc4`, from SDL3's Switch video driver at `main+0x239304`). → [`vi::CreateLayer` with the layer's size](../reference/services.md#vicreatelayer-with-the-layers-size)
|
||||
- SIGSEGV at `sdk+0x44ea94` reading address 0, in `vi::CreateLayer`, right after `am::GetSelfController()`; the caller is the game's window setup (`main+0x978cb6c`). → [`vi::CreateLayer` with `LayerCreationSettings` (SDK 22)](../reference/services.md#vicreatelayer-with-layercreationsettings-sdk-22)
|
||||
- SIGSEGV in `vi::SetLayerCrop`. → [vi layer and display calls without vi service objects](../reference/services.md#vi-layer-and-display-calls-without-vi-service-objects)
|
||||
- SIGSEGV in `android::Surface::getQueuedFrameNumber` under `nn::vi::GetLatestFrameNumber`. → [Layer frame numbers](../reference/services.md#layer-frame-numbers)
|
||||
- SIGSEGV in `vi::GetDefaultDisplayPanelIdentifier` (`main+0xa9a4`, before the window). → [Default display panel identifier](../reference/services.md#default-display-panel-identifier)
|
||||
@@ -293,6 +295,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- menus reach 60 fps with `present_interval display`, but entering gameplay returns to 30 fps despite spare GPU time. → [Unity's integer target frame rate](../reference/frame-rate.md#unitys-integer-target-frame-rate)
|
||||
- the game presents at interval 1, yet every frame takes exactly 33.3 ms of "frame work"; after only the limiter was raised, everything ran twice as fast on the iPhone. → [A render-thread limiter with a constant and a fixed time step](../reference/frame-rate.md#a-render-thread-limiter-with-a-constant-and-a-fixed-time-step)
|
||||
- 55 fps with every frame 18.2 ms, the main thread asleep most of the time; every 11th frame stays on screen two vsyncs. → [A frame-end wait polled in 2 ms sleeps](../reference/frame-rate.md#a-frame-end-wait-polled-in-2-ms-sleeps)
|
||||
- a Frostbite game holds 30 fps with spare CPU and GPU time. Raising only the frame limit and the present interval gives 60 frames a second with the game at half speed (the match clock at 3.6 game seconds a second instead of 7.5). → [Frostbite's simulation rate, found by name](../reference/frame-rate.md#frostbites-simulation-rate-found-by-name)
|
||||
- the app is active and the game keeps running, but the picture freezes while display-link callbacks stop; the log repeatedly drops queued frames. → [Present thread rescues a silent display link](../reference/frame-rate.md#present-thread-rescues-a-silent-display-link)
|
||||
- with the display link driving presents, a presented frame comes out black when three presents are on the GPU at once, or two after a dropped frame; on an M6 the same reuse also logs `[RED] display command buffer error` with `kIOGPUCommandBufferCallbackErrorPageFault`. → [A present command allocator is reused only after its own present completes](../reference/frame-rate.md#a-present-command-allocator-is-reused-only-after-its-own-present-completes)
|
||||
- "sometimes the speed increases when jumping" (Mario 1.2.1 on the iPhone): in `display` mode interval-2 frames were shown for 16.7 ms and the game visibly jumped ahead. "When pressing B, Link's move pace is speeding up" (Breath of the Wild on the iPhone); `old frames dropped by merging`. → [Frames of a dynamic present interval held on screen and at the acquire](../reference/frame-rate.md#frames-of-a-dynamic-present-interval-held-on-screen-and-at-the-acquire)
|
||||
@@ -364,6 +367,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- about one run in four stalled early (around the opening movie or the title), with no log output, not even the time-limit report. → [Dirty-page tracker race and early stalls](../reference/nvn-objects.md#dirty-page-tracker-race-and-early-stalls)
|
||||
- a CPU-written texture stays stale after later writes; letters can be missing from a glyph cache. → [Dirty-page writes missed during upload](../reference/nvn-objects.md#dirty-page-writes-missed-during-upload)
|
||||
- `[RED] NVN unimplemented function called: nvnSamplerBuilderSetBorderColorui` during renderer initialization. → [Integer sampler border colours](../reference/nvn-objects.md#integer-sampler-border-colours)
|
||||
- `[RED] sampler ID 4096 not registered` (or another ID past the sampler pool), once, from the first frames on. → [Bound handles are the driver's 32-bit words](../reference/nvn-objects.md#bound-handles-are-the-drivers-32-bit-words)
|
||||
- device / subsystem setup returns quietly and the next stage never starts. → [Version and capability checks that fail quietly](../reference/nvn-objects.md#version-and-capability-checks-that-fail-quietly)
|
||||
- a null-pointer crash early in `nnMain`, right after NVN setup should have happened (Super Mario 3D World + Bowser's Fury, `main+0x759e08`: the device singleton `main+0x1a28ea0` is still null). → [The device's API version](../reference/nvn-objects.md#the-devices-api-version)
|
||||
- null read at `main+0xb8462c` right after the first two textures, called from `main+0x670eb0` (Bayonetta 3), or cleanup crashes at `main+0x9c0d1c` after shader initialization fails (ASTRAL CHAIN). → [Newest GPU code version reported by the driver](../reference/nvn-objects.md#newest-gpu-code-version-reported-by-the-driver)
|
||||
@@ -371,6 +375,8 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- SIGBUS in `AGCDeserializedReply`, address in the guest stack region. → [NVN entry points on the big host stack](../reference/nvn-objects.md#nvn-entry-points-on-the-big-host-stack)
|
||||
- red `NVN unimplemented function called` lines for `nvnColorStateGetBlendEnable`, `nvnBlendStateGetBlendFunc`, `nvnPolygonStateGetCullFace`, `nvnDepthStencilStateGetDepthTestEnable`, `nvnBufferBuilderGetSize`, `nvnTextureBuilderGetWidth`, …. → [State read back through NVN getters](../reference/nvn-objects.md#state-read-back-through-nvn-getters)
|
||||
- an abort in device setup when `nvnTexturePoolGetSize` / `nvnSamplerPoolGetSize` returned 0. → [Pool size getters, texture address and command memory size](../reference/nvn-objects.md#pool-size-getters-texture-address-and-command-memory-size)
|
||||
- `[RED] NVN unimplemented function called: nvnTextureBuilderGetMemoryOffset`, then `nvnTextureBuilderGetRawStorageClass`. → [Builder storage getters](../reference/nvn-objects.md#builder-storage-getters)
|
||||
- `[nvn-mtl] FATAL buffer copy address is in no memory pool src=0x70d08a8b00 dst=0 n=0x29a00` as a match loads: a recorded `CopyBufferToBuffer` whose destination is 0. → [`Map` of a pool without CPU access returns NULL](../reference/nvn-objects.md#map-of-a-pool-without-cpu-access-returns-null)
|
||||
- red stub lines for NVN calls. → [NVN calls that were red stubs](../reference/nvn-objects.md#nvn-calls-that-were-red-stubs)
|
||||
- `nvnWindowGetPresentInterval`, `nvnCommandBufferSetCopyImageStride` missing. → [SDK 8 window and copy-stride entry points](../reference/nvn-objects.md#sdk-8-window-and-copy-stride-entry-points)
|
||||
- `[RED] texture bound to an image slot lacks the shader-write usage`, and compute image writes go to a dummy texture. → [Image bindings supply shader-write intent](../reference/nvn-objects.md#image-bindings-supply-shader-write-intent)
|
||||
@@ -458,6 +464,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- a scene drawn with a geometry shader per mesh runs at 5 to 15 fps on the Mac, with the submitting thread or the GPU taking most of the frame. → [Geometry-shader draws encoded a run at a time](../reference/rendering.md#geometry-shader-draws-encoded-a-run-at-a-time)
|
||||
- `SIGSEGV` in `-[AGXG18GFamilyComputeContext_mtlnext performEndEncoding]` (from `rp_begin_ex_`, or in its `dealloc` on the encoding thread); Metal validation (`MTL_DEBUG_LAYER=1 MTL_DEBUG_LAYER_ERROR_MODE=nslog`) names it: "Command buffer already has an open command encoder". → [Helper encoders end the open copy encoder first](../reference/rendering.md#helper-encoders-end-the-open-copy-encoder-first)
|
||||
- the whole picture upside down (Absolum's title logo and "Press Any Button" mirrored top to bottom); a red-reporting stub for `nvnCommandBufferSetViewportSwizzles`. → [Viewport swizzles applied as a flipped viewport](../reference/rendering.md#viewport-swizzles-applied-as-a-flipped-viewport)
|
||||
- `[RED] texture→texture copy case not implemented: 1920x1080x1→1920x1080x1 flags 0 format 260→252 3D 0→0`. → [Depth plane copies between depth formats](../reference/rendering.md#depth-plane-copies-between-depth-formats)
|
||||
- tall blue / textured panels that flickered frame to frame: the fountain's vertex shader pushed the water surface to the top of the screen. → [Metal 4 does not order operations inside one encoder](../reference/rendering.md#metal-4-does-not-order-operations-inside-one-encoder)
|
||||
- a buffer copy, inline update or fill completes, but a following copy through another Metal buffer over the same allocation reads stale bytes. → [Buffer copies through aliased Metal addresses](../reference/rendering.md#buffer-copies-through-aliased-metal-addresses)
|
||||
- many render passes with one draw each and high submit time: Metroid Dread's cutscene frames had about 180 passes with one draw each (about 5 ms of submit time per frame on the Mac). → [Inline uniform updates inside a render pass](../reference/rendering.md#inline-uniform-updates-inside-a-render-pass)
|
||||
@@ -508,6 +515,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- an NVN game's split finds a few dozen shaders (`main`'s and a loose file's) and the screen stays black but for the loading indicator, with `[RED] shader … is not in the shader map` and `program has no vertex shader`; the RomFS holds `.BNDL` files that start with `bnd2`. → [GLSLC outputs in Criterion's Bundle 2 resources](../reference/shaders.md#glslc-outputs-in-criterions-bundle-2-resources)
|
||||
- 24 shaders before the control-length fix, 1,355 after. → [SPKG packages in KTGL LINKDATA](../reference/shaders.md#spkg-packages-in-ktgl-linkdata)
|
||||
- the split finds no shaders in a RomFS made of `.sdfdata`, `.sdftoc` and `.sdfver` files. → [Shader records in Snowdrop SDF data slices](../reference/shaders.md#shader-records-in-snowdrop-sdf-data-slices)
|
||||
- the survey finds no shader container in a RomFS of `.toc` and `.cas` files (`Data/NX`, `Patch/NX`, `Data/layout.toc`, `Data/initfs_NX`); the split reads every file loosely and finds nothing. → [CompiledBytecode resources in Frostbite superbundles](../reference/shaders.md#compiledbytecode-resources-in-frostbite-superbundles)
|
||||
- `[RED] ... PKZ version 0x10000: only 0x20000 is known` stops the shader split. → [PKZ version 1 archives](../reference/shaders.md#pkz-version-1-archives)
|
||||
- the split finds zero shaders and refuses the shader build, although the CPK's DAT archives contain the objects passed to NVN at boot. → [Size-delimited PlatinumGames shader objects](../reference/shaders.md#size-delimited-platinumgames-shader-objects)
|
||||
- archive or loose asset shaders are absent from the map; only boot shaders in `main` are found, sometimes reported as raw controls with no identified code area. → [Monolith ARH1, XBC1 and HCPS/SLCT shader containers](../reference/shaders.md#monolith-arh1-xbc1-and-hcpsslct-shader-containers)
|
||||
@@ -581,6 +589,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- `[RED] shader … reflection conversion failed: a texture handle the translator could not trace to one slot (profile key tex_dyn_slots off)`, then `failed to load`, and the draws are skipped: in Mario Party Superstars every character and NPC in a lit scene is a flat grey silhouette (the depth pre-pass draws, the colour pass does not), and the opening scene's pipe is grey. → [Texture handles from game memory index the pools](../reference/shaders.md#texture-handles-from-game-memory-index-the-pools)
|
||||
- the host stops at the shader's first load: `unexpected argument buffer layout: encodedLength=640 maxAid=48`. → [An array of handles in a uniform buffer](../reference/shaders.md#an-array-of-handles-in-a-uniform-buffer)
|
||||
- `shaders with a binding whose slot was not decoded 588`; shadow cascades read through `array<texture2d_array<float>, 32> fp_t2das_cb2_0`. → [An array of handles from the driver table c2](../reference/shaders.md#an-array-of-handles-from-the-driver-table-c2)
|
||||
- `[RED] shader … reflection conversion failed: B binding fp_t2d_cb196610_10570000 has no resolved slot number`, then, with that resolved, `… reads driver-bank locations at run time that the replay layer cannot fill: c2 dynamic index`; the shader does not load and its draws are skipped. → [Arrays of c2 handles cover the whole table, with a separate sampler word](../reference/shaders.md#arrays-of-c2-handles-cover-the-whole-table-with-a-separate-sampler-word)
|
||||
- characters and props glowing white, about 10⁴ too bright, in DRAGON QUEST VII Reimagined's opening cutscene only, while walls and gameplay look right. → [A texture slot that shares its c2 word with an image slot](../reference/shaders.md#a-texture-slot-that-shares-its-c2-word-with-an-image-slot)
|
||||
- `[RED] shader … reflection conversion failed: 66 bindings, over the limit 64`, then `failed to load`, and the draws with it are dropped (a black map). → [More than 64 bindings in one shader](../reference/shaders.md#more-than-64-bindings-in-one-shader)
|
||||
- the host stops at a shader's first load: `FATAL shader … has an unexpected argument buffer layout: encodedLength=88 maxAid=8` (crash in `c1_store` / `pull_load`), with a storage buffer or image missing from its reflection json. → [Argument buffer members with attributes after their id](../reference/shaders.md#argument-buffer-members-with-attributes-after-their-id)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 173 KiB |
@@ -107,3 +107,4 @@ steamworld-dig.jpg SteamWorld Dig 01009320084A4000
|
||||
team-sonic-racing.jpg Team Sonic Racing 010092B0091D0000
|
||||
well-dweller.jpg Well Dweller 0100217023F6C000
|
||||
need-for-speed-hot-pursuit-remastered.jpg Need for Speed: Hot Pursuit Remastered 010029B0118E8000
|
||||
ea-sports-fc-27.jpg EA SPORTS FC 27 60 fps with 1.8d.310c 0100C49025D3E000
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 92.
|
@@ -102,6 +102,14 @@ Frame pacing: the host's frame step, engine frame limiters, present intervals an
|
||||
- **Check:** before cutting a game's frame limiter, find what sets its target and whether anything else holds those frames. A limiter that also enforces a slower mode (here N = 2) has to keep it.
|
||||
- **Found on:** [Taiko Risshiden V DX](../../dm/games/0100346017304000/README.md), in its menus and town; its movies, paced by their own player, ran at 60.
|
||||
|
||||
### Frostbite's simulation rate, found by name
|
||||
|
||||
- **Symptom:** a Frostbite game holds 30 fps with spare CPU and GPU time. Raising only the frame limit and the present interval gives 60 frames a second with the game at half speed (the match clock at 3.6 game seconds a second instead of 7.5).
|
||||
- **Cause:** Frostbite's `SimulationTimeSettings` caps the simulation's ticks a second: `ForceSimRate` (int32) and `MaxSimFps` (float), both 30 in EA SPORTS FC 27. The game's other 30s (its own frame regulator, the present interval 2 of `BaseDisplaySettings.PresentInterval`) only pace the frames.
|
||||
- **Fix:** `hle_fpslock.c` finds the settings by name, so no address is tied to a build. Frostbite reflects its settings classes: a class record (its name, then at +0x40 its field list) and a 0x20-byte record per field (name, hash, offset at +0x10, type). A static constructor stores the record's address into the class's type info (`adrp` / `add` of each, then `str`), and code that reads the settings asks the settings registry for the instance with the type info in `x1` and a cache word in `x2`, which keeps the instance's address; the instance holds its type info at +8, which checks the word. With `fps_target` 30 or 60 the host writes both fields to the target each frame they differ. A game's own frame limit still needs its row (EA SPORTS FC 27's frame regulator, build-gated) and `present_interval display`. Without the row, as on a build not yet registered, the simulation at 60 with the regulator at 30 runs at 30 fps at the right speed (match clock as at 30).
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md): 60 fps in a match with the match clock at the 30 fps rate. Its `main` has unwind entries for 405 functions only, so the rewriter's function matching cannot carry a cut of the regulator across updates either.
|
||||
- **Check:** `t_fpslock` builds a Frostbite module in miniature (strings, class record, field list, registration and lookup code, instance) and checks the writes, a repeated game write and a cache word whose instance has another type info.
|
||||
|
||||
## Present interval and display rate
|
||||
|
||||
### Present thread rescues a silent display link
|
||||
|
||||
@@ -98,7 +98,7 @@ The guest address space, heaps, pools, virtual address memory and the allocators
|
||||
- **Symptom:** the first `AllocateAddressRegion` fails with 0x1803; `StandardAllocator::Initialize` aborts in `nninitStartup` (an `nn::diag` abort; the NSP script's heap check reports "the host stopped before nnMain"); the alias region fills in minutes; regions a game reserves later fail ([Size-aligned regions exhaust the alias address space](#size-aligned-regions-exhaust-the-alias-address-space), [The movie player's own StandardAllocator](#the-movie-players-own-standardallocator)).
|
||||
- **Cause:** SDK 16's AddressRegionManager takes 0x3fe00000 at the start of the alias region as a node area, so the alias region must be larger than 1 GB; SDK 8 has the same 1 GB node area as the newer SDKs, and SDK 7 / 8 builds load it in another form (below). On hardware the alias region is 64 GB. On Ace Attorney Investigations Collection's SDK 17 build, `CentralHeap::Init(nullptr, pool − used)` got no 1 GB-aligned region for 3.14 GB after the 1 GB node area.
|
||||
- **Fix:** shrink the node area with a rewriter cut for that SDK build (`dm/tools/sdk_patches.py`): the two `mov w8/w9, #0x3fe00000` in the AddressRegionManager constructor → 62 MB.
|
||||
- **SDK-wide:** the same cut is also an SDK-wide function patch (`sdk_patches.py` `MATCH_CUTS`), which every game's `sdk` gets when its build has no `CUTS` and the game's profile was not brought up on it: a new game, or a new version of one, needs no cut of its own on a reviewed implementation. Five implementations cover the 18 cut builds on the game drives (SDK 7.3.2 / 8.2.1, 10.4.x, 11.4.3 to 13.3.5, 15.3.2 to 18.3.5, 19.3.x / 20.5.x); on those 18 each rule gives exactly the registered cuts, and on the 36 `sdk` builds there it matched once or not at all. The SDKs of Fire Emblem: Three Houses, Bayonetta, Donkey Kong Country: Tropical Freeze, Xenoblade Chronicles 2 and Yoshi's Crafted World have other implementations, not reviewed. A build with no reviewed implementation keeps the 1 GB node area; the NSP script lists it (not red: a game without virtual address memory never reaches it) ([Function-matched cuts for unregistered builds](rewriter.md#function-matched-cuts-for-unregistered-builds)).
|
||||
- **SDK-wide:** the same cut is also an SDK-wide function patch (`sdk_patches.py` `MATCH_CUTS`), which every game's `sdk` gets when its build has no `CUTS` and the game's profile was not brought up on it: a new game, or a new version of one, needs no cut of its own on a reviewed implementation. Six implementations cover the 19 cut builds on the game drives (SDK 7.3.2 / 8.2.1, 10.4.x, 11.4.3 to 13.3.5, 15.3.2 to 18.3.5, 19.3.x / 20.5.x, 22.2.0); on those 18 each rule gives exactly the registered cuts, and on the 36 `sdk` builds there it matched once or not at all. The SDKs of Fire Emblem: Three Houses, Bayonetta, Donkey Kong Country: Tropical Freeze, Xenoblade Chronicles 2 and Yoshi's Crafted World have other implementations, not reviewed. A build with no reviewed implementation keeps the 1 GB node area; the NSP script lists it (not red: a game without virtual address memory never reaches it) ([Function-matched cuts for unregistered builds](rewriter.md#function-matched-cuts-for-unregistered-builds)).
|
||||
- **Finding the constructor on a new `sdk` build:** search its text for the two `mov w8 / w9, #0x3fe00000` words (`08fca752`, `09fca752`); `sdis.py --fn` names the function `AddressRegionManagerC2Emm` from its dynamic symbols. SDK 7 / 8 builds load the node area with `orr w8 / w9, wzr, #0x3fe00000` (`e8230b32`, `e9230b32`), so the `mov` search finds nothing there.
|
||||
- **Found on** (the builds that take the cut):
|
||||
- [Mario + Rabbids Kingdom Battle](../../dm/games/010067300059A000/README.md) (SDK 4.4.0): the older `VammManager` constructor reserves a full 1 GB rather than 0x3fe00000; its limit and occupied length at `sdk+0x93dfc` / `+0x93e8c` are reduced together to 64 MB. Nodes are mapped in 4 KB increments as needed.
|
||||
@@ -122,6 +122,7 @@ The guest address space, heaps, pools, virtual address memory and the allocators
|
||||
- [Hollow Knight: Silksong](../../dm/games/010013C00E930000/README.md) (SDK 20.5.8): `sdk+0x145bfc` / `+0x145c68` ([Unity 6 takes its memory with no StandardAllocator and no heap](#unity-6-takes-its-memory-with-no-standardallocator-and-no-heap)).
|
||||
- [The Legend of Zelda: Tears of the Kingdom](../../dm/games/0100F2C0115B6000/README.md) (SDK 20.5.22, the same `sdk` build as [Breath of the Wild](../../dm/games/01007EF00011E000/README.md) 1.9.0): constructor `sdk+0x145cfc`, `+0x145d0c` / `+0x145d78`; no alignment cut (`VammManager::AllocateAddressRegion`, `sdk+0x145df0`, aligns regions to 64 KB or 2 MB only). Its resource heaps live in address regions after the node area: at the first descent from the Great Sky Island the alias region's high-water mark was +2.25 GB of its 2.375 GB with 1.00 GB mapped, and the game took a memory shortage (its frame check at `main+0x1fd32ec` logs `MSF` / `R` / `Rf` and plays the memory-shortage Blood Moon, which puts Link back at the start; GitHub issue #70, 7 of 8 Mac runs from the issue's save). With an 8 GB alias region the mark went on to +2.50 GB; with the cut it stays at +1.75 GB, and neither showed the shortage.
|
||||
- [BALL x PIT](../../dm/games/010086A022444000/README.md) (SDK 20.5.19): `sdk+0x145d0c` / `+0x145d78`, the SDK 20.5.22 build's offsets.
|
||||
- [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (Frostbite, SDK 22.2.0, `sdk` `fed212d6…`, also Well Dweller's): constructor `sdk+0x14def0`, `+0x14df00` / `+0x14df6c`. SDK 22's constructor is SDK 19 / 20's instruction for instruction, with 32 more bytes on its cold path (an abort code per failing result), so it is the SDK-wide rule's sixth implementation; region placement aligns to 64 KB or 2 MB only (`sdk+0x14e060`). Frostbite's `VirtualAlloc` (`main+0x17f9884`) reserves 264 regions, 2.8 GB of address space, in its first minute while mapping 0.7 GB; behind the 1 GB node area they ran past the alias region (`Couldn't reserve memory of size: 536870912`, a deliberate null store at `main+0x17f98c4`).
|
||||
- [Cult of the Lamb](../../dm/games/01002E7016C46000/README.md) (Unity 2022.3.62f3, SDK 19.3.14, `sdk` `871fb219…`): `sdk+0x1423fc` / `+0x142468`, Octopath Traveler 0's offsets. The SDK-wide rule cut it while the profile was provisional and skipped it once the profile named the build (the rewrite had no cut), so the cuts are registered for this build; region placement aligns to 64 KB or 2 MB only (`sdk+0x142544`). It also needs a 1 GB pool, as Ace Attorney Investigations Collection and Monster Train 2.
|
||||
- [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md) (SDK 14.3.0, `sdk` `2aef2cff…`): constructor `sdk+0x12d8a0`, `+0x12d8b0` / `+0x12d94c`, registered as Cult of the Lamb's was; regions are not aligned to 1 GB on this build, so no alignment cut.
|
||||
|
||||
|
||||
@@ -424,6 +424,13 @@ Games read this count as a position in their own command memory and size their h
|
||||
- **Found on:** [FINAL FANTASY X/X-2 HD Remaster](../../dm/games/0100BC300CB48000/README.md), launcher and both games.
|
||||
- **Check:** `t_nvn` invokes both setters through the real entry-point lookup and checks initialized sampler state.
|
||||
|
||||
### Bound handles are the driver's 32-bit words
|
||||
|
||||
- **Symptom:** `[RED] sampler ID 4096 not registered` (or another ID past the sampler pool), once, from the first frames on.
|
||||
- **Cause:** NVN's texture, separate texture and sampler handles are 64-bit, but the driver writes each bound one into the c2 handle table as a 32-bit word (texture ID in bits 0-19, sampler ID in bits 20-31), so the GPU never sees the upper half. The host kept the whole 64 bits of the handles of `nvnCommandBufferBindTextures`, `BindSeparateTextures`, `BindSeparateSamplers` and `BindImages`, and took the sampler ID as the handle shifted right by 20. EA SPORTS FC 27 binds separate textures with bit 32 set (`0x1000001d1`, texture 0x1d1): a shader that takes its sampler from that combined word got ID 4096, where the GPU reads sampler 0. The single `nvnCommandBufferBindTexture` record already read its handle as 32 bits.
|
||||
- **Fix:** `bind_handles` (`hle_nvn.c`) keeps the low 32 bits of each handle before it moves the IDs to the part of the host's table of the pool the command buffer bound (which may then pass 12 bits).
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md), at the title and in the menus.
|
||||
|
||||
### Version and capability checks that fail quietly
|
||||
|
||||
- **Symptom:** device / subsystem setup returns quietly and the next stage never starts.
|
||||
@@ -478,6 +485,20 @@ Games read this count as a position in their own command memory and size their h
|
||||
- **Fix:** implemented: `nvnTexturePoolGetSize` / `nvnSamplerPoolGetSize` and their memory pool / offset getters; `nvnCommandBufferFenceSync`, which Unreal's RHI records in its command buffers ([Fence syncs recorded in command buffers](#fence-syncs-recorded-in-command-buffers)); `nvnTextureGetTextureAddress` (pool address + offset, as `nvnMemoryPoolGetBufferAddress`); `nvnCommandBufferGetCommandMemorySize` (used + free, as in NVN; `GetCommandMemoryFree` is what is left in the current segment).
|
||||
- **Found on:** [Octopath Traveler 0](../../dm/games/01005270232F2000/README.md) (the pool getters and `nvnCommandBufferFenceSync`, new with Unreal); [DRAGON QUEST XI S](../../dm/games/01006C300E9F0000/README.md) (Unreal Engine 4.18: `nvnTextureGetTextureAddress`, `nvnCommandBufferGetCommandMemorySize`).
|
||||
|
||||
### Builder storage getters
|
||||
|
||||
- **Symptom:** `[RED] NVN unimplemented function called: nvnTextureBuilderGetMemoryOffset`, then `nvnTextureBuilderGetRawStorageClass`.
|
||||
- **Cause:** the renderer reads a texture builder's storage back before it initializes the texture; the host had the texture's getters (`nvnTextureGetMemoryPool` / `Offset` / `RawStorageClass`) but not the builders'.
|
||||
- **Fix:** the texture, buffer and event builders return the pool and offset `SetStorage` stored (the pool getters return its address, as `nvnTextureGetMemoryPool` does; the header the prototypes come from declares the builders' by value, so they are `NVN_NOPROTO`), and the texture builder's raw storage class is the texture's (1): it only names the page kind a virtual pool maps (`NVNmappingRequest.storageClass`), which the host's virtual pools do not distinguish.
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (SDK 22, Frostbite's NVN renderer NRO).
|
||||
|
||||
### `Map` of a pool without CPU access returns NULL
|
||||
|
||||
- **Symptom:** `[nvn-mtl] FATAL buffer copy address is in no memory pool src=0x70d08a8b00 dst=0 n=0x29a00` as a match loads: a recorded `CopyBufferToBuffer` whose destination is 0.
|
||||
- **Cause:** NVN maps a buffer or pool created with `NVN_MEMORY_POOL_FLAGS_CPU_NO_ACCESS` to NULL, and the game depends on it: Frostbite's renderer (`OpcodeCopySubresource` in `Engine.Render.Core2.PlatformNvn.nro`) takes a buffer's GPU address as `nvnBufferGetAddress + (its data pointer − nvnBufferMap)`, with a null data pointer for a GPU-only buffer. The host's storage is CPU memory, and its `Map` returned the same pointer `GetAddress` does, so the sum came to 0 (traced to a `BufferMap` of a pool with flags `0x21`, CPU_NO_ACCESS | GPU_CACHED, right before the copy).
|
||||
- **Fix:** `nvnBufferMap` and `nvnMemoryPoolMap` return NULL when the pool has no CPU access, as in NVN (`hle_nvn.c`). The host's own accesses to the storage go through the pool, not through `Map`.
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (SDK 22): the first match load.
|
||||
|
||||
### NVN calls that were red stubs
|
||||
|
||||
- **Symptom:** red stub lines for NVN calls.
|
||||
|
||||
@@ -700,6 +700,13 @@ The replay on Metal (`dm/gfx/nvn/nvn_mtl.m`) and the Vulkan and OpenGL layers. E
|
||||
|
||||
## Uniforms, copies and ordering
|
||||
|
||||
### Depth plane copies between depth formats
|
||||
|
||||
- **Symptom:** `[RED] texture→texture copy case not implemented: 1920x1080x1→1920x1080x1 flags 0 format 260→252 3D 0→0`.
|
||||
- **Cause:** the game copies its depth-stencil target (Metal `Depth32Float_Stencil8`, 260) into a depth-only texture (`Depth32Float`, 252) of the same size. A Metal blit copies only between equal formats, and the draw path does not take depth formats.
|
||||
- **Fix:** such a copy, either way between the two formats, goes through a staging buffer kept from copy to copy: the 32-bit float depth is copied out of the source with `MTLBlitOptionDepthFromDepthStencil` and into the destination's depth plane the same way (`nvn_mtl.m`, the texture copy).
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (Frostbite): from the title on.
|
||||
|
||||
### Inline uniform updates as ordered GPU copies
|
||||
|
||||
- **Cause:** reading the uniform buffer from the CPU at encode time gives the frame's *last* value, not the draw's.
|
||||
|
||||
@@ -206,6 +206,13 @@ To enroll a cut for any game's own module:
|
||||
- **Fix:** when the text ends within 32 MB of the reach (`BIG_TEXT`), the patch area goes right before the base: the stubs follow the sites in address order, so each site's stub is about as far from it as the text is long. The first pass tries the gap that keeps every site in reach (2.6 MB here); when the patch area is larger (3.6 MB, 34,322 sites), the rewriter runs itself again with exactly that size (`DM_PATCH_FRONT`, set only by the rerun) and `B()` checks every branch.
|
||||
- **Found on:** [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md) `main`: 125.3 MB of text.
|
||||
|
||||
### Two patch areas for a text longer than a branch reaches
|
||||
|
||||
- **Symptom:** `main: patch area of 0x6b9d38 bytes does not fit in -0x39c0000 before the base; rewriting again with 0x6c0000`, then a `B()` range assertion in `site_window`: the gap before the base came out negative.
|
||||
- **Cause:** a text longer than the ±128 MB a `b` reaches has no place for one patch area from which every site is in reach: before the base the last sites are too far, after the image the first ones.
|
||||
- **Fix:** such a module (`TWO` in `patch_nso.py`: the text alone ends past the reach) gets two patch areas. The front one, 16 MB before the base, takes the sites below `SPLIT` (128 MB less the front area and 1 MB of margin for a stub's exits past its site); the back one, right after bss, the key page and the frame step page (`BACK_OFF`, 64 KB aligned), takes the others. A site's stubs and their branches back stay in its own area (`use_area`); when the front sites need more room, the rewriter runs again with exactly that size, and `B()` checks every branch. The file is the image, the front area padded to 16 KB, then the back area; `fixups.tsv` adds `BACK_OFF` and `BACK_LEN`, and `IMAGE_SIZE` covers the back area. The Mac loader copies it to `BACK_OFF` and seals it read-only and executable, the iOS embedding gives it a fourth section (`gen_embed.py`: `__TEXT,__dm<name>x2`) that the loader remaps there, and `svcQueryMemory` reports it as CodeData+RX like a patch area after the image (data and bss end at it). A module that does not need it is rewritten byte for byte as before.
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) `main` (1.8d.310c): 185.6 MB of text, 177,058 sites; 3.9 MB of stubs in front and 3.2 MB at `BACK_OFF` `0xdec0000`.
|
||||
|
||||
## Cuts and observation gates
|
||||
|
||||
### Observation gates where x9–x17 are dead
|
||||
|
||||
@@ -414,6 +414,13 @@ Most service calls can be found before they crash, before the first boot or the
|
||||
- **Fix:** it returns the static layer (`hle_vi.c`).
|
||||
- **Found on:** [Absolum](../../dm/games/0100A83022A22000/README.md) (SDK 18.3.2, FNA on .NET NativeAOT with SDL3; one boot each).
|
||||
|
||||
### `vi::CreateLayer` with `LayerCreationSettings` (SDK 22)
|
||||
|
||||
- **Symptom:** SIGSEGV at `sdk+0x44ea94` reading address 0, in `vi::CreateLayer`, right after `am::GetSelfController()`; the caller is the game's window setup (`main+0x978cb6c`).
|
||||
- **Cause:** SDK 22 adds `CreateLayer(Layer**, Display*, const LayerCreationSettings*)`; the game builds the settings with the SDK's `LayerCreationSettings(int w, int h)` (`{w, h, 2}`, `sdk+0x4526a0`), and the SDK's `CreateLayer` asks the applet's self controller, which the host never made.
|
||||
- **Fix:** the host takes it over like the sized overload (`hle_vi.c`): the static layer, and the size recorded for an EGL surface.
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (SDK 22.2.0): 1920x1080.
|
||||
|
||||
### vi layer and display calls without vi service objects
|
||||
|
||||
- **Symptom:** SIGSEGV in `vi::SetLayerCrop`.
|
||||
|
||||
@@ -167,6 +167,13 @@ Finding, keying and translating shaders (`dm/gfx/tools/shader_split.py`, `dmsh_b
|
||||
- **DLC:** additional shader records ship in the DLC's data slices. The NSP script includes each extracted DLC RomFS as an extra shader root, without an ExeFS module, and fingerprints its index and extraction timestamps for split reuse. Vulkan and OpenGL builds include the DLC roots too. When installing or removing optional DLC changes an NVN shader union, the script uses an external profile with new shader tables only after every non-DLC shader row and fact matches the registered tables; package indices may change. The registered module builds, settings and build-gated cuts are preserved. A cached proof of this comparison permits repeat builds to reuse the split.
|
||||
- **Found on:** [Mario + Rabbids Sparks of Hope](../../dm/games/0100317013770000/README.md) (zstd); [Mario + Rabbids Kingdom Battle](../../dm/games/010067300059A000/README.md) (zlib records, some wrapped in zstd chunks; shorter control sections and headerless compute code).
|
||||
|
||||
### CompiledBytecode resources in Frostbite superbundles
|
||||
|
||||
- **Symptom:** the survey finds no shader container in a RomFS of `.toc` and `.cas` files (`Data/NX`, `Patch/NX`, `Data/layout.toc`, `Data/initfs_NX`); the split reads every file loosely and finds nothing.
|
||||
- **Cause:** Frostbite keeps its data in bundles that superbundle tables (`.toc`, magic `00 D1 CE 01`) list, the bundles' manifests and items in the install chunks' cas files, each item in blocks of at most 256 KB compressed with Oodle Leviathan (`8C 0C`). A toc entry gives each item's cas file by an 8-byte cas id (Data or Patch, the install chunk's `persistentIndex` from `layout.toc`, the cas number), its offset and stored size; items of one bundle need not lie together. The NVN shaders are the bundles' `CompiledBytecode` resources (`shaders/bytecode/<GUID>`, res type `0x0e2b02f7`, the type name's hash): a 0x20-byte header, then a `VNVN` record (`fb::NvnCustomShaderData` of the renderer NRO) with one control section and code area at offsets its trailer gives. `ShaderBlockDepot` resources hold parameter blocks only.
|
||||
- **Fix:** `dm/gfx/tools/frostbite.py` reads `layout.toc`'s install chunks (a DbObject), every toc's bundle entries, the manifests and the blocks; `shader_split.py` (`frostbite_jobs`, `frostbite_shaders`) decodes each `CompiledBytecode` resource with the game's own Oodle in the Mac host's tool mode, as for Trinity packs, and leaves the `.toc` and `.cas` files out of the loose scan. `profile_guess.py` turns the Oodle decoder on for a RomFS with `Data/layout.toc`. Data and Patch are read alike: keys are content hashes, so a base copy the update replaced only adds an unused shader. The resources name no vertex / pixel pairs (Frostbite pairs them in its pipeline data), so the tables have none.
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (Frostbite 2025.1.2): 83,325 bundles, 10,401 resources, 10,342 shaders (3,738 vertex, 3,306 pixel, 3,298 compute), 35 MB stored; the split takes about 6 s.
|
||||
|
||||
### SPK shader package in an MT Framework ARC
|
||||
|
||||
- **How it is stored:** the engine's one shader package, `sc\NX_64\root` (`SPK\0`, type hash `0x02358e1a`) in `nativeNXx64/sa/NX_64/root.arc` ([01](../agents/01-extract.md)). After the package's tables every shader is a code area followed directly by its control section, back to back to the end of the file: 230 vertex shaders, then 230 pixel shaders.
|
||||
@@ -392,6 +399,7 @@ Finding, keying and translating shaders (`dm/gfx/tools/shader_split.py`, `dmsh_b
|
||||
- **Cause:** the engine shares one control section among shaders whose sections differ only in GLSLC's compile information (+0x778..+0x791 and +0x7d0..+0x7e7): `DM_NVN_PROGTRACE` showed the same control pointer set first with its own code area and later with another shader's. The GPU does not read those bytes, so on hardware it makes no difference; the host's key hashes them. Masked, Batman: Arkham Knight's 24,721 control sections are 5,615; the tools read nothing there (`dmsh_build.py` reads up to +0x75f).
|
||||
- **Fix:** the profile key `shader_key_skip <offset>+<length>` (`0x770+0x78`): the key hashes that range as zeros, in `shader_split.py` (`key_ctl`, and `same_shader` ignores it) and in the host (`hle_nvn.c` `keys_hash`). Without the key, every game's keys are as before. It is a profile input of the shader chain, so the libraries follow it.
|
||||
- **Found on:** [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md): 40 shaders missing in the first 45 s before the key. With `0x7d0+0x18` alone the opening cutscene still met one whose section differed at +0x778, as [pull request #340](https://github.com/seedds/nxnative/pull/340) had found, so the range starts at +0x770.
|
||||
- **Also found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (`0x7d0+0x18`): Frostbite's NVN renderer keeps one copy of each control section in a cache keyed by a hash that leaves out the compile information (`fb::ShaderPlatformDataNvn`, `s_controlBlockCacheMutex` in `Engine.Render.Core2.PlatformNvn.nro`); 10 programs were missing in the first menus, and the 10,342 keys are 7,873 shaders with the key. Its sections differed only at +0x7d0..+0x7e7 (+0x778 is zero in all of them).
|
||||
|
||||
### Compute code with and without a header
|
||||
|
||||
@@ -864,6 +872,14 @@ Finding, keying and translating shaders (`dm/gfx/tools/shader_split.py`, `dmsh_b
|
||||
- **Fix:** `dmsh_build.py` `c2_array` names it `tex_c2a` / `samp_c2a` with the c2 byte offset of element 0; the replay fills element k from the slot whose c2 word is at that offset + 8k (combined, else separate), and the dummy elsewhere (`NVN_RB_TEXA` / `NVN_RB_SAMPA`, `c2_handle`).
|
||||
- **Found on:** [Luigi's Mansion 3](../../dm/games/0100DCA0064A6000/README.md) (586 pixel shaders, the shadow cascades).
|
||||
|
||||
### Arrays of c2 handles cover the whole table, with a separate sampler word
|
||||
|
||||
- **Symptom:** `[RED] shader … reflection conversion failed: B binding fp_t2d_cb196610_10570000 has no resolved slot number`, then, with that resolved, `… reads driver-bank locations at run time that the replay layer cannot fill: c2 dynamic index`; the shader does not load and its draws are skipped.
|
||||
- **Cause:** two gaps in [An array of handles from the driver table c2](#an-array-of-handles-from-the-driver-table-c2). The translator sized every texture array from a buffer at 32 elements (`Program.cs` `QueryTextureArrayLengthFromBuffer`) and clamps the index to the last one, but over c2 the index is any handle word's byte offset ÷ 8: EA SPORTS FC 27's pixel shader `dc446d7f52c14ea6` loops over separate texture slots i = 1, 2, …, reads each handle word at c2 byte 0x168 + 8i and samples element 45 + i, so every element it picked was clamped to 31 (a combined slot). And the handle is type 1: `BindlessToArray` ORs one fixed separate sampler word (c2 byte 0x570, separate sampler slot 1) into every element's handle, which `c2_array` did not decode (it took only `_cb2_` with type 0), so the texture array had no slot and its sampler array took that one slot.
|
||||
- **Fix:** a chain change. `Program.cs` gives an array over c2 one element per handle word up to the end of the separate sampler table (`C2HandleWords`, 301; other buffers keep 32), `c2_array` decodes type 1 with the sampler word in c2 too (`soff` in the reflection), and the replay ORs that word into each element's handle for the samplers (`NVN_RB_SAMPA`; `c2_handle` now also answers the separate sampler table). `nvn_rbind.n` is 16 bits and `NVN_REFL_MAXARG` 768 (such a pair takes 602 argument entries). The same loop reads each handle word itself at a computed c2 index (`fp_c2._m0[int(_237)]`, to test the light's handle), which `unfillable` refused for any bank; the replay fills c2's handle tables whole (`DRV2` in `encode_args`), so a computed index into c2 is accepted, and one into c0, filled only in its tables, still refused. Luigi's Mansion 3's cascade arrays become 301 long as well; the host fills the elements past the handles with the dummy.
|
||||
- **Found on:** [EA SPORTS FC 27](../../dm/games/0100C49025D3E000/README.md) (its lights in a match).
|
||||
- **Check:** `test_dmsh_reflect.py` (`DriverTableArrays`, `DriverReads`) and `test_dmsh_abi.py` (the translator's table length agrees with the header).
|
||||
|
||||
### A texture slot that shares its c2 word with an image slot
|
||||
|
||||
- **Symptom:** characters and props glowing white, about 10⁴ too bright, in DRAGON QUEST VII Reimagined's opening cutscene only, while walls and gameplay look right.
|
||||
|
||||
Reference in new issue
Block a user