metal: tables residency per encoder by default (a set kept all of title memory resident) #76
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/76"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AeroUp on 2026-11-26T13:42:02Z.
What
Heap residency currently goes through one
MTLResidencySetper heap (addAllocationon everywrite_*,useResidencySeton every command buffer). A set never forgets an allocation, and the title names thousands of textures and buffers in its descriptor heaps, so the set held all of title memory plus every host texture copy resident for the whole process. On my Mac that is what turned intokIOGPUCommandBufferCallbackErrorTimeoutafter the world load (and, with the host's texture copies,kIOGPUCommandBufferCallbackErrorOutOfMemory), followed by the known0xc0000005 at image+0x55e56f8.This flips the default to per-encoder
useResource(the existing fallback path) and keeps the set path behindVICTORY_METAL_RESIDENCY_SETS=1.Measured (M3 Pro, 18 GB, macOS 27.2.1, Series S profile, 1920x1080 layer)
The process is x86_64 because it runs the game's x86_64 code in-process; Rosetta translates the CPU side only and the Metal backend is native (no D3D12 or Wine translation). The DXIL converter is D3DMetal's
libmetalirconverterbecause Apple's Metal Shader Converter is not installed on this machine.The 4K world's first frames still stall (~20 s) and the title's own watchdog then ends the process; that is a separate problem and this change does not claim to fix it.
Testing
cargo build --release --target x86_64-apple-darwin(Metal backend, the host build) clean.crates/victory-metal/testsrun in both modes (common::backends()) and pass.Notes
If you would rather keep sets on for speed on bigger machines, an alternative is to prune the set (remove replaced entries and targets) — that is the "not done" in
docs/metal-backend.md. Until that exists, this default avoids a failure mode that looks like a hung GPU.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T14:54:56Z.
Review: CHANGES_REQUESTED
Thanks. Since this flips the default to per-encoder residency, please update docs/native-host.md (~448), which still names VICTORY_METAL_NO_RESIDENCY_SETS, and document the new VICTORY_METAL_RESIDENCY_SETS switch there.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AeroUp on 2026-11-26T16:12:44Z.
Done in
563de87:docs/native-host.mdno longer namesVICTORY_METAL_NO_RESIDENCY_SETS; the ruled-out note now namesVICTORY_METAL_RESIDENCY_SETS=1, and a short paragraph there says which path is the default and why (a set never forgets an allocation, so it holds all of title memory plus the host's texture copies, which ends inkIOGPUCommandBufferCallbackErrorTimeout). Pruning the set is listed as not done, as indocs/metal-backend.md.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:37:58Z.
Review: DISMISSED
Docs now name VICTORY_METAL_RESIDENCY_SETS and the new default. Merged onto main, victory-metal and the native tests pass, clippy and policy are clean, CI is green.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:38:52Z.
Approved, but main has moved and this now conflicts (docs/native-host.md). Please merge main into the branch and I will merge it right after.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AeroUp on 2026-11-26T16:48:06Z.
Merged
upstream/maininto the branch. One conflict indocs/native-host.md, resolved by keeping both sides: upstream's new "views of memory in no pool" bullet and this PR's residency paragraph usingVICTORY_METAL_RESIDENCY_SETS=1. Release build ofvictory-metalforx86_64-apple-darwinis clean.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T17:08:38Z.
Merged in
8c47ddd. The docs now nameVICTORY_METAL_RESIDENCY_SETS, and your merge of main resolved the conflict. Thanks!