Repository navigation
borealis: classify post-graphics query availability streams as HK_SYNC_STAMP - #1230
Conversation
…C_STAMP Post-graphics query availability streams (hk_flush_oq_pending() and hk_queue_query_available_write() with after_gfx) write only query availability memory, never attachments, images, buffers, or the geometry heap. Giving them HK_SYNC_GFX caused every subsequent graphics or ALL_COMMANDS pipeline barrier to wait for the compute availability store on the CDM subqueue, introducing avoidable VDM->CDM->VDM stalls on later renders whenever occlusion queries overflow a render's three retirement timestamp slots or use non-stamped query pools. Classify post-graphics query availability streams as HK_SYNC_STAMP, matching timestamp-only streams: - Pipeline barriers (including ALL_COMMANDS -> ALL_COMMANDS) and image layout transitions no longer order later graphics or compute work after pure query availability stores. - Query commands (HK_SYNC_QUERY_SCOPE / HK_SYNC_QRESET_SCOPE), events, and timestamps (hk_sync_stamp_scope()) still order after HK_SYNC_STAMP both within a command buffer and across command buffers/submissions. - Flush inline staged occlusion availability before entering a driver layout transition (brl_sync_transition_begin()) so it is never tagged as a transition stream. - Promote an existing HK_SYNC_STAMP post-graphics stream to HK_SYNC_GFX | HK_SYNC_GFX_MEM in hk_sync_heap_used() if a later draw in the same pass appends a geometry-heap reset to it. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J700 (MacBook Neo, Apple A18 Pro Both arms are isolated release Borealis Vulkan overlays built with identical options and loaded from private prefixes via gpubench-vk (gpubench
CRCs match base identically on all 16 CRC-checked rows ( Targeted VK CTS on exact head
Fedora 44 Mesa Asahi CI ( Health: 0 GPU faults, 0 recoveries, 0 driver warnings, 0 AVC denials, 0 core dumps, 0 leftover processes, |
|
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict at 5f170b33409f: ready
Audited hk_cmd_buffer.h, hk_query_pool.c, hk_sync.c, hk_sync.h, hk_event.c, and all post_gfx / AGX_POSTGFX / hk_queue_write() callers:
hk_flush_oq_pending()andhk_queue_query_available_write(..., after_gfx=true)save/restorecmd->sync.kind_override = HK_SYNC_STAMP, keeping post-graphics query availability publication out of application pipeline barriers while preserving ordering for query commands (HK_SYNC_QUERY_SCOPE), timestamps (hk_sync_stamp_scope()), and events (hk_event_write()athk_event.c:116).hk_sync_src_dep()materializesoq_pending_renderonHK_SYNC_STAMPandbrl_sync_transition_begin()flushesoq_pending_renderbefore asserting!st->kind_override.- The only non-query writer to
post_gfx(hk_cmd_draw.c:6742poly_heap::bottomreset) callshk_sync_heap_used()first, which flushesoq_pending_render, promotespost_gfx->sync.kind |= HK_SYNC_GFX | HK_SYNC_GFX_MEM, callsnote_last(), and waits all. - Verified at exact head
5f170b33409facross all 3 generations: J714s (G17S,20,837/0CTS, GTA VR i=0..13 -31.1%), J700 (G17P,27,418/0+5,425/0CTS,render.pass_chain oq_bar -7.72%/-9.95%), and J615 (M3,5,135/0CTS,215/215--suite asahi),0faults.
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 5f170b33409f69d7a81be033a458aa9e7638e3c6
Blockers: none
Checked:
Read the whole diff and every post_gfx / AGX_POSTGFX / hk_queue_write(..., after_gfx) writer. The only things that land in a post-graphics stream are query availability writes and the geometry-heap reset from hk_heap(). The non-ring heap path is covered by the new promotion in hk_sync_heap_used() (kind gains GFX | GFX_MEM, note_last() refreshes sync.last); the heap-ring path orders through last_heap_slot/pass_heap_last in hk_sync_heap_slot_used(), which also updates an already-open post_gfx stream and does not depend on the stream kind, so a STAMP-classified post_gfx carrying a ring reset is still ordered for the next pass on that slot. A post_gfx first created by hk_heap() stays HK_SYNC_GFX (override is only set around availability writes). Query consumers (vkCmdCopyQueryPoolResults, reset, begin), events and timestamps still name HK_SYNC_STAMP; shaders cannot read query pools, so dropping availability from GFX/ALL_COMMANDS barrier scopes is within the spec. kind_override is saved/restored, and brl_sync_transition_begin() now flushes inline availability first so its assert holds. No chip/generation gate added.
Local x86 drm-shim gate (head merged into aurora-wip 7617c835): 337/338, identical to the aurora-wip baseline (the one failure, hk_sync_stamps, fails the same way on aurora-wip itself). Test check: with the non-test hunks reverted, hk_query_oq_test fails 9/110 (e.g. "post_gfx OQ availability carries HK_SYNC_STAMP only", "subsequent render waits on r1, not post_gfx OQ availability", "transition begin flushes inline availability outside the transition"); restored: 110/110.
Rows at this head on the PR: J714s (author), J700 (Dj + ours), J615 (ours).
Evidence
- merged tree
c73b592c4d38(aurora-wip7617c835+5f170b33409f),meson test --suite asahi --suite poly: Ok 337, Fail 1 (hk_sync_stamps, also failing on plain7617c835: "bracketed compute with GFX+COMPUTE barriers emits both stamps distinctly", from #1235). - aurora-wip has since moved to
ba2c9efb; #1237/#1238 touch none of this PR's files and the merge is still clean. - revert run:
patch -Rof the non-test diff in the merged tree, rebuildhk_query_oq_testonly:110 tests, 9 failures; re-apply:110 tests, 0 failures.
What: Classify pure post-graphics query availability streams (
hk_flush_oq_pending()andhk_queue_query_available_write(..., after_gfx=true)) asHK_SYNC_STAMPinstead ofHK_SYNC_GFX, matching timestamp-only streams soGFX/ALL_COMMANDSpipeline barriers and image layout transitions do not stall subsequent renders or computes behind overflow (>3) or non-stamped query availability stores.Summary
LIBAGX_WRITE_U32S) write only query availability memory, never attachments, images, buffers, or the geometry heap. Previously they receivedHK_SYNC_GFX, so any subsequentGFX -> GFXorALL_COMMANDS -> ALL_COMMANDSpipeline barrier ordered later renders on VDM behind the CDM availability store (VDM -> CDM -> VDMroundtrip stall), even after#1221when a render exceeds three occlusion queries (nfree < count) or uses non-stamped query pools.HK_SYNC_STAMPmatches existing timestamp-only streams:brl_sync_transition_prepare()) no longer stall subsequent renders or computes behind query availability writes.HK_SYNC_QUERY_SCOPE,HK_SYNC_QRESET_SCOPE), events, and timestamps (hk_sync_stamp_scope()) still order afterHK_SYNC_STAMPboth in-CB and across CBs/submissions.hk_sync_src_dep()materializes inline staged occlusion availability onHK_SYNC_STAMPscopes, andbrl_sync_transition_begin()flushes inline availability before settingbrl_transition_activeso availability streams are never tagged as transition streams.hk_sync_heap_used()promotes an existingHK_SYNC_STAMPpost_gfxstream toHK_SYNC_GFX | HK_SYNC_GFX_MEM(and updatessync.last) if a later draw in the same pass appends a geometry-heap reset (hk_heap()).test-hk-query-oq.ccoveringHK_SYNC_STAMPbarrier isolation, in-CB and cross-CB (hk_sync_resolve_submit()) query ordering, transition isolation, event ordering, andhk_sync_heap_used()promotion.Tested
J714s,7.3.0-m5-cdirect16)5f170b33409f-Db_ndebug=false)--suite asahi215/215 PASS(0warnings in touched lines)J714s,7.3.0-m5-cdirect16)5f170b33409f-Db_ndebug=true)--suite asahi215/215 PASSJ714s,7.3.0-m5-cdirect16)5f170b33409fdEQP-VK.query_pool.occlusion_query.*434/434 PASS(7NS,0Fail,0faults)J714s,7.3.0-m5-cdirect16)5f170b33409fdEQP-VK.query_pool.statistics_query.*18,770/18,770 PASS(5NS,0Fail,0faults)J714s,7.3.0-m5-cdirect16)5f170b33409fdEQP-VK.query_pool.concurrent_queries.*2/2 PASS(0Fail,0faults)J714s,7.3.0-m5-cdirect16)5f170b33409fdEQP-VK.synchronization.op.single_queue.event.*1,631/1,631 PASS(1NS,0Fail,0faults)J714s,7.3.0-m5-cdirect16)5f170b33409f3024x1964(HK_FRAME_ANATOMY_TS=all)R i=4(bar=v3,c1 -> bar=v3,c-) andR i=7..13(bar=v*,c2 -> bar=v*,c-) drop all waits on OQpre=98(imm=1andimm=7);R i=0..13GPU wall span drops1,619.0 us -> 1,115.7 us(-503.3 us/-31.1%inTS=all) withR i=1..8overlapped back-to-back;0GPU faults. Clean A/B vs30df6feb98f:P0=58.15->58.80,P1=52.49->52.55,P2=52.25->52.78,P3=56.44->59.02,P4=55.75->57.30FPS (note:BASEran at1578 MHzmedian pstate 11-13 vsPRat1620 MHzmedian pstate 13, so FPS includes DVFS variance; the anatomy barrier drop is the direct causal proof).Tested: Assert & Release
--suite asahi(215/215each),20,837/20,837CTS (query_pool.*+synchronization.op.single_queue.event.*,0fail,0GPU faults), and GTA V Enhanced3024x1964clean +HK_FRAME_ANATOMY_TS=allon MacBook Pro M5 Pro (J714s, head5f170b33409f).Risk: two-way · J714s
Not yet: 2nd-generation hardware verification (
J700/G17P).