Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,3 @@ __pycache__/

# the loader S-Boot starts, as built (tools/ios27/s9/build-loader.sh)
/xnuloader/sboot/out/
tools/ios27/fullroot/warm-m2v/
28 changes: 0 additions & 28 deletions docs/ios27/METAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,3 @@ profile of the textured case the per-draw path is spread over the runtime (`draw
thirds of `end_pass` for scissors that differ every draw (it marks the bin grid one tile at a time; a draw whose scissor
covers the whole pass skips it, as most of CoreAnimation's main-pass draws should). The M1 runs this single-threaded code
several times faster than the S9's M3 at 1794 MHz.

## Shader compiles: off the UI, bounded, shared and warm (19 Nov 2026)

What an iOS 27 boot on the S9 showed (phone 2, `con-xnu-boot-L4-1118-2103.log`): every Settings open compiled the same 24 522-NIR compute
shader (250 224 bytes) for 24 to 28 s on one core with the GPU idle and the UI stalled; Preferences then began a fragment shader of 3 023
NIR instructions that never ended (Preferences at 130 %, launchd at 40 %, for more than three minutes). The causes and what changed:

| Cause | Change |
|---|---|
| PanVK compiled on the thread that asked for the pipeline, and the completion-handler `new...PipelineState` calls ran the compile on the caller too | `patches/frontend-async-compile.diff`: a compile runs on a worker (three at a time, QOS utility); the synchronous calls wait for it at most `STARBITE_M2V_COMPILE_TIMEOUT_MS` (default 5000, 0 = for ever) and then fail like a refused pipeline, the compile going on in the background and its result waiting for the next request of the same pipeline (key: the functions' bit-code hashes and the state; while one is still running a repeat waits 100 ms, and with four such compiles running, 200 ms); the completion-handler calls return at once. A pipeline whose compile failed after more than 10 s is not tried again for 10 minutes |
| A compile with no end: Bifrost's register allocator spills a node (or, past four rounds, up to 32) per round and rebuilds the interference graph each time | `mesa26-panvk-compile-budget.patch`: `STARBITE_PANVK_COMPILE_BUDGET_MS` (default 90 000, 0 = none) is a wall-clock budget of one compile; the allocator's rounds, its LCRA solve and its liveness loop check it and leave the compile by `longjmp`; the pipeline fails (`PANVK: ... abandoned after N ms (compile budget)` on the console) |
| One cache directory per program (`/var/local/m2v-cache/<progname>`), so only backboardd's was ever filled, a sandboxed program fell back to its own caches directory, and Preferences or SpringBoard never saw what another had compiled | `patches/hotmetal2-shared-cache.diff`: one directory per user, `/var/local/m2v-cache/u<uid>` (the runtime's files are owner-only), for every process; `STARBITE_M2V_CACHE=/dir` (mtl2-env) names another |
| The directory was made by the first process to run, with nobody to ship anything in it | `steps.d/81-m2v-cache.sh` makes `/var/local/m2v-cache` (0777), removes the per-program directories, and installs a warm cache (below) |

**A warm cache.** The runtime's entries are named by content: translated functions and pipelines under `v1/<build>/` (the build is the
bridge library's), PanVK's pipeline data in the content directory beside them (named by the SPIR-V, the pipeline state and PanVK's cache
UUID, `driver.rs`). PanVK itself cannot compile on the Mac for the Mali-G72 (it needs the kernel's GPU), so a warm cache is harvested from a
phone: boot the bundle that will ship, open Settings, Display, Appearance (Liquid Glass), the app switcher and Control Center until the
`PANVK: ... NIR instructions` lines stop, copy `/private/var/local/m2v-cache` off, run `tools/ios27/metal2/harvest-m2v-cache.sh PULLED`
(it keeps the newest build directory and the content directory of each `u<uid>/`, into `tools/ios27/fullroot/warm-m2v`, which is not in git),
and build the root: step 81 installs it, owner-only, owned by the uid. It holds for that bundle and that PanVK (about 33 MB); another
build finds none of it and compiles as before.

**Format 500 is `MTLPixelFormatYCBCR8_420_2P`** (metal2vulkan's `generated.rs`), not an unknown format: the runtime has it (`pixel_format_info.rs`,
`bind/ycbcr_convert`, converted in the shader), and the frontend's texture over an IOSurface passes the surface's YCbCr matrix on. The
`texture memory fmt 500` line is that path (`how` is "memory" for textures over an IOSurface or a buffer: they have no device upload, by
design, so no `texture device` line follows), and nothing was refused. Why the reference image did not draw is not in that log: the pipelines that sample it may simply not have been made yet (the compute and
fragment compiles above were still running), which the two changes above address; a phone run of the new bundle will say.
44 changes: 0 additions & 44 deletions tools/ios27/fullroot/steps.d/81-m2v-cache.sh

This file was deleted.

147 changes: 0 additions & 147 deletions tools/ios27/mesa-ios/mesa26-panvk-compile-budget.patch

This file was deleted.

2 changes: 1 addition & 1 deletion tools/ios27/metal/mk-bundle27.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rm -rf "$B" && mkdir -p "$B" $W/sym $W/stage
# the frontend and HotMetal2 are built from a copy with patches/frontend-dexr.diff, hotmetal2-diag.diff, frontend-flush.diff and
# frontend-turned.diff, frontend-dexr-surfaces.diff, frontend-nocopy-diag.diff, frontend-passlog.diff and frontend-nocopy-readonly.diff applied, in that order (NOPATCH=1: as they are in tools/ios27/metal2)
rm -rf $W/src27 && mkdir -p $W/src27/tools/ios27 && cp -R tools/ios27/metal2 $W/src27/tools/ios27/
[ -n "${NOPATCH:-}" ] || for p in frontend-dexr hotmetal2-diag frontend-flush frontend-turned frontend-dexr-surfaces frontend-nocopy-diag frontend-passlog frontend-nocopy-readonly frontend-async-compile hotmetal2-shared-cache; do patch -s -p1 -d $W/src27 < tools/ios27/metal/patches/$p.diff || exit 1; done
[ -n "${NOPATCH:-}" ] || for p in frontend-dexr hotmetal2-diag frontend-flush frontend-turned frontend-dexr-surfaces frontend-nocopy-diag frontend-passlog frontend-nocopy-readonly; do patch -s -p1 -d $W/src27 < tools/ios27/metal/patches/$p.diff || exit 1; done
M2=$W/src27/tools/ios27/metal2
# frontend-turned.diff includes TurnShaders.inc: tools/ios27/metal2/TurnShaders.metal (the pass that writes a turned texture into its
# surface) compiled by the same Xcode's Metal compiler and held as bytes
Expand Down
3 changes: 1 addition & 2 deletions tools/ios27/metal/mk-panvk27.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ SB=${SB:-$(cd "$(dirname "$0")/../../.." && pwd)}
# The libvulkan_panfrost.dylib of phone 1's c2 bundle (cc241e55..., 14 November) was built from exactly these patches, with the
# shim of that day, except for the two braces mesa26-panvk-batch-stats.patch restores in panvk_vX_cmd_query.c.
PATCHES="mesa26-panvk-ios mesa26-panvk-null-vs mesa26-panvk-shader-size-cap mesa26-bifrost-ra-multispill mesa26-panvk-host-images
mesa26-panvk-tiler-heap-halves mesa26-panvk-batch-stats mesa26-panvk-cpu-desc-copy mesa26-panvk-cpu-minmax mesa26-panvk-cpu-direct
mesa26-panvk-compile-budget"
mesa26-panvk-tiler-heap-halves mesa26-panvk-batch-stats mesa26-panvk-cpu-desc-copy mesa26-panvk-cpu-minmax mesa26-panvk-cpu-direct"
# mesa26-panvk-cpu-desc-copy (18 November): the descriptor copies on the CPU at submission with STARBITE_PANVK_CPU_DESC=1 (off
# without it), and the draw and copy counters of the shim's statistics line (docs/ios27/PERFORMANCE.md section 7).
# mesa26-panvk-cpu-direct (18 November): with STARBITE_PANVK_CPU_DIRECT=1 an indexed draw whose range the CPU found is recorded
Expand Down
Loading
Loading