Skip to content

borealis: use 48 KiB tile buffers where the kernel admits them - #1194

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
perf/borealis-tile-buffer-48k
Nov 27, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
perf/borealis-tile-buffer-48k

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown

What

On chips with the native imageblock, a render's tile buffer was capped at 32 KiB. The 4x G-buffer pass of
gpubench-vk render.deferred has five render targets, 24 bytes a sample, so it fit only 16x16 tiles. That is four
times the tiles a single-sample pass bins: on J773g its vertex phase took 66 µs, against 35 µs at 1x for the same
8192 triangles.

Kernels that report the new DRM_ASAHI_FEATURE_TILE_BUFFER_48K (bit 46) admit tile buffers of up to 48 KiB. When
the bit is set, a 4x layout that then takes 32x16 tiles with every target resident uses the 48 KiB budget. Here that's
the deferred G-buffer pass.

  • Every other layout keeps the 32 KiB budget, and so does every kernel without the bit.
  • The fragment SPECLM imageblock record refused tiles over 32 KiB, and with it the pass's background program. Its
    encoding is the same for 48 KiB, so it now takes up to that size. The tilebuffer layout already keeps a render
    within what its kernel admits.
  • The budgets are named constants (AGX_NATIVE_TILE_BUFFER_BYTES, AGX_NATIVE_TILE_BUFFER_48K_BYTES). There's no
    chip check: the larger budget follows the kernel's feature bit.

Why only that shape: a first version took 48 KiB for every layout. Eight RGBA32 targets at 2x spill under either
budget, but at 48 KiB six of them stay resident instead of four. The native background and end-of-tile programs take
at most four raw 32-bit targets, so those renders failed with VK_ERROR_FEATURE_NOT_PRESENT (15 CTS cases, below).

Our trace of the same workload on macOS on J773g showed 32x16 tiles at 4x with 24-byte samples, a 48 KiB tile buffer,
and the same SPECLM record this change produces (77 00 aa 06 43 00 00 00). The new test checks that record.

The kernel side is the g16 change that admits 48 KiB and reports the bit: aurora-silicon/linux#3339.

Tested

J773g (M4 Mac mini, G16G B0), gpubench-vk 13 (ae90a40). Mesa overlay via VK_DRIVER_FILES, Vulkan-only release
builds. Base 8ac326f31d4f (aurora-wip), candidate 7a5a930e0727.

Head 43bed29863dd adds a host unit test on top of the candidate and changes no driver code, so the rows below are
for the driver at head.

  • Fedora build with tests: meson test --suite asahi 212/212.
  • Tilebuffer.NativeTileBuffer48KLayouts (new, at head) checks the two layouts the change chooses between. The 4x
    G-buffer targets take 16x16 tiles at 32 KiB and 32x16 at 48 KiB (exactly 49,152 bytes), both with nothing spilled.
    Eight 2x RGBA32 targets spill under either budget, with four resident at 32 KiB and six at 48 KiB. Tilebuffer 21/21.
  • asahi-agx-ioto-state-core: the new SPECLM test passes. 32x16 / 24 B / 4x encodes the record above, and 64, 96
    and 56 KiB tiles are refused with the output untouched.
  • Offline G16G drm-shim run of all 84 gpubench-vk plan tests with the 48 KiB budget enabled: the render tile sizes of
    exactly two rows change, deferred tile msaa4 and dram msaa4, from 16x16 to 32x16 at 24 B/sample. Every other row
    keeps its tiles.

On the paired kernel (7.3.0-ARCH-m4kgtb48-2fc7c214, the g16 PR head, which reports bit 46), base and candidate:

  • The candidate saw the bit. The deferred tile msaa4 render took ms=4 tile=32x16 tib=24B.
  • CTS at --jobs 1: 26,422 cases from renderpasses.*.{suballocation,dedicated_allocation}.{attachment,multisample},
    *attachment_allocation*, *local_read*, pipeline.monolithic.multisample, renderpasses.*.suballocation.formats
    and *multisample_resolve*. Result: Pass 19,678, NotSupported 6,744, Fail 0. 0 kernel fault lines, GPU health clean.
  • gpubench, mirrored N P P N (2 runs per arm), medians, all checks valid:
row GPU µs base → candidate µs/submit base → candidate
deferred tile msaa4 d1 359.7 → 340.7 (−5.3 %) 595.2 → 581.4 (−2.3 %)
deferred tile msaa4 d2 355.2 → 338.1 (−4.8 %) 351.6 → 338.1 (−3.9 %)
deferred dram msaa4 d1 1479.0 → 1454.6 (−1.6 %) 1785.7 → 1754.4 (−1.8 %)

Earlier A/B on a lab kernel with the same 48 KiB limit but no feature bit. It ran the first version of this change
(48 KiB for every layout), which gives both deferred passes the same 32x16 layout. Mirrored N T T N N T T N, 4 runs
per arm:

row GPU µs base → candidate µs/submit
deferred tile msaa4 d1 / d2 359.8 → 341.9 (−5.0 %) / 354.9 → 338.5 (−4.6 %) −2.9 % / −3.5 %
deferred dram msaa4 d1 / d2 −1.5 % / +0.2 % −1.4 % / +0.3 %
controls: deferred tile/dram msaa1, postfx 1080p msaa4 d1/d2 −0.4 … +0.7 % −0.4 … +0.6 %
  • Per pass (HK_FRAME_ANATOMY_TS=all), the vertex/tiling phase drops 66.2 → 47.5 µs (tile) and 68.2 → 42.2 µs
    (dram). Fragment time is unchanged, 293.4 → 293.9 µs.
  • In the same lab session, the first version (48 KiB for every layout) failed 15 CTS cases:
    renderpasses.*.multisample_resolve.r32g32b32a32_{sfloat,sint,uint}.max_attachments_8_samples_2. They failed alone
    on it every time and passed on the base. This version keeps those layouts at 32 KiB, and the run above includes them.

Risk: two-way · Macs whose kernel reports DRM_ASAHI_FEATURE_TILE_BUFFER_48K: M4 G16G with the paired g16 kernel. Without the bit nothing changes, including G17P (A18 Pro, whose g17 kernel backend keeps 32 KiB) and the M3 family until its kernel reports the bit.

Not yet:

  • A J516s (M3 Pro, G15S) row. It should show no change while its kernel doesn't report the bit.
  • G17P (A18 Pro) is unaffected until its g17 kernel backend admits 48 KiB and reports the bit. That would come with its
    own row.

A render's tile buffer on chips with the native imageblock was capped at
32 KiB. With the five render targets of a 4x deferred G-buffer pass (24-byte
samples) that leaves 16x16 tiles, so the pass bins four times the tiles of a
single-sample one, and its vertex phase took 66 us instead of 35 us on J773g
for the same 8192 triangles.

Kernels that report DRM_ASAHI_FEATURE_TILE_BUFFER_48K admit 48 KiB tile
buffers. When the bit is set, a 4x layout that then takes 32x16 tiles with
every target resident uses that budget: the deferred pass above. Other
layouts keep the 32 KiB budget. Taken for every layout, the larger budget
mostly keeps more targets of a spilling layout resident, in shapes the
native background and end-of-tile programs refuse: eight 2x RGBA32 targets
keep six resident where they take four, and the render fails with
VK_ERROR_FEATURE_NOT_PRESENT. Kernels without the bit keep today's layouts.

The fragment SPECLM imageblock record refused any tile over 32 KiB, which
also refused the background program of such a pass. Its encoding is the same
for 48 KiB, so let it take up to the 48 KiB budget; the tilebuffer layout
already keeps a render within what its kernel admits. A new test checks the
32x16, 24-byte, 4x record against our own trace of that pass on J773g and
that larger tiles stay refused.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Author

Verdict at 7a5a930e0727: ready

I found no blocker. Without the new feature bit, every layout and every record is byte-identical to before. With the bit, the wider budget is taken for one shape only: 4x, 32x16 tiles, nothing spilled. The SPECLM record for that shape matches the macOS trace.

Blockers

none

Checked

  • UAPI. DRM_ASAHI_FEATURE_TILE_BUFFER_48K is (1ULL) << 46 here and in linux#3339's include/uapi/drm/asahi_drm.h.
    • On linux main the highest feature bit in use is 45 (ORDERED_PARTIAL_RENDERS), so 46 is free.
    • This copy of the header doesn't define bits 41, 44 or 45, but nothing collides with 46.
    • The kernel side reports the bit only when gpu.cfg.max_tile_buffer >= TILE_BUFFER_48K, which only the g16 config sets.
  • Without the bit (old kernels, T6030/G15, G17P, T8122, every chip whose kernel doesn't report it): hk_tilebuffer_layout() skips the new block and builds with AGX_NATIVE_TILE_BUFFER_BYTES (32768), the old literal under a name.
  • With the bit. The block is reached only after the G18G and HAL300/M5 early returns, and only with agx_chip_native_imageblock(), so on G15, G16G or G17P.
    • It builds a 48 KiB layout and keeps it only for nr_samples == 4 && tile_size == 32*16 && !agx_tilebuffer_spills(); everything else falls back to the 32 KiB layout.
    • At 4x the 2048-sample cap already limits tiles to 32x16, so the budget changes only 17-24 byte samples, from 16x16 to 32x16. The tile is at most 49152 bytes.
    • With nothing spilled, it doesn't reach the spill shapes the background and end-of-tile programs refuse, which were the source of the 15 earlier CTS failures.
  • SPECLM (agx_ioto_g17p_fragment_speclm_build()). The ceiling rises from 32768 to AGX_NATIVE_TILE_BUFFER_48K_BYTES for both callers.
    • Graphics programs take the render's layout, which only exceeds 32 KiB when the bit allowed it.
    • The compute caller builds 32x32 × 1 sample × image_block_size_per_thread_agx, which util_format_get_blocksize() sets in all three producers (hk_cmd_meta.c 1242 and 2730, agx_blit.c 224). That is at most 16 B, or 16 KiB, so the raised limit changes nothing there.
  • Build and tests, in a separate shallow clone (aarch64 host, debugoptimized, -Dvulkan-drivers=asahi -Dbuild-tests=true):
    • it builds, with no warnings in the changed files;
    • meson test --suite asahi: 212/212 OK, including asahi-agx-ioto-state-core; --suite poly: 5/5 OK;
    • test_g17p_fragment_speclm checks the traced record 77 00 aa 06 43 00 00 00 for 32x16/24 B/4x, and that 64, 96 and 56 KiB tiles are refused with the output left untouched;
    • putting the SPECLM limit back to 32 KiB fails the test.
  • Small test gap (not blocking). No unit test covers the layout choice itself. A host test of hk_tilebuffer_layout()'s decision would pin it: 4x 24 B gives 32x16 with the bit and 16x16 without, and 2x eight RGBA32 targets stay on 32 KiB.
  • Merge and text. It merges cleanly with the current aurora-wip (49fd873a1d10). Signed-off-by DjDeveloperr, with no attribution lines.

Merge gates

  • Ordering with linux#3339. Mesa is safe to merge first, since nothing changes until a kernel reports bit 46. If linux#3339 lands with a different bit, this header has to follow, so merging the kernel PR first, or confirming bit 46 is final, keeps the two in step.
  • Hardware rows. The target row is J773g (G16G) on the paired kernel, which reports the bit; it's in the PR body. Without the bit the code path is unchanged on every other chip, so no second-generation row is needed for correctness. The J516s row under Not yet is a no-change confirmation, and G17P gets its own row when its kernel reports the bit.
Evidence
head 7a5a930e072787963f51f6f641a904da66c3167c, merge-base 8ac326f31d4f, merge-tree clean with aurora-wip 49fd873a1d10

mesa  include/drm-uapi/asahi_drm.h:490   #define DRM_ASAHI_FEATURE_TILE_BUFFER_48K ((1ULL) << 46)
linux#3339 (2fc7c2147b28) include/uapi/drm/asahi_drm.h   #define DRM_ASAHI_FEATURE_TILE_BUFFER_48K ((1ULL) << 46)
linux main uapi: highest feature bit 45 (DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS)

hk_tilebuffer_layout(): G18G/HAL300 return first; imageblock && (features & TILE_BUFFER_48K)
  -> wide 48 KiB layout kept only if nr_samples == 4 && tile_size == 32*16 && !spills
compute SPECLM: 32x32 x 1 x ALIGN(image_block_size_per_thread_agx = format blocksize <= 16 B, 8)

meson test --suite asahi   -> Ok: 212, Fail: 0 (asahi-agx-ioto-state-core OK)
meson test --suite poly    -> Ok: 5, Fail: 0
mutation: SPECLM limit 32 KiB -> asahi-agx-ioto-state-core exit 1

hk_tilebuffer_layout() builds a layout with the 48 KiB budget when the kernel
reports DRM_ASAHI_FEATURE_TILE_BUFFER_48K and keeps it only when it is 4x,
32x16 and spills nothing. Pin the layouts it chooses between: the 4x G-buffer
targets of a deferred pass take 16x16 tiles at 32 KiB and 32x16 at 48 KiB with
nothing spilled, while eight 2x RGBA32 targets spill under either budget, with
four of them resident at 32 KiB and six at 48 KiB.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 43bed29863dd

Blockers:
None in the code change. The paired kernel and stock-kernel peer results still need to be recorded before promotion.

Checked: Matched the feature bit, units and 48 KiB ceiling with linux#3339. The old-kernel path retains 32 KiB. The larger layout requires four samples, a 32x16 tile and no spill. The only change since the tested Mesa head adds a unit test for the 32/48 KiB layout and spill boundaries.

Evidence

The posted J773g paired-kernel CTS reports 19,678 passes and zero failures. The paired kernel's current head differs from the tested head. Carry its result only after checking equivalent runtime blobs, and record a no-bit peer run on the current stock kernel.

@RyanTheTide

Copy link
Copy Markdown

Merge status at 43bed29863dd: the code is approved and the J773g paired-kernel row is in. One ordering item is left. DRM_ASAHI_FEATURE_TILE_BUFFER_48K (bit 46) is not in any kernel we ship: aurora-silicon/linux main stops at bit 45 (ORDERED_PARTIAL_RENDERS), and linux#3339, which reserves 46, is still open. Merging the UAPI number into Mesa before the kernel takes it risks a collision if another kernel PR claims 46 first. Without the bit this change is a no-op: the layout and SPECLM output are unchanged, and the only no-bit difference is the SPECLM refusal limit, which the 32 KiB layout never reaches. Plan: merge this right after linux#3339 lands. If you'd rather land it now and move the bit if needed, say so here.

@DjDeveloperr

Copy link
Copy Markdown
Author

J516s (MacBook Pro 16" M3 Pro, G15S) row at 43bed29863dd: PASS. G15S keeps 32 KiB tile buffers, the same as the base. Kernel: linux#3339 at f393918abe5b, one-shot boot. It doesn't report DRM_ASAHI_FEATURE_TILE_BUFFER_48K on G15S (features 0x0000010260005c07, bit 46 = 0). Base: aurora-wip 8ac326f31d4f, this PR's merge base. Both are isolated kits built on the Mac.

  • gpubench-vk ABBA on one boot (base, PR, PR, base), 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 this 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.

@DjDeveloperr
DjDeveloperr merged commit 21b6920 into aurora-wip Nov 27, 2026
@DjDeveloperr
DjDeveloperr deleted the perf/borealis-tile-buffer-48k branch November 27, 2026 21:13
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