Repository navigation
borealis: extend AGX3 root-bypass and fast-path push/descriptor-buffer draw updates - #1257
Merged
Merged
Conversation
…r draw updates Allow AGX3 direct draw loops with per-draw push-constant or root-CBV updates (such as vkd3d-proton direct draws) to stay on the root-bypass fast path instead of re-uploading the full root table and rebuilding the bind tail on every draw: - Treat non-zero HK_G17P_RANGE_SOURCE_ROOT uniform-DMA spans that do not overlap any bypass-dirtyable region (push constants, dynamic buffers, vertex attribute bases/clamps) as root-bypass safe, since mutations to fields like draw.attrib_strides[] already mark HK_ROOT_DIRTY_OTHER. - Permit vertex shaders with a constant-program preamble to use root bypass when the preamble is proven not to read the root uniform and no hoisted preamble is active. - Track push-constant reads and writes at 32-bit dword granularity (agx3_push_read_dwords / push_dirty_dwords) so fragment shaders ignore per-draw writes to disjoint vertex-only push-constant slots. - Inline 4/8/16-byte push-constant compare/copy in hk_push_constants(), skip no-op vkCmdSetDescriptorBufferOffsetsEXT() binds when the bound buffer set address/size/dynamic offset are unchanged, avoid an extra stack copy in hk_agx3_publish_vertex_state(), and invalidate host draw-ID/loader caches after GPU-built multi-draw indirect sub-streams. - Extend test-hk-root-fragment to cover disjoint push-dword tracking and hk_root_span_overlaps_bypassable(). Signed-off-by: DjDeveloperr <hey@djdev.me>
RyanTheTide
approved these changes
Nov 27, 2026
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 78b8055f6b126045a2547e7ce269faee39afb522 (code is ready; the merge waits only on a second-generation exact-head row)
Blockers: none
Checked: Read the whole diff and body, and tried to break the dirty tracking.
- Push constants: every write of
root_change.dirty_maskgoes through the helpers.hk_root_mark_push_dirty()still sets all dwords, and meta restore and the im2col push swap both mark OTHER, so nothing can leave PUSH dirty with an empty dword mask. The shader-side mask falls back to all dwords for any root use that is not a constant-offset global load, and a mask of 0 is treated as reads-all. Pipeline-cache or missing info is therefore conservative. - Descriptor-buffer offsets: the skip compares everything
hk_bind_buffer_set()would write (address, size,set_dynamic_buffer_start,buffer_active, no push or real set). Record-time descriptor readers already refusebuffer_activesets, and the embedded-sampler bind clearsbuffer_active, so skipping the generation bump cannot leave a stale CPU-side cache. - Dynamic offsets: they still go through
hk_root_mark_dynbuf_dirty()and are unchanged by this PR. - Pipeline switches and the first draw after a bind: these still hit
gfx->dirtyand the launch-match checks. A bypass launch reads non-push/dynbuf/VB ROOT spans from the oldgfx->root, which relies on the existing rule that every other root write marks OTHER (same assumption as #1222). - VS preambles: a preamble that reads the root uniform stays general,
g17p_hoisted_preamble_vastill refuses, and a PREAMBLE_OUT range hitsdefault: return 0inhk_agx3_try_push_only_vs_program(). - Secondaries: they start from a zeroed root_change.
- Gates: the PR adds no chip or board gate.
Non-blocking: - In
hk_agx3_publish_vertex_state()the memo fast path now writes the pipeline pair atout + 8even when the memo length is under 16. Today the memo always carries the pair, so this is harmless, but an assert onvdm_len >= 16would keep it honest. - The new unit tests cover the helpers but not the NIR dword collection in
hk_nir_root_use_reads().
Rows: J700 at the exact head is in the body. A second generation on the AGX3 path is still needed at78b8055f6b12(J615/G15G, and J714s or another M5 for the AGX3C path) with the indirect_draw, descriptor_buffer and push_constant CTS groups.
Evidence
- Gate:
78b8055fmerged intoaurora-wipa58f52b53bb1(clean merge-tree), x86 drm-shim build, Clang,-Dbuildtype=release -Db_ndebug=false,meson test --suite asahi --suite poly: 338/338 OK.hk_root_fragmentpasses. - Mutation: dropping the dword refinement in
hk_root_reads_ignore_dirty()(back to whole-push dirtiness) makeshk_root_fragment_testfail at line 425 (hk_root_reads_ignore_dirty(HK_ROOT_READS_PUSH, 0, BITFIELD64_BIT(2), d)), so the new checks pin the behaviour.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Extend AGX3 direct-draw root-bypass eligibility and reduce per-draw CPU recording overhead on Borealis Vulkan (affecting vkd3d-proton direct draw loops and Vulkan descriptor-buffer/push-constant workloads):
HK_G17P_RANGE_SOURCE_ROOTuniform-DMA spans (such asdraw.attrib_strides[]) to stay on the root-bypass path whenever they are disjoint from the four bypass-dirtyable root regions (push,dynamic_buffers,draw.attrib_base,draw.attrib_clamps), viahk_root_span_overlaps_bypassable().agx3_root_uniform_usage_valid && !agx3_preamble_uses_root_uniform && !g17p_hoisted_preamble_va.agx3_push_read_dwords/push_dirty_dwords) so fragment shaders ignore per-draw updates to disjoint vertex-only push-constant slots.hk_push_constants(), skip no-opvkCmdSetDescriptorBufferOffsetsEXT()binds when address/size/dynamic offset are unchanged, avoid an extra struct copy inhk_agx3_publish_vertex_state(), and clear host draw-ID/loader caches after GPU-built multi-draw indirect sub-streams (hk_agx3_draw_indirect_gpu()).test-hk-root-fragment.ccovering disjoint push-dword tracking andhk_root_span_overlaps_bypassable().Tested:
./rig/fedora-mesaci.sh 78b8055f6b12): 218/218 PASS, 0 FAIL, 0 new warnings in touched files.J700,T8140/G17P B1, stock7.3.0-41.fc44.aurora.aarch64,stock.shPRE/POST diff = 0, 0 GPU faults/recoveries/AVCs/core dumps):origin/aurora-wip99658583598vs78b8055f6b12, 304/304--verifyexact CRC matches, 0 failures):gpubench-d3d12 render.draws kind=direct:d=1825.69 -> 631.58 us(1.31x, rec446.20 -> 222.27 us2.01x),d=4499.38 -> 304.25 us(1.64x, rec499.89 -> 293.63 us1.70x, gpu147.04 -> 141.54 us).gpubench-vk render.bindless_ubo mode=desc:d=1504.20 -> 497.93 us(1.01x),d=2330.88 -> 321.72 us(1.03x).gpubench-vk render.bindless_ubo mode=ubo:d=1505.62 -> 503.50 us(1.00x),d=2332.42 -> 328.47 us(1.01x).gpubench-d3d12 render.draws kind=indirect:d=483.35 -> 82.06 us(1.02x);render.postfx:d=42517.61 -> 2466.22 us(1.02x, rec185.87 -> 147.84 us).vk_mdi,vk_cull_mdi,vk_clear_4m,vk_clear_16m,vk_copy_b2i,vk_mipchain_ctrl,d11_draws_direct,d11_draws_ind,d12_clear_4m,d12_clear_16m,d12_mipchain_ctrl):0.99x–1.03x, 100% exact CRC match.6,074 PASS / 0 FAIL):dEQP-VK.draw.renderpass.indirect_draw.*: 372/372 PASSdEQP-VK.draw.dynamic_rendering.primary_cmd_buff.indirect_draw.*: 364/364 PASSdEQP-VK.binding_model.descriptor_buffer.traditional_buffer.single.*: 238/238 PASSdEQP-VK.binding_model.descriptor_buffer.traditional_buffer.multiple.*: 95/99 PASS (4 NS)dEQP-VK.api.copy_and_blit.core.buffer_to_image.2d_images.*: 60/91 PASS (31 NS)dEQP-VK.api.copy_and_blit.copy_commands2.buffer_to_image.2d_images.*: 60/91 PASS (31 NS)dEQP-VK.api.image_clearing.core.clear_color_image.2d.*: 4824/8746 PASS (3922 NS)dEQP-VK.pipeline.monolithic.push_constant.*: 61/65 PASS (4 NS)Risk: two-way · M3, M4, Neo, M5
Not yet: Measured on J700 (G17P B1); not yet benchmarked separately on M3, M4, or M5 hardware.