From 0d57bf0c9ac975076e415f977def3c88e8322fe0 Mon Sep 17 00:00:00 2001 From: Claudius Date: Mon, 23 Nov 2026 01:10:18 +0000 Subject: [PATCH] metal-ca: PanVK's direct indexed draws on by default (STARBITE_PANVK_CPU_MINMAX/CPU_DIRECT in mtl2-env) Measured on phone 2 (23 Nov, owner's root, same kernel image and console script, fresh boots): home-screen flicks 25.9 -> 29.8 fps, a Settings list 16.1 -> 22.1 fps, vertex/tiler chains 815-829 -> 366-369 us. METAL_CA_PANVK_DIRECT=0 leaves the two lines out. PERFORMANCE.md 9.1. --- docs/ios27/PERFORMANCE.md | 27 +++++++++++++++++-- .../fullroot/steps.d/metal-ca/80-metal-ca.sh | 12 ++++++--- .../mesa-ios/mesa26-panvk-cpu-direct.patch | 3 ++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/docs/ios27/PERFORMANCE.md b/docs/ios27/PERFORMANCE.md index 2f32e6e3f1..6309d926d5 100644 --- a/docs/ios27/PERFORMANCE.md +++ b/docs/ios27/PERFORMANCE.md @@ -499,8 +499,31 @@ The bench numbers of P0 and P2 do not compare: the script's phases fell differen **The helper was the vertex/tiler cost.** On the same frames the vertex/tiler chains take 55 % less time and the GPU 30 to 37 % less in the swipe windows. That is the first change of this series that moves the GPU. The trace's busy swaps in P2 were held 0 ms at the median, against 14 to 19 ms on every earlier boot: the GPU was no longer saturated in that ring. -What the swipe fps gains is NOT measured yet. The repeat pair (`base`, then `direct`, back to back) is requested from the -tester. Until then `STARBITE_PANVK_CPU_DIRECT` stays off by default. +What the swipe fps gains was measured on phone 2 on 23 November (below): +15 % on home-screen flicks, +37 % in a Settings +list; the switches are on by default since. + +**On phone 2 (23 November), and on by default since.** The repeat that section asked for, on the owner's own root +(iOS 27.2.1, 24B156; StarbiteMetal 7b0a598c unchanged), one fresh boot each with the same kernel image (L6bt's kernel and +line plus `sweetspeed` with 16384, `sweetfb_prof=1 sgu_prof=1`) and the same console script (30 s idle on the home screen, 20 +page flicks 1.2 s apart, Settings opened and its list flicked 16 times 1.5 s apart). The only difference: B0 had the 14 +November PanVK (cc241e55, without the two patches), B1 PanVK 22bd0c44 (mesa26-panvk-cpu-minmax + -cpu-direct, as +`tools/ios27/metal/mk-panvk27.sh` builds it) with `STARBITE_PANVK_CPU_MINMAX=1 STARBITE_PANVK_CPU_DIRECT=1` in mtl2-env. +Frames a second are the framebuffer's 5 s windows that lie inside each phase (`A5XELTE FB`, pauses between flicks included). + +| | B0 (as the owner had it) | B1 (direct) | +|---|---|---| +| idle home screen (the Clock icon's 10 Hz), vertex/tiler chain | 10.0 fps, 845 us | 10.0 fps, 490 us | +| **home-screen flicks** | **25.9 fps** (26.3, 25.7, 25.9) | **29.8 fps** (34.0, 28.9, 28.1, 28.1) | +| same, vertex/tiler chain average; fragment | 815 to 829 us; 923 to 945 us | 366 to 369 us; 962 to 969 us | +| same, GPU busy (10 s); the tick asleep for the frame's GPU work; SwapEnd held | 46 to 47 %; 12.7 to 13.8 ms; 6.3 to 6.9 ms | 33 to 38 %; 7.9 to 10.4 ms; 2.3 to 2.9 ms | +| same, SwapEnd to shown | 20 to 23 ms | 17 to 20 ms | +| **Settings list flicks** | **16.1 fps** (16.6, 15.7, 16.0) | **22.1 fps** (22.9, 21.4, 22.1) | +| same, vertex/tiler chain; tick asleep; SwapEnd to shown | 635 to 651 us; 35.6 to 37.2 ms; 43 to 45 ms | 320 us; 21.4 ms; 30 ms | + +The home screen and Settings drew correctly (icons, widgets, the glass dock and search field, the blurred bar); no GPU +fault or `FAILED` line, no backboardd exit, Wi-Fi up, the same crashes as B0 (locationd, chronod). So +`tools/ios27/fullroot/steps.d/metal-ca/80-metal-ca.sh` now writes both switches into mtl2-env (`METAL_CA_PANVK_DIRECT=0` to +leave them out). The fragment chains did not move: they are what is left of a busy frame (section 9). ## 10. Re-pinning the bridge to upstream metal2vulkan (18 November; `M2V_REPIN=1`, opt-in, built) diff --git a/tools/ios27/fullroot/steps.d/metal-ca/80-metal-ca.sh b/tools/ios27/fullroot/steps.d/metal-ca/80-metal-ca.sh index 02d1a85689..9a086220db 100755 --- a/tools/ios27/fullroot/steps.d/metal-ca/80-metal-ca.sh +++ b/tools/ios27/fullroot/steps.d/metal-ca/80-metal-ca.sh @@ -3,7 +3,11 @@ # ENABLE_METAL_CA=1 (default): # - installs this build of StarbiteMetal.bundle (PanVK's kernel shim asks for asynchronous submits and answers timeline # queries truthfully; the frontend has the SWEET_MTL2_FLUSH cache-maintenance policy) -# - /private/var/local/mtl2-env: SWEET_MTL2_DEXR=1, SWEET_MTL2_FLUSH=2, STARBITE_DRM_LEAKS=0 (other lines kept) +# - /private/var/local/mtl2-env: SWEET_MTL2_DEXR=1, SWEET_MTL2_FLUSH=2, STARBITE_DRM_LEAKS=0 (other lines kept), and +# STARBITE_PANVK_CPU_MINMAX=1, STARBITE_PANVK_CPU_DIRECT=1 (PanVK records an indexed draw as a direct draw, without the +# helper compute job before it: vertex/tiler GPU time -55 %, home-screen swipes +15 %, a Settings list +37 % on phone 2, +# docs/ios27/PERFORMANCE.md 9.1); METAL_CA_PANVK_DIRECT=0 leaves those two out (a PanVK built without +# mesa26-panvk-cpu-minmax/-cpu-direct ignores them either way) # - /private/var/local/mtl2-clients = exactly $METAL_CA_CLIENTS (default "backboardd"): the list is the gate, a process # that is not on it gets no Metal device. Every Metal client wires >= 57 MiB of GPU memory when its device is made, so the # poster renderers are NOT on it by default; to give ONE of them Metal: METAL_CA_CLIENTS="backboardd CollectionsPoster". @@ -38,9 +42,11 @@ if [[ $ON == 1 ]]; then put "$F/StarbiteMetal.bundle/Info.plist" "$B/Info.plist" 644 put "$F/StarbiteMetal.bundle/_CodeSignature/CodeResources" "$B/_CodeSignature/CodeResources" 644 chown -R 0:0 "$B" 2>/dev/null || true - # mtl2-env: these three lines, once each, whatever else is there - T=$(mktemp); grep -v '^SWEET_MTL2_DEXR=\|^SWEET_MTL2_FLUSH=\|^STARBITE_DRM_LEAKS=' "$L/mtl2-env" > "$T" || true + # mtl2-env: these lines, once each, whatever else is there + T=$(mktemp); grep -v '^SWEET_MTL2_DEXR=\|^SWEET_MTL2_FLUSH=\|^STARBITE_DRM_LEAKS=\|^STARBITE_PANVK_CPU_MINMAX=\|^STARBITE_PANVK_CPU_DIRECT=' \ + "$L/mtl2-env" > "$T" || true printf 'SWEET_MTL2_DEXR=1\nSWEET_MTL2_FLUSH=%s\nSTARBITE_DRM_LEAKS=0\n' "${METAL_CA_FLUSH:-2}" >> "$T" + [[ ${METAL_CA_PANVK_DIRECT:-1} == 1 ]] && printf 'STARBITE_PANVK_CPU_MINMAX=1\nSTARBITE_PANVK_CPU_DIRECT=1\n' >> "$T" cmp -s "$T" "$L/mtl2-env" || cat "$T" > "$L/mtl2-env"; rm -f "$T" case " $CLIENTS " in *" backboardd "*) ;; *) CLIENTS="backboardd $CLIENTS";; esac same "$CLIENTS" "$L/mtl2-clients" diff --git a/tools/ios27/mesa-ios/mesa26-panvk-cpu-direct.patch b/tools/ios27/mesa-ios/mesa26-panvk-cpu-direct.patch index 43c90536aa..80160e1d7d 100644 --- a/tools/ios27/mesa-ios/mesa26-panvk-cpu-direct.patch +++ b/tools/ios27/mesa-ios/mesa26-panvk-cpu-direct.patch @@ -2,7 +2,8 @@ PanVK (JM), Starbite (iOS): with STARBITE_PANVK_CPU_DIRECT=1 (off by default; wi whose index range the CPU found (mesa26-panvk-cpu-minmax's sb_cpu_minmax, which the switch turns on too) is recorded as a direct draw: the IDVS (or vertex + tiler) job gets its indices, range and offsets when the draw is recorded, exactly as libpan's panlib_draw_indexed_indirect_helper would write them, and no helper compute job, no job-prefetch suppression and no -dependency come before it. docs/ios27/PERFORMANCE.md section 9. NOT run on a phone. Applied by tools/ios27/metal/mk-panvk27.sh +dependency come before it. docs/ios27/PERFORMANCE.md section 9.1 (run on phone 2, 23 November: vertex/tiler time -55 %; on by default in the +root's mtl2-env since, steps.d/metal-ca/80-metal-ca.sh). Applied by tools/ios27/metal/mk-panvk27.sh after mesa26-panvk-cpu-minmax. --- a/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c 2026-11-18 13:00:27