Skip to content

borealis: extend AGX3 root-bypass and fast-path push/descriptor-buffer draw updates - #1257

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
perf/borealis-draws-transfer
Nov 27, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
perf/borealis-draws-transfer

Conversation

@DjDeveloperr

Copy link
Copy Markdown

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):

  • Allow non-zero HK_G17P_RANGE_SOURCE_ROOT uniform-DMA spans (such as draw.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), via hk_root_span_overlaps_bypassable().
  • Permit vertex shaders with a constant-program preamble to use root bypass when agx3_root_uniform_usage_valid && !agx3_preamble_uses_root_uniform && !g17p_hoisted_preamble_va.
  • Track push-constant reads and writes at 32-bit dword granularity (agx3_push_read_dwords / push_dirty_dwords) so fragment shaders ignore per-draw updates to disjoint vertex-only push-constant slots.
  • Fast-path 4/8/16-byte compare/copy in hk_push_constants(), skip no-op vkCmdSetDescriptorBufferOffsetsEXT() binds when address/size/dynamic offset are unchanged, avoid an extra struct copy in hk_agx3_publish_vertex_state(), and clear host draw-ID/loader caches after GPU-built multi-draw indirect sub-streams (hk_agx3_draw_indirect_gpu()).
  • Add unit tests in test-hk-root-fragment.c covering disjoint push-dword tracking and hk_root_span_overlaps_bypassable().

Tested:

  • Fedora Mesa CI (./rig/fedora-mesaci.sh 78b8055f6b12): 218/218 PASS, 0 FAIL, 0 new warnings in touched files.
  • MacBook Neo (J700, T8140 / G17P B1, stock 7.3.0-41.fc44.aurora.aarch64, stock.sh PRE/POST diff = 0, 0 GPU faults/recoveries/AVCs/core dumps):
    • Exact-head interleaved ABBA+BAAB (origin/aurora-wip 99658583598 vs 78b8055f6b12, 304/304 --verify exact CRC matches, 0 failures):
      • gpubench-d3d12 render.draws kind=direct: d=1 825.69 -> 631.58 us (1.31x, rec 446.20 -> 222.27 us 2.01x), d=4 499.38 -> 304.25 us (1.64x, rec 499.89 -> 293.63 us 1.70x, gpu 147.04 -> 141.54 us).
      • gpubench-vk render.bindless_ubo mode=desc: d=1 504.20 -> 497.93 us (1.01x), d=2 330.88 -> 321.72 us (1.03x).
      • gpubench-vk render.bindless_ubo mode=ubo: d=1 505.62 -> 503.50 us (1.00x), d=2 332.42 -> 328.47 us (1.01x).
      • gpubench-d3d12 render.draws kind=indirect: d=4 83.35 -> 82.06 us (1.02x); render.postfx: d=4 2517.61 -> 2466.22 us (1.02x, rec 185.87 -> 147.84 us).
      • Non-regression controls (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.
    • Targeted Vulkan CTS on J700 (6,074 PASS / 0 FAIL):
      • dEQP-VK.draw.renderpass.indirect_draw.*: 372/372 PASS
      • dEQP-VK.draw.dynamic_rendering.primary_cmd_buff.indirect_draw.*: 364/364 PASS
      • dEQP-VK.binding_model.descriptor_buffer.traditional_buffer.single.*: 238/238 PASS
      • dEQP-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.

…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>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 20:24

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_mask goes 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 refuse buffer_active sets, and the embedded-sampler bind clears buffer_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->dirty and the launch-match checks. A bypass launch reads non-push/dynbuf/VB ROOT spans from the old gfx->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_va still refuses, and a PREAMBLE_OUT range hits default: return 0 in hk_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 at out + 8 even when the memo length is under 16. Today the memo always carries the pair, so this is harmless, but an assert on vdm_len >= 16 would 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 at 78b8055f6b12 (J615/G15G, and J714s or another M5 for the AGX3C path) with the indirect_draw, descriptor_buffer and push_constant CTS groups.
Evidence
  • Gate: 78b8055f merged into aurora-wip a58f52b53bb1 (clean merge-tree), x86 drm-shim build, Clang, -Dbuildtype=release -Db_ndebug=false, meson test --suite asahi --suite poly: 338/338 OK. hk_root_fragment passes.
  • Mutation: dropping the dword refinement in hk_root_reads_ignore_dirty() (back to whole-push dirtiness) makes hk_root_fragment_test fail at line 425 (hk_root_reads_ignore_dirty(HK_ROOT_READS_PUSH, 0, BITFIELD64_BIT(2), d)), so the new checks pin the behaviour.

@RyanTheTide

Copy link
Copy Markdown

78b8055f6b12 3-gen Borealis PASS (J700 + J615 + J316s, Clang 23.1.4 -Dbuildtype=release -Db_ndebug=false, isolated VK_DRIVER_FILES overlay, stock Mesa SHA-256 unchanged on all 3):

  • J316s (G13S C0, 7.3.0-aurora-fleet89): meson test --suite asahi 215/215 PASS (incl. hk_root_fragment); CTS 961 PASS / 0 regressions (draw.renderpass.indirect_draw 372/372, draw.dynamic_rendering.primary_cmd_buff.indirect_draw 364/364, descriptor_buffer.traditional_buffer.single 116/238, multiple 48/99 + 1 pre-existing graphics_geom_buffers8_sets1 GS RA failure, push_constant 61/65), 0 GPU faults/recoveries, Enforcing, 0 failed, 0 AVC.
  • J615 (G15G C0, 7.3.0-aurora-fleet90-airs2): CTS 961 PASS / 0 regressions (372/372, 364/364, 116/238, 48/99 + graphics_geom_buffers8_sets1 A/B verified identical on parent 99658583598f, 61/65), 0 GPU faults/recoveries, Enforcing, 0 failed, 0 AVC.
  • J700 (G17P B1, 7.3.0-aurora-fleet89): CTS 1,130 PASS / 0 FAIL (372/372, 364/364, 238/238, 95/99 4 NS, 61/65 4 NS); interleaved ABBA+BAAB gpubench-vk render.bindless_ubo vs 99658583598f (32/32 exact CRC 57e7bedd): desc_buf d=1 record_cpu_us 290.28 -> 281.52 us (-3.02%, non-overlapping) / d=2 us_per_submit 242.60 -> 234.37 us (-3.39%), ubo_vec4 d=1 record_cpu_us 290.60 -> 282.78 us (-2.69%, non-overlapping) / us_per_submit 603.87 -> 576.04 us (-4.61%), 0 GPU faults/recoveries, Enforcing, 0 failed, 0 AVC.

@RyanTheTide
RyanTheTide merged commit 41857fd into aurora-wip Nov 27, 2026
@RyanTheTide
RyanTheTide deleted the perf/borealis-draws-transfer branch November 27, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants