metal: tables residency per encoder by default (a set kept all of title memory resident) #76
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!76
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@AeroUp on GitHub · 2026-11-26 13:42 UTC · original
AeroUp:fix/metal-residency-sets→main· +21 −10 · 3 files · 3 commits · merged 2026-11-26 17:08 UTCWhat
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.@LakshanSivakumar on GitHub · 2026-11-26 14:54 UTC · original · requested changes
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.
@AeroUp on GitHub · 2026-11-26 16:12 UTC · original
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.@LakshanSivakumar on GitHub · 2026-11-26 16:37 UTC · original · 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.
@LakshanSivakumar on GitHub · 2026-11-26 16:38 UTC · original
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.
@AeroUp on GitHub · 2026-11-26 16:48 UTC · original
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.@LakshanSivakumar on GitHub · 2026-11-26 17:08 UTC · original
Merged in
8c47ddd. The docs now nameVICTORY_METAL_RESIDENCY_SETS, and your merge of main resolved the conflict. Thanks!