Repository navigation
SHIN MEGAMI TENSEI V (010063B012DC6000, 1.0.0): game profile, version 8 Unreal paks, UE 4.23's FMalloc layout and engine region, 60 fps and an iOS Screen setting - #173
Open
Xanawer wants to merge 1 commit into
Conversation
This was referenced Oct 26, 2026
Xanawer
force-pushed
the
smtv-port
branch
4 times, most recently
from
October 30, 2026 18:10
bde33ed to
60ac818
Compare
…SDK 9.3.1): game profile plus version 8 Unreal paks, UE 4.23's FMalloc layout and engine region, and on iOS 60 fps and a Screen setting Plays on the iPhone 18 Pro Max (user, with a build from before main's image-atomic changes): the opening, the character naming and Jouin High School. With fps_target 60 (then through this PR's own frame-limit rows, at the objects main's rule now finds) the phone's launcher offers Frame rate 30 / 60; its last logged session (60, Screen fit) ran its first 900 frames at frame time p50 16.7 ms. On the Mac a new game runs through the opening and the naming to the classroom at 60 fps (frame time p50 16.7 ms; 33.3 at 30) with no red line, at the game's own speed: the naming keyboard comes at the same wall time at either rate. - uepak.py / shader_split.py: legacy pak version 8 (UE 4.22 to 4.24: version 11's footer, five compression method names, Zlib here, read by Pak.read), deleted entries (flag 2: a patch pak's record of a file it removes) taken out of the view the splitter scans, the base pak's copy with them (main kept them as files flagged encrypted), and each pak's AES key from the main of its own version (pak_key, once per main; ue_legacy_jobs carries the main's path, never the key). Main's code_keys finds this game's key: its key callback (main+0x14180c0) returns it from two 16-byte literals 0x1460 bytes apart, one of 12 candidate pairs in main; this PR's own finder for that form (callback_keys) is gone, and code_keys gets the lower bound callback_keys had: a literal on the page before the image gave an empty candidate, and find_key's decrypt failed before the real key (GPT's review; test_uepak_key checks it). The key stays in memory, never printed. The footer is told by its layout (version 4's short one; 8 and 11 share the long one) and a version 8 entry's method by the footer's names, so main's checks of a damaged pak hold for version 8 too. test_uepak_legacy checks a synthetic version 8 pak's footer, index and reads, and a patch pak's deletion. A pak whose index is plain but whose files are encrypted is still not read (the key is known by the index it decrypts; no game here has one). 18,558 shaders split. - hle_uemalloc.c / ue_malloc.py: UE 4.23's FMallocBinned3 (74 pools of 512 MB, 37 GB of the engine's region) goes to the host allocator through main's engine-wide rule: its name getter is slot 17, so ue_malloc.py's LAYOUTS and the host's layouts get UE4_23 (18 vtable slots, no TryMalloc / TryRealloc yet; 0 for the missing slots, as main's UE3 layout has them). The rule finds this main's constructor call (main+0x1713920) and vtable (main+0x57e6238), where this PR's own cut was, and gates the call. test_ue_malloc checks the 4.23 layout. - ue_region.py: main's engine-region rule found no reservation in this nninitStartup (a red line). Like Pikmin 4's, it reserves the region only while its size variable is 0, but that variable is a global of its own ([x24, #0x650]), not the word after the base variable. A second pass, run only when the first finds nothing, so no main the first pass holds for changes, takes the variable the default path tested (ldr xT, [xB, #d]; cbnz xT right before it) and the last str to [xB, #d] before the call, xB unchanged since and nothing stored through it after, with the first pass's checks of x1: here str x8 at main+0x1885afc, where the gate goes. The host then gives the region what the alias region has room for, 4.06 GB at alias +64 MB. The profile's game_args -SwitchVirtualAddressSpaceSize=4064 and its patches.py (two nninitStartup cuts that let the option's path allocate, and their BINDING) are gone. test_ue_region checks this form, that a store beside the base still wins, that later stores of x1's constant to the stack or another object are not taken, and that a moved base register (wsp included), a later store through the base, a test that loads the base itself, or another value is red. - sdk_patches.py: no row of its own. Main's SDK-wide rules now reach every sdk build, and on this SDK 9.3.1 build (ad3fdfbd62a5) they give the node area cut (Advance Wars 1+2's implementation) and regions of 4 MB and more aligned to 2 MB (DRAGON QUEST XI S's), where this PR's row gave 32 MB to regions of 1 GB and more. The rules' comments name the build. In Engage's 5 GB block the region starts 64 MB into the alias region. - Frame rate: no hle_fpslock.c rows of its own. Main's console-variable rule (ue_cvar.py) finds this main's t.MaxFPS (main+0x761ed40) and rhi.SyncInterval (main+0x7520648) by name, the objects this PR's two rows had, and the host writes 60 and 1 into both copies of each. The game's code sets t.MaxFPS 30 at run time and the Switch device profile sets rhi.syncinterval=2; either alone kept it at 30. The profile's fps_target 60 adds the launcher's Frame rate 30 / 60. ue_cvar.py's docstring and docs/reference/frame-rate.md name the game. - iOS: a launcher setting Screen (DM_ASPECT fit / zoom / stretch, default fit; a settings.tsv row marked platform:ios, so the Mac app's settings window leaves it out, as test_launcher_settings now checks; a row in docs/env_switches.tsv). front_ios.m keeps the game view 16:9 (its drawable follows its bounds, and present letterboxes any other ratio): zoom makes it larger than the screen, stretch widens it with a transform. Touches are mapped on the same rectangle (dm_game_rect, DmGamepad.m). With main's TV scene the setting is the phone's only: on a TV the view is fitted 16:9 as main has it (DmTVVC resets the stretch transform before it lays the view out, and the phone's layout sets it again when the view comes back), and docs/settings.md says so. - nvn_mtl.m: texraw reads a packaged texture at the level it is sampled from. The pipeline-miss lookahead's scissor comment names this game too (the naming cutscene came out green, then white, before main's fix for OCTOPATH TRAVELER II). Main's own changes cover what this game needed from NVN: every virtual pool gets an address range of its own and its first mapping decides (OCTOPATH TRAVELER), the sparse tile layout queries, sparse textures with their 64 KB tile's block height (8 GOBs for the classroom's DXT5 lightmaps; a t_tex case checks that texture), and returning image atomics as Metal texture atomics, so Unreal's two global compute shaders that use the value their atomics return (4f731ba19a5f2877, c073d1efaba9ac70) now build and run. Profile: tex_flush_upload and tex_dirty_upload on (the colour grading LUT is written from the CPU; without them the picture is black), pad_layout full, depth_mode zero (the game sets near = 0), shader groups global / engine / game. Docs: the game note, the games table (version 8 paks, depth_mode, fps_target's list), the games gallery (docs/images/gallery.tsv, a Mac picture of the classroom), docs/playing.md's DM_FPS_TARGET list, docs/reference memory / nvn-objects / rendering / shaders / frame-rate, docs/settings.md, the symptom index and the game patch index (docs_patches.py). Checked on bfc7088: - CI's steps: the host tests for Wonder's profile and this one, tsan / memory-tsan, ASan and UBSan over the host tests and t_tex, tsan-threads, the thermal checks, t_perf_order and its tsan build, t_tex, the CPU-only gfx tests, the GL import check, the Python tests (957: dm/tools, dm/ios and dm/gfx tests), the Python lint against main's baseline (0 new findings), the C lint against main's baseline (clang-tidy 23.1.4: none above it, none below), the Mac host for Wonder, Hades, Digimon Story Cyber Sleuth and this profile, every gfx test compiled, the iOS compile check for both profiles and the unsigned iOS app; - the gfx run list (make run: 85 tests and 2 Python checks) passes under Wonder's profile and this one; - main's rewriter gives all three modules byte for byte as on 2006d5e (its cheats change adds only the record of the ranges it changed, *.changed.tsv): main has the region gate in place of this PR's old two nninitStartup cuts, on the store at 0x1885afc (x8); the allocator cut and gate (main+0x1713920) and the console variables t.MaxFPS (0x761ed40), rhi.SyncInterval (0x7520648) and r.Streaming.PoolSize (0x761d1b0, unused) as before; no red line; - the shader split, with main's key finder (code_keys) and its splitter changes, opens the encrypted pak and gives this profile's shader_map / shader_facts / shader_pairs rows byte for byte as before: 18,558 shaders, no red line; - main's new shader chain (d1043b780a74) builds all 18,558 of this profile's shaders (main's commits since leave the chain and the rewriter as they were; f5cc73d's NVN buffer offsets and bfc7088's Metal 4 function constants are in the boot below). A Mac boot on it from a new game through the naming to the classroom at 60 fps, the first boot of main's region gate on any game: no red line, "Unreal's engine region: 62.00 GB asked, 4.06 GB of address space", the region at alias +64 MB, the host writes t.MaxFPS 30 → 60 and rhi.SyncInterval 2 → 1 (both threads' copies), Unreal's allocator on the host malloc zone (0.75 GB in use), frame time p50 16.7 ms and p95 17.0 ms after frame 20,000 (17.7 and 17.1 in the two previous rounds' boots), 1,189 first texture uploads; the classroom at frame 29,000 at mean luma 58.7 (58.3 to 58.7 in earlier runs); - not on this commit: the iOS project (it was built on cbbb600), and so the Screen setting with main's TV scene; - reviews: GPT (codex gpt-6-astra) on the region change found two holes in its first second pass (a later store of x1's constant, to the stack or another object, would have been gated instead of the size variable; a store at the base+8 displacement to another base vetoed it), fixed with tests; its second round on the fix confirmed both closed and the first pass unchanged (234 mutated forms gave main's results) and found three narrower gaps (a later writeback store through the base, a write of wsp the base tracking missed, a test that loads the base itself or xzr), also fixed with tests. A GPT round on this rebase onto 2aae9f8 found the key-finder swap and the merges in uepak.py, shader_split.py and ue_region.py correct, and the missing lower bound in main's code_keys, fixed here. Earlier GPT rounds read this commit as rebased onto d3f7433 (the TV merge, the 4.23 allocator layout, the pak reader, the profile against main's rules: the patch deletions fixed here and the plain-index case named above), the Screen setting and the merge with cbbb600. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SHIN MEGAMI TENSEI V (
010063B012DC6000, 1.0.0, Unreal Engine 4.23 on SDK 9.3.1): a game profile, plus the general changes it needed.Rebased onto
bfc7088. Main's SDK-wide address-space rules (#635) now reach this game's SDK build, and its engine-wide Unreal allocator rule finds this game's FMallocBinned3, so this PR drops its own SDK row and allocator cut and gives that rule the Unreal Engine 4.23 slot layout instead. Main's new console-variable rule (ue_cvar.py) finds this game'st.MaxFPSandrhi.SyncIntervalby name, at the objects this PR's twohle_fpslock.crows had, so those rows are gone too. Main's new engine-region rule (ue_region.py,2006d5e) found no reservation in this game'snninitStartup, a red line: its size variable is a global of its own, not the word after the base variable. So this PR extends that rule with a second pass, run only when the first finds nothing, and drops the profile'sgame_args -SwitchVirtualAddressSpaceSize=4064and itspatches.py. The boot below is the first of main's region gate on any game. Main's new key finder (uepak.pycode_keys,8c0b808, for DRAGON QUEST III HD-2D Remake) finds this game's pak key too, so this PR's own finder for the same form (callback_keys) is gone.code_keysgets the lower boundcallback_keyshad: a literal on the page before the image gave an empty candidate, andfind_key's decrypt failed before the real key. The PR keepspak_key, which takes each pak's key from themainof its own version. With main's TV scene (#367) the Screen setting is the phone's only: a TV shows the picture fitted 16:9, as main has it. Main had already added the NVN pieces this game needed: virtual pools of one texture each (OCTOPATH TRAVELER), the sparse tile layout queries, sparse textures with their tile's block height, and image atomics as Metal texture atomics. So this PR no longer toucheshle_nvn.cornvn_tex.c, drops itsvirtual_poolsprofile key, and no longer needs #263. With main's atomics the two compute shaders that were open here build too: 0 red lines now, 7 before.Related: #93 (games filling the iPhone screen). The Screen setting is the generic fill weighed there, and like the issue it keeps Zoom and Stretch out of the default: Fit stays the default, and the other two are opt-in from the launcher. Per-game native widescreen is not part of this PR.
Tests: a
t_texcase (this game's 1024×1024 DXT5 lightmap: 8 GOBs, 3 tiled levels of 256×256 texels, against main's tile rule);test_launcher_settingscounts Screen among the iPhone-only rows;test_ue_mallocfinds the 4.23 layout;test_ue_regionfinds this game's form of the region's reservation, keeps a store beside the base ahead of it, takes the tested variable rather than a later store of the same constant to the stack or another object, and is red when the base register moved, something is stored through it after the size, the test loads the base itself, or the value differs;test_uepak_keychecks that literals on the page before the image give no key and the real one is still found;test_uepak_legacyreads a synthetic version 8 pak (footer, index, a stored and a Zlib file, a deletion record) and checks that a patch pak's deletion takes the base pak's copy out of the split's view.Docs: the game note, the games table (with
depth_mode zero: the game sets near = 0; and infps_target's list), the games gallery (docs/images/gallery.tsv, written out bydocs_gallery.py),docs/playing.md'sDM_FPS_TARGETline,DM_ASPECTindocs/env_switches.tsv,docs/settings.md(Screen, and that a TV shows the picture fitted), this game in the "Found on" lines of main'sdocs/referenceentries it relies on, the symptom index and the game patch index (docs_patches.py).Evidence
Mac, a new game through the opening and the naming to the classroom (the gallery picture this PR adds):
[RED] MapVirtual: non-contiguous mapping (true sparse) not implementeda few hundred times, then Unreal's out-of-memory abort at boot (a 0xffe00000-byte pool request sized from the tile-layout stub).After (on
cdc6cef): no crash and no red line from boot to the classroom. NoMapVirtualline; 1,189 first texture uploads (1,187 in the previous run of this PR), frame time p50 16.7 ms and p95 17.9 ms after frame 20,000.4639c51): 7 red lines; Unreal's two global compute shaders that use the value their atomics return (4f731ba19a5f2877,c073d1efaba9ac70) were not translated, and the classroom came out a little darker (mean luma 57.3 at frame 29,000).After: both build with main's atomics and run. 0 red lines, and the classroom at mean luma 58.3 to 58.6 (two runs), as with their old translations put back (58.8).
After: 60 fps. The naming keyboard comes up at about the same wall time at either rate (243.7 s at 30, 246.6 s at 60), because Unreal steps by real time.
fps_target 60(then through this PR's own frame-limit rows, at the objects main's rule now finds), the launcher loggedDM_FPS_TARGET=60andDM_ASPECT=fit, therhi.SyncInterval 2 → 1writes, andfront end: screen fit, picture 782x440 at 86,0 on the 956x440 screen. That session ran its first 900 frames at frame time p50 16.7 ms.On
bfc7088plus this PR, on an Apple M5 Mac (<id>: Wonder010015100B514000and SMT V010063B012DC6000):Main's rewriter gives all three modules byte for byte as on
2006d5e(its cheats change adds only the record of the ranges it changed,*.changed.tsv):sdktakes the SDK-wide rules' five cuts, the node area's two and the alignment's three (regions of 4 MB and more to 2 MB, where this PR's old row gave 1 GB and more 32 MB).mainhas main's region gateOBS_UE_REGIONon thestr x8atmain+0x1885afc, from the new second pass, in place of this PR's old twonninitStartupcuts; it keeps the engine-wide allocator cut atmain+0x1713920with the vtable (main+0x57e6238) and slot 17 in its fixups, and the console variables main's rule found:t.MaxFPSat0x761ed40andrhi.SyncIntervalat0x7520648, the objects of this PR's old rows, andr.Streaming.PoolSizeat0x761d1b0, which nothing writes here because the profile sets noue_texture_pool. No red line. The shader split, with main's key finder (code_keys) and its splitter changes, opens the encrypted pak and gives the profile's three shader tables' rows byte for byte as before: 18,558 shaders, no red line.Main's new shader chain (
d1043b780a74) builds all 18,558 of this profile's shaders. Then the same route, on that chain, as above, from a new game through the naming to the classroom:Unreal's engine region: 62.00 GB asked, 4.06 GB of address space, what the alias region has room for, the region at alias region +64 MB (4,064 MB fromgame_argsbefore);t.MaxFPS30 → 60 andrhi.SyncInterval2 → 1, both threads' copies, at the objects main's rule found;Review: GPT (codex gpt-6-astra) read the region change. In its first second pass it found two holes: a later store of x1's constant, to the stack or another object, would have been gated instead of the size variable, and a store at the base+8 displacement to another base vetoed the pass. Both are fixed, with tests: the pass now takes the variable the default path tested. A second round on that fix confirmed both closed and the first pass unchanged (234 mutated forms gave main's results), and found three narrower gaps, also fixed with tests: a later writeback store through the base, a write of
wspthe base tracking missed, and a test that loads the base itself orxzr. A GPT round on this rebase found the key-finder swap and the merges inuepak.py,shader_split.pyandue_region.pycorrect, and one gap in main'scode_keys, the missing lower bound, fixed here with a test. Earlier rounds read this commit as rebased ontod3f7433and found nothing in the TV merge, the 4.23 allocator layout or the profile against main's rules; in the pak reader they found the patch-pak deletions (fixed here, withtest_uepak_legacy) and the plain-index case below.Not checked:
Known issues:
main+0x3617108came up once during bring-up and hasn't happened again.Dropped in this update: the sparse-texture lifetime fix (
vpool_tex,t_sparse_life) went with this PR's pool code. Main's pool code reads a texture's sparse pages through the pool object the texture was created with, and this game finalizes its per-texture pools all the time, so a texture that outlives its pool may read zeros, or another pool's pages once the game reuses the pool object. That comes from reading the code; it did not show in the run above. It can come back as a small PR on main's pool code if you want it.Merge Danger
Door: two-way
There is one commit, with no save, cache or file-format changes, so a revert takes everything back out.
Blast Radius: moderate
dm_game_rect. Fit is the default and gives the same 16:9 letterbox as before. The Screen row shows for every game on the iPhone; it is markedplatform:ios, so the Mac app's settings window leaves it out. With a TV connected, the TV's view controller (main'sDmTVVC) now resets the game view's transform before it sets the frame, because Stretch leaves a scale transform on the view; on the TV the picture is fitted as before.uepak.LEGACYnow includes version 8, so other UE 4.22–4.24 games' version 8 paks are now read; before, the reader raised "only 4 and 11 are read". A legacy pak's deletion records (flag 2) are no longer files: main kept them as files flagged encrypted, which no read could open. Now a patch pak's deletion takes the base pak's copy out of the view the split scans. DRAGON QUEST XI S's update pak is the one legacy patch pak in the profiles; its files are not here, so whether it lists any deletions is unchecked. Main'scode_keysnow skips a pair whose literal lies before the image, a candidate that could only make the search fail.texrawis a debugging command.ue_region.py): the second pass runs only when main's first finds no reservation innninitStartup, so the nine builds main's rule finds keep their gate, and a main where neither finds one stays a[RED]line. A main that was red there and has this form now gets the gate. Checked on this game only.mainwhoseBinned3name getter is at vtable slot 17, and the host gives it theUE4_23layout. Before, such amainwas a[RED]line in the rewrite and kept its own allocator. Checked on this game only.If you'd rather take them apart, the general changes can land without the profile, as #89–#91 did for Super Smash Bros. Ultimate. They split into the Screen setting (iOS), the pak reader (
uepak.py/shader_split.py), the FMalloc layout (hle_uemalloc.c,ue_malloc.py) and the region rule's second pass (ue_region.py).🤖 Generated with Claude Code