Skip to content

borealis,agx: enable monolithic inline fragment blending on M5 - #1165

Merged
RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
oreater:pr/borealis-m5-inline-blend
Nov 27, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
oreater:pr/borealis-m5-inline-blend

Conversation

@oreater

@oreater oreater commented Nov 26, 2026 •

Copy link
Copy Markdown

What: Enable monolithic inline fragment blending on M5 (AGX3C) in Borealis and the AGX compiler, eliminating split main+epilog fragment linking and spill/reload overhead on blended draws.

Tested: J716c Apple M5 Max at a48b5106d3a: 212/212 asahi unit tests PASS, 13/13 vk_blend_bench pixel-exact PASS (tex_additive_512 -9.42%, tex_alpha_blend_512 -8.41%, rgb10a2_blend_512 -7.56%), 200/200 + 20/70 Vulkan CTS PASS (0 fail, 0 diffs), 0 kernel errors.

Risk: two-way door · M5 — A plain revert restores split main+epilog blending on M5. Every monolithic M5 blend program is verified fail-closed by hk_g17p_mono_part_refusal() (confirming exact AGX3C entry gate, no ray-query write acquire, and final pixrel before END); unrecognized shapes fall back transparently to split main+epilog.

Not yet: AGX3D (G18G, emit_agx3d) remains excluded until qualified on its hardware.

Details and verification evidence

Summary

Enables AGX_FS_STRUCTURE_INLINE_BLEND monolithic fragment+epilog compilation across M5 (agx_chip_native_or_m5(), AGX3C) for single-target blends (RGBA8, RGBA16F, RGB10A2, partial masks), 2-RT mixed MRT, discard+blend, and 4× MSAA blend, folding fsat and format conversions across the main/epilog boundary under the full AGX3C pixel protocol:

  • src/asahi/compiler/agx3_pack_binary.c: Admits non-AGX3D AGX3C inline-blend shaders (and width-supported tile formats including F16/I16/I32) into the proven class-12 single-target blend protocol while keeping m5_uniform_blend unchanged.
  • src/asahi/compiler/agx_compile.c: Prevents nir_opt_move from dragging load_input/load_frag_coord/load_ubo down into the tilebuffer interlock critical section (load_local_pixel_agx / wait_pix .. pixrel) when uses_fbfetch_output is set.
  • src/asahi/vulkan/hk_shader.c, hk_cmd_draw.c: Captures preoptimized monolithic NIR for agx_chip_native_or_m5(), verifies the AGX3C entry gate and final pixrel(..., last=true) before END fail-closed (hk_g17p_mono_part_refusal), bumps the monolithic disk-cache magic ("hkmono8"), and runs agx_nir_hoist_g17p_zs_writes before MSAA tile sample lowering.
  • src/asahi/lib/tests/test-m5-depth-export.cpp: Adds InlineBlendPublishesCompletePixelProtocol (RGBA8, RGBA16F, RGB10A2) and InlineBlendKeepsVaryingInterpBeforeTileLoad.

Build & Artifacts

  • Host: J716c Apple M5 Max (G17C B1), Fedora Remix 44, kernel 7.3.0-40.j716c19.fc44.aurora.aarch64, GCC 16.2.1
  • Meson: --buildtype=release -Db_ndebug=true -Dbuild-tests=true -Dvulkan-drivers=asahi -Dgallium-drivers=
  • Base (origin/aurora-wip 822cf58723a): libvulkan_asahi.so SHA-256 d5b7e4582e1b034642e804f6477b070504ad077c2f0a3212989f6ad785228d68
  • Head (a48b5106d3a): libvulkan_asahi.so SHA-256 6c5ca245c0e1f64b6b5b83663d7c29a0126f2c66373006f8ad19c2231a1c6290

Verification

  • Unit tests (meson test --suite asahi): 212/212 PASS, 0 FAIL (including new M5DepthExport.InlineBlendPublishesCompletePixelProtocol and M5DepthExport.InlineBlendKeepsVaryingInterpBeforeTileLoad).
  • Live M5 Max A/B (vk_blend_bench, strict 3-round ABBA, MESA_SHADER_CACHE_DISABLE=1, all 13 pixel-exact blend checks PASS on every arm):
Workload Base median Head median Delta
tex_additive_512 3.13 ms (171.6 Gpix/s) 2.83 ms (189.5 Gpix/s) -9.42%
tex_alpha_blend_512 3.27 ms (164.4 Gpix/s) 3.00 ms (179.1 Gpix/s) -8.41%
rgb10a2_blend_512 3.50 ms (153.3 Gpix/s) 3.24 ms (165.9 Gpix/s) -7.56%
mrt2_mixed_256 1.92 ms (140.3 Gpix/s) 1.79 ms (149.6 Gpix/s) -6.27%
discard_alpha_256 1.73 ms (154.6 Gpix/s) 1.64 ms (164.1 Gpix/s) -5.48%
f16_alpha_blend_512 3.08 ms (174.1 Gpix/s) 3.02 ms (177.4 Gpix/s) -1.94%
loop_alpha_blend_128 2.04 ms (65.6 Gpix/s) 2.01 ms (66.8 Gpix/s) -1.71%
mrt2_opaque_128 0.25 ms (536.8 Gpix/s) 0.25 ms (535.5 Gpix/s) 0.00%
  • Vulkan CTS (deqp-vk, base vs head):
    • 200-case dEQP-VK.pipeline.monolithic.blend.format.{r8g8b8a8_unorm,r16g16b16a16_sfloat,a2b10g10r10_unorm_pack32}.*: 200/200 PASS (100%), 0 FAIL, 0 status diffs vs base.
    • 70-case mixed format + dual-source blend slice: 20/70 PASS, 0 FAIL, 50 NotSupported (0 status diffs vs base).
  • Host health: SELinux=Enforcing, 0 DRM/asahi/GPU kernel errors.

Enable AGX_FS_STRUCTURE_INLINE_BLEND monolithic fragment+epilog
compilation on M5 (AGX3C) across single-target blends (RGBA8, RGBA16F,
RGB10A2, partial masks), 2-RT mixed MRT, discard+blend, and 4x MSAA
blend, folding fsat and format conversions across the main/epilog
boundary under the full AGX3C pixel protocol (entry gate .. final pixrel).

- agx3_pack_binary.c: admit AGX3C inline-blend shaders (and width-
  supported tile formats including F16/I16/I32) into the proven class-12
  single-target blend protocol while keeping m5_uniform_blend unchanged.
- agx_compile.c: avoid moving load_input/load_frag_coord/load_ubo down
  into the tilebuffer interlock critical section in nir_opt_move when
  uses_fbfetch_output is set.
- hk_shader.c, hk_cmd_draw.c: capture preoptimized monolithic NIR on
  agx_chip_native_or_m5(), validate the AGX3C entry gate and final
  release before END fail-closed, bump the monolithic disk-cache key
  magic ("hkmono8"), and run agx_nir_hoist_g17p_zs_writes ahead of MSAA
  tile sample lowering.
- test-m5-depth-export.cpp: add M5 inline-blend pixel-protocol tests
  (RGBA8/RGBA16F/RGB10A2) and varying-interpolation-before-lldcol test.

Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>

@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 a48b5106d3ab

Blockers: none

Checked: Read the whole diff. M5 admission keys on encoding and !emit_agx3d; the fail-closed hk_g17p_mono_part_refusal() check now also verifies the AGX3C entry gate at the recorded offset and the final pixrel before END, and the disk-cache magic is bumped so old refusals are not reused. Gate green, the two new tests pass. Non-blocking: the nir_opt_move change in agx_compile.c (no moving inputs/frag_coord/UBO loads when uses_fbfetch_output) has no chip condition, so it changes scheduling of fbfetch/blend fragment shaders on every Mac, Gallium included. It is probably neutral, but it needs a regression row outside M5; we will run GL and VK blend groups on M1 Pro and J700.

Evidence

Local Mesa gate (stands in for CI; buildbox x86 docker aurora/hk6356-mesa-x86-tests:local, clang release with asserts, -Dbuild-tests=true -Dtools=asahi,drm-shim, meson test --suite asahi --suite poly):

@RyanTheTide

Copy link
Copy Markdown

a48b5106d3ab Neo (J700, G17P B1) VK + M1 Pro (J316s, G13S C0) GL (7.3.0-aurora-fleet89, default cmdline) PASS: standalone build on aurora-wip@e1b5658fe695 (0-byte diff vs merge(aurora-wip, head)), meson test --suite asahi 214/214 PASS (-Db_ndebug=false):

  • Neo VK (VK_DRIVER_FILES overlay sha256: 1a252a74e42d..., J=1, MemoryMax=3G): dEQP-VK.pipeline.monolithic.blend.* (--deqp-fraction=1,20) 412/412 PASS / 0 FAIL, dEQP-VK.renderpasses.renderpass2.*subpass_dependencies* 41/52 PASS / 0 FAIL (11 NotSupported), dEQP-VK.renderpasses.renderpass2.*input_attachment* 7/8 PASS / 0 FAIL (1 NotSupported).
  • M1 Pro GL (Gallium asahi overlay libgallium-26.3.0-devel.so sha256: 506e8b563c3b... verified via LD_DEBUG=libs, surfaceless --deqp-surface-type=fbo): dEQP-GLES31.functional.blend_equation_advanced.* 102/102 PASS / 0 FAIL; dEQP-GLES3.functional.fragment_ops.blend.* 2,301/2,304 PASS (all fbo_* and non-initial default_framebuffer cases pass; the 3 fails are default_framebuffer.{rgb_equation_alpha_equation.add_add, rgb_func_alpha_func.{dst,src}.constant_alpha_constant_alpha} returning GL_INVALID_FRAMEBUFFER_OPERATION in glClear(incomplete framebuffer) under surfaceless default FBO/pbuffer harness).
    Both Macs: 0 GPU faults/recoveries, 0 failed units, SELinux Enforcing, 0 new AVC denials, stock system Mesa libraries untouched.

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