bluseliu50 9e651a52c7 fix: keep the shader cache inside Metal's cache directory
In the user cache directory the pipeline cache now sits in com.apple.metal/m2v. A sandboxed process may write there whenever its profile lets Metal cache shaders. macOS's iconservicesagent could not write <cache>/m2v (thousands of denials), compiled every pipeline again at each launch and was killed at its memory limit within seconds, over and over. Not run on hardware yet.
9e651a52c7 · 2026-11-10 15:51:45 +08:00
262 Commits
…
…
2026-11-10 12:00:00 +08:00

AdrenoMetal

Metal frontend through metal2vulkan and Turnip.

The frontend uses metal2vulkan and Turnip with the kernel GPU interface and selected OS ABI. GPU composition has been verified on sheng with A740.

All clients use single-sample rendering by default. NATIVE_METAL_SINGLE_SAMPLE=0 preserves a process's requested sample counts; 1 forces single-sample rendering. Texture types, pipeline sample counts and resolve outputs follow the selected policy. Same-user clients share writable shader caches. Resource aliasing, swizzles, range copies, function constants, specialized link names and allocation queries reach the runtime. Queue priorities aggregate current live requests without a process-name policy.

Build and interface details: documentation. Component sources and dependencies: catalog.

Memory reuse

Unused owned image backing is reused by pooled and dedicated images. Extra spares have no byte limit, expire after ten seconds, and go sooner under memory pressure or when a new block cannot be made. Blocks are freed off the releasing thread on the runtime's free thread, and on the releasing thread once its queue is full. An allocation failure releases kept spares and waits for posted frees before retrying. Imported memory and owner callbacks keep their release ordering.

Frame diagnostics

With gpu-trace=1, the render server writes command phases, encoding batches, attachments and Turnip pass timings to its frame trace. Kernel event 63 identifies the render, encode and completion threads. In iconservicesagent, event 65 records the Metal device and queue, then up to eight completed command buffers containing draws or dispatches. Each work record includes the command buffer status and draw and dispatch counts. GPU frame diagnostics

wallpaper-freeze=1 enables wallpaper isolation. A Poster renderer freezes GPU submission after a successful command draws into and stores an IOSurface of at least two million pixels. The completed output stays retained. Later commands remain committed and unscheduled, with their resources and queue leases retained. Already submitted work completes normally. PosterBoard and other processes keep submitting. The switch defaults to off; NATIVE_METAL_FREEZE_WALLPAPER=1 selects the same mode directly in a renderer process.

metal-flow=1 enables the runtime's lowering thread, commit submission and pipeline warm pass for testing. The switch defaults to off. Either value of metal-flow= logs the FL counts to os_log when they change.

Slow encoding operations retain source lines and enqueue times. Completion handlers and resource destructors carry individual timing and identities. Kernel sampling of the render, encode and completion threads and blocked-thread waits provide the cross-thread wait record.

python3 scripts/check-wallpaper-freeze-host.py in the resolved tree checks real pixels, callbacks, concurrent parked submissions and process selection.

The macOS plugin entry (the IOGPUMetalDevice subclass), the layout of block-compressed textures and WindowServer's frame pacing options follow macOS-DroidVM, the DroidVM port booted with UniXNU.

S
Description
No description provided
Readme MIT 15 MiB
Languages
Objective-C++ 55.5%
Rust 17.3%
C++ 13.7%
Objective-C 6.9%
C 3.8%
Other 2.7%