Repository navigation
drm/asahi: g17: tile small passes unclustered the way macOS does on the M4 Max - #2172
AxxzyWasTaken wants to merge 4 commits into
Conversation
|
The production boot stub pins at macOS 27.2 (26B123), so please retarget this to 27.2. The pass clustering here is matched to the 26.6.2 (25G83) GPU firmware; please check it against the T6041 GPU image the 27.2 stub loads. |
f06740f to
aacdae7
Compare
aacdae7 to
8231c04
Compare
|
Blockers: 2.
HW row: J616C (M4 Max) on this head over #2021, booted on the firmware the production boot stub loads. Run the same Roblox/Minecraft/SCP:SL session and a vkmark/dEQP-VK subset with and without this commit. Pass: 0 GPU recoveries, dEQP unchanged, fps equal or better, 0 AVC denials, 0 failed units, no new kernel errors. Also run one smoke boot on a 25F84 or 26B123 T6041 build showing that small passes still render after fix 1. Assisted-by: LLM (Claude:Opus 5.5) |
|
This branch sits on an earlier version of #2021. Its head is now 2ba7a68, and a test merge against it conflicts in seven files, so a rebase is needed before this can be tested as-is. After the rebase, |
|
Rebased onto Blocker 1 (resolved)
Blocker 2 (holding in Draft)Re-audited our macOS 26.6.2 ( Keeping this PR in Draft until Assisted-by: LLM (Google:Gemini 4 Neon) |
8231c04 to
df9e252
Compare
|
Re-checked at df9e252 (one commit on #2021's 2ba7a68). Blocker 1 is resolved: On blocker 2, your re-audit answers the question, and the answer is against the threshold. The same 1024x1024 (1,024 tiles) and 3091x1939 (5,917 tiles) passes appear both clustered and unclustered, so
Keeping it in draft until then is right. Assisted-by: LLM (Claude:Opus 5.5) |
|
Same-machine J616C (Apple MacBook Pro 16", M4 Max, 32-core T6041,
Verdict on Blocker 2This settles Blocker 2 decisively against a tile-count threshold:
Keeping Assisted-by: LLM (Google:Gemini 4 Neon) |
|
The updated head |
With four-cluster tiling the 32-core M4 Max runs vertex shaders on every cluster at once beside fragment work. Roblox (Vulkan) then hangs the GPU about once a minute: the firmware kills a small depth/stencil render as no-progress (reason 0), with no MMU fault and a nearly empty tiler heap. The same hang showed up on this Mac with the earlier driver until its render pool had 96 blocks. G17 firmware has no grow-request event for the USC render pool (unlike TVB growth) and a published render pool cannot be resized in place, so the pool must be sized up front. Rather than gating a fixed 96-block pool on T6041 and firmware build 25G83, derive the render pool minimum from GPU shape (active cores and cluster count) inside g17::fw::render_rt::required_blocks(), before adding ray-query scratch extras: - One- and two-cluster GPUs keep the 44-block floor (RENDER_BLOCKS), preserving the A18 Pro shared pool window invariant and the M4 Pro's narrow pool window unchanged. - Above two clusters, the base pool scales at 3 blocks (3 MiB) per enabled core, floored at RENDER_BLOCKS (44). Note that 3 blocks/core is an empirical fit from one 32-core J616C measurement (96 / 32), not a hardware-derived bound; the 40-core J614C value (120 blocks) has not been run on hardware yet. Because it keys on GPU shape, every >2-cluster G17 firmware build (including 25F84 and 26B123 on T6041) gets this floor, not only 25G83. - Ray-query scratch is added on top of this base instead of competing with it. Capacity cost in WIDE_LOWER (~3.19 GiB, shared with other lower-window allocations): queue creation allocates no VA or backing; backing is placed lazily on first render (~98 MiB span on J616C, ~122 MiB span on J614C, vs ~46 MiB before), reducing the simultaneously resident pool budget from 58 (MAX_EXECUTION_CONTEXTS) to roughly 33 on J616C and 26 on J614C. When WIDE_LOWER fills, submit enters wait_render_capacity() -> reclaim_render_capacity(), which evicts idle render pools via FreeListRelease and transparently re-arms them on next use. Only when more than ~33 (J616C) / ~26 (J614C) distinct contexts are simultaneously active for longer than QUEUE_WAIT_NS does a new submission fail with EBUSY, leaving existing contexts intact. J616C has run with 96 blocks daily since 16 Nov without hitting the cap. Resulting base render pool blocks (pages = [0, 0]): Part Clusters Cores Base blocks A18 / A18 Pro (T8140) 1 5/6 44 (unchanged) M4 (T8132, uses g16) 1 8/10 44 (if on g17) M4 Pro (T6040) 2 16/20 44 (unchanged) M4 Max 32-core (J616C) 4 32 96 (measured fix) M4 Max 40-core (J614C) 4 40 120 (untested) M5 (T8142, M5 pool path) 1 8/10 44 (unchanged) M5 Pro (T6050, M5 pool) 2 16/20 44 (unchanged) M5 Max (T6050, M5 pool) 4 32/40 96/120 (M5 uses own) M5 Ultra (T6050, M5 pool) 8 64/80 192/240 (M5 uses own) Add KUnit tests (asahi_g17_render_pool) covering these shapes, ray-query scratch addition, and invalid/oversized rejections. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
T6041 ran its 25G83 tiling passes in TA mode 1 (0x1c890 = 1), which tiles non-clustered: one of the four clusters runs the tiling and vertex work of a pass. Vertex shaders reached a quarter of the ALU rate of the GPU (2.95 vs 12.3 TFLOPS), and geometry-bound games were capped by it. Tile clustered instead on the 32-core T6041 (J616C) 25G83 build, while keeping the untested 40-core T6041 parts (J614C, J575C) on TA mode 1 until they have a hardware row. Clustered four-cluster passes receive: - Clustering metadata sized for more than two clusters, with metadata 2 at 0x1180 as macOS 26.6.2 writes on the 32-core M4 Max (metadata 2 at the M2 Pro/Max 0xc00 size allowed the tiler to write past it into metadata 3; metadata 3 and 4 keep their larger sizes). Because 25F84, 40-core 25G83, and 26B123 share RegisterPrograms::V25G83, four-cluster targets on those builds also receive the 0x1180 metadata 2 sizing while keeping TA mode 1 (non-clustered); that oversizing has not been booted on 25F84/26B123. - The four-cluster segment words of cluster_control(): 0x1c890 = 0x280540, 0x1c918 = 4, and v25g83_clustered_free_pages(clusters) = 28 + 16 * clusters free parameter-buffer pages in 0x1c9a8 (0x3c for two clusters, 0x5c for four, matching the macOS 26.6.2 capture). Two clusters keep the M4 Pro capture. - The full block table for Variant::tvb_normal_blocks on 32-core 25G83, because a clustered RD32 Minecraft frame needs about 1600-2200 blocks and never starts at the 0x45e default. 25F84, 40-core 25G83, and 26B123 keep TA mode 1 and the default heap maximum. Every other chip and build keeps its values. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Four-cluster passes size clustering metadata 1 as the M2 Pro/Max path does, 0x44 bytes per block of tiles, with 0x80, the two-cluster M4 Pro size, as the floor. On a 3456x2234 Retina frame (Minecraft RD32) that formula yields 0x100 (32x32 utiles) or 0x180 (16x16), and on 10240x10240 (point_size_10000, 16x16 utiles) it yields 0x1100. Because metadata 1 is the last sub-buffer in the TPC object, neither macOS's allocation size nor the hardware's written high-water mark was visible in the J616C 26.6.2 capture. Give it a conservative 16 KiB floor until measured, document the formula sizes on those frames, and add a KUnit test covering the four-cluster V25G83 metadata layout. (Because this keys on RegisterPrograms::V25G83 && clusters > 2, 25F84 and 26B123 on T6041 also get this conservative floor.) The per-block size stays the M2 Pro/Max formula; the floor is our own choice, not a macOS value. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…he M4 Max macOS 26.6.2 on the 32-core M4 Max clusters only some passes. The others keep the four-cluster segment control with bit 0 set (0x280541) and get no clustering buffers: the cluster tile maps and metadata 1-4 pointers are zero. Do the same for passes under 256 tiles; larger passes stay clustered. The 256-tile threshold is our own choice: which passes macOS clusters is not known. Derive cluster_pass once alongside the V25G83 segment words inside v25g83_segment_words() using the exact same condition that selects multi-cluster segment control (!ta_mode_1 && clusters > 2), so TA-mode-1 builds (25F84, 40-core 25G83, 26B123) and two-cluster layouts always keep cluster_pass == true and leave their segment and GTP registers unchanged. Add KUnit coverage in ta_mode_tests for small and large passes across TA mode 1, two-cluster, and four-cluster configurations. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
df9e252 to
4b26f80
Compare
|
Rebased onto the updated Assisted-by: LLM (Google:Gemini 4 Neon) |
|
Closing: live J616C A/B testing showed unclustered small-pass tiling regressed render performance by 3.57-3.72x. Assisted-by: LLM (Google:Gemini 4 Neon) |
Depends on #2021. This branch sits on #2021's branch, so GitHub shows #2021's four commits first; only the last commit belongs to this PR. I'll rebase it once #2021 lands.
With #2021, every four-cluster T6041 pass tiles clustered. In my macOS 26.6.2 (25G83) capture on this J616C, taken under a hypervisor while macOS ran a game, macOS clusters only some passes. The others keep the four-cluster segment control with bit 0 set (
0x1c890 = 0x280541) and get no clustering buffers: the cluster tile maps and the metadata 1-4 pointers are zero.This does the same for passes under 256 tiles (32x32); larger passes stay clustered. The 256-tile threshold is my own choice: I don't know macOS's rule for which passes it clusters. Two-cluster GPUs are unchanged.
Testing
All on a J616C (32-core M4 Max), 25G83:
M=drivers/gpu/drm/asahi), not booted as-is.tools/asahi/run-host-tests.py --only g17: 90/90. I couldn't run KUnit (no QEMU here).It conflicts in one line of
queue/render.rs(thegtp_vacall) with the PR for per-render clustering metadata. Whichever lands second needs a one-line rebase.Assisted-by: LLM (Anthropic:Claude Opus 5.5)