Repository navigation
borealis,agx: enable monolithic inline fragment blending on M5 - #1165
Conversation
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
left a comment
There was a problem hiding this comment.
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):
- base
aurora-wip90211df6816: 335/335 OK. - batch build:
90211df6816with 22 open PR heads merged on top (#1133 #1137 #1155 #1136 #1140 #1157 #1158 #1160 #1164 #1165 #1167 #1168 #1170 #1171 #1172 #1175 #1182 #1183 #1185 #1187 #1190 #1191; each also merges cleanly alone, and into currentaurora-wipd2e883ab2e3): 335/336 OK. The one failure,agx3_cmat_mixed_mma8, reproduces with #1187 alone on the base (329/330) and is caused by that PR's new test; nothing else in the batch fails.
|
|
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/13vk_blend_benchpixel-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 finalpixrelbeforeEND); 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_BLENDmonolithic 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, foldingfsatand 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 keepingm5_uniform_blendunchanged.src/asahi/compiler/agx_compile.c: Preventsnir_opt_movefrom draggingload_input/load_frag_coord/load_ubodown into the tilebuffer interlock critical section (load_local_pixel_agx/wait_pix..pixrel) whenuses_fbfetch_outputis set.src/asahi/vulkan/hk_shader.c,hk_cmd_draw.c: Captures preoptimized monolithic NIR foragx_chip_native_or_m5(), verifies the AGX3C entry gate and finalpixrel(..., last=true)beforeENDfail-closed (hk_g17p_mono_part_refusal), bumps the monolithic disk-cache magic ("hkmono8"), and runsagx_nir_hoist_g17p_zs_writesbefore MSAA tile sample lowering.src/asahi/lib/tests/test-m5-depth-export.cpp: AddsInlineBlendPublishesCompletePixelProtocol(RGBA8, RGBA16F, RGB10A2) andInlineBlendKeepsVaryingInterpBeforeTileLoad.Build & Artifacts
J716c Apple M5 Max (G17C B1), Fedora Remix 44, kernel7.3.0-40.j716c19.fc44.aurora.aarch64, GCC16.2.1--buildtype=release -Db_ndebug=true -Dbuild-tests=true -Dvulkan-drivers=asahi -Dgallium-drivers=origin/aurora-wip822cf58723a):libvulkan_asahi.soSHA-256d5b7e4582e1b034642e804f6477b070504ad077c2f0a3212989f6ad785228d68a48b5106d3a):libvulkan_asahi.soSHA-2566c5ca245c0e1f64b6b5b83663d7c29a0126f2c66373006f8ad19c2231a1c6290Verification
meson test --suite asahi):212/212 PASS, 0 FAIL(including newM5DepthExport.InlineBlendPublishesCompletePixelProtocolandM5DepthExport.InlineBlendKeepsVaryingInterpBeforeTileLoad).vk_blend_bench, strict 3-round ABBA,MESA_SHADER_CACHE_DISABLE=1, all 13 pixel-exact blend checks PASS on every arm):tex_additive_5123.13 ms(171.6 Gpix/s)2.83 ms(189.5 Gpix/s)tex_alpha_blend_5123.27 ms(164.4 Gpix/s)3.00 ms(179.1 Gpix/s)rgb10a2_blend_5123.50 ms(153.3 Gpix/s)3.24 ms(165.9 Gpix/s)mrt2_mixed_2561.92 ms(140.3 Gpix/s)1.79 ms(149.6 Gpix/s)discard_alpha_2561.73 ms(154.6 Gpix/s)1.64 ms(164.1 Gpix/s)f16_alpha_blend_5123.08 ms(174.1 Gpix/s)3.02 ms(177.4 Gpix/s)loop_alpha_blend_1282.04 ms(65.6 Gpix/s)2.01 ms(66.8 Gpix/s)mrt2_opaque_1280.25 ms(536.8 Gpix/s)0.25 ms(535.5 Gpix/s)0.00%deqp-vk, base vs head):200-casedEQP-VK.pipeline.monolithic.blend.format.{r8g8b8a8_unorm,r16g16b16a16_sfloat,a2b10g10r10_unorm_pack32}.*:200/200 PASS (100%), 0 FAIL, 0 status diffsvs base.70-case mixed format + dual-source blend slice:20/70 PASS, 0 FAIL, 50 NotSupported(0status diffs vs base).SELinux=Enforcing,0DRM/asahi/GPU kernel errors.