Repository navigation
borealis: pack consecutive query-reset command buffers - #1254
Conversation
Vulkan applications (such as GTA V Enhanced via vkd3d-proton) frequently open a frame with a run of consecutive single-stream command buffers that each record only vkCmdResetQueryPool (timestamp queries with HK_SYNC_QRESET, or non-timestamp queries with HK_SYNC_ALL). Previously hk_pack_run_member() rejected every such stream because cs->stats.calls == 0, cs->query_access is set, and HK_SYNC_QRESET was not admitted, and emit_zero_queries() only recorded query_reset_dispatches / query_reset_queries on the G17P path, forcing each tiny reset command buffer on M5 and other generations to pay a separate CDM submission and firmware turnaround. Record query_reset_dispatches and query_reset_queries in emit_zero_queries() for non-G17P paths as well, recognize pure flushed query-reset CDM streams (cs->query_access && !cs->query_reset_pending && calls == 0 && cmds == query_reset_dispatches && query_reset_queries > 0, with kind HK_SYNC_QRESET or HK_SYNC_ALL) in hk_pack_run_member(), bound them by query_reset_queries (with a conservative 32-instruction-per-query static work estimate), and keep them strictly isolated from regular compute command buffers and from differing query-reset kinds in hk_pack_plan() so regular compute packets retain COMPUTE_NO_QUERY_ACCESS and HK_SYNC_QRESET packets do not mix with HK_SYNC_ALL. Also propagate has_gpu_query_reset in hk_pack_fold_member() so packed query-reset packets preserve query-reset tracking on the packet command buffer. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
|
There was a problem hiding this comment.
Verdict: MERGE at 891b38da
Blockers: none.
Checked: no Apple material, no AI attribution, no new chip/board/firmware gates (removes the G17P-only restriction in emit_zero_queries() so all generations track query resets uniformly), human Signed-off-by, overflow-safe hk_pack_member_static_work() (__builtin_mul_overflow), strict isolation of query-reset runs from regular compute and between HK_SYNC_QRESET and HK_SYNC_ALL, has_gpu_query_reset propagation, 201 lines of unit tests across G16G/G17P/G17S (test-hk-pack.c), exact-head 3-gen Borealis hardware verification PASS (including J700 G17P deqp-vk 19,621 PASS / 0 FAIL).
Evidence
- Inspected all 4 files (
hk_pack.c,hk_pack.h,hk_query_pool.c,tests/test-hk-pack.c). - Verified
hk_pack_is_query_reset_stream()admits only pure flushed query-reset CDM streams (query_access && !query_reset_pending && calls == 0 && cmds == query_reset_dispatches && query_reset_queries > 0), rejects non-resetHK_SYNC_QRESET, isolates query-reset runs from plain compute (m->query_reset == run_query_reset) so regular compute keepsNO_QUERY_ACCESS, and keepsHK_SYNC_QRESETandHK_SYNC_ALLruns separate (((m->kinds ^ kinds) & ~HK_SYNC_GFX_MEM) == 0). - Verified
hk_pack_member_static_work()guardsquery_reset_queries * 32uwith__builtin_mul_overflow, andhk_pack_fold_member()foldspacket->sync.has_gpu_query_reset |= source->sync.has_gpu_query_reset. - Exact-head
891b38da3-gen Borealis hardware verification in comments passed with 0 failures (J700 G17Pdeqp-vk19,621 PASS / 0 FAIL).
|
Merge-train note: App approval at |
Summary
Vulkan applications (including GTA V Enhanced via vkd3d-proton) frequently begin a frame with consecutive single-stream command buffers that each record only
vkCmdResetQueryPool(HK_SYNC_QRESETfor timestamp pools,HK_SYNC_ALLfor non-timestamp pools). Previouslyhk_pack_run_member()rejected every such stream becausecs->stats.calls == 0,cs->query_accessis set, andHK_SYNC_QRESETwas not admitted, andemit_zero_queries()only trackedquery_reset_dispatches/query_reset_querieson the G17P path. Each tiny query-reset command buffer therefore paid a separate CDM submission and firmware turnaround.This PR:
query_reset_dispatchesandquery_reset_queriesinemit_zero_queries()(src/asahi/vulkan/hk_query_pool.c) on non-G17P paths as well (M5, G16, G15, AGX2).cs->query_access && !cs->query_reset_pending && calls == 0 && cmds == query_reset_dispatches && query_reset_queries > 0, with kindHK_SYNC_QRESETorHK_SYNC_ALL, ignoringHK_SYNC_GFX_MEM) inhk_pack_run_member(), bounded byquery_reset_querieswith a conservative 32-instruction-per-query work estimate.HK_SYNC_QRESETvsHK_SYNC_ALL) inhk_pack_plan(), so regular compute packets retainCOMPUTE_NO_QUERY_ACCESSand query-reset kinds never mix.has_gpu_query_resetinhk_pack_fold_member().src/asahi/vulkan/tests/test-hk-pack.cfor bothHK_SYNC_QRESETandHK_SYNC_ALLruns, isolation from regular compute and from each other, pending/mixed-stream rejection, query-count caps, andhas_gpu_query_resetpropagation.Verification
891b38daea28e90b4e5a42b3f8a324597877baa7J714s,G17S,7.3.0-m5-cdirect16)0diff warnings) & GCC release--suite asahi215/215each (hk_pack:359/359,random: 3180/30204,history: 4872/36056);dEQP-VK.query_pool.*19,236/19,276(0Fail);dEQP-VK.api.command_buffers.*126/131(0Fail); GTA V Enhanced3024x1964(0GPU faults)Live GTA V Enhanced (
3024x1964,J714s)HK_FRAME_ANATOMY_EVERY=151):48/48multi-CBpre=92query-reset bursts collapsed7 -> 1(merged=6,dispatches=9..12,flushes=0;360pre=92CDM streams across360submits =1.000CDM/submit, eliminating288CDM kicks in the sampled window).aurora-wip(99658583598, both1620 MHzmedian):P0=60.98 P1=54.99 P2=54.34 P3=61.61 P4=59.24(0GPU faults)P0=60.78 P1=54.83 P2=54.37 P3=61.21 P4=59.12(0GPU faults)