Skip to content

borealis: drop the load of a covered attachment of a direct-resolve pass - #949

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/borealis-direct-resolve-elide-load
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/borealis-direct-resolve-elide-load

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 24, 2026 •

Copy link
Copy Markdown

What: Drop the tile load of a colour attachment that the pass's first draw covers, also when the pass resolves that attachment directly in its end-of-tile program. Zink keeps GL multisample framebuffers LOAD/STORE with an AVERAGE resolve inside the pass, so those passes reloaded the whole multisample tile every frame only to overwrite it.

Tested: M4 mini (J773g, G16G B0) with this change on an earlier integration tree, not yet at this head: gpubench gl-zink compress.bw kind=msaa4 res=1440p d=1 +2.65%, and 189/189 GLES3 FBO, multisample and invalidate CTS cases pass. At this head: the asahi meson suite (184 ok, 0 fail) and fork CI (see Evidence). A drm-shim probe at this head drops the covered load on the G16G and G17P profiles and leaves blended and partial-area passes unchanged.

Risk: two-way · M3, M4, Neo

Not yet: hardware run at this head on an M4 mini (G16G) and a Neo (G17P); M3 (G15) not run.

Details

hk_g17p_elide_untouched_color() already turns the background load of an attachment that the first draw covers into a clear (hk_g17p_note_first_draw(): a full-screen triangle with no blend, logic op, discard, sample mask, partial write mask or rejecting depth/stencil test, under a viewport and scissor that cover the render area). It returned early for every native AGX3 pass with a direct colour resolve, because its rebuild of the end-of-tile programs would lose the resolve.

For a direct-resolve pass this change:

  • keeps the end-of-tile programs (which carry the resolve), the stores and the partial-render reload exactly as they are;
  • never takes the untouched-store branch, since dropping a store would drop the resolve with it;
  • rebuilds only the main background program, with the covered attachments' loads replaced by a clear;
  • still returns for a partial render area, where the direct-resolve background program merges the destination around the area.

The first draw overwrites every sample before anything reads the tile, so the clear changes nothing the pass stores or resolves. M5 passes keep the existing path (direct_resolve is only set off M5), and passes without a direct resolve are unchanged.

Evidence
  • Head a2167deffc9e on aurora-wip d40ba9f9ea2 (includes borealis: fix aurora-wip build breaks after #693 and #703 merges #944).
  • Fork CI on the head commit: asahi run 45415517685 (build-test: success), aurora-agent-policy run 45415517745 (success).
  • asahi meson suite on Fedora aarch64 (-Db_ndebug=false, meson test --suite asahi): 184 ok, 0 fail.
  • agent-policy.sh pr HEAD against a local aurora-wip base: clean.
  • drm-shim probe (ASAHI_SHIM_CHIP=g16g and g17p; 512x512 RGBA8 4x LOAD/STORE with an AVERAGE resolve to 1x, full-screen triangle, ASAHI_MESA_DEBUG=perf):
mode g16g g17p
cover "Dropped loads of covered attachments 0x1 of a pass with a direct resolve" same
blend no elision (unchanged) no elision (unchanged)
partial render area (256x512) existing non-direct path, unchanged unchanged
  • Hardware, earlier integration tree with the same change: gpubench gl-zink compress.bw kind=msaa4 res=1440p d=1 +2.65%; GLES3 FBO / multisample / invalidate CTS 189/189 pass, 0 fail.

hk_g17p_elide_untouched_color() turns the background load of an
attachment that the pass's first draw covers (hk_g17p_note_first_draw())
into a clear. It returned early for every pass with a direct colour
resolve on the native AGX3 path, because rebuilding its end-of-tile
programs would lose the resolve, so the covered load stayed. Zink
resolves a GL multisample framebuffer into its blit target inside the
pass and keeps the samples, as GL requires (LOAD/STORE plus an AVERAGE
resolve), so such a pass reloaded the whole multisample tile it was
about to overwrite on every frame.

For such a pass, do not return. Leave its end-of-tile programs, its
stores and its partial-render reload as they are, never take the
untouched-store branch (dropping a store would drop the resolve with
it), and only rebuild the main background program with the covered
attachments' loads dropped. A partial render area still returns, since
a direct resolve's background program then merges the destination around
it. The first draw writes every sample with no blend, logic op, discard,
sample mask or rejecting depth or stencil test before anything reads the
tile, so dropping the load changes nothing the pass stores or resolves.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 14:35

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at a2167deffc9e

APPROVED

Blockers

None

Checked

  • Audited hk_g17p_elide_untouched_color() and hk_g17p_note_first_draw() in src/asahi/vulkan/hk_cmd_draw.c.
  • Verified direct_resolve = !m5 && render->g17p_direct_color_resolve safely bails out on incomplete_render_area (preserving preserve_resolve_outside background loads), skips attachment store elision (!direct_resolve) so end-of-tile resolves are never dropped, only converts covered attachments' bg_atts[i].loadOp to VK_ATTACHMENT_LOAD_OP_CLEAR while keeping non-covered attachments intact, leaves cs->cr.eot.main, cs->cr.eot.partial, and cs->cr.bg.partial untouched, and checks vk_command_buffer_has_error(&cmd->vk) before mutating cs->cr.bg.main and cs->anatomy_covered.
  • Built and ran the non-layout asahi test suite (261/261 PASS) plus Borealis Vulkan compute smoke on Apple M5 Max (G17C B1), Linux 7.3 with MESA_SHADER_CACHE_DISABLE=1 and 0 GPU faults in dmesg.
  • Untested scope: Live G17P hardware execution of the direct_resolve covered-load elision path (verified via code audit and asahi unit suite; live hardware check ran on Apple M5 Max (G17C B1)), and asahi_layout_tests (pre-existing GCC C++20 designator-order error in src/asahi/layout/tests/test-layout.cpp:374).
Evidence
  • meson test --suite asahi (non-layout): 261/261 PASS (0 FAIL)
  • Live Borealis Vulkan CTS on Apple M5 Max (G17C B1), Linux 7.3 (MESA_SHADER_CACHE_DISABLE=1, 0 GPU faults in dmesg):
    • dEQP-VK.compute.pipeline.basic.*: 80/81 PASS, 0 FAIL, 1 NotSupported

@DjDeveloperr

Copy link
Copy Markdown
Author

a2167de J773g M4 mini (Apple M4, G16G B0) PASS (550 Pass / 91 NotSupported / 0 Fail across Vulkan and GLES3/Zink MSAA resolve & dynamic-rendering CTS; 6/6 gpubench compress.bw msaa4 ok; 184/184 asahi unit tests; 0 GPU faults/recoveries/dmesg).

Exact-head G16G verification details
  • Commit: a2167deffc9efff764dd93757c69dcdcfb7e11b0 (Mesa 26.3.0-devel (git-a2167deffc), Borealis Vulkan 1.4.363 + Zink GL 4.6)
  • Host/Target: Apple M4 Mac mini (J773g, Apple M4 (G16G B0)), Linux 7.3
  • Unit suite: meson test --suite asahi — 184/184 PASS (0 Fail)
  • CTS (jobs=1, verified ICD/Zink probes matched git-a2167deffc):
    • dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.basic.* (240 cases): 240 Pass / 0 Fail
    • Vulkan MSAA resolve slice (resolve_image + multisample_resolve, 200 cases): 131 Pass / 69 NotSupported / 0 Fail
    • dEQP-GLES3.functional.fbo.msaa.* (Zink, 70 cases): 48 Pass / 22 NotSupported / 0 Fail
    • dEQP-GLES3.functional.fbo.invalidate.* (Zink, 131 cases): 131 Pass / 0 Fail
  • gpubench compress.bw kind=msaa4 (6/6 status=ok):
    • Vulkan 1440p: d=1 781.25 us (132.12 GB/s), d=4 444.84 us (232.04 GB/s)
    • Vulkan 2160p: d=1 1322.75 us (175.58 GB/s), d=4 972.76 us (238.75 GB/s)
    • Zink 1440p: d=1 1366.12 us (75.56 GB/s), d=4 972.76 us (106.11 GB/s)
  • Kernel health: 0 GPU faults, 0 recoveries, 0 dmesg errors, clean idle post-run.

@DjDeveloperr
DjDeveloperr merged commit 73adc9c into aurora-wip Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged into aurora-wip as 73adc9cf8c50 (head a2167deffc9e, verified tree 3a87e3d5fa86). Verified: exact-head peer approval, exact-head M4 (G16G B0) Vulkan CTS (550/0) + msaa4 throughput/CRC verification, and fork CI asahi (45415517685) + aurora-agent-policy (45415517745).

@RyanTheTide
RyanTheTide deleted the djdev/borealis-direct-resolve-elide-load branch November 27, 2026 13:20
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