Repository navigation
borealis: keep deferred empty clear-only renders on VDM - #1244
Conversation
When Borealis defers an empty single-sample clear-only render pass in hk_optimize_empty_vdm(), it previously destroyed the VDM control stream immediately. If a later pass in the same command buffer did not absorb the clear (for example at vkEndCommandBuffer() or before a pass with different attachments), hk_flush_deferred_clears_why() had to emit a compute fast-clear (CDM) job, injecting a VDM->CDM->VDM cross-engine round-trip and blocking the following render's vertex half behind CDM. On native AGX3 / M5, keep the finalized clear-only VDM stream alive on struct hk_deferred_clear::vdm_cs while deferred: - If every cleared attachment owned by vdm_cs is absorbed without needing a memory fill (or superseded by a later clear of the same image), drop vdm_cs via hk_sync_forget_stream() and clear any render_pack/pass_merge references. - If the deferred clear flushes unabsorbed, keep vdm_cs in control_streams at its recorded VDM position without emitting any CDM fill or extra barrier, so the clear stays on VDM and allows fragment- only tile-hazard ordering with following renders. Also have hk_sync_forget_stream() clear singleton sync_pass_records entries whose first and last stream are both the forgotten stream, so dropping an absorbed empty clear pass does not rebind its footprint to an earlier unrelated render on the subqueue. Signed-off-by: DjDeveloperr <hey@djdev.me>
Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J700 (MacBook Neo, Apple A18 Pro Both arms are isolated release Borealis Vulkan overlays ( Live GPU clear-pass test (
gpubench-vk (gpubench
Targeted VK CTS on exact head
Fedora 44 Mesa Asahi CI ( Health (primary ABBA + 87k CTS slot): |
|
|
There was a problem hiding this comment.
Verdict: FINISH, then merge at 1b1f2b3d2d4f.
Blockers: Please repeat the J700 standalone clear-only depth-4 benchmark on this commit with the same interleaved baseline and include both end-to-end submit cadence and GPU time. The earlier J700 row reports 19.8 to 34.1 µs/submission in the untimed arm, with nonoverlapping samples, while the timed submit and GPU time are flat. If that tradeoff persists, please get the area owner’s disposition before landing.
Checked: The current-head J700, J413 and J316s correctness rows pass. I reviewed stream retention and removal, including the shared-attachment reference check, sync footprint removal, and the forward merge preserving the heap-slot reference updates. The requested benchmark concerns end-to-end throughput for standalone clear submissions.
|
Exact-head J714s refresh after merging
|
|
J700 (MacBook Neo, A18 Pro Setup: both arms are release Borealis overlays built with identical options and loaded from private prefixes through
In the earlier row, Reference and multi-pass rows (median A → B, all samples overlap unless noted)
What this means: with the head, a standalone empty clear-only command buffer goes back from CDM to VDM. Its untimed cadence moves from the CDM rate (about 20 µs, the same as Correctness and health:
Fedora 44 Mesa Asahi CI ( |
Keeping every unabsorbed empty clear-only render on VDM also moved standalone clear-only command buffers, which flush their deferred clears at vkEndCommandBuffer(), from a compute fill to a render of their own. On the J700 that raised their submit cost from about 20 to 34 us at depth 4 (CPU submit 9.4 to 15.6 us). The VDM render only saves something when a later render pass in the same command buffer is what flushes the clear: a compute fill there sits between two renders (VDM->CDM->VDM). Flush through hk_flush_deferred_clears_before_render() from hk_CmdBeginRendering() and keep the render there. Any other flush (end of the command buffer, a barrier, compute, a transfer) drops the kept render and fills the image as before. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
The revised flush restores compute fills for standalone clears while keeping the render stream when another render pass follows. I checked that the drop path clears all deferred references before destroying each shared stream once and that the fill path reuses the saved graphics dependencies. Please post a J700 A/B at this commit for untimed clear-only depth 4 (including submit CPU time), plus the clear-pass-load correctness check and the multi-pass row. The previous head reproduced the slowdown, so its timing does not establish recovery here.
|
J700 (MacBook Neo, A18 Pro Setup was identical to the earlier row: both arms are release Borealis overlays built with the same options (driver IDs
All four metrics overlap. In the
All four metrics overlap. No head sample sits at the ~124 µs VDM cadence any more; in the Reference and multi-pass rows (median A → B, all samples overlap unless noted)
Correctness and health:
|
There was a problem hiding this comment.
The exact-head J700 ABBA closes the earlier throughput finding: depth-4 untimed clear is 20.19 to 20.16 us/submit and CPU submit is 9.42 to 9.40 us. Depth-1 also overlaps. Clear-pass-load is clean, multi-pass CRCs match, and no GPU fault or recovery was recorded. Approved at this commit. The earlier peer rows are at 1b1f2b3; record their disposition for the final flush change before landing.
|
J714s (M5 Pro, G17S) row at 404a387, kernel 7.3.0-m5-cdirect16, base 9965858. Built on the machine, driver loaded only through VK_DRIVER_FILES.
|
There was a problem hiding this comment.
Verdict: MERGE at 404a387be357
Blockers: none
Checked: I read the full diff against merge-base 99658583598 and the head merged into aurora-wip bd7323f1 (it merges cleanly). Keeping the stream only applies where the deferral itself applies: whole, single-sample, single-layer, single-mip 2D images with every aspect cleared. So layered and multiview clears, MSAA clears, direct resolves and depth-only clears of a D/S image never reach it. Timestamped, resolving and continuation empty renders still take the earlier keep path. The kept render sits at its recorded position, so a following pass that does not take the clear sees the same VDM order as an undeferred clear. A pass that takes only some attachments keeps the stream for the rest. The redundant memory clear of the taken attachment is harmless. A later vkCmdClearColorImage of the same image drops the old stream only when no other entry uses it. Otherwise the old clear still runs first and the new fill after it, behind the application's barrier.
The drop path clears render_pack head/tail and pass_merge before destroying each shared stream once. Other work flushes through hk_cmd_buffer_get_cs_general(), and EndCommandBuffer, timestamps, queries, events and host-access barriers flush without render_follows. So a kept stream is dropped and filled before it can be packed across command buffers or carry a stamp. A held buffer copy can leave the stream mid-list when the next pass absorbs it. hk_sync_forget_stream() rebinds to the previous stream on the subqueue, so that case is covered.
The gate condition uses the existing agx_chip_agx3_path() helper and per-stream g17p_pass_ends, with no new chip or firmware checks. The new hk_sync_prior case fails without the records_replace_stream() singleton drop and passes with it. The J700 exact-head ABBA restores depth-4 untimed clear parity (20.19 to 20.16 us/submit, CPU 9.42 to 9.40). Clear-pass-load and the multi-pass CRCs are clean there and on J714s.
Not a blocker: the keep/unkeep behaviour itself has no unit test, only the hardware rows. The J413/J316s rows are at 1b1f2b3d. The final commit only changes the AGX3 flush path, but a G13/G14 regression row at this head is still owed before landing.
Evidence
- Local x86 drm-shim gate (
--suite asahi --suite poly, assert-enabled clang), head merged intobd7323f1: 339/339 Ok, the same as the tip. - Same tree with the
drop_singletonhunk inhk_sync.creverted: 338/339,hk_sync_priorFAIL. git diff --stat 1b1f2b3d2d4f 404a387be357: hk_cmd_buffer.c, hk_cmd_buffer.h, hk_cmd_draw.c only.- Exact-head rows: J700 #1244 (comment) , J714s #1244 (comment)
|
Evidence: |
What:
struct hk_deferred_clear::vdm_cswhen Borealis defers an empty single-sample clear-only render pass inhk_optimize_empty_vdm()on native AGX3 / M5, instead of destroying the VDM stream immediately.vdm_csis absorbed by a later render pass without needing a memory fill (hk_take_deferred_clears()) or superseded by a later clear (hk_defer_clear_internal()), dropvdm_csviahk_sync_forget_stream()and clear anyrender_pack/pass_mergereferences.vkEndCommandBuffer()or before a pass with different attachments), leavevdm_csincontrol_streamsat its recorded VDM position without emitting any CDMhk_clear_image()fill or extra barrier, eliminatingVDM -> CDM -> VDMcross-engine round-trips and preserving fragment-only tile-hazard ordering (load_hazard_frag) with following renders.hk_sync_forget_stream()clear singletonsync_pass_recordsentries whosefirstandlastboth match the forgotten stream, so dropping an absorbed clear-only render pass does not rebind its footprint to an earlier unrelated render on the subqueue.test-hk-sync-prior.cfor singleton pass-record cleanup onhk_sync_forget_stream().Tested:
4421add60059d3f1f73c8c0489d277b93a28d1a1on MacBook Pro M5 Pro (J714s,G17S, kernel7.3.0-m5-cdirect16) vsaurora-wip13400438325:-Db_ndebug=false) and Release (-Db_ndebug=true)--suite asahi:215/215 PASSeach (0warnings in PR diff).g17p_vulkan_clear_pass_load(empty clear-only pass followed by depth-load pass with no barrier,2x D32S8and1x D32, 8 frames each):PASS(0/8wrong on both).cts1471):dEQP-VK.api.command_buffers.*131/131 PASS,0Fail.gpubench-vk:render.pass_chain(all_bard=1197.1 us, d=4309.8 us) andrender.deferred(1080p d=1109.1 us, d=485.6 us):4/4valid=True,status=ok.3024x1964, clean A/B vs13400438325+HK_FRAME_ANATOMY_TS=allon PR):BASE(1578 MHzmed)P0=60.87 P1=53.93 P2=54.21 P3=60.31 P4=57.43->PR(1620 MHzmed)P0=60.69 P1=53.67 P2=54.55 P3=61.72 P4=59.04.112 -> 52(-53.6%), total fast-clear CDM jobs dropped234 -> 158(-32.5%), anddeferred-clear fill ... gfx=1dropped11 -> 0(all converted todeferred-clear kept vdm, overlapping on VDM with concurrent compute and next-pass vertex halves).boot=same,online=1,crashed=0,quarantined=0,0kernel errors,0GPU faults.4421add60059d3f1f73c8c0489d277b93a28d1a1J714s,G17S,7.3.0-m5-cdirect16)--suite asahi215/215,g17p_vulkan_clear_pass_loadPASS,dEQP-VK.api.command_buffers.*131/131,gpubench-vk4/4 valid, GTA V3024x1964standalone fast-clear CDM112->52(-53.6%), P360.31->61.72/ P457.43->59.04FPS,0GPU faultsRisk: two-way · J714s
Not yet:
G17P).