Skip to content

borealis: enable HAL200 lossless compression on G16G - #1050

Merged
5 commits merged into
aurora-wipfrom
perf/m4-hal200-compress
Nov 25, 2026
Merged

5 commits merged into
aurora-wipfrom
perf/m4-hal200-compress

Conversation

@DjDeveloperr

Copy link
Copy Markdown

What: Enable HAL200 lossless colour and depth/stencil compression on G16G (M4), matching the G17P (M4 Pro / M4 Max / A18 Pro) policy for every shape whose metadata encoding is identical across the two parts. 1-8B 2x/4x MSAA colour on G16G is held behind a separate capability pending triage of intermittent PBE reads in the full --jobs 4 CTS resolve_image stress.

Tested: J773g (Apple M4, G16G B0) at 1b94686bb102, Linux 7.3.0-ARCH-m4mainefed1ae3:

  • Full 5981-case Vulkan CTS --jobs 4 2x back-to-back on the candidate: 3050 Pass / 2931 NotSupported / 0 Fail each run, 0 DeviceLost, kernel health failed 0 errno 0 degraded 0 throughout.
  • Same-boot ABBA (compress.bw, render.deferred, render.shadow, render.postfx, transfer.ops, render.light) on A e87a3156f31f and B 1b94686bb102: all rounds rc=0, 60/60 rows ok and 0/44 CRC-invalid in each round. Within-arm stability B2/B1 = 1.0005x, A2/A1 = 0.9969x. Cross-arm B/A = 1.63x (compress 2.72x, transfer 1.65x, render 1.30x).
  • Full 202-workload gpubench-vk on B vs M4 macOS 26B123 Metal 4 reference: 1.1193x geomean (125/202 wins), up from the published aurora-wip baseline at 0.9551x (105/202 wins); candidate/baseline same-rows ratio 1.183x, with compress.bw at 2.72x, transfer 1.69x and render 1.13x.
  • Fedora CI with -Db_ndebug=false -Dtools=drm-shim (asahi+poly suites, 320 tests including run-shim.py): 317 Ok / 3 Fail, same 3 pre-existing asahi-egl-priority-{allow,deny,once} failures as aurora-wip tip.
  • Agent policy check (DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD) → PR is clean.

Risk: two-way · G16G (M4) and G17P (M4 Pro, M4 Max, A18 Pro). Code paths touched are read by every HAL200 AGX3B part; G18G, M5 and G15*/AGX2 stay on their existing paths through narrow capability bits.

Not yet: 1-8B 2x/4x MSAA colour compression on G16G is gated separately by AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION (G17P only) because the full --jobs 4 CTS still witnesses intermittent PBE read unmapped level 3 unit 0x41 on a handful of dEQP-VK.api.copy_and_blit.core.resolve_image.diff_layout_copy_before_resolving.{2_bit_general_transfer_dst_optimal_bind_offset, 4_bit_general_transfer_dst_optimal} variants on G16G. The Gen9 PBE / texture / ZLS / AIL metadata encodings are byte-identical across G16G and G17P, so turning MSAA colour on for G16G later is a one-row change to the capability table once the triage lands in a dedicated follow-up.

Details

The policy already shared between G16G and G17P (hk_hal200_compression_eligible) is now selected by AGX_CAP_HAL200_LOSSLESS_COMPRESSION instead of a chip-id list, so every path that depends on it — private colour and depth compression, shared DRM_FORMAT_MOD_APPLE_GPU_TILED_COMPRESSED modifiers, Gen9 compressed compute mip blits (hk_g17p_compressed_blit_supported), in-place libagx_agx3_decompress spill, and the hk_chip_shared_compression_supported modifier advertisement — enables on G16G without touching call sites.

Supporting fixes:

  • hk_image.c: use effective stencil usage for split depth/stencil layouts; check shared modifier queries with the allocation policy, reject unusable modifier lists, validate compressed import strides; extend the host-copy performance probe's cube-compatible array layer count to include native HAL200 and M5 so the HIC query reflects the real shape.
  • hk_cmd_meta.c: use a sampled-image layout for samplerless graphics resolves (the compressed source takes this path, and its push writes must match the pipeline layout even when blits use combined image samplers); split 2D-array VkCmdResolveImage into per-layer passes on native HAL200 whenever either image is compressed, mirroring hk_g17p_image_copy_slice / hk_g17p_image_blit_slice — the BG/EOT contract is single-layer and the generic vk_meta resolve otherwise reaches compressed arrays through a layered render pass whose per-layer metadata stride is derived by the hardware and is unreliable under --jobs 4 concurrency.
  • Tests: capability selection, compressed layouts and image creation with separate stencil usage, modifier lists and explicit DMA-BUF layouts; AGX3B G16G formats / shapes / usages; new HAL200 PBE-descriptor layouts with the pbe_header() helper (matching the -Winitializer-overrides discipline upstream switched to for the texture packets).
  • The new AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION bit (G17P only for now) keeps 1-8B 2x/4x MSAA colour on G16G plain while the depth MSAA, 1x colour, 16-byte colour, and shared compressed modifiers all reach the shared Gen9 encoding on G16G.
Evidence

Base A = e87a3156f31fe5ec8277c7e8b83aa690c5329ae4 (origin/aurora-wip at rebase time, rebased again cleanly onto newer tip pre-push); candidate B = 1b94686bb1021c953696ddd17af93dbe5472d310. Both AArch64 tarballs built via fedora-mbuild.sh with m5-super16-gl-vk-zink.opts (owner m4-hal200-g16g-A).

CTS pass 1 (B, 1b94686bb102) — cts-B-1/summary.json:

{"cases": 5981, "recorded": 5981, "counts": {"Pass": 3050, "NotSupported": 2931}, "stop": null, "secs": 6, "recoveries": 0, "intest_secs": 8.1}

CTS pass 2 (B, back-to-back) — cts-B-2/summary.json:

{"cases": 5981, "recorded": 5981, "counts": {"Pass": 3050, "NotSupported": 2931}, "stop": null, "secs": 7, "recoveries": 0, "intest_secs": 9.5}

Fedora -Db_ndebug=false -Dtools=drm-shim CI at 1b94686bb102: FEDORA-CI 1b94686bb1021c953696ddd17af93dbe5472d310 312/3 after-rc=1, failures = {asahi-egl-priority-allow, asahi-egl-priority-deny, asahi-egl-priority-once} (identical to aurora-wip tip e87a3156f31f re-run).

Select private colour and depth compression, shared compressed modifiers
and compressed mip blits by the native HAL200 hardware capability. G16G
uses the classic submission crossover and G17P keeps the dual-submission
crossover.

Use effective stencil usage for split depth/stencil layouts. Check
shared modifier queries with the allocation policy, reject unusable
modifier lists and validate compressed import strides. Probe supported
image dimensions for host copy layout compatibility.

Exercise capability selection, compressed layouts and image creation
with separate stencil usage, modifier lists and explicit DMA-BUF
layouts.

Use a sampled-image layout for samplerless graphics resolves. The
compressed source takes this path, and its push writes must match the
pipeline layout even when blits use combined image samplers.

Split a 2D-array VkCmdResolveImage into per-layer passes on native
HAL200 whenever either image is compressed. The qualified BG/EOT
contract is single-layer, and image copies and blits already split their
2D-array regions this way (hk_g17p_image_copy_slice,
hk_g17p_image_blit_slice); the generic vk_meta resolve otherwise reaches
the compressed array through a layered render pass whose per-layer
metadata stride is derived by the hardware and is unreliable under
concurrent GPU use.

Gate 1-8B 2x/4x MSAA colour compression on a separate
AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION capability, enabled only on G17P.
The Gen9 PBE/texture/ZLS/AIL encodings are identical across G16G and
G17P, and 1x colour (2D, arrays, cube, 3D), 16-byte single-sample 2D
colour, and 1x/2x/4x depth (single-layer and arrays, both stencil
planes) all pass the --jobs 4 full CTS on G16G at 0 failures. The 1-8B
2x/4x MSAA colour variants still hit intermittent PBE unmapped reads on
a handful of diff_layout_copy_before_resolving cases on G16G (the
qualified path on G17P), so the separate capability keeps those shapes
plain on G16G while the HAL200 contract for every other shape ships.
Follow-up on the MSAA colour side keyed on the same cap.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested a review from a team as a code owner November 25, 2026 12:54
@DjDeveloperr

Copy link
Copy Markdown
Author

Exact-Head Hardware Verification — MacBook Neo (J700, Apple A18 Pro, G17P B1 / AGX3B / HAL200) — PASS (1b94686bb102)

  • Exact head tested: 1b94686bb1021c953696ddd17af93dbe5472d310 vs merge-base e87a3156f31fe5ec8277c7e8b83aa690c5329ae4 (release -Db_ndebug=true, verified deviceName = Apple A18 Pro (G17P B1), driverInfo (git-1b94686bb1), empty BUILD-DIFF.patch).
  • Fedora --suite asahi: 315/315 PASS with DRM shim and assertions (including hal200_vulkan_msaa_depth_compression, hk_vulkan_explicit_plane_layout, test-hk-compression-contract, test-hk-g16s/g17p-compression, test-hk-g17p-decompress, test-hk-g17p-metadata-grid, test-chip-caps), 0 new warnings across all 17 touched files (CI and release).
  • Targeted Vulkan CTS (vk-default mustpass, MAX_RECOVERIES=0): 364 Pass / 268 NotSupported / 0 Fail, 0 recoveries across 632 selected cases:
    • smoke: 8 / 0
    • 2x/4x MSAA RGBA8: 10 / 0
    • 2x/4x MSAA D32 & D32S8 (renderpass1 + renderpass2): 4 / 6 & 4 / 6 (D24S8: 0 / 10 unsupported format)
    • Core resolve_image: 80 / 160
    • blit: 102 / 18, image-copy: 79 / 33, buffer-upload: 77 / 35
  • Host health: 0 GPU fault delta, 0 AVC delta, 0 failed units (7.3.0-41.fc44.aurora.aarch64, SELinux Enforcing).

gpubench-vk Non-Regression Check (A1/B1/B2/A2 + BAAB thermal order check)

Workload Base (e87a3156) Head (1b94686b) Delta Notes
compress.bw msaa4 1080p 294.99 us 294.77 us -0.07% G17P 4x MSAA color compression intact
render.heavy geom 1080p 1,036.27 us 1,033.59 us -0.26%
copy.bw buf2img 22.90 GB/s 22.98 GB/s -0.37% 12/12 64 MiB CRCs 8e2eb8fc
copy.bw buf2buf 23.99 GB/s 24.08 GB/s -0.35%
copy.bw img2img 23.66 GB/s 23.49 GB/s +0.71%
render.heavy fill 1080p (BAAB) 814.34 us 805.32 us -1.11% Order-reversed check (warm)
render.heavy fill 2160p (BAAB) 3,012.05 us 2,994.12 us -0.60% Order-reversed check (warm)
render.postfx 4 1080p (BAAB) 800.00 us 799.38 us -0.08% Order-reversed check (warm)
  • All 5/5 compute CRCs matched on both arms (gaussian, bilateral, sobel, harris, stereo).

@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: FINISH, then merge at 1b94686bb1021c953696ddd17af93dbe5472d310.
Blockers: 1. src/asahi/vulkan/hk_image.c:982 now rejects the external format query for a supported compressed RGBA8 dma-buf with color-attachment and attachment-feedback-loop usage. The explicit import at line 1586 still accepts it. Preserve import eligibility in the format query and keep the allocation policy in modifier-list selection.
Checked: The HAL200 capability now governs the shared compression path. The separate MSAA color bit has a measured fault on G16G. Checked matching resolve layouts and descriptor writes, per-layer address selection, split stencil usage and compressed plane pitch. J773g and J700 have exact passing rows.

Evidence

For an otherwise eligible RGBA8 2D dma-buf, the former query used hk_g17p_shared_compression_supported(), which allows feedback-loop usage for imports. The new query passes that same usage to hk_can_compress_create_info(). Its color path necessarily returns false at hk_image.c:462–474 when that bit is set. Explicit creation still uses the sharing helper at line 1588. Zink forwards the image's usage to the external format query in zink_resource.c:1348–1385.

Please cover both sides in the compression contract test: the dma-buf query and explicit import should accept a compatible RGBA8 modifier with feedback-loop usage, while modifier-list allocation should keep declining compression for that usage. The layout and packed-format checks can stay common.

J773g ran the 5,981-case selection twice with 3,050 passes and 2,931 unsupported in each run. The J700 row reports 364 targeted passes and zero failures or GPU faults. These exercise the transfer paths but do not cover this external modifier query.

Use the shared modifier predicate when reporting image format support. A compatible compressed dma-buf can be imported with attachment feedback even though modifier-list allocation declines compression for that usage.

Exercise the query, explicit plane layout and modifier list with the same RGBA8 dma-buf usage on G16G and G17P.

Signed-off-by: Diljit Singh <hey@djdev.me>
Keep bit 15 for sparse binding and give the two HAL200 compression capabilities distinct bits. Exercise all three capability predicates in the chip table test.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Author

Updated perf/m4-hal200-compress to 82f42e549d19 (4d95804089cb + clean merge of origin/aurora-wip 72c49c5ea0cc incorporating #1052, no force push):

  • External dma-buf format query (4d95804089cb): restored hk_g17p_shared_compression_supported() in hk_GetPhysicalDeviceImageFormatProperties2() so compatible compressed RGBA8 dma-buf queries and explicit imports succeed with VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT while modifier-list allocation still declines compression for that usage. Covered both sides in test-hk-compression-contract.c on G16G and G17P.
  • #1052 capability-bit merge (82f42e549d19): kept AGX_CAP_SPARSE_BINDING at 1u << 15, moved AGX_CAP_HAL200_LOSSLESS_COMPRESSION / AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION to 1u << 16 / 1u << 17, and kept both test suites intact (git merge-tree against current origin/aurora-wip afbcf61fd96 is clean).

Exact-head verification at 82f42e549d19:

  • Fedora (-Db_ndebug=false, --suite asahi): 321/321 PASS (0 failed), including hk_compression_contract, hk_g17p_compression, hk_g17p_decompress, and chip_caps.
  • J773g (T8132, G16G B0, 7.3.0-ARCH-m4mainefed1ae3):
    • Full 5,981-case CTS (--jobs 1): 3,050 Pass / 2,931 NotSupported / 0 Fail / 0 recoveries / 0 faults.
    • Targeted CTS (301 Pass / 384 NotSupported / 0 Fail / 0 recoveries) + 10× dEQP-VK.api.copy_and_blit.core.depth_stencil_msaa_copy.* (--jobs 4, 0 recoveries / 0 faults).
    • Targeted gpubench-vk: 44/44 CRCs valid.
    • Note on --jobs 4 full 5,981-case CTS on 7.3.0-ARCH-m4mainefed1ae3: 4-way A/B (82f42e549d19 vs 1b94686bb102 vs pure origin/aurora-wip 72c49c5ea0cc vs pre-#1050 base e87a3156f31f) confirmed intermittent cross-VM compute UL1C(3)/UL1C(4) (unit 0x31/0x41, va 0x0..0x380 and va 0x400fff..., compute_owners: quarantined vs render_owners: 0) recoveries reproduce identically on pure origin/aurora-wip (72c49c5ea0cc) and e87a3156f31f without #1050; all tested builds pass all 5,981 cases at --jobs 1 with 0 recoveries and 0 faults. Tracking that aurora-g16 kernel cross-VM compute issue separately.

Ready for @RyanTheTide re-review and merge.

Keep bit 16 for full ZLS render bounds and move the Borealis HAL200 compression capabilities to bits 17 and 18.

Signed-off-by: Diljit Singh <hey@djdev.me>

Copy link
Copy Markdown
Author

Merged #1040 into this branch at 94284cc11874d4bdbaa5ed3fa857f011c47728b4. Sparse binding keeps bit 15 and ZLS full render bounds keeps bit 16. Borealis HAL200 lossless and MSAA colour compression now use 1u << 17 and 1u << 18, respectively.

Fedora passed all 316 Asahi tests on this commit with -Db_ndebug=false and DRM-shim enabled, including the chip capability and compression contract tests.

@DjDeveloperr

Copy link
Copy Markdown
Author

Exact-Head Hardware Verification Refresh — MacBook Neo (J700, Apple A18 Pro, G17P B1 / AGX3B / HAL200) — PASS (94284cc11874)

  • Exact head tested: 94284cc11874d4bdbaa5ed3fa857f011c47728b4 (release -Db_ndebug=true, verified deviceName = Apple A18 Pro (G17P B1), driverInfo (git-94284cc118), empty BUILD-DIFF.patch).
  • Fedora --suite asahi: 316/316 PASS with DRM shim and assertions (including dma-buf feedback-loop contract, hal200_vulkan_msaa_depth_compression, explicit plane layout, and test-chip-caps with bits 17/18), 0 new warnings across all 17 touched files.
  • Targeted Vulkan CTS (vk-default mustpass, MAX_RECOVERIES=0): 364 Pass / 268 NotSupported / 0 Fail, 0 recoveries — matched all 632 outcomes from 1b94686bb102 case-for-case (smoke 8/0, 2x/4x MSAA RGBA8 10/0, D32/D32S8, core resolve_image 80/160, blit 102/18, image-copy 79/33, buffer-upload 77/35).
  • gpubench-vk sanity: compress.bw msaa4 1080p 293.47 us/submit (G17P 4x MSAA color compression intact), render.heavy fill 688.47 us (1080p) / 2,424.24 us (2160p), 3/3 64 MiB copy CRCs matched 8e2eb8fc, 5/5 compute CRCs matched (gaussian, bilateral, sobel, harris, stereo).
  • Host health: 0 GPU fault delta, 0 AVC delta, 0 failed units (7.3.0-41.fc44.aurora.aarch64, SELinux Enforcing).

@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: FINISH, then merge at 94284cc11874d4bdbaa5ed3fa857f011c47728b4.
Blockers: src/asahi/lib/agx_chip_caps.h also gives bit 17 to the native mixed epilog in #1059. Once #1059 lands, forward this change with distinct HAL200 lossless and MSAA bits, such as 18 and 19 if still free. Run the capability and compression-contract tests and refresh the J773g and J700 rows at the resulting head.
Checked: The compressed dma-buf feedback-loop query now agrees with explicit import. Both use the shared modifier predicate. The predicate admits the HAL200 lossless capability or the AGX3C/HAL300 hardware format, then checks the image shape and store class. Modifier-list allocation still declines feedback-loop compression.

Evidence

The test now covers query and explicit import acceptance plus allocation refusal with feedback-loop usage. The exact J700 row reports 316/316 host tests, 364 CTS passes, zero CTS failures and zero GPU faults. The J773g row tests an earlier head.

Keep bit 17 for the native mixed-format epilog and move the Borealis HAL200 compression capabilities to bits 18 and 19.

Signed-off-by: Diljit Singh <hey@djdev.me>

Copy link
Copy Markdown
Author

Verified 32940bc028ae49ba119527b1258a89d3716c22b1 after merging #1059. Native mixed epilog keeps bit 17. Borealis HAL200 lossless and MSAA colour compression use 1u << 18 and 1u << 19, respectively.

Fedora passed all 318 Asahi tests with -Db_ndebug=false. On J773g (G16G B0), kernel 7.3.0-ARCH-m4mainefed1ae3, single-worker Vulkan CTS finished with 301 Pass / 384 NotSupported / 0 Fail in the targeted set and 3,050 Pass / 2,931 NotSupported / 0 Fail in the 5,981-case qualification set. All 44 targeted gpubench CRCs matched. The kernel journal recorded zero GPU faults or recoveries, and the driver recovery counter was unchanged.

@DjDeveloperr

Copy link
Copy Markdown
Author

PASS on MacBook Neo J700 (Apple A18 Pro, G17P B1 / AGX3B / HAL200) at exact head 32940bc028ae (Borealis git-32940bc028, kernel 7.3.0-41.fc44.aurora.aarch64, zero reboots):

  • Fedora Asahi unit suite (-Db_ndebug=false + DRM shim): 318/318 PASS (including HAL200 lossless/MSAA color caps at bits 18/19, compression contract, MSAA depth, explicit-plane layout); 0 new compiler warnings across all 17 PR-touched files.
  • Vulkan CTS (vk-default, 632 cases, MAX_RECOVERIES=0): 364 Pass / 268 NotSupported / 0 Fail / 0 recoveries (100% case-for-case match with prior rows).
  • Compression / copy / compute sanity (gpubench-vk):
    • compress.bw 1080p 4× MSAA (d1): 292.83 µs/submit, CRC 8e8e7791 (matches prior 293.47 µs).
    • compress.fill (d1): 686.11 µs (1080p), 2,702.70 µs (2160p, single-run sanity).
    • 64 MiB buffer→image, image→image, buffer→buffer copies: 3/3 CRC 8e2eb8fc; Gaussian/bilateral/Sobel/Harris/stereo compute: 5/5 expected CRCs.
  • System health: 0 GPU faults, 0 new AVC denials, 0 failed units, SELinux Enforcing.

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

Resolved: HAL200 lossless compression and MSAA colour compression are capability bits (AGX_CAP_HAL200_LOSSLESS_COMPRESSION, AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION) in the chip caps table, and the format-properties path tests the capability. The contract test pins which chips carry them and that MSAA compression implies lossless. Bits moved to 18/19 after #1059. 318/318 asahi, exact-head J773g + J700 PASS, mirror CI green. Clearing my change request.

DjDeveloperr added a commit that referenced this pull request Nov 25, 2026
Resolve the conflict in test-hk-compression-contract.c with #1050
(HAL200 lossless compression on G16G), keeping both #1050's HAL200
format/modifier/image-creation checks and #732's R11G11B10 EOT class
assertions intact.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr DjDeveloperr closed this pull request by merging all changes into aurora-wip in b502b36 Nov 25, 2026
astaff pushed a commit to astaff/mesa that referenced this pull request Nov 26, 2026
…l200-compress

borealis: enable HAL200 lossless compression on G16G
@RyanTheTide

Copy link
Copy Markdown

Post-merge regression on G16G with an older kernel. M4 Air (J713, Apple M4 G16G, 7.3.0-aurora-fleet85): on aurora-wip, 3,744 of 128,141 cases in renderpasses.renderpass1/2, api.image_clearing, dynamic_rendering.primary_cmd_buff and synchronization2.op.single_queue fail. Packaged Mesa passes all of them on the same boot. Bisect: the first bad commit is this merge (5269d5817de9); its parent e736b5f2fa7c is good. Every depth/stencil attachment submit gets IOCTL: submit failed! (err: EINVAL) from the kernel. Your rows used a newer 7.3.0-ARCH-m4main... kernel, so I think the compressed depth/stencil path needs a kernel change that fleet85 doesn't have.

Two asks: (1) Which kernel change does this need, and is it in the current EDGE/fleet89 kernel? (2) Per the no-gates rule, Mesa should read that capability from the kernel UAPI and fall back to uncompressed depth/stencil when it's missing. Right now every G16G Mac on an older kernel loses depth/stencil rendering. If the capability can't be probed, we should revert the depth/stencil half until it can.

Evidence

traces/gpu/20261127-merge-blitz-rows/1171-j713/ (bisect-g16g-ds-einval.log, kmsg.txt, np-aurora-wip-90211df, np-system-mesa). Found during the J713 row for #1171, which isn't the cause.

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