Repository navigation
Support the macOS 27 address-space layout - #11
Conversation
macOS 27 leaves no room for the fixed guest layout: the shared cache fills 0x1_8000_0000..0xF_C000_0000 (where stack and heap were searched for) and the system reserves ~24 GiB at a randomized place in 0x70_0000_0000..2^39, so the 64 GiB alias region at 0x70_0000_0000 cannot be reserved and startup fails. Keep the fixed layout when it fits (macOS 26). Otherwise place stack, heap and alias region side by side in one free hole below 2^39, as the iOS layout does, shrinking the alias region in 4 GiB steps down to 8 GiB. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
I'm on macOS 27.0.1 (M4 Pro) too, so this fix matters here. I've been running the game with a local allocator that fixes the same problem a different way: it searches for the alias region first, then stack and heap below it, and only shrinks the alias region when
Suggestion: only shrink when the size is the default. If |
|
感谢贡献! |
The side-by-side fallback shrank the alias region from TOTK_ALIAS_GIB down to 8 GiB, so an explicit size below 8 always failed and a larger one could be lowered without notice. Only the default size shrinks now; an explicit size is tried as given and the start fails naming the variable if it does not fit. The loop also no longer subtracts below the smallest size. Reported by @RVZO6 in ly05010419#11. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks @RVZO6, you're right on both points. Fixed in a396e2d, following your first suggestion:
The loop is also restructured so it can't subtract below the smallest size, because an explicit value under 4 GiB would otherwise have wrapped. The docs say so too. Booted the packaged app on macOS 27.0 (M4 Pro), with the result taken from the
The macOS 26 path (the fixed layout at |
Resolved against the iOS layout change (alias_len / alias_requested). An explicit TOTK_ALIAS_GIB now pins one size on the side-by-side fallback, as on iOS: it is no longer rejected below 8 GiB or silently reduced, and a size that does not fit fails with its own message. Only the default size shrinks in 4 GiB steps down to 8 GiB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…inear BC rows Three layout rules now match the original NVN driver (found by digitalhivehub for nxnative, PR #11 98fc8a0 / bacf2cb; checked here against 15 original-driver shapes): - CUBEMAP_ARRAY depth already counts layer-faces: the size and the upload were six times too large, and Metal's arrayLength is depth / 6 cubes. - Packaged layout byte 0: the low nibble is log2 block height, the high nibble log2 block depth; 3D textures ignored the packaged block depth before. - Linear textures count pixel rows, also for compressed formats. In TOTK 1.4.3 the two 4x4 cube arrays now report 0xc00 bytes, as the driver does (0x4800 before); the grass save and the quick menu look the same as before. The texture layout probe adds the 15 driver shapes; the old code fails the cube case. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XEAgjWRRPcUigVLG8vrbv5
…inear BC rows Three layout rules now match the original NVN driver (found by digitalhivehub for nxnative, PR ly05010419#11 98fc8a0 / bacf2cb; checked here against 15 original-driver shapes): - CUBEMAP_ARRAY depth already counts layer-faces: the size and the upload were six times too large, and Metal's arrayLength is depth / 6 cubes. - Packaged layout byte 0: the low nibble is log2 block height, the high nibble log2 block depth; 3D textures ignored the packaged block depth before. - Linear textures count pixel rows, also for compressed formats. In TOTK 1.4.3 the two 4x4 cube arrays now report 0xc00 bytes, as the driver does (0x4800 before); the grass save and the quick menu look the same as before. The texture layout probe adds the 15 driver shapes; the old code fails the cube case. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XEAgjWRRPcUigVLG8vrbv5 (cherry picked from commit 3c482a7)
Summary
On macOS 27 the game stops at startup with
FAIL: reserve the 64 GiB alias region at 0x70_0000_0000. macOS 27 lays out the address space below 2^39 differently:0x1_8000_0000..0xF_C000_0000, which is where the 6 GiB stack and heap were searched for.0x70_0000_0000..2^39on every launch, so a fixed 64 GiB reservation at0x70_0000_0000never fits. EvenTOTK_ALIAS_GIB=16fails on some launches.This PR keeps the fixed macOS 26 layout whenever it fits. When it doesn't,
memory_inituses the approach the iOS layout already takes: stack, heap and the alias region go side by side in one free hole below 2^39. The alias region shrinks in 4 GiB steps, down to 8 GiB, until it fits; the game uses less than 3 GiB of it. The size reported to the game comes from the samealias_size(), so the game sees the size that was actually reserved.macOS 26: the original
reserve_fixed(ALIAS_SPACE_AT, …)path runs first and is unchanged. The fallback runs only when that path fails. The only other change makes the cachedalias_size()value adjustable.Testing
FAIL: reserve the 64 GiB alias region at 0x70_0000_0000on every launch.guest layout: alias 0x7d00000000+0x300000000 stack 0x7b90000000+0x10000000 …(12 GiB)guest layout: alias 0x7180000000+0x500000000 stack 0x7010000000+0x10000000 …(20 GiB)first presented frameand kept running and translating new shaders.【红】预排布贴图存储不在内存池里,回退 CPUline appeared once after the first frame.mtl_addris a pool-index lookup that doesn't depend on where the guest regions sit, so I don't think it's related, but I couldn't compare it with a macOS 26 run.The layout was measured with a small
mach_vm_regionprobe; the details are in the docs paragraph added todocs/how-it-works.md.中文摘要:macOS 27 的共享缓存占满
0x1_8000_0000..0xF_C000_0000,系统还在0x70_0000_0000..2^39的随机位置保留约 24 GiB,固定布局无法预留,启动即失败。本 PR 在固定布局可用时(macOS 26)保持不变;否则像 iOS 布局一样把栈、堆和别名区放进同一个空洞,别名区按 4 GiB 递减到最少 8 GiB。已在 macOS 27.0.1 上启动到第一帧;未在 macOS 26 上复测。🤖 Generated with Claude Code