Skip to content

asahi,borealis: port pre-packed BG clears and raw32/W16 reloads to native AGX3 - #1432

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/g17p-packed-bg-clears
Dec 1, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/g17p-packed-bg-clears

Conversation

@AxxzyWasTaken

Copy link
Copy Markdown

What: Port pre-packed background clear shaders and raw32/W16 tile reload paths to native AGX3 (G17P / HAL200) in Asahi/Borealis instead of falling back to AGX2-only paths.

Tested:

  • Host x86-64 (-Db_ndebug=false, rebased on aurora-wip 8b59f2b0a70, head 5fc6d245c0ae): meson test --suite asahi 359/359 PASS (0 fail, 0 skip).
  • J616C (Apple M4 Max, G17P, 7.3.0-j616c-parity5+, Release ARM64 libvulkan_asahi.so) at exact head 5fc6d245c0ae:
    • ASAHI_MESA_DEBUG=verify gpubench-vk --test render.deferred --depths 2: exact CRC 2cfe9a54, 0 faults.
    • 3-round interleaved A/B vs aurora-wip (8b59f2b0a70, depth=2):
      • render.postfx: wall 287.15 -> 285.51 us (-0.57%), GPU 270.40 -> 269.04 us (-0.50%), CRC 4707efa8 exact.
      • render.light: wall 60.16 -> 60.15 us (-0.01%), GPU 7.46 -> 7.42 us (-0.56%).
      • render.deferred: wall 109.47 -> 109.26 us (-0.19%), CRC 2cfe9a54 exact.
      • overlap.passes: ratio 1.16 -> 1.16 (+0.27%).
    • dmesg: 0 GPU/DART faults or recoveries.

Risk: two-way door · touches AGX3 background clear and raw32/W16 tile reload lowering; gated to AGX3 native paths.

Not yet: Second Apple Silicon generation hardware row (e.g. M3/M4 base/M5) and full VK-CTS renderpass sweep.

…tive AGX3

Extend the M5 background clear and load fast paths to native AGX3b chips
(G15G/S/C, G16G, and G17P):

1. Pre-packed tile background clears (`packed_clear_mask`): enable on
   `agx_chip_native_or_m5()` for single-sample aligned targets
   (`R8G8B8A8_UNORM`, `B8G8R8A8_UNORM`, `R16G16B16A16_FLOAT`,
   `R16G16_FLOAT`, `R16_FLOAT`, `R11G11B10_FLOAT`) across single-RT,
   dedicated dual-RT, multi-RT, and mixed MRT Borealis paths, gated on
   tilebuffer byte alignment via `agx_m5_packed_clear_rt_ok()`.
2. Raw32 `R11G11B10_FLOAT` background reloads (`raw32_load_mask`):
   pack separate `background_raw32_desc` / `layered_background_raw32_desc`
   `R32_UINT` descriptors in `hk_image_view` while keeping the typed
   `background` / `layered_background` descriptors intact so partial-area
   `preserve_resolve_outside` reloads still read typed float3 resolve
   targets (also fixing M5 when the shader skips raw32 for misaligned
   offsets). Include the raw32 descriptor and mode bit in
   `struct hk_g17p_bg_eot_dev_key` so single-RT cached BG programs never
   alias raw32 vs typed views, and bind the layered descriptor for
   targets 1+ on layered multi-target reloads.
3. W16 FP16 background reloads: enable `load_f16` on AGX3b exclusively
   for `PIPE_FORMAT_R16_FLOAT` tile formats (`R16F`, `RG16F`, `RGBA16F`),
   which store directly via W16 `lstcol` without `fltnorm`. Keep 8-bit
   normalized W16 reloads (`U8NORM`/`S8NORM`/`SRGBA8`) M5 (AGX3c)-only
   because AGX3b `fltnorm` has no f16 register source operand.
4. Tests: extend `asahi-g17p-mrt-mixed` with AGX3b binary decode checks
   covering single-RT/dual-RT/MRT packed clears, 5-RT alignment gating,
   raw32 `R11G11B10_FLOAT` reloads, W16 FP16 reloads, and negative tests
   verifying 8-bit normalized, MSAA, and `preserve_resolve_outside`
   reloads stay on W32/typed paths.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners November 30, 2026 21:23

@aurora-silicon-review aurora-silicon-review Bot 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: HOLD at 5fc6d245

Blockers:

  • Second GPU-generation hardware row missing: Current hardware evidence covers J616C (M4 Max, G17P) only. Because this PR modifies shared agx_bg_eot.c, hk_image_view.c (background_raw32_desc / hk_image_view_can_raw32_bg()), and hk_cmd_draw.c paths used by both native AGX3 (G17P) and M5 (AGX3C), please add an exact-head hardware row on a second Apple Silicon generation (ideally M5 to verify non-regression on the refactored background_raw32_desc path, or another generation).
  • Renderpass clear/reload conformance coverage: Please include a targeted Vulkan CTS renderpass clear/load sweep covering the newly enabled native AGX3 packed-clear and raw32/W16 reload formats (R8G8B8A8_UNORM, B8G8R8A8_UNORM, R16_FLOAT, R16G16_FLOAT, R16G16B16A16_FLOAT, R11G11B10_FLOAT, including mixed MRT reload+clear passes).

Checked:

  • Audited full production diff (+671/-123 across 7 files):
    • src/asahi/lib/agx_bg_eot.c: cleanly widens packed_clear_mask, raw32_load_mask, and R16_FLOAT W16 reload to agx_chip_native_or_m5(), while correctly keeping U8NORM/S8NORM/SRGBA8 W16 reloads M5 (AGX3C)-only because AGX3B fltnorm lacks an f16 register source operand, and gating load_f16 on !key->preserve_resolve_outside.
    • src/asahi/vulkan/hk_image_view.{c,h}: cleanly splits HK_DESC_USAGE_{,LAYERED_}BG_EOT_RAW32 into dedicated background_raw32_desc / layered_background_raw32_desc descriptors so typed descriptors remain intact for paths such as preserve_resolve_outside.
    • src/asahi/vulkan/hk_cmd_draw.c: hk_build_g17p_mixed_bg_eot(), hk_g17p_bg_eot_dev_key_init(), and hk_build_g17p_bg_eot() consistently check nr_samples == 1, !preserve_resolve_outside, !spilled[rt], and 4-byte tilebuffer offset alignment before setting raw32_load_mask, and include raw32 in dk->pbe_valid (bit 2) to keep the device BG/EOT cache key unambiguous.
  • Noted host meson test --suite asahi 359/359 PASS and J616C exact-head 5fc6d245c0ae A/B (render.postfx -0.50%, render.light -0.56%, render.deferred -0.19%, exact CRCs, 0 faults).
Evidence
  • Head commit: 5fc6d245c0ae... (MERGEABLE into aurora-wip).
  • Modified files: agx_bg_eot.{c,h}, lib/meson.build, test-agx-g17p-mrt-mixed.c, hk_cmd_draw.c, hk_image_view.{c,h}.

@AxxzyWasTaken

Copy link
Copy Markdown
Author

Targeted J616C (M4 Max, G17P, 7.3.0-j616c-parity6+) Vulkan CTS renderpass clear/load format sweep (96 cases across R8G8B8A8_UNORM, B8G8R8A8_UNORM, R16_FLOAT, R16G16_FLOAT, R16G16B16A16_FLOAT, B10G11R11_UFLOAT_PACK32, plus mixed MRT attachment_allocation.input_output.* clear+load passes) on our m4mega-v22 build carrying 5fc6d245c0ae: 87/87 supported PASS (0 fail, 9 not supported), 0 GPU/DART faults in dmesg.

@RyanTheTide

Copy link
Copy Markdown

Second-generation row + renderpass clear/load sweep: J615 (MacBook Air M3, G15G, native AGX3) at exact head 5fc6d245: clean, no regression.

Base aurora-wip 8b59f2b0 vs head 5fc6d245, both release ICDs (-Db_ndebug=true) cross-built with the same options and swapped with VK_DRIVER_FILES on the same boot. Saved 7.3.0-aurora-edge kernel, firmware 27.2. Userspace only, no reboot, silent. Restored: Enforcing, 0 failed units. G15G takes the same native AGX3 background/EOT path this PR changes.

Renderpass clear/load sweep (VK CTS 1.4.7.1, both arms):

group base head
renderpasses.renderpass1.suballocation.formats.* 6,015 P / 435 NS 6,015 P / 435 NS
renderpasses.renderpass2.suballocation.formats.* 3,243 P / 237 NS 3,243 P / 237 NS
renderpasses.renderpass1.suballocation.attachment_allocation.* 356 P / 244 NS 356 P / 244 NS
renderpasses.renderpass1.suballocation.simple.* 5 P / 4 NS 5 P / 4 NS

9,619 Pass -> Pass, 0 Fail, 0 regressions. These cover every format with LOAD/CLEAR/DONT_CARE load ops, plus draw and clear_draw, through both render pass APIs.

Broader graphics groups, both arms: api.smoke, api.image_clearing.core.clear_color_attachment.* (2,147 P), partial_clear_color_attachment.* (1,017 P), draw.renderpass.* (11,713 P). 14,885 Pass -> Pass, 0 regressions. 0 new GPU fault lines in either run.

gpubench-vk (--warmup-ms 300 --runs 5 --run-ms 300), interleaved base, head, base, head, with output CRCs:

test depth base (2 runs) head (2 runs) change CRC both arms
render.deferred 1 980.4 / 980.4 990.1 / 911.9 -3.0% (one fast head run; treat as noise) 2cfe9a54
render.deferred 2 530.0 / 530.0 530.0 / 528.2 -0.2% 2cfe9a54
render.postfx 1 1369.9 / 1382.5 1382.5 / 1388.9 +0.7% 4707efa8
render.postfx 2 1102.9 / 1107.0 1123.6 / 1107.0 +0.9% 4707efa8
render.shadow 1 2702.7 / 2678.6 2702.7 / 2702.7 +0.4% c0fb9993
render.shadow 2 2127.7 / 2127.7 2127.7 / 2127.7 0.0% c0fb9993

Output is bit-exact across arms. Timings are within run-to-run spread, about ±1%. Kit and raw output on our buildbox store: kits/test/20261201-gpu-ungate-pr1432, traces/gpu/20261201-gpu-ungate-pr1432.

This doesn't cover the M5 (AGX3C) refactor of background_raw32_desc the review also mentions; that still needs an M5 row.

@aurora-silicon-review aurora-silicon-review Bot 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 5fc6d245c0ae

Blockers:

  • None.

Checked:

  • Previously audited full 7-file diff (+671/-123, MERGEABLE against aurora-wip): agx_bg_eot.{c,h}, hk_image_view.{c,h}, hk_cmd_draw.c, test-agx-g17p-mrt-mixed.c, lib/meson.build — cleanly enables pre-packed BG clears and raw32/W16 reloads on native AGX3 while keeping U8NORM/S8NORM/SRGBA8 W16 reloads M5-only, splitting background_raw32_desc cleanly, and preserving preserve_resolve_outside / spill / alignment guards and cache-key uniqueness (dk->pbe_valid bit 2).
  • Both earlier review blockers are now satisfied at exact head 5fc6d245c0ae:
    • Two Apple Silicon GPU generations verified on the changed native AGX3 path: J616C (M4 Max, G17P) and J615 (M3 Air, G15G), plus host meson test --suite asahi 359/359 PASS.
    • Renderpass clear/load conformance verified: J616C 87/87 targeted format cases PASS and J615 9,619 renderpass format/allocation/simple + 14,885 image-clearing/draw-renderpass VK CTS cases (24,504 Pass->Pass, 0 regressions, bit-exact CRCs, 0 GPU faults).
Evidence
  • Head: 5fc6d245c0ae0b7e6a89682d1b5b5a8e1b97dac1 (base aurora-wip, MERGEABLE).
  • Host: meson test --suite asahi 359/359 PASS (-Db_ndebug=false).
  • J616C (G17P, M4 Max): gpubench-vk A/B (render.postfx -0.50%, render.light -0.56%, render.deferred -0.19%, bit-exact CRCs), 87/87 targeted renderpass clear/load CTS PASS, 0 faults.
  • J615 (G15G, M3 Air): 24,504 VK CTS cases Pass->Pass (0 Fail, 0 regressions), gpubench-vk bit-exact CRCs, 0 faults.

@DjDeveloperr
DjDeveloperr merged commit f11583b into aurora-silicon:aurora-wip Dec 1, 2026
@m0d16l14n1

Copy link
Copy Markdown

Base M5 row (MacBook Air 15" M5, J815, G17G), kernel 7.3.0-aurora-j815-dev, PR head 5fc6d24 vs aurora-wip 8b59f2b, release builds, dEQP-VK 1.4.7.1 (+ KhronosGroup/VK-GL-CTS@c2c05e95f97f):

  • every mustpass renderpass / renderpass2 / dynamic_rendering / image clearing / load_store_op_none / clear_attachments case (59,741): 36,797 = 36,797 Pass, 0 diffs.
  • dEQP gate (15,958): 11,297 = 11,297 Pass, 0 diffs. 0 GPU faults.
  • gpubench-vk render.light / render.heavy / render.tvb (depth 2, 3 rounds): GPU time 4.79 / 261.2 / 19,797 us vs 4.75 / 260.6 / 19,811 us on the base: neutral.

@RyanTheTide

Copy link
Copy Markdown

@DjDeveloperr, code-owner heads-up: App approval at 5fc6d245c0ae from a different lane. This PR goes into the merge train's next combined A/B (batch 23, stacked on batch 22: #631 #664 #673 #1422 #1423 #1429 #1431 #1432 #1433 #1434 #1436) on M1 Pro G13S + M4 G16G. If that row is clean, I plan to land it via --admin under the 6-point rule no earlier than one hour from now, unless you post a hold.

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