Repository navigation
borealis,asahi: keep HSR opaque for partial-MRT draws via epilog clear-fill - #712
Conversation
|
Exact-head Apple M5 Pro (
Assisted-by: LLM (Google:Gemini 4 Neon) |
|
Review at bf025b7. Reviewed the delta in bf025b7. The earlier commits belong to #703. The stream tracking looks sound to me: continuation streams default to all-live (
|
bf025b7 to
37ab06d
Compare
|
Thanks for the detailed review — R2 (
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Re-review at 37ab06d. All six code points are fixed: the chip list is gone, and the gate is now the AGX3 ISA plus the linked-program and epilog properties. The FRAGMENT_CONTROL accesses use the packed accessors. The translucency cause now comes from one bit reported by the tilebuffer and epilog lowering. I traced it through the masked-store, sample-mask, spill, tile-load, HAL200 store-back, colormask and fbfetch causes, plus the prolog/main Still open:
Assisted-by: LLM (Claude:Opus 5.5) |
|
Clean-room M5 Pro (
The rewritten ISA/native-epilog gate and single translucency-cause bit are live and green on M5 Pro ( Assisted-by: LLM (Google:Gemini 4 Neon) |
37ab06d to
7e89050
Compare
|
Pushed R3 at Addressed the remaining items from the R2 review:
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Exact-head M4 (
Assisted-by: LLM (Gemini:4 Neon) |
|
Re-checked at 7e89050. Fixed: the G18G PPP path now emits Still open, rows only:
Assisted-by: LLM (Claude:Opus 5.5) |
|
M4 Pro (J616s, T6040, G17P) row against base, one boot of the default fleet kernel (7.3.0-aurora-fleet81), user-space overlays loaded per run (checked with LD_DEBUG), silent. Head 7e89050 vs base 986f71b (#703's head, so only this PR's commit differs).
That's the M4 Pro row. M3 is still to come. Assisted-by: LLM (Claude:Opus 5.5) |
…r-fill
In multi-attachment render passes where a geometry draw writes only a
subset of bound colour attachments (such as a 4-RT G-buffer write inside
a 5-RT dynamic rendering pass with local read), agx_nir_lower_tilebuffer
marks the epilog translucent because not all bound attachments are
written. That disables ISP hidden-surface removal (HSR) and forces every
occluded fragment to shade.
On AGX3, an OPAQUE or PUNCH_THROUGH draw covering a tile allows the ISP
to skip the tile's background (BG) shader as well as earlier opaque
draws. Promoting a partial-MRT draw to OPAQUE without preserving live
unwritten attachments therefore loses LOAD_OP_CLEAR / LOAD_OP_LOAD /
partial-render BG state.
Solve both cases generally and safely across hardware partial renders:
1. Add epilog constant clear-fill (AGX_EPILOG_CLEAR_FILL_{ZERO,
BLACK_OPAQUE,WHITE}) in agx_fs_epilog_key / agx_nir_fs_epilog_native.
When a partial-MRT opaque draw on the first stream of a non-resuming
pass leaves untouched LOAD_OP_CLEAR attachment(s) with no prior user
writes, materialize those constant clear values in the epilog so all
live attachments are written and the draw stays natively OPAQUE /
PUNCH_THROUGH even if a partial render skips bg.partial.
2. Expose a single translucency-cause bit
(translucent_only_for_unwritten_rts) and color_rts_written from
tilebuffer/epilog lowering through agx_shader_info /
agx_linked_shader, and track per-stream bg_live_mask,
user_color_written_mask, and pending opaque_color_written so
partial-MRT draws whose untouched attachments are LOAD_OP_DONT_CARE
with no prior writes can also promote safely to OPAQUE /
PUNCH_THROUGH without extra stores, while any live BG, cross-draw
write, or non-unwritten translucency cause keeps the draw
translucent.
vkCmdClearAttachments draws pass force_translucent = in_clear_attachments
so mid-pass attachment clears (including single-attachment clears that
previously linked OPAQUE) stay translucent and never discard prior
subpass/background colour state. All AGX3 PPP emitters (HAL200, HAL300,
and G18G) consume effective_fragment_pass_type using packed
FRAGMENT_CONTROL accessors.
Gate on existing AGX3 ISA / native-epilog / linked-program properties
(agx_chip_isa() == AGX_ISA_AGX3, g17p_tile_formats / native_epilog, and
g17p_colour_classes != 0) without a hand-kept chip list, and add unit
tests for clear-value classification, pass-type transitions,
translucency-cause reporting, and epilog clear-fill NIR lowering.
Signed-off-by: Diljit Singh <hey@djdev.me>
7e89050 to
c87bb97
Compare
|
Rebased onto merged
|
satchlj
left a comment
There was a problem hiding this comment.
Verdict at c87bb9788c82
APPROVE — Clean, well-factored partial-MRT HSR opaque promotion and epilog clear-fill implementation on AGX3, with conservative stream/pass-merge/clear-attachment tracking, full unit coverage, and clean live M5 Max Vulkan CTS results.
Blockers
None.
Checked
- Audited all 14 changed files (
+1058/-55) againstaurora-wip:agx_nir_lower_tilebuffer.c,agx_nir_prolog_epilog.c,agx_linker.c,agx_linker.h: verifiedtranslucent_only_for_unwritten_rtsis set strictly when unwritten RTs are the sole cause of translucency (cleared on blending, partial colormask, explicitpreserve_rt, logicop, or deferred API sample mask), 2-bit per-RTclear_fill_rt(NONE,ZERO,BLACK_OPAQUE,WHITE) materializes constant tile stores on unwritten cleared attachments, disk-cache keys are bumped (hkpe-v2,hkmono7,hkmlr5), andhk_m5_uniform_blend_key()rejects non-zeroclear_fill_rt.hk_partial_mrt_hsr.h: verified exact-bit clear-value classification (hk_partial_mrt_classify_clear_value(), rejecting-0.0fand matching exact float/integer 0 and 1 patterns) and pure-function pass-type selection (hk_partial_mrt_hsr_select_pass_type()handlingforce_translucent,preserved_color_mask | *opaque_color_written,promote_pt_for_full_quads,tag_write_disable, andrasterizer_discard).hk_cmd_buffer.c,hk_cmd_draw.c,hk_cmd_meta.c: verified per-streambg_live_mask,bg_clear_fill_rt,user_color_written_mask, andopaque_color_writtenlifecycle across first streams, continuation/split streams (hk_cs_init_graphics()conservatively initializesbg_live_mask = bound_color_maskandbg_clear_fill_rt = 0), M5 pass-merge continuations (hk_m5_attachment_continues()requiresLOAD_OP_LOAD),vkCmdClearAttachments(in_clear_attachmentsforces translucent and updatesuser_color_written_maskunlessin_begin_rendering_clear),hk_g17p_elide_untouched_color()/hk_g17p_note_first_draw()(app_color_writtenseparation), and stale-key invalidation (hk_fs_clear_fill_stale()inhk_gfx_republishes_render_state(),hk_flush_dynamic_state_slow(), andhk_g17p_indirect_records_eligible()).
- Built and ran all 248 non-layout
asahiunit tests (248/248 PASS, including newhk_partial_mrt_hsr_test). - Ran live Vulkan CTS on Apple M5 Max (G17C B1), Linux 7.3 with
MESA_SHADER_CACHE_DISABLE=1(0failures,0GPU faults indmesg). - Untested scope:
asahi_layout_testsexcluded due to a pre-existing GCC C++20 designated-initializer order error insrc/asahi/layout/tests/test-layout.cpp:374; non-M5 AGX3B / AGX2 hardware execution and SPM partial-render stress paths were not executed on hardware.
Evidence
- Build & unit suite (
c87bb9788c82):248/248non-layoutasahitests passed (hk_partial_mrt_hsr_testOK). - Live Vulkan CTS on Apple M5 Max (G17C B1), Linux 7.3 (
MESA_SHADER_CACHE_DISABLE=1,0GPU faults indmesg):dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.basic.*:240/240passed (0failed)dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.unused_attachments.*:1147/1200passed (0failed,53not supported)dEQP-VK.renderpasses.dynamic_rendering.partial_secondary_cmd_buff.unused_attachments.*:1147/1200passed (0failed,53not supported)dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.suballocation.attachment.4.*:8/18passed (0failed,10not supported)dEQP-VK.conditional_rendering.clear_attachments.*:60/60passed (0failed)dEQP-VK.conditional_rendering.draw_clear.*:109/139passed (0failed,30not supported)dEQP-VK.compute.pipeline.basic.*:80/81passed (0failed,1not supported)
|
Exact-head M4 (
1. Scaled SPM verifier (
|
| Group | Cases | Pass | Fail | NS |
|---|---|---|---|---|
dynamic_rendering.primary_cmd_buff.basic.* |
240 | 240 | 0 | 0 |
local_read |
172 | 148 | 0 | 24 |
dynamic_rendering.*secondary*(basic_draw|suballocation) |
2,084 | 1,518 | 0 | 566 |
unused_clear_attachments |
945 | 945 | 0 | 0 |
dynamic_rendering.*random |
8,262 | 4,839 | 0 | 3,423 |
image_clearing.*clear_color_attachment |
12,936 | 6,328 | 0 | 6,608 |
| Total | 24,639 | 14,018 | 0 | 10,621 |
0 Crash, 0 Timeout, 0 Warnings, 0 dmesg lines.
3. gpubench-vk render.deferred ABBA (1080p, 60974fafd0d9 vs c87bb9788c82, us_per_submit median of ABBA)
| Mode | MSAA | Depth | Base (60974fafd0) |
Head (c87bb9788c) |
Speedup | Delta | CRC (valid) |
|---|---|---|---|---|---|---|---|
tile |
1 | 1 | 762.20 us | 506.09 us | 1.506x | -33.6% | 2cfe9a54 (true) |
tile |
1 | 2 | 461.25 us | 242.37 us | 1.903x | -47.5% | 2cfe9a54 (true) |
tile |
4 | 1 | 1730.12 us | 1488.10 us | 1.163x | -14.0% | 5e4130ce (true) |
tile |
4 | 2 | 1340.49 us | 1106.19 us | 1.212x | -17.5% | 5e4130ce (true) |
dram |
1 | 1 | 1282.05 us | 1285.36 us | 0.997x | +0.3% | 2cfe9a54 (true) |
dram |
1 | 2 | 965.25 us | 968.99 us | 0.996x | +0.4% | 2cfe9a54 (true) |
dram |
4 | 1 | 3759.61 us | 3787.88 us | 0.993x | +0.8% | 7c09507f (true) |
dram |
4 | 2 | 3424.66 us | 3424.66 us | 1.000x | 0.0% | 7c09507f (true) |
System health
health: failed 0 errno 0 degraded 0, recoveries 0 hang_kills 0, 0 GPU dmesg errors across all runs, 0 failed units.
Summary
Fixes the general TBDR hidden-surface removal (HSR) performance gap in Borealis where partial-MRT draws (such as G-buffer geometry passes writing a subset of bound color attachments inside a wider dynamic rendering /
VK_KHR_dynamic_rendering_local_readpass) were forced toAGX_PASS_TYPE_TRANSLUCENT, disabling ISP front-to-back HSR and causing full overdraw across covered layers.Root Cause & Silicon Behavior
agx_nir_lower_tilebuffersets*translucent = true, forcingAGX_PASS_TYPE_TRANSLUCENT.AGX_PASS_TYPE_OPAQUE/AGX_PASS_TYPE_PUNCH_THROUGHis unsafe when an unwritten attachment holdsLOAD_OP_CLEAR,LOAD_OP_LOAD, or a prior draw's color output: on AGX3 silicon, anOPAQUEdraw covering a tile allows the ISP to skip running the tile's BG shader (bg.main/bg.partial), losing unwrittenLOAD_OP_CLEAR/LOAD_OP_LOAD/ partial-render reload contents.SPM-Safe Design (
7e890506558fae4e6b253c6d3f60ed9e42651eb2)agx_chip_isa() == AGX_ISA_AGX3,g17p_tile_formats/native_epilog, andg17p_colour_classes != 0).agx_linker.h,agx_nir_prolog_epilog.c): Encodes 2-bit per-RT clear-fill modes (NONE,ZERO(0,0,0,0),BLACK_OPAQUE(0,0,0,1),WHITE(1,1,1,1)) inagx_fs_epilog_key::clear_fill_rt. When an unwritten boundLOAD_OP_CLEARattachment matches one of those exact bit patterns (rejecting-0.0fand depth/stencil), the native epilog emits a constantnir_store_outputwith pass-through opaque write-mask0xf. Every bound attachment is written directly by the fragment epilog, soagx_nir_lower_tilebuffernaturally keeps the shaderOPAQUE/PUNCH_THROUGHeven if ISP skipsbg.mainorbg.partialon a hardware partial render (SPM-safe).agx_compile.h,agx_tilebuffer.h,agx_nir_lower_tilebuffer.c,agx_linker.c): Reportstranslucent_only_for_unwritten_rtsandcolor_rts_writtendirectly from tilebuffer/epilog lowering throughagx_shader_info/agx_linked_shader(including disk-cache version bumps and info serialization), so no other translucency cause (blending, masked stores, sample-mask, spills, tile-loads, fbfetch,reads_tib,tag_write_disable) can ever be promoted.vkCmdClearAttachments(hk_partial_mrt_hsr.h,hk_cmd_buffer.{h,c},hk_cmd_draw.c,hk_cmd_meta.c):bg_live_mask,bg_clear_fill_rt,user_color_written_mask, andopaque_color_written.hk_cs_init_graphics) conservatively mark all bound color attachments as live non-clear-fillable (bg_live_mask = bound_color_mask,bg_clear_fill_rt = 0) so partial-render reloads (bg.partial) are never bypassed.clear_fill_rtwith zero fast-link cache churn (hk_fs_clear_fill_stale()invalidates only when a prior user write or mid-passvkCmdClearAttachmentstouches a clear-filled RT).LOAD_OP_DONT_CAREattachments with no live BG or prior user writes promote directly toOPAQUE/PUNCH_THROUGHwith zero extra stores, while any unwritten attachment inbg_live_mask | user_color_written_mask | opaque_color_writtenfalls back toTRANSLUCENT/TRANSLUCENT_PUNCH_THROUGH.vkCmdClearAttachmentsdraws passforce_translucent = in_clear_attachmentsso mid-pass attachment clears (including single-attachment clears) stay translucent and never discard prior subpass/BG colour state.effective_fragment_pass_typevia packedFRAGMENT_CONTROLaccessors.src/asahi/vulkan/tests/test-hk-partial-mrt-hsr.c): Covers clear-value classification, pass-type transitions (DONT_CARE, live BG, cross-draw conflicts, punch-through/full-quad,force_translucent,tag_write_disable,rasterizer_discard), translucency-cause reporting, and realagx_nir_fs_epilogNIR lowering (1x/4x MSAA + pure-integerR32_UINT/R16G16B16A16_SINT).Verification (Exact Head
7e890506558fae4e6b253c6d3f60ed9e42651eb2)1. Host CI (
fedora-mesaci.sh, assert-enabled-Db_ndebug=false)FEDORA-CI 7e890506558fae4e6b253c6d3f60ed9e42651eb2: 223 Ok / 0 Fail / 0 Timeout / 0 Skipped (includeshk_partial_mrt_hsrunit tests)..github/aurora/agent-policy.sh pr HEAD: PR head is clean.2. MacBook Neo (
Apple A18 Pro (G17P B1)) — Strict ABBArender.deferred(1080p,mode=tile)Base:
#703R2 (9f53266b7491, runtime-identical onG17Pto#703R3986f71bf5a49), Head:#712R3 (7e890506558f),A1/B1/B2/A2interleaved, CRC-verified bit-exact:1080p,mode=tile)A1/A2avg (us/submit)B1/B2avg (us/submit)msaa=1,depth=11380.7(1282.1 / 1479.3)700.5(688.7 / 712.3)2cfe9a54(valid)msaa=1,depth=21219.7(1157.4 / 1282.1)575.4(569.5 / 581.4)2cfe9a54(valid)msaa=4,depth=13452.4(3333.3 / 3571.4)2857.2(2840.9 / 2873.6)5e4130ce(valid)msaa=4,depth=23248.9(3164.6 / 3333.3)2617.9(2604.2 / 2631.6)5e4130ce(valid)3. MacBook Neo — Silicon BG / Clear-Fill / MSAA4 Probe (
test_partial_mrt_bg)TOTAL FAILURES: 0) covering arbitraryLOAD_OP_CLEARblue (non-clear-fill fallback),CLEAR_FILL_ZERO,CLEAR_FILL_BLACK_OPAQUE,CLEAR_FILL_WHITE,LOAD_OP_LOAD(half-screen & fullscreen), cross-draw RT0+RT1 followed by RT0-only invalidatingclear_fill,LOAD_OP_DONT_CAREHSR promotion, and MSAA4 wide-clear (blue + black_opaqueR16G16B16A16_SFLOAT).4. MacBook Neo — True Hardware SPM Partial-Render Proof (
test_partial_mrt_spm 90000 2048)2048×2048(4,194,304 px× 2 RTs),90,000quads/burst (360,000tris/pass), freshVkDeviceper case (TVB_INITIAL_PAGES = 32blocks,GROW_BLOCKS = 10,TVB_MAX_BLOCKS = 0xd19 = 3,353blocks on T8140 G17P).asahi_g17_report: every single case hit334TVB_GROWrequests (max_counter = 333 = 0x14d, total2,338grows), exhaustingTVB_MAX_BLOCKS = 3,353soprepare_growth()returnedOk(None)->TvbGrowReply(grew = false)-> 1 forced hardware mid-pass partial render (SPM store +bg.partialreload) per case (7 total), corroborated by exactly 7(role=0, ring=1, tag=0x1e)firmware reports (0on non-overflow runs).bad_rt0=0 bad_rt1=0on every pixel of every case):CLEAR_FILL_{BLACK_OPAQUE,WHITE,ZERO}) & Case 7 (LOAD_OP_DONT_CARE):1514.5–1522.0 ms(OPAQUE HSR active across hardware SPM).NON_CONST_CLEAR,LOAD_OP_LOAD):7739.9–7741.0 ms(~5.1× slower translucent fallback preserving BG across SPM).CLEAR_FILL_THEN_USER_WRITE_INVALIDATE):3675.8 ms(burst 1 OPAQUE HSR + burst 2 invalidated to translucent preserving mid-pass cyan write across SPM).5. MacBook Neo — Vulkan CTS (
cts-vk4, Vulkan CTS 1.4.7.1, 0 Fail)dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.basic.*dEQP-VK.draw.dynamic_rendering.*secondary_cmd_buff.basic_draw.*(*secondary_cmd_buff*basic*)dEQP-VK.renderpasses.dynamic_rendering.*secondary_cmd_buff.suballocation.*clear*dEQP-VK.renderpasses.dynamic_rendering.*secondary_cmd_buff.suballocation.unused_attachment.*dEQP-VK.renderpasses.dynamic_rendering.*secondary_cmd_buff.local_read.*dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.local_read.*dEQP-VK.renderpasses.*.unused_clear_attachments.*dEQP-VK.api.image_clearing.*.clear_color_attachment.*dEQP-VK.renderpasses.dynamic_rendering.*.random.*(Note: in Vulkan CTS 1.4.7.1 there is no
dEQP-VK.renderpasses.dynamic_rendering.*secondary_cmd_buff.basic.*group —basic.*only exists underprimary_cmd_buff, and*secondary_cmd_buff*basic*across the full caselist is the 482-testdEQP-VK.draw.dynamic_rendering.*secondary_cmd_buff.basic_draw.*suite above.)6. MacBook Neo System Health
neo-no-idle-sleep.service:active, PMU0xf701:30 00.FAULTS_DELTA=0(0GPU kfaults),AVC_DELTA=0(0SELinux AVC denials).