A Mac-only pack (--platform mac-app or mac) failed its address region step with a red iPhone-layout diagnostic when a game's regions exceeded the profile's mem_alias while fitting the Mac host's console-sized alias region (Minecraft Dungeons in issue #2860: 37 GB through nn::os::AllocateAddressRegion, reach 38.92 GB inside the Mac's 64 GB region).
Make profile_guess.py region_verdict (with region_findings as a backwards-compatible wrapper) target-aware:
- For Mac-only builds whose regions exceed the profile's iPhone layout, evaluate reach directly against the alias size recorded in the host's regions.tsv header (# alias region <size>;: 64 GB Switch 1, 128 GB Switch 2).
- Keep the verdict red with the explicit stop reason if the check boot exited early or never reached nnMain (a refused request leaves no row in the table), if reach exceeds the Mac run's alias region, or if the table omits the alias header.
- Stamp Mac-only verdicts with '(rewrite <id>, Mac only)' so repeat Mac-only builds skip while a later IPA build re-runs and reports the iPhone layout; clean checks that also fit the iPhone keep the shared '(rewrite <id>)' stamp.
Follows up on PR #3287 and addresses the address-regions step of issue #2860 (the later shader split failure in #2860 stays open).
Co-authored-by: Eliran Zach <[email protected]>
Register update 1.0.6 with its shader and startup prewarm tables. Enable dynamic texture slots for the vertex shaders that read handles from NVN c2. All four previously rejected shaders bind buffer textures in the offline match replay on Apple M6. Record the runtime evidence and pending audio, online, DLC and iPhone checks.
Since 8c94bd1e (#2965), lib_from_map copied every .metallib file mapping into
allocator-owned dispatch_data and unmapped the source immediately on both iOS
and macOS. iOS needs owned bytes so retained Metal inputs do not exhaust its
restricted task map; macOS has no such restriction, and copying turned clean
reclaimable file pages into ~1.3-1.5 GB of charged/compressed malloc on heavy
NVN games such as Ocarina of Time (Switch 2).
Borrow the file mapping on macOS (TARGET_OS_OSX) and release it from the
dispatch_data destructor on QOS_CLASS_UTILITY (unmapping immediately if
dispatch_data_create returns NULL), while keeping the owned-data lifetime
contract unchanged on iOS. Add diagnostic override DM_MSL_LIB_COPY (=1 copies
on macOS, =0 borrows on iOS), label borrowed vs. copied mode in mtl_mem_stat,
extend t_library_data for loose and packed-image borrow lifetimes and failure
cleanup, and update docs/env_switches.tsv and docs/reference/memory.md.
Verified with t_library_data (737/737 checks), test_env_switches.py and
test_docs.py (8/8), Mac host build (--check-tables), iphoneos syntax check,
and Fast Fusion (040041E0212AE000) regression on M4 Pro / macOS 27.2.1
(2976/2976 shaders, 0 new RED lines, 1,653 / 44 MB borrowed libraries,
prepare 0.99 s -> 0.77 s, peak 4958 -> 4925 MB).
Fixes#3284
Co-authored-by: sqmagellan <[email protected]>
FMallocBinned3 leaves a freed small block untouched in a per-thread cache until
it is reused. TMap::Add(Key, *Found) depends on that: growing the map frees the
block Found points into before the entry is copied from it. The host's malloc
zone clears the block at once, so the copy reads zeros. In SHIN MEGAMI TENSEI
V: Vengeance this empties a battle task list and stalls the fight.
Keep each thread's 16 most recently freed blocks of 32 KiB or less intact in a
per-thread ring (at most 512 KiB per allocating thread), draining on thread
exit via a pthread_key_t destructor as well as on Trim and TLS-cache teardown,
and move small reallocations by hand so the old block joins the same ring
unless the block still fits or cannot shrink further. Wire t_ue_heap_span into
the TSan test target.
Refs #2345, #1034
Co-authored-by: Eliran Zach <[email protected]>
Co-authored-by: kenCalx <[email protected]>
The SDK's AddressSpaceAllocator[Base]::AllocateSpace probes up to 512
uniformly random addresses via svcQueryMemory with no linear fallback.
Horizon gives a 39-bit process a 2 GB stack region, whereas the host's
default mem_stack is 256 MB to fit iOS's 5 GB reservation budget; once
several 8 MB Unity worker stacks and dozens of 1 MB stacks are live,
random placement fragments 256 MB until no contiguous 8 MB gap remains
(Refs #1809, #2012; supersedes PR #3267 without shrinking mem_alias).
Intercept the SDK's AddressSpaceAllocator[Base] constructors and
AllocateSpace overloads (PLT-only across SDK 1.3.1 through 22.2.0,
Switch 1 and Switch 2) in hle_stack_alloc.c. Constructors identify the
stack-region allocator by its exact [g_stack, g_stack + g_stack_cap)
bounds and guard size without relying on internal C++ struct offsets;
non-stack allocators (AslrSpaceManager, RemoteRegionManager) and any
allocator with forbidden regions pass straight through to the SDK.
Stack placements route to dm_stack_alloc in hle_svc.c, which packs
against g_map under g_map_lock (stacks >= 2 MB top-down, smaller stacks
bottom-up), prefers 16 KB host-page alignment when compatible, keeps a
per-thread in-flight hint cleared on svcMapMemory to avoid concurrent
collisions, and logs [RED] [mem] stack region full if simultaneously
live stacks genuinely exhaust mem_stack.
Give Switch 2 (spec: Ounce) titles a 128 GB default alias region on Mac in hle_svc.c while keeping iOS on the profile's mem_alias, clear DM_ALIAS_SIZE in region_check so Switch 2 probes run in the host's console-sized alias region, and enforce Horizon's physical-pool limit (mem_map_limit) by default on Switch 2 while keeping explicit on/off overrides and Switch 1's existing default.
This resolves the Switch 2 startup allocator failures diagnosed in PR #3188 (two 60 GB reservations exceeding 64 GB and an uncapped physical-memory probe nulling the allocator) in the host without putting a 128 GB reservation into provisional iOS profiles.
Co-authored-by: Eriksrevenge1 <[email protected]>
Check malloc and shared-buffer destinations in pkg_edges_take before copying.
When an edge-snapshot allocation fails (such as edge 1 returning NULL after
edge 0 succeeds under iOS virtual-address exhaustion), free any partial edge
snapshot and clear both edge lengths so pkg_edges_clean takes the conservative
re-upload path rather than dereferencing NULL or skipping modified edge bytes.
Separately add lightweight ownership and crash diagnostics to investigate the
open iOS VA exhaustion and uncaught std::bad_alloc:
- Track live/peak heap edge-snapshot allocations, sizes, and failures in
pkg_edges_take / pkg_edges_drop / pkg_edges_gpu / NvPkg dealloc, and log the
first failure once via RED_ONCE.
- Track lib_from_map owned shader-library count, bytes, and dispatch_data_create
failures in the periodic memory line.
- Preserve image basename, image-relative offset, and raw PC in crash_off and
host-thread dumps when dladdr returns <redacted> or omits the symbol name.
- Print sub-GB free gaps in MB/KB/B and list per-class region counts plus the
four largest file and non-guard other regions in dm_vm_census.
Checked t_pkg_edges_oom (50 checks), t_library_data (658 checks), t_crash_diag
(12 checks), t_nvn, check_t_readback (335 cases x 2 with Metal validation),
Mac host build, iphoneos27.2 syntax check across all 5 modified sources, and
test_docs.py (7/7). Underlying iOS VA exhaustion remains open pending iPhone
retest.
Refs #3240
Co-authored-by: Joseph Hau <[email protected]>
Xenoblade Chronicles 3's six build-bound Monolith allocator cuts shrink
its 60 GB reservation to 4 GB and its first arena to 512 MB to fit an
iPhone's 4.375 GB alias region. Because patch_nso.py rewrites modules
once for every platform, the Mac ran that compact layout too, where the
first chapter's cutscene after the mid-scene battle returns null for a
0x217a0-byte allocation (sig=11 addr=0x8 at main+0x43060, issue #3149).
Extract the Mac restoration policy from PR #3218 without its unverified
DM_WIDE_ALIAS / wide-IPA entitlement changes or the 288 MB compact-arena
change, and generalize it to cover both build-bound CUTS and matched
MATCH_CUTS:
- Rewriter (patch_nso.py, nso_match.py): mark iOS-only alias cuts via
ALIAS_CUTS or alias_only=True on MATCH_CUTS, assert the cut bytes
survive later rewrite passes, and emit # ALIAS_CUT rows in fixups.tsv.
- Host (dm.h, hle_svc.c, loader.c): share dm_alias_size() in dm.h so
standalone loader tests keep linking; on Mac, undo_alias_cuts restores
original bytes before sealing text when the alias region is at least
the Switch's 64 GB (DM_SWITCH_ALIAS), failing closed on byte mismatch,
and keeps cuts when DM_ALIAS_SIZE < 64 GB or DM_KEEP_ALIAS_CUTS=1.
- Packing (scripts/build_ipa_from_nsp.py): set DM_KEEP_ALIAS_CUTS=1 in
region_check so derived-profile checks still measure the iPhone binary.
- Profile (dm/games/010074F013262000/patches.py): list all six Monolith
allocator cuts in ALIAS_CUTS while keeping the 512 MB iOS cut intact.
Checked: test_patches, test_nso_match, test_nsp_incremental,
test_ipa_unsigned (154/154), test_env_switches, test_docs (8/8), ruff
(0 new findings), t_nro / t_symbols / t_svc_memory (plain + ASan/UBSan
for t_nro and t_symbols), Mac host build for 010074F013262000, iOS
syntax check for loader.c and hle_svc.c, and DOOM 3 (010029D00E740000)
full-route regress.py check + live HUD gameplay.
Open: rerun Xenoblade Chronicles 3 Handheld mode (Zstd worker crash in
issue #3149) with the restored 60 GB layout before associating it with
the same cause, and fingerprint XC3's allocator functions into
MATCH_CUTS (build -> game) once XC3's main binary is mounted.
Co-authored-by: Gabriel Tran <[email protected]>
Align writable data and bss to the host page while keeping text and read-only data at their original offsets. Update the NRO segment header and references to the relocated data. The jump solver driver and synthetic NSO/NRO checks verify the resulting layout.
Register the base build, its 33,335 shader keys and the opening's
pipeline prewarm list. The port uses the existing Unreal region and
allocator support, SDK 10 services and Zstandard pak reader.
The supplied NSP passed extraction and all five NCA hash checks. On an
Apple M6 with macOS 27.2.1, the windowed test with the iPhone-sized alias
region reached the beach rescue and prologue title card. The beach
scene ran at a median 33.4 ms per frame with zero reported audio
underruns. One unexercised global shader reports unsupported operations.
All shader entries built for Mac and iOS. The Finder app passed strict
signature verification and the unsigned IPA passed its CRC checks.
113 targeted tests passed. Combat, saving and reloading, later areas,
and gameplay on iPhone and iPad remain unverified.
Co-authored-by: seedds <[email protected]>
Co-authored-by: BoL <[email protected]>
Add OS memory-pressure handling (DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, mem_trim, DM_NVN_MEM_PRESSURE, DM_CTL memtrim) and system-wide memory logging; retire packaged-texture re-upload spares idle for >3 s (spare_trim); and evict uploaded NvPkg textures unused for 30 s on memory pressure and every 10 s on devices with Metal working set under 6 GB (pkg_evict_idle / pkg_sweep, DM_NVN_TEX_EVICT_IDLE).
Unify idle-use tracking onto main's g_tu_now / g_treg[].used / g_pool_walk / seen_stamp_used, drop evicted serials cleanly via own_drop_where_locked (nvn_owner.m), and clean evicted entries from g_pkg_share. Add t_pkg_spare and t_pkg_evict, extend t_rt_recycle, and update docs.
Co-authored-by: Stan Bono <[email protected]>
Exclude block-linear, non-buffer textures in CPU_NO_ACCESS storage from raw global memory admission (nvnTextureGetTextureAddress) and avoid admitting aliased CPU_NO_ACCESS virtual pools on MapVirtual unless a reachable address was already given out (pool_t.asked). Lower BIG_MIN from 512 MB to 256 MB so small direct lookups in 256-511 MB pools wire only their 16 MB chunks instead of the whole pool.
Add t_gpu_only_addr and update memory/nvn-objects reference docs.
Co-authored-by: Stan Bono <[email protected]>
Extract the host NVN improvements and Ocarina of Time smoke route from PR #1971:
- Keep non-virtual NVN_MEMORY_POOL_FLAGS_SHADER_CODE pools out of the raw pool
table when only nvnMemoryPoolGetBufferAddress is queried (nvnBufferInitialize
and pointer scans still admit them).
- Pre-wire file-backed shared buffers with mlock outside g_res_mu before
queuing residency additions, and munlock them right after res_commit_retiring.
- Match present_shape against the window crop aspect before the full texture
aspect when DM_SCREEN_ASPECT is set.
- Protect frame step from idle-GPU startup late frames, probe unpaced holds
whose GPU work fits a shorter hold, and switch automatic 30 fps links to
60 Hz at frame latency 2 when frames are late at hold 2 (while honoring an
explicit DM_PRESENT_LINK or DM_PRESENT_LATENCY).
- Add dm/games/0400486024DEC000/smoke.tsv and update the reference entries and
symptom index.
Co-authored-by: Stan Bono <[email protected]>
Co-authored-by: uncraftablexd <[email protected]>
Add profile for FINAL FANTASY VIII Remastered (01008B900DC0A000,
update 1.0.1_5 / v196608, SDK 7.4.0, BaseEngine). main is a small
loader and the game ships 14 NROs loaded with nn::ro; Rendering.nro and
Platform.nro draw via OpenGL ES / EGL and compile GLSL at run time with
GLSLC from subsdk0 (34 shaders captured: 18 vertex, 16 pixel).
Needs the 16 KB module data relayout in the previous commit for
Math.nro and Platform.nro. Plays through the intro and first playable
section on Mac with no DM_ switches; later-area shaders, peak memory
and iOS testing remain open in the game note.
Co-authored-by: Gabriel Tran <[email protected]>
Horizon maps code modules at 4 KB, while macOS and iOS map at 16 KB
with W^X (loader.c seals [0, round16K(text_end)) read+execute and
gen_embed.py places it in __TEXT). Any NSO or NRO whose data starts
below round16K(text_end) (such as FINAL FANTASY VIII Remastered's
Math.nro at 0x2000 and Platform.nro at 0x3000) ends up with read-only
data and faults with SIGBUS in relocate().
Add dm/tools/mod_layout.py and invoke relayout_module() inside
patch_nso.py right after nso.load() for all NSO and NRO modules:
- Shift ro, data and bss up by whole 4 KB pages so data starts at or
past round16K(text_end), keeping TEXT_END at the true code end and
leaving on-disk .nro files and nro.tsv untouched.
- Rewrite the embedded NRO0 header (when present), MOD0 (+4 and its
six offsets), dynamic pointer tags, .dynsym values (excluding
STT_TLS), RELA/JMPREL/RELR, text adrp/adr/literal references into the
moved range (skipping +4, MOD0 in text, in-text literal pools and
unallocated 0xDC words), and .eh_frame_hdr/.eh_frame (including
empty FDE augmentations, sdata4 counts, omitted search tables and
explicit LSDA lpstart pointers).
- Check data_off >= round16K(text_end) in loader.c read_layout() for
every module, and add mod_layout.py to the rewriter cache keys in
build_ipa_from_nsp.py and regress.py.
Co-authored-by: Gabriel Tran <[email protected]>
Record the Kokiri Forest benchmark and the same-binary pool toggle
for PR #2714. The measured peak swings tracked graphics memory
during the load. Link the game measurements from the memory reference.
Co-authored-by: Esteban Viera <[email protected]>
MapMemory dirties the destination when it copies in the stack.
UnmapMemory copied the bytes back and removed the mapping, leaving
dirty pages resident across the stack region.
Reject device-shared destinations before copyback. After copyback,
release whole anonymous host pages. Partial pages can hold live
neighbors, and file-backed stacks retain their backing.
The host memory tests covered device sharing, copyback, reclaiming an
interior page, preserving both neighbors, remapping and file backing.
Cuphead passed the Mac smoke comparison with 27 stack maps on each
run. The memory tests exercised stack unmap.
Co-authored-by: Esteban Viera <[email protected]>
The private utility queues and global queues do not drain autoreleased
temporaries at each work item boundary. Give each of the five background
pipeline workers a local pool and publish its result before draining it.
On an M4 Pro MacBook Pro with macOS 27.2.1, a synthetic 256-job burst
peaked at 256 live temporaries before and one after in five trials.
The focused Metal tests, iPhone SDK compile check, clang-tidy check
and documentation tests passed. In-game memory remains unmeasured.
Co-authored-by: Esteban Viera <[email protected]>
Hitman Absolution v131072 aborted before nnMain because the SDK's rtld
list could not identify the module that QueryMemory found. The SDK now
gets module ranges and exact-base symbol lookups from the host loader.
The diagnostic APIs use those lookups to build their own list and call
the game's exports for the read-only data bounds.
Return whole free spans outside the guest reservation and an
inaccessible block at the Darwin address limit. The native walk now
visits the loaded modules and terminates without scanning free pages.
Hitman reached the title and opening cinematic on an M4 Pro with
macOS 27.2.1. Well Dweller and Hades passed the quick regressions.
Memory and loader tests, focused lint, docs and iOS syntax checks passed.
Co-authored-by: Vrieza Rahman <[email protected]>
Register update 1.05 and its 4,614 shaders. Decode bare-zlib Snowdrop
caches and verify their block sizes. Match the compact Snowdrop
allocator across the base and update, and match the older SDK's
allocator functions across their reviewed implementations.
The memory changes work around the iPhone alias limit. The Mac build
reaches character creation with the preview and all six supplied DLC
licenses. The unsigned iOS build matches its separate RomFS image.
Kingdom Battle reaches language selection with identical shader output.
Co-authored-by: Nuno Ferreira <[email protected]>
Co-authored-by: Ishtiaq Ul Haq Syed <[email protected]>
Register v1048576 and its shader tables and prewarm list. The Switch
Unreal Engine 4.24 allocator uses an 18-slot vtable with its name getter
at slot 17. Recognize that layout in the existing constructor matcher
and route its allocation methods to the host malloc zone. This lets the
engine boot in its 4.06 GiB region under the iPhone-sized layout, where
its original 37 GiB pool reservation failed during startup.
On Apple M6 with macOS 27.2.1, the game ran through the opening Piccolo
fight at about 30 fps with all 17 DLC licences reported and no host
errors. All 75,430 Mac shaders built. The 67 targeted tests and C and
Python lint checks passed. iPhone gameplay remains unverified.
guest_file_init started the watcher after mapping the files, before
mem_init_once filled in the guest layout and alias bitmaps. A sweep
could read a null bitmap, and the first dirty-page scan could read
uninitialized region pointers.
Create the watcher after the layout and bitmaps are ready so thread
creation publishes the initialized state to both paths. The startup
test checks the state at pthread_create and fails on the old code.
The memory and memory-file targets passed on macOS 27.2.1 with Xcode
27.2. The docs tests and focused clang-tidy check also passed.
Co-authored-by: Oliver Ames <[email protected]>
Co-authored-by: kenCalx <[email protected]>
Upload feedback waited on the residency commit lock on the serial Metal
4 feedback queue. A slow commit could delay later completions. Once the
GPU is done, retire temporary staging on a worker and hold its slot and
pending count until removal and release. Batches using only the slot's
own staging complete on the feedback queue.
Log completed residency and selected queue commits of 100 ms or more
outside the commit lock. The original NX18 iPhone freeze remains open.
The Metal fixture holds the commit lock while later feedback runs and
checks that retirement still controls slot reuse and the pending count.
Co-authored-by: Oliver Ames <[email protected]>
Co-authored-by: kenCalx <[email protected]>
Give Metal allocator-owned dispatch data and unmap each source before
loading it. Loose metallibs and packed-image entries share the same path,
with prompt descriptor closure and the original content digest preserved.
Manifest prewarm still processes its complete lists.
Metal retained the old mapping-backed input for the lifetime of its
library/functions. With only 32 MiB left for new mappings, a real-Metal
Mac loader failed at library 527; owned data loaded all 4,096 libraries
(199.88 MiB payload) using malloc-managed space. The equal-load probe costs
about 219 MiB more charged memory than mapped input.
Checked 655 library-ownership assertions, the focused warmup/archive/
admission/prebuild tests, the Mac host build, all 267 iPhone source compile
checks, docs and relevant C/Objective-C lint. Earlier full Isaac and
Catherine regressions passed for this loader change; gameplay timing is
not claimed. Startup and sustained play on the reporter's iPhone remain
unverified, so keep the issue open for that retest.
Refs #2965
Co-authored-by: Joseph Hau <[email protected]>
PR #2270 found guest-backed upload buffers accumulating independently
of staging. Allow an opt-in source budget at texture boundaries and
resolve the source again if staging starts a new batch. Sparse gather
addresses remain together, and completion retains each batch’s sources.
Metal readback passed with the budget disabled and at 96 MiB.
Co-authored-by: Stan Bono <[email protected]>
Ocarina of Time’s residency census in PR #2566 found a 64 MB zero buffer.
Copy each colour fill or scissored clear in bands that fit the 4 MiB buffer,
grouping whole depth slices where possible. Metal readback passed for
levels, layers, volumes, large scissors and compressed alias clears.
Co-authored-by: Stan Bono <[email protected]>
Ocarina of Time’s residency census in PR #2566 found a 296 MB shadow
target occupying a 333 MB heap. Preserve the small-target reuse allowance
and cap the extra headroom for large targets. The existing GPU retirement
path still owns heap lifetime. Heap sizing, reuse and lifetime tests passed.
Co-authored-by: Stan Bono <[email protected]>
Keep reusable staging after bursts until the configured idle interval.
Drop completed buffers from Metal residency and reset a fully idle
slot's cached demand so a small upload can resume with a 4 MiB block.
Default to zero on all platforms. An explicit zero logs the baseline
for device comparisons.
Co-authored-by: Adrian Smith <[email protected]>
Trace fixed storage-buffer pointer sources into reflection and admit their
actual target pools to the existing raw-memory table before argument reuse.
Keep the GPU helpers and commit-time table refresh unchanged.
Check sparse source mappings and queued inline updates before reading pointer
words, and reject overflowing pool lookup ranges. This addresses the omitted
pool case diagnosed in PR #1585, not the separate whole-mesh GPU hang.
Co-authored-by: nafields <[email protected]>
Use the existing host allocator gate to leave Unity address-space room
without lowering the memory size games use to choose their graphics quality.
Keep explicit caps and correct the recovery instructions for profiles whose
pool was reduced by an earlier heap check.
Cover cap generation and persistence in the tool tests. Record the real
heap/region probes, paired pool-versus-cap comparison and fresh-save TUNIC
regression under the iPhone alias limit. Pokemon Friends quality selection
with the cap and iPhone runtime validation remain open.
Refs #2830, #2843
Co-authored-by: Jesus Aragon <[email protected]>
Let consecutive submissions append to unused arena tails, retaining each
block through its latest writer's fence. Prefer the smallest completed
block and the most recently used equal-sized block so peak allocations
can age out. Retire ordinary blocks above four after 600 idle submissions,
while preserving the existing large-scratch retirement policy.
Shader argument caches borrow their buffers from the owning arena rather
than pinning scratch for shaders no longer drawn. Check the pass before
accessing a cached buffer. Count all idle releases and publish atomic
arena diagnostics. Preserve current main's arena_take address contract;
the duplicate PR address fix is already covered by 44d67fbe/1073e98b.
On Apple M4 Pro, macOS 27.2.1, NieR 1.0.3's opening-flight route against
b04c42b0: the unobscured baseline retains 24 blocks (96 MB), both candidates
two (8 MB). GPU allocated at frame 12300 falls 2401 -> 2313 MB; peak
footprint 2316 -> 2228/2225 MB, with 59.9 fps throughout the clean runs.
The full regression exits 0: CHANGED only for moving ships, below the
baseline screenshot variation. A covered baseline and an interrupted
overlapping measurement are documented separately from the memory claim.
Isaac was skipped at the user's request; no iPhone run.
Allocator GPU tests pass 25/25/22/20 checks; argument-generation tests pass
42 checks. Restoring strong shader ownership fails the physical-retirement
assertion in an isolated negative test. Docs and environment-switch checks
pass, and LLVM 23.1.5 reports no new lint findings. Final standards and spec
reviews found no remaining issues.
Co-authored-by: Oliver Ames <[email protected]>
Co-authored-by: kenCalx <[email protected]>
Metal opens pipeline archive files whole, but startup admitted every bundled,
prewarm and device archive without allowing for later host allocations. BotW's
reported save-load abort on a restricted iPhone task map disappears with
DM_PSO_MTL4=0; the exact introducing commit and affected-phone retest remain open.
Snapshot all three sources and require their validated page-rounded sizes plus
2 GiB of runtime headroom to fit the actual task map's largest free gap. If the
map cannot be read or the set does not fit, use the established MTLDevice path
before opening archives or creating the compiler, serializer or prebuild. Keep
valid cache files and stamps. This is host-bound, without a game/profile gate;
the reserve is conservative policy based on the Mac census, not a phone minimum.
Checked: eight admission scenarios, archive/bundle/prewarm/depth suites,
iPhoneOS syntax and docs. Full NieR and Octopath routes against 6c079578 keep
all 15,205 shaders unchanged, with no new crashes, hangs, interface failures or
red diagnostics. Octopath passes with its known baseline depth-mode mismatch.
NieR's timed screenshot gate differs; three fixed-frame replays per revision
pass within the established noise. The Mac was busy, so no performance gain is
claimed. The environment-switch catalogue failure also occurs on baseline.
Rebased onto edc7eff9 and reran admission, archive, bundle, prewarm,
background lookup, lookup completion, pending, stall and depth/stencil checks,
plus iPhoneOS syntax and docs: all pass. The full game runs above predate
this integration rebase.
Refs #2444
Co-authored-by: arnavaggarwal-dev <[email protected]>
Make DM_REGISTER own the Mach-O data section, natural entry alignment
and declaration-level ASan no-redzone policy. Use it for HLE, libc,
forced takeover and alias entries, Vulkan, OpenGL/EGL, NVN, and services,
including the handwritten prepo takeover. Remove prefix exclusions.
A CPU-only integration test links the real producers and exercises their
import, graphics bootstrap and service section walks under ASan/UBSan
without a global ignorelist. It checks 24-byte entries and confirms an
ordinary global retains its ASan redzone. CI runs it.
Apple clang 21 confirms no_sanitize("address") removes global redzones.
The integration test passes: 424 HLE entries (134 Vulkan, 226 GL/EGL),
25 forced, 509 NVN and two services. The full host ASan/UBSan suite has
zero findings and 65 passing t_time checks. The touched C sources have
no new LLVM 23 lint findings; 35 supporting tests pass.
Isaac passes its full regression on Apple M6, macOS 27.2, Xcode 27.2.
DOOM 3 could not start because the Python environment lacks lz4; that
unrelated dependency gap is left separate under the verification policy.
Original PR CI still has five queued jobs; clang-tidy, unsigned iOS and
labeling passed. Revised code is validated locally before landing.
Co-authored-by: Daniel <[email protected]>
The host took over nv::SetGraphicsAllocator and SetGraphicsDevtoolsAllocator
and only recorded the callbacks, which nothing read. The SDK's setter is
what installs the dispatch behind NvOsAlloc, which the movie extractor
allocates with: Mortal Kombat 11's story transition got a null SampleTable
from the SDK's 32 KB bootstrap heap. Both takeovers are removed, so the
game's call reaches the SDK's setter as on the console (checked on SDKs
3.7.0 to 21.4.3; on Switch 2 it also sets up nn::gs's allocator).
Native-texture movie output accepts a buffer of capacity zero (MK11 passes
its texture with capacity 0); the texture object check still rejects null
and non-texture pointers. Flush resets the AAC converter and closes Vorbis
inside the decode lock, so the first packet after a seek decodes as from a
fresh decoder.
Checked: t_nv, t_movie_avc, t_movie_vpx (also with ASan and UBSan);
Mega Man Legacy Collection and Fast Fusion boot to their frame loops
through the SDK setter; Mario Golf's opening movie plays as on main.
Co-authored-by: YubiSmart Labs <[email protected]>
On NVN a pool's Finalize ends its memory and every texture on it. The host ended only the pool's
sharing-table entries: a texture object the game finalizes later kept its serial entry, and the
entry held the Metal texture (the owner does not retire what an entry holds, #1326). Packaged
textures, which the sharing table never names, and finalized serials' ghost entries were kept the
same way. Ocarina of Time finalizes the 288 MB pool of its 12288x12288 Depth16 shadow target at the
load into Hyrule Field and the texture object only at the load back into Kakariko Village (or the
castle grounds), after making the target again: the old 300 MB heap stayed resident through the
field and beside the new one at the next load, the iPhone 17's doubled heap when it was ended for
memory on 2026-11-14.
- The owner indexes each pool's live texture objects from initialization to Finalize (g_pool_tex,
the pool recorded at initialization, checked by own_check_locked). own_pool_finalize_locked ends
their entries whatever they hold, then every live or ghost entry that still names one of those
textures, a packaged texture of the pool (g_pkg_share) or a part of one (own_hook_parts: a
package's texture the GPU took over), each a note.
- drop_entries_naming_locked, shared with the release of drawn-over targets, skips a table the
held counts say holds none of them, and stops once it has found them all.
- Work encoded before the Finalize keeps the textures until it completes, and pins still hold them.
A later lookup reads as an empty slot, as an ID of a finalized texture does; t_readback's
stale_pools expected a made texture to be kept (#934), and now expects an empty slot.
- The 300-frame memory line counts the entries that went with their pools.
The holder was found by PR #2775, whose version removed the entries naming the pool's shared
textures; on the Mac with the iPhone's settings (Kakariko -> field -> Kakariko, 2026-11-13 save) it
let the old heap go about 330 submissions after the pool's Finalize instead of about 20,000, the set
in the field 3,850 against 4,211 MB, the village load's peak after a commit 4,142 against 4,375 MB.
This version treats that target the same way. Not yet run on the iPhone.
Tests: t_serial_owner 191 (a pool's live object holding a packaged texture and a finalized serial
holding the package's texture lose their entries; fails without the index), t_rt_recycle 27 (a pool
finalized before its texture object; 3 checks fail without the fix), t_readback, the gfx run list,
test_docs. Regress (quick, base e6a358f5): Xenoblade Chronicles 2 PASS, 15,910 shaders unchanged, no new
red lines, 29.9 -> 30.1 fps, peak 2,031 -> 2,016 MB. Its route finalizes no pool, so it covers the
index's upkeep only; Ocarina of Time, the one local game whose loads finalize such a pool, has no route.
On iOS the guest went in files only when its memory pool alone did not fit the room
to the memory limit at start. The host's own memory comes out of the same room and
grows after that reading: Metal's copies of the game's textures, render targets,
upload staging and malloc. Mario Kart World's 9 GB pool stayed anonymous on an iPad
with 11.97 GB of room, and iOS ended it at 11.94 GB of footprint after 28 minutes
(issue #1184); the same game in files held about 4.2 GB on an 8 GB iPhone. The
session's "GPU allocated" rise (6.1 -> 9.5 GB) is not host memory: Metal's allocated
size counts the zero-copy buffers over the guest's pools.
The rule now adds a margin of half the pool (guest_host_margin), and the start line
names it; DM_GUEST_FILE_HOST=<size> sets another (0: the rule before). What has to
fit is the guest's touched pages and the host's memory together. Measured on a 16 GB
M6 Mac with the guest in files (DM_MEMSTAT: footprint less the guest class), about
5 minutes each, as a share of the pool: The Binding of Isaac 0.21 (host 0.41 GB of
3.21), Mario Golf: Super Rush 1.23 (host 3.22 GB, as much as its pool), Fast Fusion
at least 0.77 (host 4.90 of 9), Ocarina of Time about 1.24 (host 5.39 at a load,
4.3-4.8 walking; guest 6.4 GB from its note), Mario Kart World at least 1.33 (the
iPad). The host's share alone runs from a tenth of the pool to all of it, so no
smaller margin on the host would hold. With half the pool every 9 GB pool goes in
files on iOS, and 3.21 GB pools stay anonymous with 6 and 8 GB limits. The Mac,
with no limit known, is unchanged.
Checked: t_svc_memory's file_rule (make -C dm/host/tests memory memory-file, all six
runs pass), test_docs, test_env_switches, an iOS SDK syntax check of hle_svc.c. Not
run on a phone or the iPad yet; the Mac's 2560x1440 window adds some graphics memory
against a phone. No regress run: the decision only acts on iOS.
The guesser gave every Unreal main with an NPDM system resource a 64 GB alias
region (mem_reserve 0x1028000000 / mem_alias 0x1000000000). An iPhone reserves
the profile's block as it is and iOS grants about 6 GB, so a provisional IPA
stopped with FATAL reserve guest AS before any guest code ran (Dispatch,
iPhone 15 Pro Max). The Mac gained nothing from it: it reserves the Switch's
64 GB alias region whatever the profile says. It also hid iPhone-layout faults
from the address region check.
The Unreal rule is removed: these games take the 5 GB block of every game with
virtual address memory (4.375 GB alias region, 128 MB heap until the heap
check). ue_malloc.py and ue_region.py already fit Unreal to any alias region;
the engine region gets 4.06 GB. Minecraft Dungeons II's profile, the only
committed one with the 64 GB values, moves to the same block: with
DM_ALIAS_SIZE=0x118000000 on the Mac it played to first control at 60 fps, the
alias region mapped up to +1.51 GB, footprint 2.46 GB, no [RED] line.
A lookup that does not know how far it reads asks for length 1: an indirect indexed draw's index buffer and a storage buffer whose address the game keeps or pushes (NVN_RB_SBUFU / SBUFQ). In a large pool (512 MB and up, in 16 MB strides) big_lookup gave it a chunk reaching a 64 MB guess past the address, made or lengthened at its stride. Every stride such lookups started in got its own 80-96 MB chunk; they overlap, a lengthened chunk keeps its shorter one alive, and Metal counts each no-copy buffer whole. Trails in the Sky 1st Chapter reached 4,243 MB of shared buffers over its 1,507 MB pool and its command buffers failed out of memory on an M1. The guess was no bound either: the GPU may read further.
Such a lookup now takes one buffer of the whole pool (big_full), as raw global memory's pool table already did, and every later lookup of the pool shares it. pool_ent's unk becomes reach (REACH_WHOLE / REACH_END / REACH_SHORT); the per-thread lookup cache answers an unknown-length lookup only with a buffer that reaches its pool's end (pc_holds). Chunks made before stay resident for what was encoded with them. The host logs "one buffer of the whole pool (why)" when a pool is made whole.
Test: check_t_pool_chunks, 178 checks pass: a short cached chunk does not answer an unknown-length lookup, twenty strides and the pool's end share one whole-pool buffer, a known-length lookup then takes it, the short chunk stays, and the GPU writes 96 MB past the address. 23 of them fail with the 64 MB guess. Reference entry: Unknown-length lookups made a chunk at every stride (memory.md).
Trails (PR author, M1): 2,685 MB allocated after a save load, about 3,150 MB after seven minutes of play, no out-of-memory failure. Not run here. regress.py check on an M4 Pro: Mario Kart World (race route, 2,372 MB pool) PASS, and Fire Emblem Three Houses (prologue, 1,544 MB pool) the same as main; neither makes a pool whole, so the change does not reach them.
Co-authored-by: jonareyess <[email protected]>
GetInfo(UsedMemorySize) reported the heap plus the profile's mem_used (and the giant
bss), but SetHeapSize charged the rewritten modules' size, patch areas and key pages
included, which the Switch never counts. A game whose rewritten modules were larger
than mem_used was refused the heap the host had just offered: MIO: Memories in Orbit
(68 MB of modules against the default 64 MB) aborted in nninitStartup.
The host now keeps one figure for the used memory beside the heap (used_beside_heap:
mem_used, the giant bss and, with mem_map_limit, the pages mapped in the alias
region), which GetInfo reports and SetHeapSize and MapPhysicalMemory charge, as
Horizon does. mem_used only decides the game's heap size. The NSP script's two ways of
setting it to cover the modules (refine_after_rewrite after the rewrite, and the heap
check's pool-failure signal) are removed; profiles keep the values they have, which
give a heap close to hardware's. Reporting the true module size as used memory instead
was measured and rejected: 7 of 14 local builds would lose 18-157 MB, and Wonder's
heap matches hardware with 64 MB beside 74 MB of rewritten modules.
PR #950 (the packer sizing mem_used for virtual-address titles that set a heap) is
superseded. Breath of the Wild: same 3.05 GB heap, regress.py check green on shaders,
boot and red lines. Refs #941 (its MDI_MAX and flat-shading parts stay open).
pool_gone_release took a retired pool buffer's fence from one expression, g_fence + (atomic_load(&g_sub_on) ? 1 : 0). C leaves the order of the two reads open, and clang reads g_fence first. mtl_sub_commit clears the flag only after its ++g_fence, so g_fence read before a commit's ++g_fence and the flag after its clear gave the fence before that submission's, which may already be done: defer_kick could take the buffer out of the residency set and free it while the submission, which looked the pool up before the generation bump, still ran. Found by reading the code (PR #2328), not seen in a game; the window is two adjacent loads.
The flag (now g_sub_open) holds the open submission's own fence, g_fence + 1 from mtl_sub_begin (only the submit thread moves g_fence, and segment cuts commit under the submission's fence), and 0 once its commit has cleared it. pool_gone_release reads it first and reads g_fence only on a 0, which the clear after ++g_fence makes count that submission. The fence is exact in every order: the PR's fix, a 0/1 flag read first, left a buffer one fence late when a commit landed between the reads, a fence a game that stops submitting never reaches. The other readers of the flag test it for nonzero. A test hook between the two reads (g_pool_gone_between, from the PR; the host never sets it) lets t_pool_retire land a commit there.
Checked: t_pool_retire 18 checks, 0 failed in 5 of 5 runs; with g_fence read first the new case fails 2 checks (the buffer gone while its submission is open), and with the PR's 0/1 flag read first 2 checks (the buffer one fence late, not freed with no submission after it), 3 of 3 runs each. The whole graphics test run (make -k run in dm/gfx/tests), lint_c tidy (nothing above baseline) and test_docs pass. Not run: any game or regress.py (one helper and the flag's two stores, covered by the unit test), the iPhone.
Co-authored-by: dean0396 <[email protected]>
No SDK-wide node-area rule matched the sdk of Orbitals (SDK 21.4.2 for
the Switch 2), so the AddressRegionManager kept its 1 GB node area at
the start of the alias region: Unreal's engine region started at alias
+1.00 GB and could not fit an iPhone's 4.375 GB alias region.
The constructor (sdk+0x16db70, 332 bytes) is the SDK 20.5 Switch 2
build's instructions in another order, with 32 more bytes on its cold
path (an abort code per failing result): the node area limit at +0x18
and the occupied length at +0xa4 take the same 0x3fe00000 -> 0x3e00000
(62 MB) cut, the rule's ninth implementation. The same function, at the
same offset, matches once in the sdk of Sonic Frontiers Definitive
Edition (21.4.1), Resident Evil 4 (21.4.3) and Splatoon Raiders
(21.4.4). Region placement on this build aligns to 64 KB or 2 MB only
(sdk+0x16dd14), so it needs no alignment cut.
Checked: Orbitals with the iPhone's alias region on the Mac
(DM_ALIAS_SIZE=0x118000000) gets a 4.06 GB engine region at +0.06 GB
and plays through the opening into the first area (high-water mark
+4.00 GB of +4.12 GB); Resident Evil 4 rewritten with the rule reaches
its title with its 32 GB and 6.93 GB regions from alias +0.07 GB; Sonic
Frontiers (which takes a heap, no regions) reaches Cyber Space 1-1.
A take-over ran on the stack of the game thread that called it unless it
was registered with HLE_FORCE_BIG, and each moved there only after it
crashed on a small stack: the file system (Super Mario 3D World's 8 KB
save thread), add-on content, AudioOut, the controller applet (Drag x
Drive), Mario Kart 8 Deluxe's offline page (#2541). 13 of 1,067 had it.
HLE_FORCE now registers the big-stack stub for every take-over.
HLE_FORCE_DIRECT keeps the caller's stack for the 7 that run the game's
own code, whose stack use is the game's: ro::LoadModule (both forms) and
UnloadModule (an NRO's init and fini), and the JIT plugin's Create,
Destroy, Control and GenerateCode.
- Stack arguments: a stub with more than 8 parameters enters at
dm_bigstack_enter_n with the bytes its caller passed on the stack in x17
(8 per parameter past the eighth, rounded up to 16), which the entry
copies to the host stack; dm_bigstack_enter carries none, so the NVN,
Vulkan and GL layers' entries and log lines behave as before. The
parameter count is checked at compile time (at most 16).
- The stubs are local to their file (two files share static names), and
programs without hle_bigstack.c get weak pass-through entries.
- Take-overs that report their game call site map it through
dm_bigstack_caller (audio, the audio renderer, nn::diag's aborts, whose
backtrace no longer runs on the game's stack).
- t_bigstack: a 12-parameter take-over called from the top of a stack,
and garbage in x17 on a plain entry.
Checked: host tests, graphics tests, the iOS compile check, test_docs.
regress.py check, M4 Pro: Hades 60.2 -> 60.1 fps, OCTOPATH TRAVELER II
59.8 -> 59.8 fps, both PASS, no new red line (a first candidate crashed
both at boot: the other entries left x17 unset, hence the two entry
points). Mario Kart 8 Deluxe 4.0.0 on the Mac: the Info page opens and
closes, the menu takes input after.
mtl_ext_tex registered a Vulkan swap chain image or a GL window texture with the present path
(a serial, the residency set) with no way back: vkDestroySwapchainKHR and win_make dropped only
their own references, so each swap chain recreation (a console mode switch from the iPhone's
in-game menu, a TV connected) or window surface of another size kept its textures, about 24 MB
for three 1920x1080 RGBA8 images. Each present also pinned its texture, and the unpin handed the
pin's reference to the deferred-release queue, which only an NVN submission's fence drains: the
Vulkan and GL layers make none, so one entry a frame stayed for the whole session, holding its
texture.
mtl_ext_tex_release is mtl_ext_tex's pair: it waits for the presents queued so far (a submitted
present's ticket counts at its completion), takes the serial out without the deferred-release
queue (own_ext_take), and takes the texture out of the residency set at once or, with a present
still in flight, when the last one completes. A present of an external texture is not pinned.
vkDestroySwapchainKHR and win_make call it. Reference entry: Vulkan and GL presentation textures
were never released (memory.md). Found by an audit of the presentation path.
Checked: t_vk_swapchain_life (new: 140 swap chains of 3 images, each presented 3 times to an
offscreen layer and destroyed: none left alive; before, 420 of 420 and 420 queue entries), also
with MTL_DEBUG_LAYER=1 and DM_PRESENT_LINK=0; t_present_alloc, t_present_crop, t_present_rescue,
check_t_present_snap, t_vk_desc, t_vk_dontcare, t_vk_1d, t_gl_imports; lint_c.py tidy: nothing
above the baseline. regress.py check: Hades (Vulkan) PASS, 74/74 shaders, 59.7 -> 60.0 fps, peak
2394 -> 2387 MB; OCTOPATH TRAVELER II (NVN, the shared present code) 13,980/13,980 shaders, no new
red line, screenshots within noise, fps 48.6 -> 59.6 with the same p50 frame (window covered,
other jobs running: noise). Not covered: the in-flight branch (a present's ticket already counts
at completion); no GL game on this Mac's drives; no iPhone run.
res_commit held g_res_mu, the lock every res_add and res_remove takes,
for the whole [MTLResidencySet commit], which takes 10-25 ms when it
adds hundreds of MB while the GPU runs. The upload batches' completion
handlers commit their staging's removal on their own threads, so the
submit thread, adding a scene's new textures, waited for those commits.
res_add and res_remove now only queue the change under g_res_mu, each
holding its allocation; res_commit takes the queue and applies and
commits it under g_res_commit_mu (taken before g_res_mu, never inside
it). A res_commit returns once every change queued before it is
committed, also one another thread's commit took, and a removed
allocation stays alive until the commit that takes it out of the set.
The queue commits that held g_res_mu to stay apart from the set's
commit, the present snapshot's and the encode thread's (nvn_rec.h, for
every command buffer), hold g_res_commit_mu.
- Switch Sports Resort's first court frame (855 textures, 908 MB, M2
Max, PR #2379): the submit thread's res_add calls 42-56 -> 1.5-1.7 ms
in all, the frame 242-263 -> 224-232 ms.
- t_res_commit (new, Metal validation): res_add / res_remove do not wait
for a commit under way, res_commit waits for it, racing commits leave
nothing out of the set, a removed buffer lives until its commit.
- regress.py check (M4 Pro): OCTOPATH TRAVELER II with the encode thread
(DM_NVN_ENC_THREAD=1) and Mario Kart World on the direct path pass;
fps and frame p99 unchanged.
Co-authored-by: bymaxmarc <[email protected]>
pkg_upload_ reads a texture in a large pool (BIG_MIN), or in a pool no
address was given out in, through a zero-copy buffer of the upload batch
(up_big_src). After taking the texture's staging (up_alloc), which may
flush the batch, it made a second buffer for every texture, flush or not,
so each staged upload put its storage into the residency set twice.
It now records the batch (g_up_seq) when it makes the first buffer and
makes a second only when the batch changed.
- Switch Sports Resort's first court frame (855 textures, 908 MB, M2 Max,
PR #2378): up_big_src buffers 2,852-2,858 -> 1,429-1,437, residency
commits 678-692 -> 520-523 ms, the frame 263-270 -> 243-251 ms.
- Mario Kart World, 200 s regress route (M4 Pro): up_big_src buffers
24,696 (5,429 MB) -> 12,082 (2,424 MB); 60.0 fps and frame p99
unchanged.
- t_upload_src: one buffer per texture in one batch, one more for a
texture whose staging flushed its batch, every texel checked under
Metal validation; main's code fails 2 of its 41 checks.
- regress.py check: Mario Kart World and OCTOPATH TRAVELER II pass
(Octopath does not reach up_big_src).
Same cause found earlier in PR #2342.
Co-authored-by: bymaxmarc <[email protected]>
A new single-sample Depth16Unorm or Depth32Float texture is zeroed by buffer copies from the shared zero buffer, in pieces of rows that fit it, instead of a clear-only render pass (PR #2306). On an M3 Pro (18 GB, macOS 27.3) a clear pass on a large depth attachment ends in kIOGPUCommandBufferCallbackErrorOutOfMemory whatever memory is free, and the queue then fails every command buffer: Ocarina of Time makes a 12288x12288 Depth16Unorm (296 MB) and a 4096x4096 Depth32Float at each save load, and about half its loads there ended at the 32-failures stop (res_top_once). The PR author's standalone Metal 4 program failed clear passes on Depth32Float 4096x4096 and Depth16Unorm from about 5000x5000 up, and never a copy into the same textures up to 16384x16384. The cause is Apple's driver; the host now zeroes these textures the way that does not reach it. Every size is copied, not only 16 MB and more as in the PR: a copy writes the same zeros at any size, and the size where clear passes fail on other GPUs is unknown. A row is at most 64 KB and the zero buffer at least 4 MB, so a depth texture never grows it. Stencil formats and multisample textures keep the clear pass (a plain buffer copy cannot write them). The PR's second part, a one-second wait after an out-of-memory failure and at most three re-uploads per texture of a dropped upload, is left out: nothing measured it apart from the copies, and the cap could leave a static texture unwritten for good after transient failures. New reference entry (A clear pass on a large depth texture fails with Insufficient Memory), New textures start as zero updated, symptom index regenerated, a line in Ocarina of Time's note.
Checked (M4 Pro): t_zero_depth under the Metal validation layer, 55 checks, 0 failed (Depth16 and Depth32F from 17x5 to 16384x129, levels, layers, a cube, read back as zero on the GPU, and the copies a level takes; against the clear pass its copy counts fail); t_clear_ds, t_clear_msaa, t_direct_upload, t_linear_readback, t_view_swizzle, t_nvn; test_docs; regress.py check on OCTOPATH TRAVELER II against 547c5db6: PASS, 13,980 / 13,980 shaders, 0 changed MSL, 59.8 / 59.8 fps, p99 18.1 / 18.15 ms, no new red line (its depth_mode boot flag is the baseline's too); whether its depth targets reach the copies (its Unreal targets may be depth-stencil) was not seen. The PR author: 203 Ocarina of Time runs on the M3 Pro with their version (copies from 16 MB, with the retry throttle), none failed. Not run: Ocarina of Time on an M3 Pro with this commit, the iPhone
Co-authored-by: AmateurWizrd <[email protected]>
S2Arm (jhaizhou-ops/S2Arm #258, #305) saw kIOGPUCommandBufferCallbackErrorHang in 6 of 6
Ocarina of Time runs on an M1 Pro (macOS 27.0.1) when it punched its guest files during
play, and now never punches. Here (M4 Pro, macOS 27.2, the Kokiri Forest deck save, 8
minutes a run) a probe wrote, fsynced and punched unmapped alias-region pages of the
guest files the game uses: 36.5 GB in 2.39 million 16 KB punches and 49 GB in 140,000
whole-run punches, no command buffer error; four runs with the sweep itself had none
either. Frames over 1 s came with and without punching. The entry names what may
differ (machine and OS; S2Arm punched ranges the moment they were unmapped, the sweep
only pages given back a whole interval earlier) and the iPad run still to do.
- gsb_store / gsb_store_buf take block-compressed, 3D and linear storage (swz kernel); an upload waits while the command buffer being encoded holds a store into the texture (gsb_held)
- From a texture's first store its edge-page bytes live in a buffer the GPU writes too (pkg_edges_gpu), so a write beside it is not taken as a write into it: Minecraft Dungeons II re-uploaded 17-22 small textures without it, 0 with it
- The CPU landing cost 159-316 us a frame for Tears of the Kingdom's four targets (bench, M4 Pro)
- Tests: t_readback (hazards, edge bytes after a store), t_cpu_storage, t_nvn 6c3/6c4 through the queue; Octopath Traveler II regress PASS; Minecraft Dungeons II title to Squid Coast A/B against main