Skip to content

borealis: allow final-pass colour resolves and STORE->DONT_CARE in pass merging - #1195

Merged
DjDeveloperr merged 8 commits into
aurora-wipfrom
perf/borealis-final-resolve-pass-merge
Nov 27, 2026
Merged

DjDeveloperr merged 8 commits into
aurora-wipfrom
perf/borealis-final-resolve-pass-merge

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown

What: Allow consecutive render pass instances to merge when the continuing instance discards a stored attachment (STORE -> DONT_CARE) or terminates the merged tile pass with a final colour resolve over whole attachments, both in-buffer (hk_m5_pass_merge_begin()) and across command buffers at submission (hk_render_pack.c).

Tested: Exact head 8116d1358e00 (merged onto aurora-wip c2940816a18d) on two Apple Silicon generations — J700 MacBook Neo (G17P B1) and J773g M4 Mac mini (G16G B0):

  • J700 (G17P B1) exact-head 8116d1358e00 vs c2940816a18d (same-boot ABBA+BAAB, n = 4/arm, stock 7.3.0-41.fc44.aurora.aarch64, isolated release Mesa overlays; see comment):
    • render.msaa_merge 4x rgba16f 1080p d4: -33.5% wall (1240.7 -> 825.1 us), -16.9% GPU (cmds 2 -> 1, zero distribution overlap, expected CRCs on every run)
    • render.msaa_merge 4x rgba8 1080p d4: -22.3% wall (1131.2 -> 878.7 us), -17.6% GPU
    • render.msaa_merge 2x rgba8 1080p d4: -18.3% wall (755.3 -> 617.3 us), -13.7% GPU
    • Targeted Vulkan CTS on 8116d1358e00: 12,352 cases (9,750 dynamic_rendering resolve, 2,602 renderpass2 resolve) — 5,417 Pass, 6,935 NotSupported, 0 Fail, 0 recoveries.
    • Host health: stock.sh PRE/POST=0, SELinux=Enforcing, 0 GPU faults/warnings/AVCs/failed units.
    • Full extended matrix & controls (render.postfx, render.deferred, render.light flat within ±0.7%, GPU 0.00%; ASAHI_MESA_DEBUG=verify 7/7 clean) verified on f73f756c23f below.
  • J773g (G16G B0, second generation) (see comment): PASS (render.msaa_merge 4x rgba16f d4 0.654x, 4x rgba8 d4 0.780x, 2x rgba16f d4 0.798x, controls 0.996x–1.015x, 12,693 resolve/multisample CTS cases 5,536 Pass / 0 Fail, 0 faults; exact-head 8116d1358e00 recheck PASS).
  • CI & unit tests on 8116d1358e00: Fedora 44 Mesa Asahi CI (asahi + poly) 217/0 PASS (0 new warnings); hk_render_pack_test 294/294 PASS on both G17S and G16G (including 30 new assertions for hk_m5_pass_merge_non_local_src() and 3-CB resolve hazard chains).

Risk: two-way door · HAL200 (M3/M4/A18 Pro G15/G16/G17P) and HAL300/M5 (G17G/G17S/G17C) running Borealis Vulkan. Plain revert restores the prior storeOp/resolveMode refusal. AGX2 and G18G unaffected.

Not yet: None (both J700 G17P B1 and J773g G16G B0 exact-head rows and non-author review at 8116d1358e00 are complete).

Details

Previously, hk_m5_attachment_continues() and hk_render_pack_continues() required identical storeOp and rejected any non-NONE resolveMode. In multi-pass MSAA workloads where earlier passes use storeOp = STORE, resolveMode = NONE and the final pass uses loadOp = LOAD, storeOp = DONT_CARE, resolveMode = AVERAGE_BIT (e.g. render.msaa_merge, deferred/postfx MSAA pipelines), passes 0..N-2 merged, flushed the entire MSAA surface to DRAM, and pass N-1 started a second render pass to reload the MSAA surface before resolving.

  • In-buffer continuation (src/asahi/vulkan/hk_cmd_draw.c):
    • hk_m5_attachment_continues() permits STORE -> DONT_CARE on colour attachments (and depth/stencil when zls_precise) and final-pass colour resolves over whole attachments whose resolve target matches the pass dimensions, ignoring VK_RENDERING_ATTACHMENT_RESOLVE_SKIP_TRANSFER_FUNCTION_BIT_KHR on the resolving pass.
    • Final-pass resolves are restricted to framebuffer-local dependencies (!ordered), with no pending transfer (!hk_sync_xfer_pending), no resolve-target aliasing of existing attachments, and no tile footprint overlap with an earlier render pass in the same command buffer.
    • hk_m5_pass_merge_begin() updates attachment metadata, rebuilds render->cr.eot.main through the existing BG/EOT cache while preserving bg.main, bg.partial, and eot.partial (so partial renders and mid-pass splits still store/reload samples cleanly), updates tile_resources (M5), sets process_empty_tiles and appends the resolve target to cs->fragment_attachments and hk_sync_pass_footprint() when direct resolve is selected, and re-packs zls_control_only/zls_control_last on depth/stencil STORE -> DONT_CARE.
    • When the resolving pass ends, hk_m5_pass_merge_refusal() already refuses further continuation (resolve / g17p_direct_color_resolve), so the resolving pass cleanly terminates merging.
  • Submit-time render packing (src/asahi/vulkan/hk_render_pack.c):
    • hk_render_pack_continues() permits colour STORE -> DONT_CARE and local final-member colour resolves while refusing continuation after any resolving pass (x->resolve_mode != VK_RESOLVE_MODE_NONE).
    • hk_render_pack_boundary() / render_pack_streams_match() require whole attachments for resolving members, allow eot.main, process_empty_tiles, tile_resources.{primary,secondary}_bytes, and merged fragment_attachments to differ when the final member changes EOT/resolves, and hk_render_pack_add() folds process_empty_tiles, tile_resources maxima, and the merged fragment_attachments set onto the packet stream.
  • Unit tests (src/asahi/vulkan/tests/test-hk-render-pack.c): Added 28 assertions (236 -> 264) across both G17S and G16G covering STORE -> DONT_CARE, invalid store transitions (STORE -> NONE, DONT_CARE -> STORE, depth STORE -> DONT_CARE), local vs ordered final-member resolves, partial render-area refusal, run termination after a resolving member, and packet folding of EOT, empty-tile processing, tile resources, and fragment attachment sets.
Evidence

Provenance

  • Hardware: J700 MacBook Neo (apple,j700 apple,t8140), Apple A18 Pro (G17P B1), Fedora 44, kernel 7.3.0-41.fc44.aurora.aarch64 (boot 8b28e162-b180-44b5-8a9b-231a2442f7dc).
  • Base (origin/aurora-wip 41fe336dffa): libvulkan_asahi.so SHA-256 0a304f30318edee9c4559715d2319b4e86487458e832fd757a3ac53d4c62cb0c
  • Head (f73f756c23f): libvulkan_asahi.so SHA-256 afc288bc43686ac88501b8365f1d0b3a19c6535b3231493d99a25dd51d65ccd1
  • Protocol: gpubench-vk (0167e1f028ca0dea1e6a45fcb52f86d9ba5b0616f84381422548a2c25f112e98), --warmup-ms 300 --runs 5 --run-ms 250 --timed-runs 3 --timestamps on, MESA_SHADER_CACHE_DISABLE=true, exact-commit same-boot A1 B1 B2 A2 B3 A3 A4 B4 (n = 4 per arm).

J700 ABBA+BAAB Results

Test Params Depth Base µs/sub Head µs/sub Wall Δ Base GPU µs Head GPU µs GPU Δ CRC (A = B = expected)
render.msaa_merge samples=4, fmt=rgba16f, passes=4, 1080p d4 1453.5 992.1 -31.75% 1888.0 1539.6 -18.46% 57e9bbd5
render.msaa_merge samples=4, fmt=rgba16f, passes=4, 1080p d1 1602.6 1131.2 -29.41% 1720.3 1418.9 -17.52% 57e9bbd5
render.msaa_merge samples=4, fmt=rgba8, passes=4, 1080p d4 1216.6 943.4 -22.45% 1536.6 1304.0 -15.14% c8d1f0a2
render.msaa_merge samples=4, fmt=rgba8, passes=4, 1080p d1 1329.8 1059.3 -20.34% 1378.8 1187.2 -13.89% c8d1f0a2
render.msaa_merge samples=4, fmt=rgba8, passes=4, 1440p d4 2283.2 1773.0 -22.34% 2815.4 2373.5 -15.70% 35623166
render.msaa_merge samples=4, fmt=rgba8, passes=4, 1440p d1 2451.0 1953.1 -20.31% 2587.2 2202.8 -14.86% 35623166
render.msaa_merge samples=2, fmt=rgba8, passes=4, 1080p d4 732.5 568.8 -22.35% 910.6 805.6 -11.53% c8d1f0a2
render.msaa_merge samples=2, fmt=rgba8, passes=4, 1080p d1 841.8 731.0 -13.16% 786.8 686.6 -12.73% c8d1f0a2
render.postfx (ctrl) msaa=4, 1080p d1 / d2 728.9 / 602.4 727.8 / 601.7 -0.15% / -0.12% 527.5 / 680.6 527.3 / 680.6 -0.04% / 0.00% 668d6f0a
render.deferred (ctrl) mode=tile, msaa=4, 1080p d1 / d2 1103.8 / 863.6 1098.9 / 863.6 -0.44% / 0.00% 878.9 / 867.2 878.9 / 867.2 0.00% / 0.00% 6dc74b48
render.light (ctrl) kind=tri d1 / d8 122.3 / 28.9 121.5 / 28.9 -0.68% / +0.10% 9.5 / 5.8 9.5 / 5.8 +0.23% / 0.00% —

Per-run wall µs/sub (A1 A2 A3 A4 vs B1 B2 B3 B4):

  • 4x rgba16f 1080p d4: 1404.5 1453.5 1453.5 1453.5 vs 980.4 992.1 992.1 996.0
  • 4x rgba16f 1080p d1: 1562.5 1602.6 1612.9 1602.6 vs 1126.1 1136.4 1131.2 1131.2
  • 4x rgba8 1080p d4: 1162.8 1213.6 1225.5 1219.5 vs 932.8 943.4 943.4 943.4
  • 4x rgba8 1440p d4: 2232.1 2272.7 2293.6 2293.6 vs 1760.6 1773.0 1773.0 1785.7
  • 2x rgba8 1080p d4: 690.6 750.8 714.3 753.0 vs 568.2 569.5 568.2 570.8

Frame Anatomy Proof (render.msaa_merge, 4x RGBA16F 1080p)

  • Base 41fe336dffa: pass-merge continue (draws_before=1, 2) -> pass-merge end: color store op -> cmds=2 recs=2.
  • Head f73f756c23f: pass-merge continue (draws_before=1, 2, 3) -> no tail: ... direct resolve -> cmds=1 recs=1.

Correctness & CI

  • ASAHI_MESA_DEBUG=verify smoke on f73f756c23f: 7/7 workloads (render.msaa_merge ×4, render.postfx msaa4, render.deferred tile msaa4, compress.bw msaa4 db9d414b) PASS, empty stderr, bit-exact CRCs.
  • Vulkan CTS (deqp-vk --jobs 1, MESA_SHADER_CACHE_DISABLE=true): 5,131 cases (dynamic_rendering.*(resolve|multisample), pipeline.monolithic.multisample.resolve.*, renderpass2.dedicated_allocation.*multisample*): 2,153 Pass, 2,978 NotSupported, 0 Fail.
  • Fedora 44 Mesa Asahi CI (./rig/fedora-mesaci.sh f73f756c23fe9ae46f17b2a718919ad3b0ad8a2b): 215/0 PASS, 0 new warnings.
  • drm-shim CI (-Dbuildtype=debugoptimized -Db_ndebug=false -Dtools=drm-shim -Dbuild-tests=true): hk_render_pack_test 264/264 PASS, meson test --suite asahi 329/332 PASS (only the 3 pre-existing container asahi-egl-priority-{allow,deny,once} failures).
  • DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD: PR is clean.

…ss merging

Allow consecutive render pass instances to merge when the continuing
instance discards a stored attachment (STORE -> DONT_CARE) or terminates
the merged tile pass with a final colour resolve over whole attachments,
both within a command buffer (hk_m5_pass_merge_begin) and across command
buffers at submission (hk_render_pack).

Previously, a multi-pass MSAA sequence such as MSAA draw passes with
STORE followed by a final MSAA draw+resolve pass with LOAD/DONT_CARE
merged the intermediate passes, flushed the entire MSAA surface to DRAM,
and started a second render pass to reload the MSAA surface and resolve
it. Rebuilding the final end-of-tile program (and updating direct-resolve
empty-tile processing, fragment attachments, tile resources, and sync
footprints) eliminates the intermediate MSAA store/reload round trip.

Final-pass resolves are restricted to framebuffer-local dependencies
over whole attachments whose resolve target does not alias an existing
attachment or share a tile footprint with an earlier render pass, and
never allow further continuation after the resolving pass.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 03:20
@DjDeveloperr

DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Author

J773g (M4 Mac mini, G16G B0, second generation) at 0bca37a851bb (aurora-wip 5ab97d0f2c60 merged, plus the preserve_load build fix), against aurora-wip 5ab97d0f2c60: PASS, no regression. The MSAA pass-merging speedup holds at the merged head.

The setup is the same as below. Both arms were built natively on the Mac for this head.

gpubench-vk ABBA (us_per_submit, head/base; lower is better; CRCs equal on all four runs of every row):

row A1 / B1 / B2 / A2 head/base
render.deferred , d1 489.40 / 488.60 / 478.47 / 476.95 1.001
render.deferred , d2 238.10 / 238.66 / 236.41 / 237.15 1.000
render.light , d16 59.64 / 59.73 / 59.49 / 59.14 1.004
render.msaa_merge fmt=rgba16f samples=4, d1 872.09 / 647.95 / 643.78 / 879.77 0.737
render.msaa_merge fmt=rgba8 samples=4, d1 767.26 / 646.55 / 650.76 / 773.20 0.842
render.msaa_merge fmt=rgba16f samples=2, d4 325.38 / 258.62 / 258.62 / 325.38 0.795
render.msaa_merge fmt=rgba16f samples=4, d4 591.72 / 386.60 / 386.60 / 591.72 0.653
render.msaa_merge fmt=rgba8 samples=4, d4 497.51 / 388.60 / 388.60 / 500.83 0.778
render.postfx , d1 958.47 / 946.37 / 906.34 / 917.43 0.988
render.postfx , d2 779.22 / 777.20 / 775.19 / 775.19 0.999

A first ABBA pass overlapped an 8 s build on the Mac, so it was discarded and rerun; the table is the rerun.

VK CTS at 1 worker, the same 12,693-case list as below, both arms: 5,536 Pass and 7,157 NotSupported, with 0 cases that differ.

GPU health: 0 faults, 0 recoveries and failed 0 errno 0 degraded 0 at start and end.


Older head c61216471920: J773g (M4 Mac mini, G16G B0, second generation) at c61216471920 (review fix plus an aurora-wip merge), against its aurora-wip parent fa8970cda14f: PASS, no regression. The MSAA pass-merging speedup holds at this head.

The setup is the same as below: release Borealis Vulkan overlays loaded through VK_DRIVER_FILES on stock 7.3.0-ARCH-m4mainefed1ae3, system Mesa untouched, each arm's vulkaninfo showing its git SHA. Both arms were built for this head natively on the Mac.

gpubench-vk ABBA (us_per_submit, head/base; lower is better; CRCs equal on all four runs of every row):

row A1 / B1 / B2 / A2 head/base
render.msaa_merge samples=4 fmt=rgba16f, d1 874.64 / 649.35 / 646.55 / 874.64 0.741
render.msaa_merge samples=4 fmt=rgba16f, d4 589.39 / 386.60 / 386.60 / 589.39 0.656
render.msaa_merge samples=4 fmt=rgba8, d1 769.23 / 652.17 / 646.55 / 767.26 0.845
render.msaa_merge samples=4 fmt=rgba8, d4 495.87 / 388.60 / 389.11 / 496.69 0.784
render.msaa_merge samples=2 fmt=rgba16f, d4 323.97 / 258.84 / 258.62 / 324.68 0.798
control render.postfx d1 / d2, two repeats 931.68 / 906.34 / 903.61 / 906.34 · 777.20 / 781.25 / 779.22 / 779.22 0.985 / 1.003, then 1.014
control render.deferred d1 / d2 483.87 / 488.60 / 488.60 / 489.40 · 238.10 / 236.97 / 238.10 / 238.28 1.004 / 0.997
control render.light d16 59.89 / 61.45 / 60.48 / 61.14 1.007

The first render.postfx d1 pass read 1.028 because of one outlier run (B2 955.41). The two repeats in the table read 0.985 and 1.014.

VK CTS at 1 worker, the same 12,693-case list as below, both arms: 5,536 Pass and 7,157 NotSupported, with 0 cases that differ.

GPU health: 0 faults, 0 recoveries and failed 0 errno 0 degraded 0 at start and end.


Older head 8116d1358e00: J773g (M4 Mac mini, G16G B0, second generation) at 8116d1358e00 (aurora-wip merged in), against its aurora-wip parent c2940816a18d: PASS, no regression. The MSAA pass-merging speedup holds on the merged head.

The setup is the same as below: release Borealis Vulkan overlays loaded through VK_DRIVER_FILES on stock 7.3.0-ARCH-m4mainefed1ae3, system Mesa untouched, each arm's vulkaninfo showing its git SHA. Both arms were rebuilt for this head: the base is the aurora-wip parent of the merge.

gpubench-vk ABBA (us_per_submit, head/base; lower is better; CRCs equal on all four runs of every row):

row A1 / B1 / B2 / A2 head/base
render.msaa_merge samples=4 fmt=rgba16f, d1 854.70 / 645.16 / 649.35 / 857.14 0.756
render.msaa_merge samples=4 fmt=rgba16f, d4 590.55 / 386.10 / 386.60 / 595.24 0.652
render.msaa_merge samples=4 fmt=rgba8, d1 769.23 / 647.95 / 649.35 / 767.26 0.844
render.msaa_merge samples=4 fmt=rgba8, d4 495.87 / 388.60 / 389.11 / 497.51 0.783
render.msaa_merge samples=2 fmt=rgba16f, d4 324.32 / 258.62 / 258.62 / 323.97 0.798
control render.postfx d1 / d2 882.35 / 898.20 / 879.77 / 882.35 · 773.20 / 771.21 / 775.19 / 773.20 1.008 / 1.000
control render.deferred d1 / d2 488.60 / 490.20 / 489.40 / 485.44 · 236.59 / 237.53 / 236.41 / 237.53 1.006 / 1.000
control render.light d16 60.36 / 59.56 / 59.82 / 59.46 0.996

VK CTS at 1 worker, the same 12,693-case list as below, both arms: 5,536 Pass and 7,157 NotSupported, with 0 cases that differ.

GPU health: 0 faults, 0 recoveries and failed 0 errno 0 degraded 0 at start and end.


Older head ef675c15145c: J773g (M4 Mac mini, G16G B0, second generation) at ef675c15145c, against its merge-base 41fe336dffae: PASS, no regression. The MSAA pass-merging speedup holds after the barrier fix.

The setup is the same as below: release Borealis Vulkan overlays loaded through VK_DRIVER_FILES on stock 7.3.0-ARCH-m4mainefed1ae3, system Mesa untouched, each arm's vulkaninfo showing its git SHA. The base overlay is the same build as below.

gpubench-vk ABBA (us_per_submit, head/base; lower is better; CRCs equal on all four runs of every row):

row A1 / B1 / B2 / A2 head/base
render.msaa_merge samples=4 fmt=rgba16f, d1 864.55 / 643.78 / 642.40 / 869.57 0.742
render.msaa_merge samples=4 fmt=rgba16f, d4 588.24 / 386.60 / 386.60 / 589.39 0.657
render.msaa_merge samples=4 fmt=rgba8, d1 767.26 / 645.16 / 649.35 / 767.26 0.844
render.msaa_merge samples=4 fmt=rgba8, d4 497.51 / 388.60 / 389.11 / 495.87 0.783
render.msaa_merge samples=2 fmt=rgba16f, d4 323.97 / 258.84 / 258.84 / 323.97 0.799
control render.postfx d1 / d2, two repeats 890.21 / 900.90 / 872.09 / 877.19 · 781.25 / 775.19 / 769.23 / 773.20 1.003 / 0.994, then 0.993
control render.deferred d1 / d2 481.54 / 487.80 / 487.80 / 489.40 · 235.48 / 235.85 / 236.41 / 236.59 1.005 / 1.000
control render.light d16 58.80 / 59.59 / 58.39 / 58.55 1.005

The first render.postfx d1 pass read 1.063 because of one outlier run (B2 958.47). Two repeats right after read 1.003 and 0.993.

VK CTS at 1 worker, the same 12,693-case list as below, run on the head only, compared with the base run below: 5,536 Pass and 7,157 NotSupported, with 0 cases that differ.

GPU health: 0 faults, 0 recoveries and failed 0 errno 0 degraded 0 at start and end.


Older head f73f756c23fe: J773g (M4 Mac mini, G16G B0, second generation) at f73f756c23fe, against its merge-base 41fe336dffae: PASS, no regression. MSAA pass merging is much faster on G16G.

Both arms are release Borealis Vulkan overlays, cross-built off the Mac and loaded from private prefixes through VK_DRIVER_FILES, on the stock kernel 7.3.0-ARCH-m4mainefed1ae3. System Mesa wasn't touched. Each arm's vulkaninfo shows its git SHA.

gpubench-vk ABBA (us_per_submit, head/base; lower is better; CRCs equal on all four runs of every row):

row A1 / B1 / B2 / A2 head/base
render.msaa_merge samples=4 fmt=rgba16f, d1 864.55 / 645.16 / 647.95 / 874.64 0.744
render.msaa_merge samples=4 fmt=rgba16f, d4 590.55 / 386.10 / 386.60 / 591.72 0.654
render.msaa_merge samples=4 fmt=rgba8, d1 769.23 / 646.55 / 649.35 / 769.23 0.842
render.msaa_merge samples=4 fmt=rgba8, d4 498.34 / 389.11 / 388.60 / 499.17 0.780
render.msaa_merge samples=2 fmt=rgba16f, d4 324.32 / 258.62 / 258.84 / 323.97 0.798
control render.postfx d1 / d2 884.96 / 895.52 / 909.09 / 911.85 · 779.22 / 779.22 / 775.19 / 781.25 1.004 / 0.996
control render.deferred d1 / d2 484.65 / 487.01 / 488.60 / 476.95 · 237.15 / 235.48 / 235.11 / 234.93 1.015 / 0.997
control render.light d16 59.30 / 59.32 / 59.23 / 58.71 1.005

VK CTS at 1 worker, 12,693 cases: dEQP-VK.renderpasses.dynamic_rendering.*resolve* (9,750), renderpasses.renderpass2.*multisample* (2,931) and pipeline.monolithic.multisample.resolve.* (12). Both arms give 5,536 Pass and 7,157 NotSupported, with 0 cases that differ.

GPU health: 0 faults, 0 recoveries and failed 0 errno 0 degraded 0 at start and end.

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

Blockers:

  1. attachment_set_merge() increases its local count on a dry run without filling the corresponding dst->list entry, then includes that unwritten slot in the duplicate scan. The capacity check can therefore depend on leftover entries and disagree with the actual merge. Calculate both using the same initialized scratch union, preferably reusing hk_drm_attachment_set_add() for overlap coalescing, and test a near-full set with multiple resolve targets.
  2. Add the M4 or M5 regression row listed in the PR before landing this shared scheduling change.

Checked: Reviewed same-buffer continuation, cross-buffer packing, per-pass footprint handling, EOT replacement, color/ZS store transitions, and the current Neo evidence. The posted Neo CTS row reports 2,153 passes and zero failures.

Evidence

render_pack_streams_match() passes a local copy and apply=false, while hk_render_pack_add() uses apply=true for the final member. After a new member, those calls currently scan different contents for the same logical attachment list.

@DjDeveloperr

Copy link
Copy Markdown
Author

Verdict at f73f756c23fe: changes needed

Blockers

  1. A final-pass resolve can merge into a tile pass whose earlier fragment shaders still read or write the resolve image.
    • Cause. hk_m5_pass_merge_dependency() (src/asahi/vulkan/hk_pass_merge.h:91-93) calls any barrier "local" when its second scope is colour output with attachment access, whatever its first scope is. That was safe while a continuing instance only touched the first instance's own attachments. A resolve now writes a new image in that same stage, and nothing checks how the first instance's descriptors access that image.
    • Sequence.
      • Pass A: 4x colour C, LOAD/STORE, no resolve. Its fragment shader samples the single-sample image X (layout GENERAL).
      • vkCmdPipelineBarrier2 with one memory barrier: FRAGMENT_SHADER/SHADER_SAMPLED_READ → COLOR_ATTACHMENT_OUTPUT/COLOR_ATTACHMENT_WRITE. This is the write-after-read barrier the app needs before it overwrites X.
      • Pass B: C with LOAD/DONT_CARE, resolveMode = AVERAGE, resolveImageView = X.
    • What happens.
      • That barrier classifies as HK_M5_MERGE_DEP_LOCAL, so ordered is false and the any_resolve ? "resolve" refusal (hk_cmd_draw.c:4649) never runs.
      • The resolve checks at hk_cmd_draw.c:4659-4684 cover only pending transfers, A's attachments and other streams' pass records. X is in none of them, so B merges.
      • The rebuilt eot.main then writes X at the end of each tile. A's fragment shaders in tiles processed later can still sample any part of X, so they read resolved data instead of the old contents.
      • A storage write to X from A's fragment shader fails the same way: A's write can land after the resolve.
      • Without the merge, the barrier keeps all of A's fragment work ahead of B's resolve.
    • Other paths with the same gap.
      • Using a layout transition (SHADER_READ_ONLY_OPTIMAL → COLOR_ATTACHMENT_OPTIMAL) instead of GENERAL changes nothing: hk_m5_pass_merge_classify() drops transitions of non-attachment images (hk_cmd_draw.c:4234-4239).
      • Across command buffers (A at the end of one; the barrier and B at the head of the next), the same sequence passes hk_render_pack_continues() (hk_render_pack.c:74). hk_render_pack_att carries no resolve view, so nothing there could check it.
    • Suggested fix. Allow a final resolve only when every barrier recorded between the two instances has its first scope inside the attachment stages (early/late fragment tests, colour output) or outside graphics. For render packs this also covers the tail and head barriers.
      • For example, keep a flag next to ordered in hk_m5_pass_merge_classify() and hk_render_pack_classify()/hk_render_pack_note_barrier(), and refuse any_resolve/y_resolves when it is set.
      • A barrier whose first scope covers only attachment stages cannot order A's shader accesses to X anyway, so an app relying on one already races.
      • A unit test that asserts the resolve is refused after a FRAGMENT_SHADER → COLOR_ATTACHMENT_OUTPUT barrier would pin this down.

Checked

  • STORE -> DONT_CARE:
    • The merged pass skips A's intermediate store, just as an equal-store-op merge already does.
    • Partial renders keep eot.partial/bg.partial, so mid-pass flushes still store and reload every sample.
    • A continuation after a DONT_CARE member can only keep DONT_CARE.
    • Depth/stencil drop is in-buffer only, behind zls_precise, with zls_control_only/_last repacked. Render packs refuse it.
  • Resolve gating:
    • Colour only, over whole attachments, with a matching resolve-target extent. Refused under ordered dependencies.
    • Nothing continues after the resolving member: in-buffer, hk_m5_pass_merge_refusal() sees resolve_mode/g17p_direct_color_resolve; in packs, x->resolve_mode refuses.
    • Without a direct resolve (M5), is_attachment_stored() still stores the MSAA image and the end-of-rendering meta resolve runs as before.
  • Pack fold: B's EOT, process_empty_tiles, tile-resource maxima and fragment attachment set reach the packet. B's sync requirements and pass records carry over.
  • Chip gating: unchanged (agx_chip_native_or_m5()). AGX2 and G18G are untouched.
  • Merge and policy:
    • Merges cleanly onto aurora-wip e1b5658fe695.
    • agent-policy.sh pr HEAD: PR is clean. Commit and PR text are fine and signed off.
  • Build and tests:
    • Debugoptimized build with -Dvulkan-drivers=asahi -Dbuild-tests=true: no warnings in the touched files.
    • meson test --suite asahi 212/212, --suite poly 5/5, hk_render_pack_test 264/264.
  • Mutations the tests catch:
    • Dropping || ordered from the resolve refusal in hk_render_pack_continues() causes 4 failures.
    • Dropping the whole-attachment resolve check in render_pack_streams_match() causes 2 failures.

Still owed: the blocker above, then the second-generation hardware row (M4 G16G) listed under Not yet. The J700 row and targeted CTS in the PR body stand for this head.

Evidence

Classifier probe, built against hk_pass_merge.h at f73f756c23fe with the hk_render_pack_test flags:

FS sampled read -> colour output write: LOCAL
FS storage write -> colour output write: LOCAL
ALL_GRAPHICS -> colour output write: LOCAL
FS read -> FS write (control): ORDERED

Tests:

meson test --suite asahi   Ok: 212  Fail: 0
meson test --suite poly    Ok: 5    Fail: 0
hk_render_pack_test        264 tests, 0 failures

Mutations:

- if (y_resolves && (!is_color || ordered))  ->  (!is_color)
  FAIL final-member colour resolve refuses across an ordered dependency (x2)
  FAIL final-member colour resolve refuses ordered dependencies (x2)
  264 tests, 4 failures
- resolving whole-attachment check -> if (0)
  FAIL final-member colour resolve refuses partial render areas (x2)
  264 tests, 2 failures

…cs barriers

hk_m5_pass_merge_dependency() classifies any barrier whose destination
scope is attachment-only (e.g. FRAGMENT_SHADER -> COLOR_ATTACHMENT_OUTPUT)
as HK_M5_MERGE_DEP_LOCAL, regardless of its source stage. That is safe
when continuing only the first instance's attachments, but a final-pass
colour resolve writes a separate resolve image in COLOR_ATTACHMENT_OUTPUT:
merging across a FRAGMENT_SHADER -> COLOR_ATTACHMENT_OUTPUT WAR/WAW
barrier lets earlier fragment shaders in later tiles race with the resolve
target writes.

Track barriers whose first scope covers non-attachment graphics stages
while reaching graphics (hk_m5_pass_merge_non_local_src()) across both
in-buffer pass merges (hk_pass_merge_candidate::non_local_src,
hk_cs::m5_non_local_src) and submit-time render packs
(hk_render_pack_edges::head_non_local_src/tail_non_local_src,
hk_render_pack_run_state::non_local_src), and refuse final-pass resolves
whenever set while preserving non-resolving continuations.

Add unit tests covering hk_m5_pass_merge_non_local_src(),
hk_render_pack_continues(), single-boundary head/tail/in-buffer refusals,
and 3-command-buffer runs where a non-local barrier precedes a later
resolving member.

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

Copy link
Copy Markdown
Author

Addressed the non-attachment graphics source barrier blocker in ef675c15145c:

  • Added hk_m5_pass_merge_non_local_src() in src/asahi/vulkan/hk_pass_merge.h to detect any barrier whose first scope covers graphics stages outside the attachment stages (EARLY_FRAGMENT_TESTS, LATE_FRAGMENT_TESTS, COLOR_ATTACHMENT_OUTPUT) while its second scope reaches graphics.
  • Tracked this flag through both in-buffer pass merging (hk_pass_merge_candidate::non_local_src, hk_cs::m5_non_local_src) and submit-time render packing (hk_render_pack_edges::head_non_local_src/tail_non_local_src, hk_render_pack_run_state::non_local_src), refusing final-pass colour resolves whenever set (including across multi-pass/multi-CB chains) while still allowing non-resolving continuations.
  • Added unit tests in src/asahi/vulkan/tests/test-hk-render-pack.c covering hk_m5_pass_merge_non_local_src() stage combinations, hk_render_pack_continues(), head/tail/in-buffer boundary refusals, and a 3-CB chain where a non-local barrier precedes a later resolving member.

Verified on ef675c15145c:

  • Fedora CI (asahi + poly): 215/0 PASS
  • hk_render_pack_test: 294 tests, 0 failures (both G17S and G16G)

Exact-head J700 confirmation row will follow next.

@DjDeveloperr

Copy link
Copy Markdown
Author

Verdict at ef675c15145c: changes needed

The resolve-after-barrier hazard from the last review is fixed. What's left is a build break on the current base.

Blockers

  1. The PR no longer builds once merged into aurora-wip (1e793d856d4a).
    • Cause. The merge is textually clean, but borealis: fold clear-only passes into deferred clears, drop dead clears, and extend dead Z/S store kill to D32S8 #1171 (1eece864) removed hk_rendering_state::process_empty_tiles_without_z, no_z_store_ok and zls_control_only_no_z_store. hk_m5_pass_merge_begin() still sets two of them:
      hk_cmd_draw.c:4799: error: 'struct hk_rendering_state' has no member named 'process_empty_tiles_without_z'
      hk_cmd_draw.c:4866: error: 'struct hk_rendering_state' has no member named 'no_z_store_ok'
      
    • Fix. Rebase and map them to what borealis: fold clear-only passes into deferred clears, drop dead clears, and extend dead Z/S store kill to D32S8 #1171 added:
      • In the direct-resolve branch, process_empty_tiles_without_z = true becomes render->empty_tiles_other = true. Otherwise a later dead depth/stencil store kill (hk_take_pending_z_store()) rebuilds process_empty_tiles without the resolve, and empty tiles stop getting resolved.
      • In the depth/stencil STORE -> DONT_CARE branch, no_z_store_ok = false becomes clearing render->pending_zs_store_mask. Otherwise the merged pass records a pending store for an aspect it no longer stores.
    • Check. With exactly those two lines changed, the merged tree builds with no new warnings in the touched files. meson test --suite asahi passes 214/214, --suite poly 5/5 and hk_render_pack_test 294/294.

Checked (incremental fix f73f756c23fe..ef675c15145c)

  • The new check:
    • hk_m5_pass_merge_non_local_src() flags any graphics source stage outside early/late fragment tests and colour output, when the destination reaches graphics.
    • ALL_GRAPHICS, ALL_COMMANDS, BOTTOM_OF_PIPE (which hk_sync_kinds_src() treats as ALL) and mixed FS|COLOR sources count. COLOR-only, attachment stages only, compute and TOP_OF_PIPE sources don't.
    • It covers memory, buffer and image barriers.
  • In one command buffer:
    • pass_merge.non_local_src is cleared when each candidate is made (hk_CmdEndRendering2KHR()).
    • It is set in hk_m5_pass_merge_classify() and carried on the stream as hk_cs::m5_non_local_src.
    • So A → non-local barrier → B (merged) → local barrier → C (resolve) is refused at C.
    • Event waits and anything else that records work already end the candidate.
  • Across command buffers:
    • head_non_local_src and tail_non_local_src are zeroed with cmd->render_pack at begin/reset.
    • hk_render_pack_end() seeds the tail flag from the stream, and later tail barriers OR into it.
    • run_non_local_src() folds in the run state, both edges and the member's stream, and hk_render_pack_run_join() carries it forward. A non-local barrier anywhere earlier in a run therefore blocks a later resolving member, as in the three-command-buffer test.
    • Only barriers inside the tile pass are counted, which is right: earlier passes are ordered by stream waits.
  • Non-resolving continuations: unaffected. render.msaa_merge uses COLOR_ATTACHMENT_OUTPUT -> COLOR_ATTACHMENT_OUTPUT barriers, so the measured merge still applies.
  • At the PR head:
    • No warnings in the touched files.
    • asahi 212/212, poly 5/5, hk_render_pack_test 294/294.
    • agent-policy.sh pr HEAD: PR is clean. Both commits are signed off with no attribution lines.
  • Mutations the tests catch:
    • Dropping non_local_src from hk_render_pack_continues(): 8 failures.
    • Not carrying run->non_local_src: 4.
    • Ignoring the head flag: 4.
    • Ignoring the tail flag: 2.
    • Not masking the local stages: 4.

Still owed:

  • The rebase above.
  • A J700 row at the rebased head. The Tested section is still at f73f756c23f; a short render.msaa_merge rerun plus the targeted resolve/multisample CTS is enough.
  • The second-generation row listed under Not yet.
Evidence
merge aurora-wip 1e793d856d4a + ef675c15145c: clean; ninja: 2 errors (above)
same merge with the two-line mapping:
  meson test --suite asahi   Ok: 214  Fail: 0
  meson test --suite poly    Ok: 5    Fail: 0
  hk_render_pack_test        294 tests, 0 failures

PR head ef675c15145c:
  meson test --suite asahi   Ok: 212  Fail: 0
  meson test --suite poly    Ok: 5    Fail: 0
  hk_render_pack_test        294 tests, 0 failures

mutations (hk_render_pack_test):
  continues: drop "|| non_local_src"          -> 8 failures
  run_non_local_src: drop run->non_local_src  -> 4 failures (incl. "a resolving CB2 does not join a run with an earlier non-local barrier")
  run_non_local_src: drop head flag           -> 4 failures
  run_non_local_src: drop tail flag           -> 2 failures
  non_local_src: no "& ~local_stages"         -> 4 failures

Update hk_m5_pass_merge_begin() for #1171's pending depth/stencil store
fields:
- set render->empty_tiles_other = true (replacing removed
  process_empty_tiles_without_z) when adding a direct colour resolve
- clear render->pending_zs_store_mask (replacing removed no_z_store_ok)
  when depth/stencil store ops change on STORE -> DONT_CARE.

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

Copy link
Copy Markdown
Author

Merged aurora-wip (c2940816a18) cleanly at 8116d1358e00 and updated the two #1171 fields in hk_m5_pass_merge_begin():

  • render->empty_tiles_other = true when adding a direct colour resolve (replacing removed process_empty_tiles_without_z).
  • render->pending_zs_store_mask = 0 when depth/stencil store ops change on STORE -> DONT_CARE (replacing removed no_z_store_ok).

Verified on 8116d1358e00:

  • Fedora CI (asahi + poly): 217/0 PASS
  • hk_render_pack_test: 294 tests, 0 failures (both G17S and G16G)

Exact-head J700 rerun (render.msaa_merge + resolve/multisample CTS) is running now and will post right after.

@DjDeveloperr

Copy link
Copy Markdown
Author

Verdict at 8116d1358e00: ready

Blockers

None. The build break against aurora-wip from the last review is resolved.

Checked (delta ef675c15145c..8116d1358e00)

  • The merge resolution is exactly the two mapped lines. git show --remerge-diff 8116d135 differs from the automatic merge of c2940816a18d only in:
    • render->empty_tiles_other = true in the direct-resolve branch of hk_m5_pass_merge_begin();
    • render->pending_zs_store_mask = 0 in the depth/stencil STORE -> DONT_CARE branch.
  • Interaction with borealis: fold clear-only passes into deferred clears, drop dead clears, and extend dead Z/S store kill to D32S8 #1171's dead depth/stencil store kill:
    • hk_CmdBeginRendering() runs hk_take_pending_z_store() before every instance. A continuing instance loads depth/stencil, so it kills nothing and clears the first instance's pending store.
    • At the end of the merged instance, the pending store is rebuilt from the merged render state. A resolve keeps empty_tiles_other set, so a later kill keeps process_empty_tiles and still resolves empty tiles.
    • A depth or stencil STORE -> DONT_CARE drop leaves no pending store, so nothing later rewrites the ZLS words this PR repacked.
    • Colour-only merges keep the first instance's mask, as before.
  • Test-merge onto current aurora-wip 65866bbd5bb3:
    • Clean, and the merged tree no longer references either removed field.
    • Debugoptimized build with -Dvulkan-drivers=asahi -Dbuild-tests=true: no warnings in the touched files.
    • meson test --suite asahi 214/214, --suite poly 5/5, hk_render_pack_test 294/294.
  • Policy: agent-policy.sh pr HEAD: PR is clean. The merge commit is signed off, with no attribution lines.

Still owed before merge:

  • The J700 and J773g rows at this head.
  • The Tested and Evidence sections still name f73f756c23f. Update them with those rows, and drop the second-generation item from Not yet once J773g is in.
Evidence
git show --remerge-diff 8116d135 (hk_cmd_draw.c only):
-         render->process_empty_tiles_without_z = true;
+         render->empty_tiles_other = true;
-      render->no_z_store_ok = false;
+      render->pending_zs_store_mask = 0;

merge aurora-wip 65866bbd5bb3 + 8116d1358e00:
  meson test --suite asahi   Ok: 214  Fail: 0
  meson test --suite poly    Ok: 5    Fail: 0
  hk_render_pack_test        294 tests, 0 failures

@DjDeveloperr

DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Author

J700 (MacBook Neo, A18 Pro G17P B1) at exact head 8116d1358e00, against base aurora-wip c2940816a18d: PASS. The merge still fires after the aurora-wip merge and with the barrier guard, and the speedup holds.

Both arms are release Borealis Vulkan overlays, cross-built off the Mac with the same options and loaded from private prefixes through VK_DRIVER_FILES, on the stock kernel 7.3.0-41.fc44.aurora.aarch64. System Mesa wasn't touched. Each arm's driver id shows its git SHA.

gpubench-vk ABBA+BAAB (A1 B1 B2 A2 B3 A3 A4 B4, n = 4 per arm, render.msaa_merge passes=4 1080p d4, median us_per_submit; lower is better):

row base head wall Δ GPU Δ base runs / head runs
4x rgba16f 1240.7 825.1 -33.5% -16.9% 1237.6 1237.6 1243.8 1243.8 / 825.1 ×4
4x rgba8 1131.2 878.7 -22.3% -17.6% 1131.2 ×4 / 871.1 877.2 880.3 883.4
2x rgba8 755.3 617.3 -18.3% -13.7% 748.5 755.3 757.6 755.3 / 615.8 617.3 617.3 618.8

The runs don't overlap on any row. CRCs match the expected value on every run of both arms (57e9bbd5 for rgba16f, c8d1f0a2 for rgba8).

Frame anatomy (HK_FRAME_ANATOMY, 4x rgba16f 1080p): base gives cmds=2 recs=2 (pass-merge end: color store op). Head gives cmds=1 recs=1, with every pass continuing (draws_before 1, 2, 3) and no store-op split.

VK CTS at 1 worker on head, 12,352 cases: renderpasses.dynamic_rendering.*resolve* (9,750) and renderpasses.renderpass2.*resolve* (2,602). Results: 5,417 Pass, 6,935 NotSupported, 0 Fail, 0 recoveries.

Health: 0 GPU faults, 0 driver warnings, 0 AVC denials, failed 0, SELinux Enforcing. stock.sh is the same before and after.


Exact-head addendum: J700 at c61216471920 (after the review fixes and the #1206 att_bloom merge), against merge-base fa8970cda14f: PASS.

  • Setup: isolated fedora-mbuild kits, one per SHA, with driver ids git-c612164719 and git-fa8970cda1 on the A18 Pro. Stock kernel 7.3.0-41, no reboot.
  • gpubench-vk ABBA+BAAB after a 30 s warm-up (b h h b h b b h), median us per submit at 1080p:
    • render.msaa_merge 4x rgba16f (passes=4): d1 1770 → 1250 (−29.4 %), d4 1572 → 1075 (−31.6 %).
    • render.deferred mode=tile msaa=4: d1 −0.4 %, d4 −0.2 %.
    • render.postfx msaa=4: d1 −0.1 %, d4 −1.1 %.
    • All 48 results ok, with every output check valid.
  • CTS on the head: every renderpasses.*resolve* case (renderpass1, renderpass2, dynamic_rendering), 33,387 cases at 3 workers: 11,450 Pass, 21,937 NotSupported, 0 Fail, 0 recoveries.
  • Health: 0 GPU faults, 0 driver warnings, 0 AVC denials, 0 failed units and 0 core dumps. stock.sh was identical before and after.

Exact-head addendum: J700 at 0bca37a851bb (the aurora-wip 5ab97d0f2c60 merge plus the preserve_load fix), against merge-base 5ab97d0f2c60: PASS.

  • Setup: isolated release kits built with the same options, with driver ids git-0bca37a851 and git-5ab97d0f2c on the A18 Pro. Stock kernel 7.3.0-41, no reboot.
  • gpubench-vk ABBA+BAAB (A1 B1 B2 A2 B3 A3 A4 B4, n = 4 per arm), median us per submit at 1080p:
    • render.msaa_merge 4x rgba16f (passes=4): d1 1515.2 → 1050.4 (−30.7 %), d4 1288.7 → 880.3 (−31.7 %).
    • render.msaa_merge 4x rgba8 (passes=4): d4 1184.8 → 924.2 (−22.0 %).
    • The base and head runs don't overlap on any msaa_merge row.
    • render.deferred mode=tile msaa=4: d1 +0.4 %, d2 +0.3 %. render.postfx msaa=4: d1 −0.2 %, d2 +0.2 %. Both overlap with base.
    • CRCs match base on all 7 rows (57e9bbd5, c8d1f0a2, 6dc74b48, 668d6f0a).
  • Frame anatomy: base gives cmds=2 recs=2, head gives cmds=1 recs=1.
  • CTS on the head at 1 worker: 33,025 cases, made of every renderpasses.*resolve* case (30,517), memory.*alias* (108) and renderpasses.*.attachment_allocation.* (2,400). Results: 11,242 Pass, 21,783 NotSupported, 0 Fail, 0 recoveries.
  • Health: 0 GPU faults, 0 driver warnings, 0 AVC denials, failed 0. stock.sh was identical before and after.

Exact-head addendum: J700 at 1a8a0d9866f1 (post-#1212 aurora-wip merge), against merge-base 13400438325f: PASS.

  • Setup: isolated release kits built with the same options, with driver ids git-1a8a0d9866 and git-1340043832 on the A18 Pro. Stock kernel 7.3.0-41, no reboot.
  • gpubench-vk ABBA+BAAB (A1 B1 B2 A2 B3 A3 A4 B4, n = 4 per arm), median us per submit at 1080p:
    • render.msaa_merge 4x rgba16f (passes=4): d1 1515.2 → 1050.4 (−30.7 %), d4 1366.1 → 931.1 (−31.8 %).
    • render.msaa_merge 4x rgba8 (passes=4): d4 1240.7 → 965.3 (−22.2 %).
    • The base and head runs don't overlap on any msaa_merge row.
    • render.deferred mode=tile msaa=4: d1 +0.2 %, d2 +0.3 %. render.postfx msaa=4: d1 0.0 %, d2 0.0 %. Both overlap with base.
    • CRCs match base on all 7 rows (57e9bbd5, c8d1f0a2, 6dc74b48, 668d6f0a).
  • Frame anatomy: base gives cmds=2 recs=2 (pass-merge end: color store op), head gives cmds=1 recs=1.
  • CTS on the head at 1 worker: 33,025 cases, made of every renderpasses.*resolve* case (30,517), memory.*alias* (108) and renderpasses.*.attachment_allocation.* (2,400). Results: 11,242 Pass, 21,783 NotSupported, 0 Fail, 0 recoveries.
  • Health: 0 GPU faults, 0 driver warnings, 0 AVC denials, failed 0. stock.sh was identical before and after.

…hment_set_add

attachment_set_merge() previously incremented its local count during
dry-run (apply=false) without populating dst->list, causing subsequent
duplicate checks to read unwritten slots beyond dst->count and allowing
the dry-run capacity check to disagree with the real submission merge.

Always build the union in a freshly initialized scratch
hk_drm_attachment_set using hk_drm_attachment_set_add() (sharing its
duplicate/overlap/adjacency coalescing) and copy back to *dst only when
apply is true. Link hk_drm_render_core.c into hk_render_pack_test and
add unit tests for a near-full attachment set with poisoned unused slots
and multiple resolve targets (both coalescing fit and overflow refusal).

Signed-off-by: DjDeveloperr <hey@djdev.me>
Merge aurora-wip (fa8970c, including #1206 attachment image bloom
narrowing) and update hk_m5_pass_merge_begin() to fold final-pass
resolve targets into render->att_bloom (via shared hk_image_att_bloom()
with UINT64_MAX fallback for unsafe images) and cs->sync.kind
(HK_SYNC_GFX_MEM when m5_attachments_reach_memory is set) before
hk_sync_merge_rendering().

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

Copy link
Copy Markdown
Author

Addressed both the attachment_set_merge() review blocker and the #1206 follow-up:

  1. 755a3fb6449 (Ryan's attachment_set_merge() blocker):

    • attachment_set_merge() now validates and commits through a single initialized scratch hk_drm_attachment_set using the real hk_drm_attachment_set_add() helper, copying the scratch set back to dst only when apply is true. Dry-run and commit paths can no longer disagree on capacity or read unwritten slots.
    • Linked hk_drm_render_core.c into hk_render_pack_test and added unit coverage for a nearly full attachment set with poisoned trailing slots and multiple resolve targets (both exact-fit and overflow rejection).
  2. c6121647192 (aurora-wip merge through fa8970cda14f / #1206):

    • Merged aurora-wip (fa8970cda14f) and added shared hk_image_att_bloom() to fold final-pass resolve target images (falling back to UINT64_MAX when unsafe) into render->att_bloom and HK_SYNC_GFX_MEM in hk_m5_pass_merge_begin() before hk_sync_merge_rendering().
  3. Verification at c6121647192:

    • Fedora arm64 release build + unit suite: 214 Ok / 0 Fail (3 unrelated 30s load timeouts on agx_tests, hk_pack, hk_compute_pair), hk_render_pack_test 312 tests, 0 failures, ICD git-c612164719.
    • Exact-head J700 and J773g confirmation rows queued at c6121647192.

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

Blockers: none in the code. The attachment_set_merge() blocker from my review at f73f756c23fe is fixed by 755a3fb6449. Two items are still open before merge:

  1. The branch is DIRTY against aurora-wip 5ab97d0f2c60. Please merge aurora-wip once (no rebase). The conflicts are in hk_cmd_draw.c and tests/test-hk-render-pack.c, against bcd0ad7 (exact buffer-alias and VA-range tracking for ALIAS_BIT render sync and packing). They are semantic, not textual:
    • In hk_render_pack_classify(), keep both sides. aurora-wip's transparent now allows ALIAS_BIT images unless they are undef_alias and hk_render_pack_aliases_va(); your *non_local_src |= hk_m5_pass_merge_non_local_src(...) stays as well.
    • In hk_begin_rendering(), take aurora-wip's loop (hk_image_mem_may_alias_buffer(), m5_attachments_alias_image, has_alias_image_render/buffer_alias_mem_gen) and keep hk_image_att_bloom() for the bloom part.
    • The merge-path copy of the old aliasing rule in hk_m5_pass_merge_begin() (the direct-resolve loop that sets m5_attachments_reach_memory from the resolve image, hk_cmd_draw.c:4832-4839 at this head) does not conflict textually, but it should follow the same new rule. Otherwise a resolve target merged into a pass is classified differently from one that starts its own pass.
  2. The J773g (G16G) row at the merged head (the second-generation regression row; Dj's last update says it is queued). The J700 row at c61216471920 covers this head; a short rerun at the merged head is enough.

Checked:

  • The fix. attachment_set_merge() now builds the union in a freshly initialized scratch set through hk_drm_attachment_set_add(). It copies the result back only when apply is set, so the dry run (render_pack_streams_match()) and the commit (hk_render_pack_add()) run the same code on the same contents.
  • Trying to break it. Unwritten slots are never read. complete is the AND of both sets, and the struct has no other fields to lose in *dst = merged. Rebuilding dst through the helper only coalesces further, and the helper's entries stay pairwise non-touching, so a span that grows cannot newly overlap an entry it already passed. Zero-size, null or wrapping entries make the merge refuse instead of being silently dropped.
  • The new tests are real. With only the old attachment_set_merge() restored, hk_render_pack_test fails 4 of 312 (the two near-full set cases, each run twice).
  • Merge c61216471920. It folds the resolve targets into att_bloom through the shared hk_image_att_bloom() and adds HK_SYNC_GFX_MEM when the resolve reaches memory. That matches what hk_begin_rendering() does for a pass that is not merged.
  • Earlier fixes. The ef675c15145c non-local-source refusal and the 8116d1358e00 #1171 field mapping are unchanged since Dj's checks.
Evidence

x86 clang build (release + asserts), hk_render_pack_test only:

  • head c61216471920: 312 tests, 0 failures
  • head with 755a3fb6449's hk_render_pack.c hunk reverted: 312 tests, 4 failures
    • FAIL near-full attachment set with coalescing resolve targets packs line678 (x2)
    • FAIL near-full attachment set folds cleanly at submit line689 (x2)

git merge-tree --write-tree origin/aurora-wip c61216471920: CONFLICT in src/asahi/vulkan/hk_cmd_draw.c and src/asahi/vulkan/tests/test-hk-render-pack.c. aurora-wip commits since merge-base fa8970cda14f touching those files: bcd0ad7, b587acb, b6df568, bcad442 (via #1145, #1144, #362).

…pass-merge

Resolve semantic conflicts against bcd0ad7 in hk_cmd_draw.c and
test-hk-render-pack.c:
- Keep both aurora-wip's ALIAS_BIT VA-alias transparent check and
  hk_m5_pass_merge_non_local_src() in hk_render_pack_classify().
- Keep aurora-wip's hk_image_mem_may_alias_buffer() / alias_image_render
  loop in hk_begin_rendering() alongside hk_image_att_bloom().
- Apply the same hk_image_mem_may_alias_buffer() / alias_image_render
  rule to merged resolve targets in hk_m5_pass_merge_begin() so merged
  resolve targets match hk_begin_rendering() and hk_sync.c.
- Keep both the final-member resolve fold and timestamp packet tests in
  test-hk-render-pack.c.

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

@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: HOLD at 3733de1d29ae

Blockers:

  1. src/asahi/vulkan/hk_cmd_draw.c:5025: the head doesn't build. The resolve-target hk_sync_pass_footprint() call in hk_m5_pass_merge_begin() passes 9 arguments, but aurora-wip's hk_sync_pass_footprint() (hk_sync.c:149) now takes 10 (bool preserve_load after preserve_layers):
    hk_cmd_draw.c:5030:18: error: too few arguments to function call, expected 10, have 9.
    Fix: pass false as preserve_load. Resolve targets are written whole and never loaded, the same as the color resolve entries in hk_begin_rendering()'s preserve_loaded[] table (only LOAD_OP_LOAD attachments set it). Then post J773g + J700 rows at the new head.

Checked:

  • The resolution of the bcd0ad7 conflicts is otherwise what the merge message says:
    • hk_render_pack_classify() keeps both aurora-wip's VA-alias transparent test and hk_m5_pass_merge_non_local_src().
    • hk_m5_pass_merge_begin()'s resolve targets now use the same hk_image_mem_may_alias_buffer() / alias_image_render rule as hk_begin_rendering().
    • The old unconditional ALIAS/LINEAR "reach memory" loop is replaced by that rule, which still covers LINEAR, SPARSE and buffer-bound or exported ALIAS memory.
    • Both test blocks are kept in test-hk-render-pack.c.
  • The approval at c612164 (the attachment_set_merge() fix) still stands for the code.
Evidence

Local x86 drm-shim gate (-Dtools=asahi,drm-shim, clang) of this head merged into aurora-wip a97571c6b283. The merge is clean, and #1204 only touches src/asahi/compiler/, so this is the head's own tree: ninja fails on libhk.a.p/hk_cmd_draw.c.o with the error above. aurora-wip a97571c6b283 alone: 338 Ok / 0 Fail.

…_load

Pass preserve_layers (matching hk_begin_rendering()) and preserve_load=false
to hk_sync_pass_footprint() in hk_m5_pass_merge_begin() after #1144 added
the preserve_load parameter.

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

@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 0bca37a851bbdc97885ab10bced6357f04fc97e5

Blockers: none. The build break from my review at 3733de1d29ae is fixed. Rows are owed: J773g (G16G) and J700 (G17P) at this head.

Checked: I read the delta 3733de1d29ae..0bca37a851bb.

  • hk_m5_pass_merge_begin() now passes 10 arguments to hk_sync_pass_footprint() for each resolve target:
    • preserve_layers = render->view_mask && render->view_mask != BITFIELD64_MASK(pass_layers), which is the expression hk_begin_rendering() uses for the same resolve entries in its written[] loop. The old call passed false here, so a sparse-multiview resolve now counts as partial (preserve). That is the more conservative footprint and matches the non-merged path.
    • preserve_load = false, which matches preserve_loaded[] for the resolve slots in hk_begin_rendering(): only LOAD_OP_LOAD colour/depth/stencil attachments set it, and resolve targets are written whole.
  • The rest of the bcd0ad7 resolution was checked at 3733de1d29ae and is unchanged.
Evidence

Local drm-shim gate (x86 clang, release + asserts, meson test --suite asahi --suite poly):

  • aurora-wip fffdc5c7c634: Ok 338, Fail 0
  • aurora-wip fffdc5c7c634 + 0bca37a851bb (clean merge, tree 488ca6c6fdc1): Ok 338, Fail 0. It builds; hk_render_pack_test passes.

@RyanTheTide

Copy link
Copy Markdown

0bca37a851bb J700 (Neo, Apple A18 Pro / G17P B1, 7.3.0-aurora-fleet89) PASS: Borealis exact-head overlay ICD (VK_DRIVER_FILES, -Dbuildtype=release -Db_ndebug=false, stock /usr/lib64/libvulkan_asahi.so verified byte-identical before/after); meson test --suite asahi 215/215 PASS; deqp-vk 1,956 PASS / 0 FAIL (api.smoke.* 8/8, renderpasses.dynamic_rendering*resolve* 1,5 689/1938, renderpasses.renderpass2.*resolve* 1,5 1259/4214); 0 GPU faults/recoveries, Enforcing, 0 failed units, 0 new AVC.

@RyanTheTide

Copy link
Copy Markdown

0bca37a851bb J615 (M3 Air, Apple M3 / G15G C0, 7.3.0-aurora-fleet90-airs2) PASS: Borealis exact-head overlay ICD (VK_DRIVER_FILES, -Dbuildtype=release -Db_ndebug=false, stock /usr/lib64/libvulkan_asahi.so verified byte-identical before/after); deqp-vk 1,956 PASS / 0 FAIL (api.smoke.* 8/8, renderpasses.dynamic_rendering*resolve* 1,5 689/1938, renderpasses.renderpass2.*resolve* 1,5 1259/4214); 0 GPU faults/recoveries, Enforcing, 0 failed units, 0 new AVC.

@RyanTheTide

Copy link
Copy Markdown

This PR had every row at its head and our approval: J700 + J615 at 0bca37a851bb, both PASS. It was about to merge, but it now conflicts with aurora-wip 27439695. #1212 (merged 13400438) changed hk_render_pack.c's registers_differ() to take the two hk_cs and to read the main/partial EOT via full_eot_main() / full_eot_partial(). This PR adds the eot_changes parameter and the !eot_changes && ... guards (process_empty_tiles, eot.main) in the same lines, plus the resolving check at the caller.

To finish:

  1. Merge aurora-wip into the branch. Keep borealis: multi-slot geometry heap ring and cross-CB pre-graphics/elided render packing #1212's hk_cs signature, add bool eot_changes, and apply the guard to full_eot_main(cs_a/cs_b). Maintainer edits are off, so we can't push it.
  2. Since the resolution touches the merge predicate, post J700 + one other-generation row at the new head (PEER-ROWS can run J700/J615 again).

We'll do the resolution review and gate as soon as it's pushed.

@RyanTheTide

Copy link
Copy Markdown

1a8a0d9866f1 J700 (Neo, Apple A18 Pro / G17P B1, 7.3.0-aurora-fleet89) + J615 (M3 Air, Apple M3 / G15G C0, 7.3.0-aurora-fleet90-airs2) PASS: Borealis exact-head overlay ICD (VK_DRIVER_FILES, -Dbuildtype=release -Db_ndebug=false, stock /usr/lib64/libvulkan_asahi.so verified byte-identical before/after on both Macs); meson test --suite asahi 215/215 PASS; deqp-vk 1,956 PASS / 0 FAIL on J700 and 1,956 PASS / 0 FAIL on J615 (api.smoke.* 8/8, renderpasses.dynamic_rendering*resolve* 1,5 689/1938, renderpasses.renderpass2.*resolve* 1,5 1259/4214); 0 GPU faults/recoveries, Enforcing, 0 failed units, 0 new AVC.

@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 1a8a0d9866f1

Blockers: none

Checked:

  • Merge 1a8a0d98 (aurora-wip 13400438, i.e. #1202 + #1212) resolves the hk_render_pack.c conflict by keeping both sides:
    • registers_differ() takes #1212's hk_cs pair plus this PR's eot_changes, and the guard wraps full_eot_main(cs_a/cs_b).
    • The caller keeps the resolving partial-area refusal and passes eot_changes.
    • hk_render_pack_add() keeps this PR's process_empty_tiles / tile-resource accumulation and #1212's ZLS_CONTROL merge.
    • The last-member eot.main uses #1212's unelided-restore select, so a resolving final member still provides the EOT.
  • Head merged into aurora-wip 6fb394da: local drm-shim gate 338 Ok / 0 Fail.

To finish: J700 + one other-generation row (J615) at 1a8a0d98. The rows at 0bca37a8 predate this hand-resolved merge of the merge predicate.

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