Skip to content

asahi,hk: scan out compressed interchange on Gen9 descriptors (8-bit and 10-bit) - #183

Merged
DjDeveloperr merged 2 commits into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/gl-interchange-scanout
Nov 25, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/gl-interchange-scanout

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 7, 2026 •

Copy link
Copy Markdown

What:
Enable compressed APPLE_INTERCHANGE scanout on Gen9 2D compression chips (G17P / M4 Max, M5) across Asahi Gallium and extend compressed interchange scanout to 10-bit RGB (XRGB2101010 / ARGB2101010 / XBGR2101010 / ABGR2101010) in both Asahi Gallium and Borealis Vulkan:

  • Commit 1 (828bbb5955a4): Allow Gen9 2D compression chips to advertise and scan out compressed APPLE_INTERCHANGE buffers in Asahi Gallium, guarding fast-clear and cross-chip storage-image constraints cleanly.
  • Commit 2 (ec791567c7d0): Extend compressed interchange scanout support to 10-bit RGB formats in both Asahi Gallium and Borealis Vulkan (asahi,borealis: rebased cleanly past mesa#641, mesa#745, and mesa#978 onto aurora-wip 9a21c0c6220a).

Tested:

  • Host clang unit tests (-Db_ndebug=false, at ec791567c7d0): 194/194 PASS (0 failed).
  • J616C M4 Max (T6041 / G17P, 7.3.0-j616c-p3dcp+, Display P3 10-bit XRGB2101010 active on eDP-1, installed to /opt/aurora-mesa, libgallium PT_TLS=56B, dlopen OK):
    • Native Asahi Gallium GL/EGL (git-ec791567c7): OpenGL 4.6 (Core & Compatibility) + OpenGL ES 3.2 on Apple M4 Max (G16C B1); glmark2-wayland [build] 6209 FPS / [shading] 5772 FPS (score 5989).
    • Borealis Vulkan (git-ec791567c7, MESA_SHADER_CACHE_DISABLE=true): render.deferred d=1,2 (229.2 us, valid=true, crc=2cfe9a54), render.postfx d=1,2 (valid=true, crc=4707efa8), compute.conv2d d=1,4 (valid=true, crc=2d55a14d), compute.uber d=1,4 (valid=true, crc=9963f56c).
    • Regression tuple: 0 GPU faults in dmesg, 0 failed system/user units, max-health.sh PASS.

Not yet:

  • Second-Mac (M5 / Neo) GL + Vulkan 10-bit scanout smoke row at ec791567c7d0.

Risk:
two-way · Gen9 2D compression Macs (M4 Pro/Max G17P, M5, Neo) running compressed scanout and 10-bit RGB display output (plain revert restores uncompressed scanout).

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from 100959a to fc75496 Compare November 17, 2026 21:24
@AxxzyWasTaken

AxxzyWasTaken commented Nov 17, 2026 •

Copy link
Copy Markdown
Author

Rebased onto current aurora-wip (4ad5457); the code applied without conflicts. One change: test-layout's interchange check (added in October) expected the window-system pitch to be the macroblock row, ceil(w/16) * 1024. This PR hands out the per-pixel-row pitch because appledrm's drm_gem_fb_create() checks (height - 1) * pitch + width * 4 against the buffer, so the test now expects that and checks the bound. 14427d3 doesn't overlap: with MESA_EGL_WL_SCANOUT set it asks for LINEAR only, otherwise nothing changes. Build and 138/138 asahi unit tests pass; still a draft until it's re-measured on this base.

Disclosure: prepared with an AI tool (the commit carries Assisted-by: LLM); tested on my M4 Max as described.

@RyanTheTide

Copy link
Copy Markdown

Thanks for the rebase and the pitch/bounds test. Since this applies to every G17P machine, we can run the interchange path on an A18 Pro and an M4 Pro (internal panel, offscreen GL checks, a scroll/power before-and-after on the current base) if you'd like rows from more than the M4 Max. Just say when the head is final.

@RyanTheTide

Copy link
Copy Markdown

Blockers: 3.

  1. src/gallium/drivers/asahi/agx_pipe.c:90: adding DRM_FORMAT_MOD_APPLE_INTERCHANGE to agx_best_modifiers also changes what agx_query_dmabuf_modifiers() (:2973) and agx_is_dmabuf_modifier_supported() (:2997) report. Both walk that array with no check on chip or format.
    • Every chip (M1, M2, M3) and every format (R16F, YUV, 10-bit) would now advertise a modifier that only G17P can create.
    • Compositors pass that list to clients through dmabuf feedback, so an import on another chip would take the interchange descriptor path, which has only run on one M4 Max.
    • Fix: filter both queries with the same predicate agx_interchange_allowed() uses (GPU capability plus the four 32-bit formats). Add a test showing the modifier list on a non-G17P device is unchanged.
  2. agx_pipe.c:547: dev->chip != AGX_CHIP_G17P picks one chip id. What decides this is whether the GPU's descriptors can read and write the interchange layout, which is what the texture/PBE changes in agx_native_descriptor.c depend on. Please key it on that descriptor-generation capability, so later generations with the same descriptors get it automatically and older ones are refused for a stated reason. Which modifiers the display accepts already comes from the display's own list.
  3. Commit fc75496 has no Signed-off-by. Its only trailer is Assisted-by: LLM, which belongs on the last line of the PR body (Assisted-by: LLM (<Vendor>:<Model>)), not in the commit.

What I checked: the WSI pitch change and the new bound in test-layout.cpp agree with drm_gem_fb_create()'s size check. The metadata padding (next power of two in tiles x 8 B) matches 8 << (log2ceil(tx) + log2ceil(ty)) for the sizes tested. The PBE stride for interchange encodes macroblocks per row as described.

HW row: this rebased head. On the M4 Max internal panel: scrolling and animation power against aurora-wip, offscreen GL checks identical, 0 GPU faults. On the A18 Pro: the same panel check. On one non-G17P Mac (M2): the dmabuf modifier list and a desktop session unchanged. 0 new kernel errors and 0 failed units on all three.

Assisted-by: LLM (Claude:Opus 5.5)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from fc75496 to aa5eaf4 Compare November 21, 2026 21:51
@AxxzyWasTaken AxxzyWasTaken changed the title asahi: scan out compressed interchange on G17P asahi: scan out compressed interchange on Gen9 descriptors Nov 21, 2026
@AxxzyWasTaken

Copy link
Copy Markdown
Author

Addressed all three code/hygiene blockers in aa5eaf4105c8 (rebased onto aurora-wip ee3abd08):

  • Switched from AGX_CHIP_G17P to capability gating on AGX_DESCRIPTOR_GENERATION_9.
  • Filtered agx_query_dmabuf_modifiers(), agx_is_dmabuf_modifier_supported(), and agx_resource_from_handle() through the same predicate, fixed s_tiling bounds for AIL_TILING_INTERCHANGE, and added Interchange.ModifierSupport covering every enum agx_chip × format × nocompress case.
  • Removed Assisted-by: LLM from the commit message (human Signed-off-by only; PR body updated).
  • asahi_layout_tests 31/31, libasahi_tests 59/59, asahi-native-descriptor 448/448 pass. Happy to take the A18 Pro / M4 Pro / M2 hardware rows offered in review while we run the rebased J616C desktop/offscreen row.

Assisted-by: LLM (Google:Gemini 4 Neon)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from fe208e5 to 3d963c0 Compare November 22, 2026 17:08
@AxxzyWasTaken

Copy link
Copy Markdown
Author

Rebased onto aurora-wip (2fa71805e3e -> 3d963c030d2) to resolve the conflict in src/gallium/drivers/asahi/agx_native_descriptor.c after #708 (compressed_2d_ms kept GPU-only alongside compressed_2d and strided) and drop the stale gfya commit.

Host verification (meson test --suite asahi): 161/161 PASS (0 fail, 0 skipped, including asahi_layout_tests, libasahi_tests, asahi-native-descriptor). Keeping Draft pending the rebased J616C + cross-Mac hardware rows.

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Thanks for the update. Checked 3d963c0 (the delta from aa5eaf4 is only the #708 conflict resolution).

From my last review:

  1. Modifier queries: fixed. agx_query_dmabuf_modifiers(), agx_is_dmabuf_modifier_supported() and the import path (agx_pipe.c:220) all go through agx_dmabuf_modifier_supported(), and Interchange.ModifierSupport covers it.
  2. Chip-id gate: fixed in form. The scope changed though, see below.
  3. Signed-off-by: fixed.

Remaining:

  • agx_g17p_compression.h:113: Gen9 covers G15G/S/C and G16G as well as G17P, but the other users of compressed Gen9 2D images still stop at G17P. Gallium only compresses on G17P (agx_pipe.c:473, :499; see the comment at :524), and Borealis only offers interchange on G17P (hk_image.c:731, hk_image.h:344). On M3 and M4-base GPUs this would be the first compressed image Gallium writes through that PBE path, and GL would advertise and accept a modifier that Vulkan on the same machine refuses. Please put this behind one capability shared by Gallium compression, Borealis interchange and this patch (for example a field in agx_chip_info), enabled for the parts with rows. That way the three cannot drift apart. On the display side, selection by the plane's own list is right: appledrm hides interchange on H17P firmware (T8140, T8122) and on the T8132 panel, so the newly enabled combinations are mainly M3 Pro/Max and non-H17P external DCPs, none of which has been run.
  • agx_pipe.c:2978: agx_dmabuf_modifier_external_only() keeps GPU_TILED_COMPRESSED sample-only on AGX3 because there is no in-place decompression, but interchange is compressed too and is not covered. A shared interchange buffer that reaches agx_decompress() (feedback loop, agx_state.c:14904; incompatible view, :191; shader image write, :233) gets reallocated by transition_resource() and stops being the buffer the display or the peer holds. Should interchange also be external_only on import? If not, what keeps a shared interchange image off those paths?
  • Nit: test-layout.cpp:291 and hk_image.h:344 still describe interchange as G17P-only.

Hardware: there are no rows at 3d963c0 yet. On the A18 Pro, appledrm offers only LINEAR on the internal panel, so it would only confirm the fallback. The M4 Pro is the second G17P display that takes interchange. Rows that would cover this head: M4 Max and M4 Pro internal panels (KMS modifier shows interchange, offscreen GL identical, scroll power against aurora-wip, 0 GPU faults), plus one AGX2 Mac (M2) with the dmabuf modifier list and a desktop session unchanged. If the gate stays at Gen9, it also needs a row on an M3 Pro/Max or another non-G17P Gen9 machine whose display offers interchange.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

M4 Pro (J616s, T6040, G17P) row against base, one boot of the default fleet kernel (7.3.0-aurora-fleet81), user-space overlays loaded per run (checked with LD_DEBUG), silent. Head 3d963c0 vs base 2fa7180. The compositor uses the system Mesa, so an overlay can't change the scanout path, and I didn't take a panel CRC. I checked the modifier lists instead:

  • Kernel: every plane's IN_FORMATS already lists 0x0c00000000000003 (APPLE_INTERCHANGE); the current framebuffer is LINEAR.
  • Mesa: the head adds 0x0c00000000000003 to the EGL dma-buf modifiers for XR24/AR24/AB24/XB24 on surfaceless and on gbm (card2). The base offers only 0x...02 (external-only), 0x...01 and LINEAR.

So on M4 Pro the new modifier is advertised by both sides. A real scanout test (an installed build, compositor on the internal panel, screenshot vs base) is still open, and so is the shared-capability point from my last comment.

Assisted-by: LLM (Claude:Opus 5.5)

@AxxzyWasTaken

AxxzyWasTaken commented Nov 22, 2026 •

Copy link
Copy Markdown
Author

Updated aurora-silicon/mesa#183 to 96f9b1274181 addressing @RyanTheTide's review items on 3d963c03:

  1. Unified interchange capability (agx_chip_has_gen9_2d_compression()): Gallium private 2D compression, Borealis hk_interchange_format, and Gallium interchange scanout all gate on one shared agx_chip_info::has_gen9_2d_compression capability (currently enabled on G17P where hardware rows exist) instead of Gen9-wide.
  2. Fail-closed shared-BO / incompatible compressed view safety:
    • Kept DRM_FORMAT_MOD_APPLE_INTERCHANGE non-external-only so compositors rendering to GBM scanout BOs imported as EGLImage FBOs can still select it, while guarding agx_decompress(), agx_shadow(), and agx_legalize_feedback_loop_surf() with agx_resource_is_shared() so shared BOs can never silently reallocate/detach.
    • Incompatible compressed render targets (including background/end-of-tile) and written non-writeable storage images fail closed via batch rejection (agx_reject_g17g_tile() / agx_native_descriptor_reject_batch(), no abort()), while read-only storage images (including dynamically indexed read-only slots) remain allowed.
  3. Comment nits: Fixed in test-layout.cpp and hk_image.h.
  4. Verification at 96f9b1274181: Full host Asahi suite 230/230 PASS (0 Fail, 0 Skipped, 0 Timeout) + 5-chip AGX_TEST_INTERCHANGE_SHARED_BO=1 drm-shim matrix (g13g, g15g, g16g, g17p, t6041) all pass.

Assisted-by: LLM (Anthropic:Claude Opus 5.5, Google:Gemini 4 Neon)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from 3d963c0 to 96f9b12 Compare November 22, 2026 22:05
@RyanTheTide

Copy link
Copy Markdown

Checked 96f9b12 against my last review on 3d963c0.

Fixed:

  • Shared capability: Gallium colour and depth compression, Borealis hk_interchange_format() (hk_image.c:731) and the interchange modifier now all read agx_chip_has_gen9_2d_compression() (agx_chip.h:797), a new agx_chip_info field set only on G17P, and test-chip.c pins it there. That covers the drift between Gallium, Borealis and GL.
  • No more abort() on the background/end-of-tile descriptor failures: they reject the batch now.
  • The comments in test-layout.cpp and hk_image.h no longer call interchange G17P-only.

Not as described:

  • The update says interchange stays external_only on import. In the code it doesn't. agx_gallium_dmabuf_modifier_external_only() (agx_native_descriptor.h:204-219) returns false for DRM_FORMAT_MOD_APPLE_INTERCHANGE, its comment says "intentionally stays renderable", the commit message says the same, and test-agx-native-descriptor.c:1181 checks that it is not external-only. The renderable choice is reasonable, since compositors leave external-only modifiers out of their render-target tranches. Please fix the PR description so it says what the code does.
  • What protects a shared interchange BO instead: agx_decompress() (agx_pipe.c:1597) no longer reallocates a resource that is agx_resource_is_shared(), and the paths that needed it reject the batch. That covers incompatible views (agx_state.c:10386, :11313), writes to a non-writeable image (agx_state.c:6175), and, on AGX3 through agx_decompress_inplace() (agx_state.c:17129), feedback loops and a spilled compressed target. So the BO is never swapped, but in those cases the frame is silently not drawn (one mesa_loge at submit, agx_batch.c:1462). Please say in the description which of these a compositor can actually reach with its scanout buffer.

Tests:

  • check_interchange_and_shared_bo() (test-agx-g17p-blit.c:1724) only runs with AGX_TEST_INTERCHANGE_SHARED_BO set, and no test() in meson.build sets it. The five-chip shared-BO matrix is therefore a manual run and not part of meson test --suite asahi. Please add it per shim chip, the way AGX_TEST_XFB_COPY_PROGRAM is added, so CI keeps it.

Effect on other chips:

  • agx_resource_is_shared() (agx_state.h:1385) also counts SCANOUT, DISPLAY_TARGET and SHAREABLE, and the agx_decompress() early return and the storage-write reject apply on every chip. On AGX2 a scanout or shareable compressed buffer that used to be reallocated on an incompatible view or an image write now has its batch dropped, even though AGX2 has in-place decompression. That is probably rare, and the old reallocation detached the BO anyway, but it changes M1/M2 behaviour. image_pbe_mask is now also computed on every chip (agx_state.c:4031). An M2 row covers this, see below.

Hardware: no rows at 96f9b12 yet. The M4 Max numbers in the body are from the 5 Nov build and 0815451b + #603. My M4 Pro row was at 3d963c0 and covered only the modifier lists. Rows that would cover this head:

  • M4 Max or M4 Pro internal panel, with this head installed so the compositor uses it: KMS framebuffer modifier 0xc00000000000003, screenshot matches base, no "dropping work" lines in the journal, 0 GPU faults.
  • M2: desktop session and dmabuf modifier list unchanged.
  • M3 or M4 Air: modifier list unchanged, since G15G and G16G are now explicitly off.

Assisted-by: LLM (Claude:Opus 5.5)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from 96f9b12 to 78ebc97 Compare November 22, 2026 22:51
@AxxzyWasTaken

Copy link
Copy Markdown
Author

Rebased onto aurora-wip 27ef0e8e511 (including merged aurora-silicon/mesa#698 at bc2d02495f5) at 78ebc9757019 and addressed the three items from @RyanTheTide's review on 96f9b127:

  1. PR description matches code: Removed the stale external_only claim. The body now accurately describes that DRM_FORMAT_MOD_APPLE_INTERCHANGE intentionally stays renderable (external_only = false) so compositors can render to GBM scanout BOs imported as EGLImage FBOs, explains the agx_resource_is_shared() / fail-closed batch rejection protection (agx_reject_g17g_tile() / agx_native_descriptor_reject_batch()), and states which paths a Wayland compositor can vs cannot hit on a scanout buffer.
  2. 5-chip shared-BO matrix wired into CI (meson.build): Added per-chip test() entries (asahi-{g13g,g15g,g16g,g17p,t6041}-gallium-interchange-shared-bo) running asahi-g17p-blit under tests/run-shim.py with AGX_TEST_INTERCHANGE_SHARED_BO=1, matching the AGX_TEST_XFB_COPY_PROGRAM pattern.
  3. Host tests at 78ebc9757019: meson test --suite asahi 238 / 238 PASS (Fail: 0, Skipped: 0, Timeout: 0), including all 5 new per-chip shared-BO shim tests (g13g, g15g, g16g, g17p, t6041) and hk_g17p_compression / hk_g16s_compression.

Fresh J616C compositor/scanout row at 78ebc9757019 (KMS modifier 0xc00000000000003, screenshot match, 0 "dropping work" lines, 0 GPU faults) will follow before leaving Draft.

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Checked 78ebc97 against my review of 96f9b12. Apart from the rebase onto 27ef0e8 (the agx_chip.h table conflict, where has_gen9_2d_compression is still true only on G17P), the only change is the new meson.build tests.

Fixed:

  • The description now matches the code: interchange stays renderable, shared BOs are protected by agx_resource_is_shared() plus batch rejection, and it lists which paths a compositor's scanout buffer can reach and which ones reject.
  • The shared-BO check now runs in meson test --suite asahi on g13g, g15g, g16g, g17p and t6041 (meson.build:396). The check works out its expected result from agx_chip_has_gen9_2d_compression(), so the non-G17P runs check that those chips keep their old modifier lists.

Still open, hardware only (no rows at 78ebc97 yet):

  • M4 Max or M4 Pro internal panel running this head: KMS framebuffer modifier 0xc00000000000003, screenshot matches base, no "dropping work" lines, 0 GPU faults.
  • M2: desktop session and modifier list unchanged, since the shared-resource checks also run on AGX2.
  • M3 or M4 Air: modifier list unchanged (G15G/G16G are off). Your pending list doesn't have this one yet.

No code changes needed from me. Once those rows are in at this head, this is fine from my side.

Assisted-by: LLM (Claude:Opus 5.5)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from 78ebc97 to cd53c06 Compare November 23, 2026 00:09
@AxxzyWasTaken

Copy link
Copy Markdown
Author

Rebased cleanly onto aurora-wip 7248af95852 (post-#744 / #576, trivial 3-row agx_chip.h table merge with AGX_QUIRK_HW_TXF_BOUNDS) at cd53c06b593. meson test --suite asahi passes 238 / 238 (Fail: 0, Skipped: 0, Timeout: 0, including all 5 per-chip gallium-interchange-shared-bo tests). Also added M3 / M4 Air (G15G/G16G unchanged modifier list) to the pending hardware row list in the description.

Assisted-by: LLM (Google:Gemini 4 Neon)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from cd53c06 to 7168ff0 Compare November 23, 2026 06:08
@AxxzyWasTaken

Copy link
Copy Markdown
Author

Rebased onto aurora-wip efabab38502 at 7168ff0e96b (resolved two additive context hunks in src/gallium/drivers/asahi/tests/test-agx-g17p-blit.c from #746; git range-diff against cd53c06b593 is otherwise identical). meson test --suite asahi passes 238 / 238 (Fail: 0, Skipped: 0, Timeout: 0, including all 5 per-chip gallium-interchange-shared-bo tests).

Assisted-by: LLM (Google:Gemini 4 Neon)

@AxxzyWasTaken

Copy link
Copy Markdown
Author

J616C (Apple MacBook Pro 16", M4 Max, 32-core T6041, G16C B1, 7.3.0-j616c-ia34) exact-head hardware verification at ce2e58746315 (vs exact parent efabab3850):

Fix Included in ce2e58746315

Running dEQP-VK.drm_format_modifiers.* on 7168ff0e96 caught 24 regressions (VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT on {r8g8b8a8,b8g8r8a8}_{unorm,srgb} across create_explicit_modifier* and export_import*): hk_image_init() still validated explicit DRM_FORMAT_MOD_APPLE_INTERCHANGE rowPitch against the macroblock row pitch (DIV_ROUND_UP(width, 16) * 256 * blocksize) instead of the per-pixel-row pitch (* 16 * blocksize) returned by ail_get_wsi_stride_B() / vkGetImageSubresourceLayout(). Updated src/asahi/vulkan/hk_image.c to match ail_get_wsi_stride_B().

Verification at ce2e58746315

  • Overlay resolution: Mesa 26.3.0-devel (git-ce2e587463), Borealis, derived from Honeykrisp and 4.6 (Core Profile) Mesa 26.3.0-devel (git-ce2e587463).
  • Gallium EGL dma-buf modifier query (eglQueryDmaBufModifiersEXT): advertises DRM_FORMAT_MOD_APPLE_INTERCHANGE (0x0c00000000000003, external_only=0) on XR24, AR24, AB24, XB24 (alongside 0x0c00000000000002(ext=1), 0x0c00000000000001(ext=0), LINEAR(ext=0)).
  • Vulkan dEQP-VK.drm_format_modifiers.* (1,572 cases): 870 Pass / 702 NotSupported / 0 Fail — bit-exact match with exact parent efabab3850 (870/702/0), fixing all 24 7168ff0e96 regressions!
  • Offscreen GLES3 smoke (glmark2-es2-drm --off-screen): build 1567 FPS, terrain 487 FPS, score 1026, 0 dropping work lines.
  • Health: 0 GPU faults/timeouts/recoveries, 0 failed systemd units, 0 SELinux AVC denials.
  • (Note: overlay-mode verification; full compositor KMS scanout verification with 0x0c00000000000003 requires installing Mesa system-wide and restarting the compositor.)

Assisted-by: LLM (Google:Gemini 4 Neon)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from 7168ff0 to ce2e587 Compare November 23, 2026 09:42
@AxxzyWasTaken

AxxzyWasTaken commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Rebased cleanly onto aurora-wip 3d146691998 at 5787c0148d5 (resolved src/asahi/lib/agx_chip.h conflict after #839/b5c9978ee23 — added gen9_2d_comp to AGX_CHIP_ROW_TEST_CS and dropped duplicate agx_chip_native_hal200() — and agx_pipe.c/agx_state.{c,h} rsrc->base → rsrc->base.b updates after #689 u_threaded_context; git range-diff against ce2e5874631 is otherwise identical). meson test --suite asahi --suite poly (-Db_ndebug=false) passes 252 / 252 (Fail: 0, Skipped: 0, Timeout: 0, including all 5 per-chip gallium-interchange-shared-bo tests and the new threaded-context tests).

Assisted-by: LLM (Google:Gemini 4 Neon)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch 3 times, most recently from 5787c01 to e8c9662 Compare November 24, 2026 15:56
@AxxzyWasTaken AxxzyWasTaken changed the title asahi: scan out compressed interchange on Gen9 descriptors asahi,hk: scan out compressed interchange on Gen9 descriptors (8-bit and 10-bit) Nov 24, 2026
@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from e8c9662 to 1c766c1 Compare November 24, 2026 16:59
A window that can't scan out GPU tiling got LINEAR: 30.9 MB written and
read by the display every frame, about 3.7 GB/s each way at 120 Hz. Offer
DRM_FORMAT_MOD_APPLE_INTERCHANGE for plain 32-bit 2D buffers on chips with
the shared AGX_CAP_GEN9_2D_COMPRESSION capability in agx_chip_caps.h
(currently G17P), so it wins against LINEAR in a display modifier list and
nothing else.

Put Gallium private 2D depth compression, Borealis interchange, and
Gallium interchange behind AGX_CAP_GEN9_2D_COMPRESSION so they cannot
drift apart across Gen9 parts (private Gen9 colour compression continues
to be gated by agx_chip_gen9_color_compression() for G16G and G17P).

Texture and PBE descriptors now carry its stride on Gen9, the native
descriptor gate admits it, the pitch is per pixel row because DRM core
checks pitch * height, and metadata is padded to the power-of-two size
appledrm expects. The layout test's interchange check expects that pitch.

Filter agx_query_dmabuf_modifiers(), agx_is_dmabuf_modifier_supported(),
and agx_resource_from_handle() through the same capability and format
predicate so chips without AGX_CAP_GEN9_2D_COMPRESSION and unsupported
formats keep their existing modifier list. Keep
DRM_FORMAT_MOD_APPLE_INTERCHANGE non-external-only so compositors that
render to GBM scanout BOs imported as EGLImage FBOs can select it, while
guarding agx_decompress() and writable storage-image descriptor uploads
specifically for shared compressed Interchange resources and guarding
agx_shadow(), agx_legalize_feedback_loop_surf(), and spilled-RT paths
with agx_resource_is_shared(), failing closed via batch rejection on
incompatible compressed views (sampled, storage, or render-target
background/end-of-tile) or writable Interchange storage images instead of
reallocating and detaching a shared BO or aborting. Exclude Interchange
and AGX3 shared compressed targets from agx_fast_clear_surface_eligible()
so scanout clears stay on the VDM+PBE path.

Measured on the M4 Max internal panel at 120 Hz: scrolling 12.7 W to
11.9 W, memory rail 4.96 W to 4.36 W.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
Extend DRM_FORMAT_MOD_APPLE_INTERCHANGE compressed 2D scanout on Gen9 2D
compression chips (G17P) from 8-bit RGB/RGBA to 10-bit 32-bpp RGB/RGBA:
- Gallium asahi: admit B10G10R10A2_UNORM, B10G10R10X2_UNORM,
  R10G10B10A2_UNORM, and R10G10B10X2_UNORM in agx_interchange_format().
- Borealis Vulkan: admit VK_FORMAT_A2R10G10B10_UNORM_PACK32 and
  VK_FORMAT_A2B10G10R10_UNORM_PACK32 in the Borealis Interchange format
  predicate.

All 32-bpp 10-bit formats have 4-byte texels matching
ail_initialize_interchange() (16x16 macroblocks, 1024-byte tile stride,
8-byte metadata tiles, matching appledrm apple_get_ix_layout() for
XR30/AR30 DCP_FORMAT_L10R) and share Gen9 compressed PBE/texture channel
class 0x26 (AGX_CHANNELS_R10G10B10A2).

Fix AGX3 tilebuffer and PBE handling for 10-bit void-alpha formats
(B10G10R10X2_UNORM / R10G10B10X2_UNORM):
- Pad 3-component AIL_ISA_FORMAT_RGB10A2 stores with 1.0 alpha in
  agx_nir_lower_tilebuffer.c on G17P/M5 (lower_g17p_formats), and accept
  3-component RGB10A2 pack (filling lane 3 with 1.0f) and 1..4-component
  RGB10A2 unpack in agx_compile.c, so X2 clears, reloads, draws, blends,
  and zero-mask preserves compile cleanly instead of refusing 3-channel
  packed tile ops.
- Prevent agx_opt_compact_constants from narrowing 32-bit float constants
  feeding AGX3 FLTNORM_AGX3 / PACK_RGB10A2_AGX3 to 16-bit registers.
- Point AGX3 PBE swizzle_a at tile channel 3 (0b11) for void-alpha
  R10G10B10A2 targets in agx_state.c so X2 bits store opaque alpha instead
  of tile channel 0 (red).
- Reject AGX_LAYOUT_INTERCHANGE on Gen10 texture descriptors (Gallium and
  Borealis) and reject uncompressed Interchange PBE descriptors in Borealis.

Add host unit tests covering 8-bit and 10-bit Interchange layout, modifier
admission/queries (including FP16/UINT non-advertisement), Gen9 compressed
PBE and texture descriptors, and Gallium 10-bit A2/X2 scanout allocation,
fast-clear CDM exclusion, and clear+blend compilation.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/gl-interchange-scanout branch from 1c766c1 to ec79156 Compare November 24, 2026 23:43
@AxxzyWasTaken
AxxzyWasTaken marked this pull request as ready for review November 24, 2026 23:43
@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners November 24, 2026 23:43

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict at ec791567c7d0

Approve. Enabling Gen9 2D compressed interchange scanout (8-bit and 10-bit RGB/XRGB) behind AGX_CAP_GEN9_2D_COMPRESSION, wiring the tiling_config / page_aligned_layers / compressed_interchange / swizzle_a descriptor fields across libasahi, Gallium, and Vulkan, and covering all 5 chip targets with drm-shim shared-BO tests plus descriptor/compression contract tests are clean and pass unit and live Apple M5 Max Vulkan + Gallium GLES3 10-bit verification without faults.

Blockers

None.

Checked

  • Audited all 23 changed files (+1593/-81), confirming ail_initialize_interchange() sets layout->stride_el[0] = DIV_ROUND_UP(width_px, 16) * 16 matching the PBE/texture tiling_config stride expressions in agx_state.c, AGX_CAP_GEN9_2D_COMPRESSION stays gated to AGX_CAPS_G17P, and the 10-bit UTIL_FORMAT_TYPE_VOID alpha swizzle_a = 3 path in agx_batch_upload_pbe_internal cleanly covers agx_chip_native_or_m5.
  • CI on aurora-silicon/mesa: no PR status checks configured on this repo.
  • Local build (-Dbuildtype=release -Db_ndebug=false -Dtools=drm-shim) applied cleanly onto origin/aurora-wip (d5d67353ae1c), Meson --suite asahi --suite poly: 300/300 OK, including:
    • asahi-g13g-gallium-interchange-shared-bo, asahi-g15g-gallium-interchange-shared-bo, asahi-g16g-gallium-interchange-shared-bo, asahi-g17p-gallium-interchange-shared-bo, asahi-t6041-gallium-interchange-shared-bo (5/5 OK)
    • hk_compression_contract, hk_native_descriptor, asahi-native-descriptor, hk_g17p_compression, hk_g16s_compression, agx3_layout, agx_m5_layout, asahi_layout_tests (all OK)
  • Live Apple M5 Max Vulkan & Gallium GLES3 verification (MESA_SHADER_CACHE_DISABLE=true, private install prefix for GLES3 surfaceless FBO):
    • dEQP-VK.api.smoke.*: 8/8 Passed, 0 Failed
    • dEQP-VK.drm_format_modifiers.*: 870/1572 Passed, 0 Failed, 702 Not supported
    • dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color.2d.a2b10g10r10_unorm_pack32.a2r10g10b10_unorm_pack32.*: 8/12 Passed, 0 Failed, 4 Not supported
    • dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color.2d.a2r10g10b10_unorm_pack32.b8g8r8a8_unorm.*: 8/12 Passed, 0 Failed, 4 Not supported
    • dEQP-GLES3.functional.fbo.color.tex2d.rgb10_a2*: 2/2 Passed, 0 Failed
    • dEQP-GLES3.functional.fbo.render.shared_colorbuffer.rbo_rgb10_a2*: 3/3 Passed, 0 Failed
    • dEQP-GLES3.functional.texture.format.sized.2d.rgb10_a2*: 4/4 Passed, 0 Failed
    • dEQP-GLES3.functional.fbo.color.tex2d.rgba8*: 3/3 Passed, 0 Failed
    • Kernel GPU fault delta: 0
  • Untested scope: live physical display scanout via DCP/Wayland compositor on a G17P device (Gen9 2D compression is enabled on AGX_CAPS_G17P, not Gen10 M5; verified via g17p/t6041 drm-shim tests and contract tests).
Evidence
Meson (--suite asahi --suite poly, -Dbuildtype=release -Db_ndebug=false -Dtools=drm-shim): Ok: 300, Fail: 0
  - asahi-g13g-gallium-interchange-shared-bo: OK
  - asahi-g15g-gallium-interchange-shared-bo: OK
  - asahi-g16g-gallium-interchange-shared-bo: OK
  - asahi-g17p-gallium-interchange-shared-bo: OK
  - asahi-t6041-gallium-interchange-shared-bo: OK
  - hk_compression_contract / hk_native_descriptor / asahi-native-descriptor: OK
dEQP-VK.api.smoke.*: 8/8 Passed
dEQP-VK.drm_format_modifiers.*: 870/1572 Passed, 0 Failed, 702 Not supported
dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color.2d.a2b10g10r10_unorm_pack32.a2r10g10b10_unorm_pack32.*: 8/12 Passed, 0 Failed, 4 Not supported
dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color.2d.a2r10g10b10_unorm_pack32.b8g8r8a8_unorm.*: 8/12 Passed, 0 Failed, 4 Not supported
dEQP-GLES3.functional.fbo.color.tex2d.rgb10_a2*: 2/2 Passed
dEQP-GLES3.functional.fbo.render.shared_colorbuffer.rbo_rgb10_a2*: 3/3 Passed
dEQP-GLES3.functional.texture.format.sized.2d.rgb10_a2*: 4/4 Passed
dEQP-GLES3.functional.fbo.color.tex2d.rgba8*: 3/3 Passed
GPU fault delta: 0

@RyanTheTide

Copy link
Copy Markdown

ec791567c7d0 J615 (M3 Air, G15G C0, 7.3.0-aurora-fleet85) + J413 (M2 Air, G14G B0, 7.3.0-aurora-fleet89) isolated GL+Borealis VK non-regression PASS (MESA_SHADER_CACHE_DISABLE=1, libgallium PT_TLS=0x34 / 52 B, dlopen(libEGL_mesa.so.0, RTLD_NOW) OK, 0 GPU faults, 0 AVC, 0 failed units, Enforcing):

  • J615 (G15G C0): gpubench-gl render.light 757.6 us, render.postfx 1080p msaa=1 180 fps (crc=2133faaa valid=true) & msaa=4 140 fps (crc=9d7ff6f3 valid=true), gpubench-vk render.light 618.4 us / compute.light 418.1 us, dEQP-GLES3 abs 48/48, fbo.color.tex2d.rgb10_a2* 2/2, dEQP-VK api.smoke 8/8, blit_image.*a2b10g10r10_unorm_pack32 8/12 pass (0 fail, 4 NS).
  • J413 (G14G B0): gpubench-gl render.light 258.9 us (render.postfx passes valid=true crc=b52e3012 under ASAHI_MESA_DEBUG=sync; branch base 9a21c0c6220a predates the #979 revert of #822), gpubench-vk render.light 208.5 us / compute.light 130.0 us, dEQP-GLES3 abs 48/48, rgb10_a2* 2/2, dEQP-VK api.smoke 8/8; A/B vs base 9a21c0c6220a on blit_image.*a2b10g10r10_unorm_pack32 and a2r10g10b10_unorm_pack32 shows exact parity (7/12 pass, 1 pre-existing general_general_linear fail, 4 NS on both base and PR).

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.

4 participants