Repository navigation
borealis: extend AGX3 direct-draw fast path to depth bias, continued passes, and dynamic UBOs - #1433
Conversation
There was a problem hiding this comment.
Verdict: CHANGES_REQUESTED at 038c2b08
Blockers:
- Silent stale-address corruption on alternating push-only and dynamic-UBO-only draws (
src/asahi/vulkan/hk_cmd_draw.c:17758-17990):- When a pipeline uses both push constants and a dynamic UBO (
fast->push_bypass_ready && fast->dynbuf_bypass_ready),hk_agx3_push_bypass_ioto_prepare()bakesfast->ioto_bytesonce from the initial snapshot(push=P0, dynbuf=D0). - In
hk_agx3_fast_direct_draw_begin(), every Ioto emission copies from the unmodified initial templatehk_copy_small_inline(ioto_cpu, fast->ioto_bytes, ioto_len)and then only patchespush_relocsifpatch_pushis true ((dirty_mask & HK_ROOT_DIRTY_PUSH) != 0) and only patchesdynbuf_relocsifpatch_dynbufis true ((dirty_mask & HK_ROOT_DIRTY_DYNBUF) != 0), without updatingfast->ioto_bytesor re-patching the non-dirty side fromcached->loader_ranges. - Concrete failure sequence:
- Draw 1 (slow path) snapshots
fast->ioto_byteswith(P0, D0). - Draw 2 updates only the dynamic UBO offset (
D0 -> D1,patch_push=false,patch_dynbuf=true): emits(P0, D1)and updatescached->loader_ranges, whilefast->ioto_bytesstill holdsD0. - Draw 3 updates only push constants (
P0 -> P1,patch_push=true,patch_dynbuf=false): copiesfast->ioto_bytes(restoring staleD0!) and patches onlyP1-> Draw 3 silently executes with(P1, D0)instead of(P1, D1). - The symmetric sequence (Draw 2 updates push
P0 -> P1, Draw 3 updates dynbufD0 -> D1) copies staleP0fromfast->ioto_bytesand executes Draw 3 with(P0, D1)instead of(P1, D1).
- Draw 1 (slow path) snapshots
- Fix by keeping
fast->ioto_bytessynchronized with every committed patch (e.g., copying the patchedioto_cpuback tofast->ioto_bytes— or patchingfast->ioto_bytesin place only after all falliblereturn falsechecks succeed — or re-patching both relocation sets fromcached->loader_rangeson every emission), and add a drm-shim + hardware regression test covering alternatingpush-only -> dynbuf-only -> push-onlydraws on the same pipeline.
- When a pipeline uses both push constants and a dynamic UBO (
- Second GPU-generation hardware row missing: Once the stale-template bug is fixed, please re-run
meson test --suite asahi+J616Cexact-head verification and add a second Apple Silicon generation hardware row (e.g. M5G17S/AGX3C, which is also enabled inhk_agx3_push_bypass_ioto_prepare()andhk-g17s-kernel-fast-direct-draw-ext).
Checked:
- Audited
hk_cmd_buffer.c,hk_cmd_buffer.h,hk_cmd_draw.c, andmeson.build(+1770/-179across 7 files):- Verified
hk_agx3_push_bypass_ioto_prepare()zeroes allfast->dynbuf_*,fast->push_*, andfast->vs_*fields on entry, and verifiesshort_maskand bump uploader bounds before advancing cursors inhk_agx3_fast_direct_draw_begin(). - Verified
cs->m5_orderedremains excluded while non-orderedcs->m5_continued_passis admitted. - Verified
fast->push_inline_immcannot run withpatch_dynbuf(fast->dynbuf_range_count == 0).
- Verified
Evidence
- Head commit:
038c2b08c3b8896802dd6300406fd993e08a4bfa(MERGEABLEintoaurora-wip). - Stale template copy site:
src/asahi/vulkan/hk_cmd_draw.c(hk_agx3_fast_direct_draw_begin()), copyingfast->ioto_bytesintoioto_cpufollowed by guardedif (patch_push)andif (patch_dynbuf)loops with no writeback tofast->ioto_bytes.
There was a problem hiding this comment.
The stale-address finding is addressed in source at 15d906c. The code now patches the last committed Ioto template after the validation exits and copies that template into the new draw. The shim assertions cover preservation across alternating updates and lack of mutation on invalid dynamic-buffer fallback. The posted suite and J616C results identify the previous head. Please post current-head shim results and exercise alternating push-only and dynamic-UBO-only draws on J616C and a second enabled GPU generation before merge.
…passes, and dynamic UBOs
Extend the cached AGX3 direct-draw emitter (hk_agx3_direct_draw_fast)
across three additional steady-state workloads while preserving every
correctness invariant of hk_draw_impl():
1. Static depth_bias.enable shadow passes: remove the
dyn->rs.depth_bias.enable arming exclusion. hk_flush_gfx_state()
validates cs->cr.dbias_is_int and emits depth-bias PPP state on the
first draw before arming, and any change to depth-bias enable,
factors, or representation mutates dyn->generation and dyn->dirty,
which already declines the fast path.
2. Non-ordered merged/continued passes (cs->m5_continued_pass): remove
the cs->m5_continued_pass exclusion from arming and admission while
keeping cs->m5_ordered excluded so ordered continuations still run
hk_m5_ordered_draw_hazard() on every draw. Drop direct_draw_fast in
hk_cmd_buffer_end_graphics() so the first draw of a merged pass
always enters hk_flush_gfx_state() (verifying sample locations and
depth-bias state) before re-arming for subsequent draws in that pass.
3. Dynamic UBO offset updates (HK_ROOT_DIRTY_DYNBUF) and combined
push-constant + dynamic-UBO bypass:
- Snapshot desc->non_dynbuf_generation and FS/VS root read masks
(agx3_root_reads, agx3_dynbuf_reads, agx3_push_read_dwords).
- Extend hk_agx3_push_bypass_ioto_prepare() to collect root-set
HK_G17P_RANGE_SOURCE_BUFFER ranges and relocations, enforcing
lockstep cluster sharing per dynamic-buffer descriptor in
l->plan.shared.
- In hk_agx3_fast_direct_draw_begin(), admit
(dirty_mask & ~(HK_ROOT_DIRTY_PUSH | HK_ROOT_DIRTY_DYNBUF)) == 0
when FS and (when launch->has_general_root) VS ignore the dirty
root fields. Validate every tracked dynamic-buffer descriptor
(non-zero base_addr, 4B alignment, bounds and uint64 overflow
guards) along with short-LDIMM and uploader/Ioto bounds before
advancing any cursor or emitting bytes.
- Patch both push and dynamic-UBO relocations in one Ioto program
copy and one 28B VDM State Update, update cached->loader_ranges,
and mark bypass_launched without clearing dirty_mask so the lazy
full-root upload invariant stays intact.
Extend hk_cpu_upload_bench with unit tests for static depth bias,
non-ordered vs ordered continued passes, dynamic UBO bypass matching
hk_agx3_try_push_only_vs_program() byte-for-byte, FS/VS read-mask
fallbacks, invalid/OOB/misaligned/overflow descriptor fallbacks, and
combined push-constant + dynamic-UBO sequences on G17P and G17S.
Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
…nsions Add agx3_vulkan_fast_direct_draw_ext and wire it into the g17p, t6041, and g17s-kernel drm-shim suites with ASAHI_MESA_DEBUG=verify and strict stream validation. Exercises static depth_bias.enable direct and indexed draws, non-ordered and ordered merged dynamic rendering passes, VS dynamic-UBO offset sweeps with FS-disjoint and FS-dirty slots, and combined push-constant + dynamic-UBO updates. Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
15d906c to
915c288
Compare
|
Fixed the stale
|
There was a problem hiding this comment.
The updated head retains the committed-template fix. The posted 3/3 shim pass covers alternating dynamic-UBO and push-constant updates, and the reported current-head J616C run passes the bindless UBO output and depth-bias checks. Please confirm the alternating sequence itself on hardware and post the second enabled GPU-generation row, especially AGX3C. The J616C benchmark and CTS results are useful coverage for their exercised paths.
There was a problem hiding this comment.
Verdict: MERGE at 915c288.
Checked: The committed Ioto template retains both relocation classes across alternating updates. The current-head shim rows cover the alternating sequence on three profiles, and the current-head J616C UBO and depth-bias checks passed without faults. An additional GPU-generation hardware row can follow separately. This resolves my earlier hold.
|
Base M5 row (MacBook Air 15" M5, J815, G17G), kernel 7.3.0-aurora-j815-dev, PR head 915c288 vs aurora-wip 8b59f2b, release builds, dEQP-VK 1.4.7.1 (+ KhronosGroup/VK-GL-CTS@c2c05e95f97f):
|
|
@DjDeveloperr, code-owner heads-up: App approval at |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed 915c288f90c0 against the earlier direct-draw revision and the tested correction. Both relocation classes now update the retained template after the final fallible check, before its single copy to the arena. The current driver delta from the tested correction is comments and whitespace. The added Vulkan sequences alternate valid dynamic offsets and push constants on one pipeline. Three shim profiles passed, and J616C passed its bindless UBO CRC and four depth-bias cases. The remaining evidence is alternating-draw readback on hardware, then J773g and a post-P0 J700 comparison.
What: Extend Borealis's AGX3 direct-draw fast path to cover dynamic depth bias, continued render passes, and dynamic UBO offsets (preserving
#1306's inline-immediate push-constant path and#1354's reset invariants), with drm-shim unit tests covering all three extensions.Tested:
-Db_ndebug=false, rebased onaurora-wip8b59f2b0a70, head038c2b08c3b8):meson test --suite asahi362/362 PASS (0fail,0skip), including the new drm-shim direct-draw fast-path extension tests.G17P,7.3.0-j616c-parity5+, Release ARM64libvulkan_asahi.so) at exact head038c2b08c3b8:ASAHI_MESA_DEBUG=verifygpubench-vk --test render.bindless_ubo --depths 2: exact CRC57e7bedd,0faults.deqp-vkdEQP-VK.dynamic_state.monolithic.rs_state.depth_bias*: 4/4 PASS (0fail).aurora-wip(8b59f2b0a70,depth=2, no regression on standard non-dynubo draws):render.light60.11 -> 59.98 us(-0.22%),render.deferred109.41 -> 109.23 us(-0.16%, CRC2cfe9a54),render.bindless_ubo163.13 -> 163.00 us(-0.08%, CRC57e7bedd),render.shadowGPU208.96 -> 208.96 us(+0.00%, CRCc0fb9993).dmesg:0GPU/DART faults or recoveries.Risk: two-way door · extends Borealis's AGX3 direct-draw fast path; falls back cleanly to the general draw path when bypass preconditions are not met, and
dynbuf_*state is zeroed on command buffer reset.Not yet: Second Apple Silicon generation hardware row and a dedicated dynamic-UBO / depth-bias direct-draw microbenchmark in
gpubench-vk.