Repository navigation
asahi: keep every M5 colour attachment in the tilebuffer - #948
Merged
Merged
Conversation
The M5 profile drew a framebuffer with more than one colour attachment either an attachment at a time, each pass a render of its own that reloads and stores the depth attachment, or in one pass that keeps attachment 0 in the tilebuffer and has every fragment load and store the other attachments as images. Both cost far more than the draw: a render of four RGBA8 attachments ran at a third of the speed Borealis reaches on the same M5 for the same work. Borealis keeps all of them in the tilebuffer: one background program clears or reloads each attachment and one end-of-tile program stores each through its own PBE (hk_build_m5_mrt_bg_eot). Both drivers take those shaders from agx_bg_eot.c, so Gallium only needs their admission and argument layout: - agx_g17g_mrt_resident_layout admits what hk_m5_mrt_layout_supported does for a single-sample layout: two or more attachments that all fit in the tilebuffer, each with a multi-target end-of-tile store class, in a layout agx_g17p_classify_mrt names. It reads only the formats and the sample count, so the batch's layout, its epilogs and the framebuffer fetches compiled for it agree. - agx_build_native_g17g_mrt_bg_eot passes the dense PBE table and the per-target tile offsets to the end of tile, and the per-attachment clear colours and reload textures to the background, as Borealis does. - Such a batch lays every attachment out in the tilebuffer, and its draws and clears run once. The native draw records only see whether there is colour, so the draw profile admits the batch. Multisampled, layered and other multi-attachment framebuffers keep the previous paths. The single-attachment tile programs are unchanged; their Ioto program tail and reload sampler move into helpers the multi-target programs share. A no-op DRM shim test draws into four RGBA8 attachments on G17S and checks the layout, the single draw, the multi-target end of tile and that the M5 submission gate accepts the render. Signed-off-by: Diljit Singh <hey@djdev.me>
A batch that keeps every M5 colour attachment in the tile (agx_g17g_mrt_resident) gives its fragment epilog one tile store per attachment. The compiler orders those stores and selects their pixel classes by the framebuffer's tile partitions, which it takes from the epilog key (agx_compile_nir_tile). Only the multisample epilog builder passed that key, so a single-sample one was compiled without partitions. That works while the epilog stores the attachment at byte 0 of the tile, but not otherwise: on M5 a masked attachment keeps its contents through a tile load/store pair (preserve_zero_mask), and when the attachment at byte 0 is not stored, for example in a clear through a quad of another attachment, the ordering pass declines and the packer refuses the whole fragment program. Indexed draw buffer conformance tests with mixed integer formats then dropped their draws. Pass the epilog key for a single-sample M5 epilog too. The epilog that keeps only attachment 0 in the tile (rt0_resident) has a single partition and is unchanged, as are the other chips. The no-op DRM shim test of the resident layout now also draws into eight slots of mixed formats with two empty ones: a clear through a quad of each attachment and a draw under partial colour masks. Without this change those fragment programs are refused. Signed-off-by: Diljit Singh <hey@djdev.me>
satchlj
approved these changes
Nov 24, 2026
satchlj
left a comment
Member
There was a problem hiding this comment.
Verdict at c9396a6f5c02
APPROVED
Blockers
None
Checked
- Audited
agx_g17g_mrt_resident_layout(),agx_g17g_fb_mrt_resident(),agx_compile_variant(),agx_update_fs(),agx_build_meta_shader_internal(), andagx_build_native_g17g_mrt_bg_eot()insrc/gallium/drivers/asahi/agx_state.c,agx_clear()inagx_pipe.c,agx_batch_init()inagx_batch.c, and the new tests insrc/gallium/drivers/asahi/tests/test-agx-m5-mrt-resident.c. - Verified layout admission (
active >= 2, single-sample, single-layer, non-spilling 32x32 tile, validagx_g17p_mrt_eot_selectorper attachment) matchesagx_bg_eot.c's multi-target background (textures[2 * rt],clear_base + 8 * rt,clear_base = loads ? 8 : 4) and EOT (active_count >= 2dense PBE table atu0, per-target tilebyte offsets atu4 + 4i) argument layouts, and confirmedagx_nir_fs_epilogreceives tile partitions when!rt0_resident. - Built and ran the non-layout
asahitest suite (254/254 PASS, includingasahi-g17s-m5-mrt-residentandasahi-g17s-kernel-m5-mrt-residentwith0refused programs at the M5 gate) plus live Gallium Asahi GLES3 FBO/MRT/blend/clear CTS (351/351 PASS) and Borealis Vulkan compute smoke on Apple M5 Max (G17C B1), Linux 7.3 withMESA_SHADER_CACHE_DISABLE=1and0GPU faults indmesg. - Untested scope: Full GLES3/KHR-GL30 draw-buffers CTS sweep and
asahi_layout_tests(pre-existing GCC C++20 designator-order error insrc/asahi/layout/tests/test-layout.cpp:374).
Evidence
meson test --suite asahi(non-layout):254/254 PASS(0 FAIL)asahi-g17s-m5-mrt-resident:OKasahi-g17s-kernel-m5-mrt-resident:OK(shim: M5 gate: 15 submits, 15 renders, 0 computes, 45 render programs, 0 compute programs; 0 refused)
- Live Gallium Asahi GLES3 + Borealis Vulkan CTS on Apple M5 Max (
G17C B1), Linux 7.3 (MESA_SHADER_CACHE_DISABLE=1,GL_RENDERER = Apple M5 Max (G17C B1),0GPU faults indmesg):dEQP-GLES3.functional.fbo.color.repeated_clear.*:108/108 PASS,0 FAILdEQP-GLES3.functional.fbo.color.tex2d.*:36/36 PASS,0 FAILdEQP-GLES3.functional.draw_buffers_indexed.*:76/76 PASS,0 FAILdEQP-GLES3.functional.fbo.color.blend.*:14/14 PASS,0 FAILdEQP-GLES3.functional.fbo.color.clear.*:36/36 PASS,0 FAILdEQP-GLES3.functional.fbo.completeness.attachment_combinations.*:81/81 PASS,0 FAILdEQP-VK.compute.pipeline.basic.*:80/81 PASS,0 FAIL,1 NotSupported
|
Verdict at Blockers: None. The mainline build repairs described in the PR are now merged as Mesa #944. The current exact review adds the M5 Max row. Checked: Exact fork build and policy CI passed. On M5 Max G17C, the independent review measured 351/351 Gallium FBO, blend, clears and draw-buffer cases with zero GPU faults. The M5 Pro G17S row carries both changes unchanged through the context-only rebase and passed 76/76 draw buffer and 302/302 FBO cases. Its timings compare whole composed builds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: The M5 GL profile drew a framebuffer with two or more colour attachments either one attachment per render pass, or with attachment 0 in the tilebuffer and every fragment loading and storing the others as images, both far slower than the draw. This keeps every attachment of a single-sample layout that fits in the tile resident, with one background and one end-of-tile program built from the shared
agx_bg_eot.cshaders in the same argument layout Borealis uses, and passes the tile partitions to the single-sample M5 epilog so masked or partial attachments still compile.Tested: J714s M5 Pro (G17S B1) on the composed test build
git-dba993db23, which carries these two commits (rebased here with context-only changes):dEQP-GLES3.functional.draw_buffers*76/76 pass,fbo.color.*302/302 pass, 0 GPU/MMU faults. A 4×RGBA8 1440p render runs 2.16× faster at queue depth 4 (564.33 → 261.78 µs) and 1.82× at depth 1 (706.21 → 388.80 µs). New shim tests pass in mirror CI on this head (links under Evidence).Risk: two-way · M5 family (G17G, G17S, G17C); the Gallium driver only, single-sample multi-attachment framebuffers.
Not yet: an isolated hardware re-run with only these commits on
aurora-wip(the rows above come from the composed build), if reviewers want one; no G17G or G17C row.Details
1/2
asahi: keep every M5 colour attachment in the tilebuffer. Borealis already keeps all attachments in the tilebuffer on M5: one background program clears or reloads each attachment and one end-of-tile program stores each through its own PBE (hk_build_m5_mrt_bg_eot). Both drivers take those shaders fromagx_bg_eot.c, so Gallium only needs their admission and argument layout:agx_g17g_mrt_resident_layout()admits whathk_m5_mrt_layout_supported()does for a single-sample layout: two or more attachments that all fit in the tilebuffer, each with a multi-target end-of-tile store class, in a layoutagx_g17p_classify_mrt()names. It reads only the formats and the sample count, so the batch's layout, its epilogs and the framebuffer fetches compiled for it agree.agx_build_native_g17g_mrt_bg_eot()passes the dense PBE table and per-target tile offsets to the end of tile, and the per-attachment clear colours and reload textures to the background.Multisampled, layered and other multi-attachment framebuffers keep the previous paths. The single-attachment tile programs are unchanged; their Ioto program tail and reload sampler move into helpers the multi-target programs share.
2/2
asahi: give a resident M5 multi-target epilog its tile partitions. The compiler orders a fragment epilog's tile stores and picks their pixel classes from the framebuffer's tile partitions in the epilog key (agx_compile_nir_tile). Only the multisample epilog builder passed that key. That works while the epilog stores the attachment at byte 0 of the tile, but on M5 a masked attachment keeps its contents through a tile load/store pair (preserve_zero_mask), and when the byte-0 attachment is not stored (for example a clear through a quad of another attachment) the ordering pass declined and the packer refused the whole fragment program. Indexed draw-buffer conformance tests with mixed integer formats then dropped their draws (4 of 76 failed with 1/2 alone). The single-sample M5 epilog now gets the key too; the attachment-0-only epilog (rt0_resident) has a single partition and is unchanged, as are the other chips.Tests (no-op DRM shim,
asahisuite).asahi-{g17s,g17s-kernel}-m5-mrt-resident:g17s-kernelpasses every submission through the M5 kernel's checks and fails on a refused one.No runtime switches, environment variables or new chip gates; admission uses the existing
agx_chip_g17_m5().Evidence
aurora-wip387af5e6a02(Merge agx,borealis: share SSBO vectorization, bounded CSE, loop spill room, and canonical minmax across chips #941):644036a4928asahi: keep every M5 colour attachment in the tilebuffer (clean cherry-pick)c9396a6f5c02dc9b180921eac8f168880279d68fasahi: give a resident M5 multi-target epilog its tile partitionsaurora-wipmoved thecompile_samplesblock ofagx_build_meta_shader_internal()intoagx_prepare_meta_nir(). 2/2 keeps that and adds only its epilog-key selection, passed toagx_compile_nir_tile().git range-diffagainst the tested commits shows context-only differences in both commits; the added code is identical.DjDeveloperr/mesa, temporary branch, exact commitc9396a6f5c0):asahi(build plus the asahi test suite): run 45404046369 success, 269 OK / 0 fail, includingasahi-g17s-m5-mrt-residentandasahi-g17s-kernel-m5-mrt-residentaurora-agent-policy: run 45404046168 successaurora-wiptip: these commits rebase onto0e7919d41cf(Merge borealis,asahi: enable hardware indirect index bounds on G17P #760) without conflicts (git range-diff: all=) as60bbebbe707, and merge cleanly into the newerf9b9a5435cf.asahithere: run 45416655413, 277 OK / 1 fail. The one failure,asahi-agx-chip-caps(2 of 366 checks,AGX_CAP_NATIVE_PREAMBLEon G16G andAGX_CAP_VDM_INDIRECT_INDEX_BOUNDSon G17P), fails identically on0e7919d41cfalone (run 45418268129); no file of this PR is involved.Hardware: Apple M5 Pro (J714s, G17S B1, AGX3C)
git-dba993db23(OpenGL ES 3.2 Mesa 26.3.0-devel (git-dba993db23)), system Mesa untouched,MESA_LOADER_DRIVER_OVERRIDE=asahi.git-8956dffd84, which has neither commit; it differs from the tested build by more than this PR, so the timing ratio is an end-to-end figure for the composed builds. An earlier composed build with 1/2 only gave the same timings (261.78 µs at depth 4, 389.41 µs at depth 1).GLES3 CTS (
deqp-runner,deqp-gles3,-j 4, pbuffer 256×256,rgba8888d24s8ms0):dEQP-GLES3.functional.draw_buffers*dEQP-GLES3.functional.fbo.color.*Four RGBA8 render targets at 2560×1440 (bandwidth microbenchmark,
MESA_SHADER_CACHE_DISABLE=1, status ok, 0 stderr errors):A 70-row GL microbenchmark suite on the same build: 70/70 ok, 0 Mesa stderr lines, 0 kernel faults or warnings.