Skip to content

drm/asahi: g16: accept 48 KiB tile buffers on the M4 - #3339

Merged
DjDeveloperr merged 2 commits into
mainfrom
feat/g16-tile-buffer-48k
Nov 27, 2026
Merged

DjDeveloperr merged 2 commits into
mainfrom
feat/g16-tile-buffer-48k

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: on the M4 (G16G), let render commands use tile buffers of up to 48 KiB, as macOS does, and tell userspace with a new feature bit. Pairs with aurora-silicon/mesa#1194, which uses 48 KiB tiles only when the kernel reports the bit.

  • Per-chip limit: the g16 configuration now holds each chip's tile-buffer limit (max_tile_buffer): 48 KiB for T8132 (M4, G16G), 32 KiB as before for T6030 (M3 Pro, G15S) and T8122 (M3, G15G).
  • Admission: render admission checks a command's tile buffer (sample size × utile width × utile height × samples) against that limit instead of a fixed 32 KiB.
  • Feature bit: new DRM_ASAHI_FEATURE_TILE_BUFFER_48K, bit 46 (a #define after the enum, like bits 32–45). The g16 backend reports it only when the chip's limit is 48 KiB. The g15, g17 and g18 backends don't report it.
  • Basis: a hypervisor capture of Metal on macOS 26B123 on the J773g (deferred tile MSAA4 1080p pass): utile_config 0x6002 and tilebuffer_control 0x40018, which is 32×16 utiles at 4 samples and 24 × 2 KiB = 48 KiB per tile. 48 KiB is the value macOS uses. This PR does not claim it is the hardware maximum.
  • Why: at 32 KiB, Mesa has to use 16×16 utiles for such MSAA4 passes, which doubles the tile count, and the tiling half of the pass pays for it.

Tested: J773g (M4 Mac mini) at 2fc7c2147b28 with the paired Mesa change: the MSAA4 deferred rows are 4.8–5.3 % faster on the GPU, the Vulkan CTS run below has 0 failures, and there were 0 GPU faults. The second commit (f393918abe5b) only rewords the bit's comment in the UAPI header, with no code change, so these results stand for the head.

  • Setup: kernel 7.3.0-ARCH-m4kgtb48-2fc7c214 (main d3552efa + the first commit), built natively on the J773g. Mesa base aurora-wip 8ac326f vs the Mesa PR 7a5a930, both on this kernel, in one boot, in the order base, PR, PR, base. gpubench-vk 13.
row (lower is better) GPU µs, Mesa base → PR GPU time µs per submit
render.deferred tile 1080p MSAA4 d1 359.7 → 340.7 −5.3 % −2.3 %
render.deferred tile 1080p MSAA4 d2 355.2 → 338.1 −4.8 % −3.9 %
render.deferred dram 1080p MSAA4 d1 – −1.6 % −1.8 %
  • Probe: on this kernel the Mesa PR sees the bit and takes 32×16 tiles at 4 samples (24 B per sample).
  • Where the time goes: an earlier lab run with the same 48 KiB kernel limit (no feature bit; Mesa with the limit forced on) gave the same picture.
    • Tile MSAA4 was −5.0 % at d1 and −4.6 % at d2.
    • The tiling (vertex) part of the pass went from 66.2 to 47.5 µs; Metal takes 42.7 µs.
    • The fragment part was unchanged.
    • The MSAA1 deferred rows and postfx MSAA4 were within ±0.7 %.
  • Vulkan CTS, single worker, with the Mesa PR on this kernel: 26,422 cases (render-pass cases, pipeline.monolithic.multisample, renderpasses suballocation.formats, multisample_resolve). 19,678 pass, 6,744 not supported, 0 fail. 7,630 of these cases also ran on the lab kernel: 0 fail.
  • Faults: 0 GPU faults, recoveries or new kernel errors on the three boots of these kernels (this commit once, the lab kernel twice). After each, the Mac was back on its default kernel with 0 failed units.
  • Host: the asahi-m4 host selftests pass, 26/26 files, at both commits. checkpatch --strict is clean, with no new rustfmt hunks.
    • test-command-stream.py has a new admission test: a 32 KiB tile is accepted under both limits; a 48 KiB tile (24 B × 32×16 × 4 samples) is refused at 32 KiB and accepted at 48 KiB; a 56 KiB tile is refused under both.

Risk: two-way door (a plain revert undoes it) · Macs on the g16 backend (M4 G16G gets 48 KiB; M3 G15S/G15G stay at 32 KiB)

  • Scope: only the render tile-buffer check and one new feature bit. Userspace that doesn't know the bit keeps tiles at 32 KiB or less, as now.
  • If a 48 KiB tile were mishandled on the M4, MSAA4 passes that use it would render wrongly or fault. The CTS and gpubench runs above found neither.

Not yet:

  • A J516s (M3 Pro, G15S) row.
  • Whether G15S also takes 48 KiB (asked of the M3 side). Until a row shows it, T6030 and T8122 stay at 32 KiB.

macOS 26B123 runs MSAA4 render passes on the M4 (G16G) with 48 KiB
tiles: 32x16 utiles of up to 24 bytes per sample. The g16 backend
refused any tile buffer over 32 KiB, so Mesa has to fall back to
16x16 utiles for the same passes, which doubles the tile count of
a 1080p MSAA4 pass.

Keep the limit per chip in the g16 configuration: 48 KiB for T8132,
32 KiB for the M3 family (T6030, T8122) until each is shown to work
there. Report the higher limit as DRM_ASAHI_FEATURE_TILE_BUFFER_48K,
bit 46, so that userspace sizes tiles from what the kernel accepts.
The g15, g17 and g18 backends do not report the bit.

The 48 KiB value is the one macOS programs on this GPU; the hardware
may accept more, but this backend does not claim it.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 03:08
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at f393918a: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at f393918a
Conflicts ok none
PR text ok Risk: two-way · (a plain revert undoes it) · Macs on the g16 backend (M4 G16G gets 48 KiB; M3 G15S/G15G stay at 32 KiB) - Scope: only the render tile-buffer check and one new feature bit. Userspace that doesn't know the bit keeps tiles at 32 KiB or less, as now. - If a 48 KiB tile were mishandled on the M4, MSAA4 passes that use it would render wrongly or fault. The CTS and gpubench runs above found neither.

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Non-author review at 2fc7c2147b28: ready, 0 blockers. The code, UAPI and tests check out. CI and the M3 row are still owed.

Checked

  • UAPI bit: bit 46 is free. main defines bits 32–45 (45 is ORDERED_PARTIAL_RENDERS), and the only other open PR that touches asahi_drm.h (drm/asahi: g17: let an exhausted excuse end the blocker's allowance #2887) adds no feature bit.
  • Mesa side: mesa#1194 defines DRM_ASAHI_FEATURE_TILE_BUFFER_48K ((1ULL) << 46) under the same name. It reads the bit only on the native-imageblock path, and only for 4x 32×16 layouts that don't spill. M5 keeps its own 64 KiB path.
  • Compatibility: everything userspace could submit before is still accepted. A new Mesa on an old kernel sees no bit and stays at 32 KiB.
  • Per-chip limit: T8132 gets 48 KiB, and T6030 and T8122 stay at 32 KiB in Config. The g15 backend keeps its own 32 KiB MAX_TILE_BUFFER. g17 keeps 32 KiB, or 64 KiB on M5. Neither g15, g17 nor g18 reports the bit. params.rs derives the bit from the same Config value the check uses, so the two can't disagree.
  • Admission:
    • Both g16 render paths go through check_render_for(), and the only command::Context is built in g16/queue.rs from self.cfg.
    • The tile size is the product of four __u8 fields, so it can't wrap u32 (255⁴ < 2³²). Samples (1/2/4) and utile sizes (16/32) are still checked.
    • The limit is now 32768 bytes on the 32 KiB chips and 49152 on T8132.
  • Encoding: for the 48 KiB MSAA4 tile, tilebuffer_control is div_round_up(49152, 2048) | 2 << 17 = 0x40018, the value in the macOS capture. Nothing else in g16 is sized from the tile bytes: the tile map and TPC sizes follow the tile count.
  • Local checks in a scratch worktree:
    • checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
    • asahi-m4 host suite (run-host-tests.py): 26/26 pass, including the new tile_buffer_limit_follows_the_context.
    • rustfmt: no new differences in the touched files; the existing ones are already on main.
  • Branch and commit: the branch merges cleanly onto main ef29ad17facb. Nothing under drivers/gpu/drm/asahi, the UAPI header or the asahi-m4 selftests has landed since d3552efa9522. The commit is signed off, with no attribution.
  • Hardware at this exact head: J773g with mesa#1194: 0 CTS failures in 26,422 cases, 0 GPU faults, and the MSAA4 deferred rows 4.8–5.3 % faster on the GPU.

Before merge

  • CI at this head: 7/19 checks pass, 12 still running when this was posted; they need to finish green.
  • A J516s (M3 Pro, G15S) non-regression row. T6030 and T8122 go through the same g16 code and stay at 32 KiB.
  • Nits, not blocking:
    • The "Change:" and "Setup:" bullets in the PR body are empty.
    • The bit's comment says "instead of 32 KiB", but g17 admits 64 KiB on M5 without reporting the bit. "Without it, 32 KiB is the portable limit" would be exact.

The M5 path of g17 admits 64 KiB tile buffers without reporting
DRM_ASAHI_FEATURE_TILE_BUFFER_48K, so "instead of 32 KiB" in the bit's
comment is wrong there. Say that the bit is about the GPU that reports
it, and that 32 KiB is the portable limit without it. Comment only.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 27, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Re-review at f393918abe5b: READY, 0 blockers.

  • Delta: 2fc7c2147b28..f393918abe5b is a single commit. It rewords only the comment on DRM_ASAHI_FEATURE_TILE_BUFFER_48K in include/uapi/drm/asahi_drm.h (4 lines). Nothing outside the header changes, and the #define is unchanged. So the J773g rows and the host results at 2fc7c2147b28 still hold for this head.
  • Wording: "on this GPU … Without it, 32 KiB is the portable limit" is now exact for g17, which admits 64 KiB on M5 without reporting the bit. That closes my earlier nit.
  • Commit and PR body: checkpatch.pl --strict on the new commit gives 0 errors, 0 warnings, 0 checks. The commit is signed off, with no attribution. The branch still merges cleanly onto main 398e97133f99, and the PR body's "Change" and "Setup" bullets are now filled in.
  • CI at this head: 19/19 checks pass.
  • Still owed: the J516s (M3 Pro, G15S) non-regression row.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (MacBook Pro 16" M3 Pro, G15S) row at f393918abe5b: PASS. G15S stays at 32 KiB tile buffers. One-shot boot of the exact head on the default cmdline, with Mesa at mesa#1194's head 43bed29863dd; build ID 7.3.0-m3-maint-gf393918abe5b.

  • Feature word: DRM_ASAHI_FEATURE_TILE_BUFFER_48K is not reported. The features word is 0x0000010260005c07, bit 46 = 0.
  • gpubench-vk: mesa#1194 against its aurora-wip base 8ac326f31d4f, ABBA on this boot. 14 rows: render.deferred (tile and dram, msaa 1 and 4, d1/d2) and render.postfx (1440p msaa 1 and 4, 1080p msaa 4).
    • Geomean 1.001×.
    • The largest changes are +2.2 % on deferred tile msaa1 d1 (one slow base run) and −1.0 % on postfx 1440p msaa4 d1.
    • Deferred tile msaa4: d1 3,937 → 3,906 µs, d2 3,623 → 3,623 µs.
    • The GPU was at S8 (1,380 MHz) in 95 % of busy samples.
  • CTS at mesa#1194's head, one deqp-vk process, 2,076 multisample and resolve cases sampled evenly from renderpasses.renderpass{1,2}.*multisample*, renderpasses.dynamic_rendering.*multisample*, pipeline.*.multisample.* and api.copy_and_blit.*resolve*: 928 Pass, 1,148 NotSupported, 0 Fail.
  • 0 GPU faults or recoveries, 0 failed units, and no new kernel errors beyond this Mac's per-boot MTP HID line.
  • Clean reboot to stock, verified.

@DjDeveloperr
DjDeveloperr merged commit 9af21b0 into main Nov 27, 2026
19 of 21 checks passed
@DjDeveloperr
DjDeveloperr deleted the feat/g16-tile-buffer-48k branch November 27, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant