Skip to content

drm/asahi: g17: tile small passes unclustered the way macOS does on the M4 Max - #2172

Draft
AxxzyWasTaken wants to merge 5 commits into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:pr/t6041-small-passes-unclustered
Draft

AxxzyWasTaken wants to merge 5 commits into
aurora-silicon:integration/aurorafrom
AxxzyWasTaken:pr/t6041-small-passes-unclustered

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • My daily module since 16 Nov, with drm/asahi: g17: tile clustered on the 32-core M4 Max (T6041 25G83) #2021 and other work that isn't in this PR. That build ran Roblox (Vulkan) for 11+ minutes with 0 GPU recoveries, Minecraft (Sodium, OpenGL) at ~450 fps at RD32, and, since today's fix for the metadata copies, SCP:SL.
  • Never A/B tested on its own: I haven't compared fps or stability with and without it.
  • This branch: built (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 (the gtp_va call) with the PR for per-render clustering metadata. Whichever lands second needs a one-line rebase.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

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.

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, with what a four-cluster pass needs:

- Clustering metadata sized for more than two clusters, as the M2
  Pro/Max path sizes it (meta1 per block of tiles, meta2-4 fixed).
- The four-cluster segment words of cluster_control(): 0x1c890 =
  0x280540, 0x1c918 = 4, and 32 + 16 x clusters = 0x60 free parameter
  buffer pages in 0x1c9a8. The two-cluster capture (0x200440 / 4 /
  0x3c) stays for two clusters.
- A per-build tiler heap normal maximum: the four-cluster 25G83 build
  may use every slot of the block table. A clustered RD32 Minecraft
  frame needs about 1600-2200 blocks; at the 0x45e normal maximum the
  pass never starts and the firmware recovers with reason 0.

25F84 keeps TA mode 1, and every other build keeps its values.

Measured on the J616C (32-core M4 Max, 25G83): vertex-shader ALU 2.95
-> 10-11.5 TFLOPS; Sodium-style terrain 1.93 -> 0.68 ms per frame with
identical images; Minecraft RD32 105 -> ~300 fps, with no GPU
recoveries over several sessions, heavy and concurrent stress included.
G17 host tests 31/31.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
With four-cluster tiling the 32-core M4 Max runs vertex shaders on every
cluster at once. 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.

Give firmware variants a smallest render pool, 44 blocks as before, and
96 for T6041 25G83. Owners grow to it on their first render, as they grow
for ray-query scratch.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…them

macOS 26.6.2 on the 32-core M4 Max (25G83), captured under a hypervisor
while running a game, spaces a clustered pass's tiler metadata 2, 3 and 4
0x1180, 0x1400 and 0x1600 apart and writes 0x5c free parameter-buffer
pages. Metadata 2 was 0xc00, the M2 Pro/Max size, so the tiler could
write past it into metadata 3. Use 0x1180 and 0x5c; metadata 3 and 4 keep
their larger sizes.

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. Metadata 1 is the last sub-buffer, and the macOS
26.6.2 capture on the M4 Max does not show its size. Give it a 16 KiB
floor instead.

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.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/t6041-small-passes-unclustered branch from aacdae7 to 8231c04 Compare November 21, 2026 09:48
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

  1. drivers/gpu/drm/asahi/g17/queue/render.rs:551-553 and 573-582: cluster_pass depends only on self.clusters <= 2. The zeroing of gtp[1], [4], [5], [6] and [7] therefore runs on every four-cluster pass under 256 tiles, including passes on T6041 builds that run TA mode 1. In fw/render.rs:760 the four-cluster segment control, and so the control | 1 at :773, is chosen only for !args.ta_mode_1. But Layout::new (buffer/target.rs:128) allocates the gtp sub-buffers for every RegisterPrograms::V25G83 variant. V25F84 and V26B123 (fw/variant.rs:233-247) inherit V25G83's programs, and hw/t6041.rs:113 and :136 set ta_mode_1: true. So on 25F84, and on 26B123 (the 27.2 firmware), small passes now get 0x1c041/0x1c9d0, 0x1c948 and 0x1c888 written as 0 while the tiler still runs in mode 1 with segment control 1. Nothing on those builds has been tested with that, and it contradicts "every other build keeps its values". Derive cluster_pass from the same condition that selects cluster_control(): true unless !variant.ta_mode_1 && clusters > 2 && small. Better, decide it once in fw/render.rs and return it with the segment words. Add a ta_mode_tests case with ta_mode_1: true, clusters: 4 and a small pass that asserts the gtp registers are unchanged.
  2. queue/render.rs:686 CLUSTERED_MIN_TILES = 256 is a threshold the commit says is a guess ("which passes macOS clusters is not known"). The change has not been booted on its own and has no A/B. As it stands it changes the tiling mode for most small passes on the M4 Max with no measurement that this helps or is safe. Either show which property of the pass the 25G83 capture correlates with (for example, the passes that kept 0x280541 against their tile counts), or bring a same-machine A/B on this head: frame time and stability, plus GPU recoveries, with and without the commit.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants