Repository navigation
borealis: keep barriers cheap until memory aliases, then strengthen them in place (G17P, M5) - #554
Conversation
|
Thank you for the thorough write-up and the bt matrix; patching the noted records in place is a neat way to avoid the device-wide cost. We select behaviour by a hardware property, not by the chip it was tested on. The new mechanism is keyed on Could you select it with a predicate for that property (alongside We can run bt and the event/replay dEQP subsets on our A18 Pro (also G17P) and M4 Pro. The branch also needs a rebase. |
050acbd to
c7dbd54
Compare
|
Rebased on aurora-wip
Yes please to the A18 Pro and M4 Pro bt and event/replay runs. |
|
@jgoyvaerts, from the mesa merge train: #552 ("give M5 barriers memory scope only while a host import may alias", M5 driver lane) merged into aurora-wip at 263ddb7 a short while ago, and this PR now conflicts with it in This isn't a textual conflict we can resolve for you: both PRs now decide M5's barrier memory scope at record time and patch noted records later.
Could you rebase onto 263ddb7 and reconcile the two? Either express #552's import-alias case through your mechanism (one patching path for G17P and M5), or keep #552's M5 rule and limit this PR to G17P, with a comment on why. The M5 driver lane (which wrote #552) can answer questions about its patch sites and the packing interaction. Its M5 tests are Once it's rebased, it gets an independent review and the M5 Pro (alias A/B + packtest + sync gate) and Neo rows in the next train batch. The train holds it until then. |
|
Thanks for switching to |
Notes for the rebase onto #552 (
|
c7dbd54 to
2644e78
Compare
|
Rebased on aurora-wip
Your three M5 decisions:
Tested on M4 Pro (G17P), guarded, 0 recoveries: trace shows the DXVK and vkd3d sets take @DjDeveloperr yes please to the M5 gate (alias A/B, packtest alias cases, dEQP |
|
Thanks for the rebase onto #552's mechanism: one path selected by Since the event and transfer/task-launch flush changes also reach M5, an M5 row from someone with one would help; we have none here. As agreed, we will run the A18 Pro and M4 Pro barrier, event and capture/replay dEQP rows on 2644e78 and post them here. |
2644e78 to
f91d963
Compare
|
Commit messages only, for the pre-PR checklist: the commits no longer carry Assisted-by: LLM (Claude:Opus 5.5) |
|
Blockers: 2.
Commits 1-3 change capture/replay memory and buffer placement on every chip (G13-G18), not only on the VA-tagged ones, but the only hardware row is M4 Pro. HW row (on the rebased head): M4 Pro and A18 Pro: bt (all modes) 0 stale rows except inflight, plus the 7106-case replay/descriptor-buffer/external-memory list and Assisted-by: LLM (Claude:Opus 5.5) |
f91d963 to
7ebd619
Compare
|
Rebased on aurora-wip
Tested on M4 Pro (G17P), kernel m4.177, guarded, 0 recoveries: meson Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Follow-up on 7ebd619. One blocker is still open.
- Resolved: point 1. The branch applies to aurora-wip again. Keeping
hk_cdm_caches_pending()from #558 while droppinghk_cdm_alias_scope_unpatched()is right, and themock_bo_alloc(..., NULL)test line is fine. - Still open: point 2 (blocker).
src/asahi/vulkan/hk_event.c:165-182,206-208has not changed.hk_dependency_waits_for_host()still returns false for aVkDependencyInfowith zero barrier structs, and that is a valid wait on an event the host sets. Such a wait gets no alias scope, so the evalias case is still reachable. Fix: return true when the dependency info has no barriers, or when the event was not set earlier in this command buffer. - Still open: point 3 (
hk_buffer.c:288-292, unbound capture/replay buffer address), not a blocker. - Evidence: the new rows (meson 220/220, the 37339-case dq-fast list, the GL set) are on M4 Pro only. The bt alias rows are still from
2644e788a. The rows from our last comment are still needed on the new head: bt plus the replay/descriptor-buffer/event list on M4 Pro and A18 Pro, the G13/G14 capture/replay andmemory.*run, and the M5 alias/event subset.
Assisted-by: LLM (Claude:Opus 5.5)
J714s (M5 Pro, G17S / AGX3C) Hardware Row —
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Follow-up on the J714s (M5 Pro, G17S) row for 7ebd619. The blocker from my last comment is still open, because the code hasn't changed.
What the row covers: the M5 event subset (5,922/3/0 on head and base, no status diffs), capture/replay BDA plus descriptor_buffer with no diffs, and 147/147 unit tests. Those count toward the M5 part of the evidence list.
Still open:
- Blocker,
src/asahi/vulkan/hk_event.c:165-182,206-208:hk_dependency_waits_for_host()still returns false for aVkDependencyInfowith no barrier structs. The CTS event list passing doesn't show this case is safe. It needs an event the host sets, a wait with an empty dependency info, and memory that first aliases after the command buffer was recorded. The event list doesn't build that combination. Fix as before: treat an empty dependency info, or an event not set earlier in this command buffer, as a host wait. - The M5 alias arms are the part of the row that tests this PR's patch-in-place path, and only
hostprivran. The next arm hitsvkAllocateMemory = -2on both base and head, so it says nothing about the change either way. Please size that arm's allocation from the device's reported heap size, or skip it when the heap is too small, and re-run the remaining alias arms on G17S. - Still needed on 7ebd619: the bt alias rows plus the replay/descriptor-buffer/event list on M4 Pro and A18 Pro (the bt rows are still from
2644e788a), and the G13/G14 capture/replay andmemory.*run.
HW rows (our Macs): J616s (M4 Pro) and Neo (A18 Pro, G17P), the bt alias list plus dEQP-VK.synchronization*.event*, dEQP-VK.binding_model.descriptor_buffer.* and the capture/replay BDA cases on head and merge-base. Pass: 0 status diffs and 0 GPU recoveries. M1 Pro (G13S) and M2 (G14G): capture/replay plus dEQP-VK.memory.*, with the same pass.
Assisted-by: LLM (Claude:Opus 5.5)
7ebd619 to
2eaec51
Compare
|
New head Point 2 (blocker), Point 3, Rebase. One conflict, in J616s (M4 Pro, G17P), kernel m4.177, head vs merge-base
M5 alias arms (Dj's row). I couldn't change the arm that fails @RyanTheTide, could you run the A18 Pro (Neo) bt + replay/descriptor-buffer/event row, and the M1 Pro (G13S) and M2 (G14G) capture/replay + Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-checked at 2eaec51. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review of 2eaec513f3cc against the pre-PR checklist. 0 code or attribution blockers remain (all functional points from the 7ebd619d review are cleanly addressed), but 1 hard-rule naming blocker (§6) remains alongside owed multi-generation hardware rows (§5).
Blocker (§6 Naming — hard rule)
- New user-visible Meson test names and test executables added by this PR use the
hk-prefix instead of Borealis (brl-):src/asahi/meson.build:'hk-' + chip + '-capture-replay'and'hk-g17p-event-alias'src/asahi/vulkan/meson.build:'hk-vulkan-capture-replay'and'hk-vulkan-event-alias'
- Per pre-PR checklist §6, existing upstream
hk_*C filenames/symbols wait for#591, but new user-visible executables and Meson test names must use thebrl-prefix (e.g.,brl-vulkan-capture-replay,brl-vulkan-event-alias,brl-<chip>-capture-replay,brl-g17p-event-alias), matching#614.
Checklist & Code Audit (all clear)
- Previous blockers resolved:
- Host-event wait detection (
src/asahi/vulkan/hk_event.c:168-189):hk_dependency_waits_for_host()now treats a wait as host-capable whenever any barrier namesVK_PIPELINE_STAGE_2_HOST_BITor the combinedsrcStageMaskisVK_PIPELINE_STAGE_2_NONE(covering zero-barrier andNONE-source waits per VUID 03839/01158). Secondary command buffers replay into the primary viavk_cmd_queue_execute(), so secondary waits setcmd->state.alias_host_waiton the primary. Covered by the new event-alias shim test. - Unbound KHR capture/replay opaque address (
src/asahi/vulkan/hk_buffer.c:652):hk_GetBufferOpaqueCaptureAddress()now returns0when!buffer->vk.device_addressinstead of hittingvk_buffer_address()'s assert, and the capture/replay shim test checks this before bind.
- Host-event wait detection (
agx_bo_create_at()& capture/replay placement (agx_bo.c,agx_device.c,agx_device_virtio.c,hk_device_memory.c):- Ownership of
vaon both native and virtio failure paths is clean (no leak or double-free),AGX_BO_NO_CACHEprevents VA reuse while freed, and the rebase overa66f5d46bproperly skipsagx_bo_cache_has()forcapture_replayallocations.
- Ownership of
- In-place patching & cache maintenance (
hk_cmd_buffer.c,hk_cmd_buffer.h,hk_tess_batch.c,hk_cmd_draw.c):hk_cmd_buffer_patch_alias_sites()flushes patched words on cached command memory (hk_g17p_cached_cmd_memory()) before fencing,hk_cs::alias_pinprotects pinned tessellation tails and moves cleanly acrosshk_cs_merge_cdm_until(), andhk_va_tagged_caches()selects the shared dynamic mechanism by hardware property. Keeping the M5-only end-of-stream flush (agx_chip_g17_m5) has a documented hardware justification (bt xsubon G17P).
- Clean-room & attribution (§4): Clean-room throughout; all 4 commits carry human author/committer and single human
Signed-off-by:with no agent trailers; PR body has theAssisted-by:disclosure.
Owed Hardware / Runtime Evidence (§5)
- Covered on
2eaec513f3cc: J616s (M4 Pro, G17P) —btalias modes (0 stale outside out-of-modelinflight, default andweakbarrier), 7,106-case dEQP-VK replay/descriptor-buffer/external-memory/sparse list (0 diffs), 6,213-casesynchronization*.event*(0 diffs), GL set identical,meson --suite asahi --suite vulkan231/231, 0 GPU recoveries. - Still owed on the final head:
- M5 (J714s / G17S): The prior M5 row was on
7ebd619d, and the aliaspacktestarms afterhostprivaborted identically on base and head withvkAllocateMemory = -2(VK_ERROR_OUT_OF_DEVICE_MEMORY). Needs re-run on the final head including the remaining M5 alias arms once the test harness sizes its allocation to the reported heap. - A18 Pro (Neo, second G17P SoC):
btalias matrix + replay/descriptor-buffer/event dEQP subset (0 diffs, 0 recoveries). - AGX2 (M1 Pro G13S / M2 G14G): Commits 1–3 change capture/replay memory and buffer placement across every chip;
dEQP-VKcapture/replay +memory.*no-regression rows are still owed.
- M5 (J714s / G17S): The prior M5 row was on
Assisted-by: LLM (Gemini 4 Neon)
2eaec51 to
26e8749
Compare
|
New head
Each rename sits in the commit that adds the test: the capture/replay names in commit 2, the event-alias names in commit 4. The commit messages now name the tests the same way. As in #614, the meson variables (
Assisted-by: LLM (Claude:Opus 5.5) |
J714s (M5 Pro, G17S B1 / AGX3C) Runtime Row —
|
|
Re-checked at 26e8749. Against 2eaec51 the only change is the four Meson test names ( On the J714s row at this head: the alias arms are what this PR's patch-in-place path needed on M5, and 9/9 passing in both pack modes, with the earlier
Still to come on 26e8749: the A18 Pro bt alias matrix with the replay/descriptor-buffer/event list, and the M1 Pro (G13S) and M2 (G14G) capture/replay and Assisted-by: LLM (Claude:Opus 5.5) |
26e8749 to
29774f8
Compare
|
New head
What was wrong: the opaque query. J616s (M4 Pro, G17P), kernel m4.177, against merge-base
M5. We have no rows of our own. @DjDeveloperr, the full event list and the BDA/ Assisted-by: LLM (Claude:Opus 5.5) |
|
@RyanTheTide it's up: aurora-wip Conflicts and how they were resolved:
J616s at
Edit, 17:52 UTC: rows at
Still open: the J714s run Dj asked for, and the Neo row your fleet reruns. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 5a78251f
Blockers:
- Exact-head hardware rows owed from the prior review (
f5577f47) andNot yet:- Finish the queued J616s (
G17P)btalias modes and 6,213-casesynchronization*.event*runs at5a78251f. - Add the J714s (M5 Pro) exact-head comparison against
b15642289coveringsynchronization*.event*, BDA capture/replay,descriptor_buffer, and the packtest alias arms in both packing modes.
- Finish the queued J616s (
Checked:
- Merge commit
5a78251f(2785fdd19+aurora-wipb15642289): 0 code blockers found.agx_bo.c,agx_device.c,agx_device_virtio.c:agx_bo_create_at()takes ownership ofvaand frees it on both native and virtio allocation failure paths withAGX_BO_NO_CACHE.hk_buffer.c: preserves#1067sparse descriptor replay (hk_get_buffer_replay_addrs()restoring both buffer and residency-map addresses) alongside KHR capture/replay placement, andhk_GetBufferOpaqueCaptureAddress()returnsopaque_capture_address/0when unbound.hk_device.{c,h}:hk_va_tagged_caches()covers G17P and M5,hk_CreateDevice()respectsagx_cdm_ordering_memory_scope()(multi-die M5) while keepingASAHI_M5_HOST_ALIAS_STATICM5-only, andva_alias_resourcesexact counting stays intact for byte/2D stencil tiling and compute paths.hk_cmd_buffer.{c,h},hk_cmd_dispatch.c,hk_cmd_draw.c,hk_event.c,hk_tess_batch.c:alias_pinprotects patch-site barrier records from being dropped inhk_tess_batch_stage()and updates cleanly acrosshk_cs_merge_cdm_until()folding/linking;hk_dependency_waits_for_host()accurately narrows host-set event detection; Borealis test/executable names usebrl-.
Evidence
- Head:
5a78251f(MERGEABLE,+1032/-313across 26 files). - Exact-head J616s (
5a78251fvsb15642289): 7,106-case dEQP-VK replay/descriptor-buffer/external-memory/sparse (6647 P / 459 NS,0diffs), GLES3392/392,meson --suite asahi --suite vulkan354/354. - Remaining items to clear: queued J616s
bt+synchronization*.event*at5a78251fand the M5 J714s exact-head rerun requested in the prior review.
|
Current
The standalone capture/replay fixture passed on both candidate runs. On both baselines it stopped at the opaque buffer replay-address check. On J700, the event alias fixture reported zero late patches for each of the three host-wait patterns and one for the device-set control. That fixture checks recording-time behavior and does not submit GPU work. There were no GPU faults or boot changes. Both exact contributor-fork CI checks passed. M2 coverage and the full exact M5 event/BDA/descriptor and both-mode alias runs remain due. |
There was a problem hiding this comment.
Verdict: FINISH at 5a78251
Checked: Verified exact contributor CI and the J616s alias/event evidence, plus the independent J700 and J316s comparisons. J700’s recording-time alias fixture does not submit GPU work. The full J714s M5 event, BDA, descriptor and both-packing-mode alias comparison remains due; keep the tracked M2 coverage.
|
The M2 regression check is complete on J473 (G14G), running the saved All 42 Vulkan CTS statuses matched (31 Pass and 11 NotSupported per arm) across event synchronization, BDA capture/replay and descriptor buffers. The standalone opaque-address replay failed on baseline and passed on the candidate. No GPU faults or boot changes. The J714s event, BDA/descriptor and both alias packing modes are still outstanding. |
|
Jonathan, two items remain on #554.
If you’re taking the merge, please keep both event paths and let us know here. If there’s no update by November 30 at 19:56 AEDT, I’ll refresh and carry the tested forward merge, then request exact-head review. The J714s row is still queued. |
Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Superseded 12-01: not a hold under the merge bar (no shown failure). No code affirmation for integration delta; follow-ups: integrated build, M5 Pro event/BDA/descriptor/alias comparisons
The current integration changes shared command and synchronization paths since the earlier reviewed build. Please confirm the current integrated build and provide the outstanding M5 Pro event, BDA capture/replay, descriptor buffer and both alias packing-mode comparisons. The earlier recording-time fixture did not submit GPU work.
|
Merged aurora-wip at |
aurora-wip's e9831e6 moved the host-alias trace from ASAHI_M5_HOST_ALIAS_TRACE to ASAHI_MESA_DEBUG=hktrace, still on M5 only, and 68378cf removed the ASAHI_M5_HOST_ALIAS_STATIC override. This branch traces and patches on every chip with VA-tagged caches (hk_va_tagged_caches(), G17P and M5), so the merge takes hktrace for the trace and keeps this branch's chip condition without the removed override. The event-alias test read the trace through ASAHI_M5_HOST_ALIAS_TRACE; it now adds hktrace to ASAHI_MESA_DEBUG, keeping the caller's flags, as aurora-packtest does. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-reviewed at 265c547cfd9f. Both code items from my last review are fixed, so I'm clearing my change request.
hk_buffer.c: capture/replay buffers take both replay addresses fromhk_get_buffer_replay_addrs(), so #1067's sparse residency-map address is kept, and a KHR buffer only reserves its own VA whenbufferDeviceAddressCaptureReplayEXTis enabled.hk_CreateDevice: dynamic alias tracking is chosen byhk_va_tagged_caches(), not by the M5 check, and the M5 static-mode override isn't extended to G17P.hk_CmdSetEvent2(hk_event.c:342) dispatches pending transfer writes before it records the alias site or the visibility flush.hk_dependency_waits_for_host()treats no barriers, and HOST or NONE source stages, as host waits.- The new test names use
brl-.
Merge waits on one row: J714s (M5 Pro) at this head, with the synchronization event, BDA capture/replay and descriptor-buffer lists against base, and the alias fixture in both packing modes. It's requested. Merge-result CI on current aurora-wip is at https://github.com/DjDeveloperr/mesa/tree/ci/head-554-ec520d24.
|
J714s row at MacBook Pro (M5 Pro, G17S B1), stock
Handback: postflight clean (stock snapshot, boot, |
|
J700 (G17P) second-generation row, merge-tree: mesa#554 merge-tree row · J700 MacBook Neo (A18 Pro, G17P B1), stock Fedora 44 kernel 7.3.0-41.fc44.aurora, same boot, userspace only · base aurora-wip tip
Evidence on Mini: |
|
J714s merge-tree row (FRONTIER-554): The tested head is a local merge commit MacBook Pro (M5 Pro, G17S B1), stock
Handback: postflight clean (same boot, stock snapshot, |
There was a problem hiding this comment.
Verdict: MERGE at 265c547
Checked: The conflict resolution keeps capability-based alias tracking and the landed trace control. Event recording dispatches pending transfer writes and refreshes the stream before recording or flushing the alias site. Capture/replay gets both addresses through the common replay helper, including the sparse residency address, and separate VA reservation is limited to the EXT path. The J714s comparison passed capture/replay and alias fixtures and matched all 12,993 CTS outcomes. The J700 integration matched 3,254 CTS outcomes with no GPU faults. The exact fork build and policy suites passed.
Follow-ups: A future revision to these paths can split capture/replay address handling from barrier optimization so each change can be tested independently.
|
Merged as |
Conflicts: - hk_device_memory.c, hk_system_memory_fits(): aurora-wip moved the reserve into hk_memory_reserve(); this branch's overflow-safe comparison now uses it. - hk_device_memory.c, hk_AllocateMemory(): aurora-wip's capture/replay memory (aurora-silicon#554) is allocated at its own address after the same admission check. With DRM_ASAHI_FEATURE_IDLE_VM_RECLAIM it is left to the kernel too: no MemAvailable check, so the check's cache eviction is gone with it. A kernel refusal of capture/replay memory now evicts the idle cached BOs and tries once more, as agx_bo_create_checked() does for other memory, at a fresh reservation of the same address (a failed agx_bo_create_at() frees its address). - test-hk-memory-oom.c: both sides' cases stay. The reclaim case also allocates capture/replay memory past the mock kernel's limit with a BO in the cache, and checks it reads no MemAvailable and evicts once. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
What: G17P and M5 caches are tagged by virtual address, so a barrier needs a memory-scoped flush once a page is mapped at two GPU addresses, but on G17P that choice was made when the barrier was recorded: a command buffer recorded before memory aliased kept the cheap flush, and every word read through the second mapping later came back stale (#266's bt test). This PR moves G17P onto #552's patch-site mechanism (cheap flush until the first aliasing resource appears, then patched in place), gives capture/replay memory a single mapping, and fixes
bufferDeviceAddressCaptureReplayEXTbuffers, which all failed withVK_ERROR_UNKNOWN.Tested: J616s M4 Pro (G17P), kernel 7.3.0-m4.219, at
265c547cf(merge of aurora-wip31b9bb786, see Evidence) against aurora-wip31b9bb786: dEQP-VK 7106-case replay/descriptor-buffer/external-memory/sparse list 6647 P / 459 NS on both, 0 cases differ;memory.*(4745) 0 differ;synchronization*.event*6213 cases serial 6210 P / 3 NS on both, 0 status differences; dEQP-GLES3 texture+samplers identical to base case for case; meson--suite asahi --suite vulkan386 Ok / 1 Skipped, includingbrl-g17p-event-alias; 0 GPU recoveries, 0 kernel error lines. Not repeated at this head: the bt alias-mode stale-word rows (last at5a78251f9: late 16/24 -> 0/24 and the other modes 4 -> 0). Other Macs on earlier heads only: A18 Pro and M2 (RyanTheTide,5a78251f9), M5 J714s (DjDeveloperr,7ebd619d1and26e87494a).Risk: two-way door · G17P (M4 family, A18 Pro) and M5 for the barrier patching; every Mac for commits 1-3 (
agx_bo_create_at(), capture/replay memory placement). The merge of aurora-wip keeps its per-importva_alias_resourcescount, so the byte and 2D stencil tiling and the optimized compute kernels decide aliasing exactly as aurora-wip does on every chip. Checked unaffected: A18 Pro and M2 oncb450e343, M5 on earlier heads; nothing but the J616s at this head.Not yet: an M5 rerun at this head: the full
synchronization*.event*and BDA/descriptor_bufferlists (hk_event.candhk_buffer.cchanged since the M5 rows) and the packtest alias arms in both packing modes, with the KHR buffer bound before its address is queried; A18 Pro, M1 Pro and M2 rows at this head; the bt alias modes at this head. Not re-run on this head: the GLES31 subsets, the vkd3d-proton d3d12 suite, the recording-contention bench and bt cost. Not covered: a shader that polls host memory without an event (outside the memory model).Details
Problem. G17P and M5 GPU caches are tagged by virtual address. When one page is mapped at two GPU addresses, a read through one mapping after a barrier sees the writes through the other only if the barrier's flush has memory scope. On G17P that scope followed a live count of resources with a second mapping, but the count was read when the barrier was recorded. A command buffer recorded while nothing aliased kept the cheaper flush. When memory aliased later, every word read through the second mapping came back stale (#266's bt test). That covers:
#552 solved the same problem on M5 with patch sites: a dependency recorded while nothing aliases keeps the cheap flush, its barrier word is noted, and the memory-scope flush is written over it when the first aliasing resource appears. This PR moves G17P onto that one mechanism. The old device-wide rule makes every DXVK and vkd3d-proton device pay about 1 µs per compute→compute barrier. Both enable sparse and fd/host-import features, but they create aliasing objects only for tiled/reserved resources or shared handles. Sources: DXVK d3d11_buffer.cpp:72-76, d3d11_texture.cpp:148-152; vkd3d-proton resource.c:4094-4101 via CreateReservedResource only, memory.c:860-881 (heaps are not sparse).
Change. Based on aurora-wip
43beb2fc9(contains #552263ddb7f, the #571 test stubs, #558's pack boundary, #440,2a5667ad3's G17P compute submit packing, and Dj's 11-23/24 BO-cache and byte-stencil work). Rebased fromefabab385; what changed in the rebase:hk_AllocateMemory(): ordinary memory keepsagx_bo_create_checked()(99d210278,9b22559a8). Capture/replay memory never comes from the cache, so it runshk_system_memory_fits()itself and, asagx_bo_create_checked()does, evicts the BO cache and asks once more before refusing.hk_memory_oomgets a capture/replay case for that (fails without the eviction).hk_BindBufferMemory2(): the storage-backing record (newer than the old base) skipped memory with a secondreplay_vamapping; that mapping is gone, so the condition is too.hk_byte_stencil_validate_dispatch()(45883f922) readva_alias_resources, which commit 4 removes. It now asks!may_alias_memory && alias_live == 0: exact on G17P and M5 (host_alias.dynamic), and on other chips also covers the fd and dma-buf imports the old count missed.11b92e58a) and the newtest-agx-bo-cachemock.asahi: create a BO at a GPU address the caller chose: addsagx_bo_create_at(). The virtio backend also no longer leaks the VA when BO creation fails.borealis: map capture/replay memory once and bind capture/replay buffers into it: like RADV, memory allocated withVK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BITgets its only address in the capture/replay region (the captured one on replay), and a KHR capture/replay buffer takes memory address + offset (VUID-VkBindBufferMemoryInfo-bufferDeviceAddressCaptureReplay-09200, -buffer-09201). So capture/replay no longer aliases at all, and hk: give M5 barriers memory scope only while a host import may alias #552's secondreplay_vamapping of descriptor-buffer capture/replay memory goes with it.bufferDeviceAddressCaptureReplayEXTbuffers keep their own VA. Their fill page was only created for the KHR feature, so every EXT capture/replay buffer failed withVK_ERROR_UNKNOWN. Fixed here.vkGetBufferDeviceAddress()may not ask before that: VUID-vkGetBufferDeviceAddress-bufferDeviceAddress-03324 (which replaced VUID-VkBufferDeviceAddressInfo-buffer-02600) allows an unbound capture/replay buffer only withVK_EXT_buffer_device_address's feature, and those buffers have their own VA from creation.vkGetBufferOpaqueCaptureAddress()has no binding rule and must return theopaqueCaptureAddressthe buffer was created with: it returns that address, also before the bind, or 0 (no specific address) when none was asked for (hk_buffer.c).brl-{g13g,g17p}-capture-replay. They also check both queries before the bind: the KHR opaque query on capture and on replay, and the EXT address query.borealis: stop counting KHR capture/replay among the features that alias memory, inhk_device_may_alias_memory()and the alias trace.borealis: patch barrier records on G17P as on M5 when memory first aliases: one patching path for both chips.alias_live,host_alias.patch_lock, submit-time patch, 0→N patch of every executable command buffer) is now selected by the hardware property,hk_va_tagged_caches()(hk_device.h, used athk_device.cand inhk_cdm_alias_scope(),hk_device.h), instead of the M5 chip check.va_alias_resources,alias_import). G17P therefore counts what M5 counts: buffers and image planes with an address of their own, fd/dma-buf imports for their lifetime, and host imports only while their pages may be mapped elsewhere (hk_host_import_track(),hk_device_memory.c).hk_cmd_buffer_patch_alias_sites(),hk_cmd_buffer.c).hk_cmd_draw.c). A site on a tessellation stage's tail is not dropped by the next batched draw (hk_cs::alias_pin,hk_tess_batch.c). It moves with inline merges.uses_eventsmemory scope throughout. That flag is also set byvkCmdSetEvent2, which DXVK records for its event queries. Now only a wait for an event the host may set turns the command buffer to memory scope (hk_event.c,hk_cmd_alias_scope()). Such a wait's barriers may hold only host operations in their first scope (VUID-vkCmdWaitEvents2-pEvents-03839), so it has no barriers, or barriers whose srcStageMask isHOSTorNONE. Only a device source stage with noHOSTbeside it rules the host out (hk_dependency_waits_for_host(),hk_event.c). The shim testbrl-g17p-event-aliasrecords each form, ends the command buffer and then creates the first aliasing resource: the command buffer must already have memory scope. An event set in the same command buffer must still wait for the patch. That wait is the only way a running command buffer reaches memory aliased after it started, and the G17P CDM reads about 256 bytes of stream past the launch it runs, also across event waits. Setting an event records a site (hk_event.c).hk_cmd_buffer.c). The end of a G17P command already makes its writes visible at every address. bt xsub, with the second address created while the writer runs, read exact even on the old base without any patching. The earlier version's End upgrade on visible-completion kernels is dropped.patch_lockread lock wheneverhost_alias.dynamicis set (hk_queue.c), which now includes G17P. aurora-wip2a5667ad3packs compute submits on G17P too; its boundary and tail flushes askhk_cdm_alias_scope(), which on G17P now followsalias_liveas on M5, so a boundary drops memory scope only while nothing aliases.hk_cmd_buffer_move_alias_sites()is inline again sohk_execution_allowanceruns the real one (hk: tests: stub hk_cmd_buffer_move_alias_sites() #571's stubs removed). New unit checks: sites and the pin move with an inline merge, and a pinned tessellation tail stays (hk_tess_batch).ASAHI_M5_HOST_ALIAS_TRACEnow also works on G17P (name kept for the M5 gate's scripts).ASAHI_M5_HOST_ALIAS_STATICstays an M5 override: G17P always takes the dynamic tracking when its device enables a feature that can alias.Follows #266, #472 and #552.
Merge of aurora-wip
b15642289(5a78251f9, no rebase). Conflicts and what the resolution does:hk_buffer.c: borealis: preserve sparse residency map VA on buffer capture/replay #1067 restores a sparse buffer's residency-map address next to its own address on descriptor replay. Both stay, beside the KHR placement;vkGetBufferOpaqueCaptureAddress()'s address now comes fromhk_get_buffer_replay_addrs().hk_CreateDevice(): dynamic alias tracking is taken where the caches are VA-tagged (hk_va_tagged_caches(): G17P, M5) and the device does not already give every barrier memory scope (agx_cdm_ordering_memory_scope(), multi-die M5).ASAHI_M5_HOST_ALIAS_STATICapplies on M5 only.hk_cdm_alias_scope()followsagx_cdm_ordering_memory_scope()too.va_alias_resources: aurora-wip035af0da4made it an exact per-import count on every chip, read by the byte and 2D stencil tiling and the optimized compute kernels. It stays for those paths with all its sites (own-VA buffers and image planes, fd/dma-buf and untracked host imports); barrier scope followsalias_liveas in this series. The byte stencil check is aurora-wip's again, so the earlier risk note about it on chips without VA-tagged caches no longer applies. The capture/replay memory mapping it also counted is gone with commit 2.hk_cmd_buffer.{c,h}: aurora-wip's AGX2 sparse patch sites move with a stream merge beside the alias sites. aurora-wip now cleans patched words on cached command memory itself, so that part of commit 4 is in the base.hk_cmd_draw.c: the dispatch flush keeps G18G's sealed-dispatch check.test-hk-memory-oom's host-import section checks the per-import count on G13G, and G17P beside G17C withhost_alias.dynamic, where barrier scope followsalias_live. The newhk_query_oqtest gets ahk_cdm_note_alias_site()stub, and the new host-pointer mock passes the VA argumentmock_bo_alloc()takes in this series.Evidence
Merge
265c547cf(aurora-wip31b9bb786, no rebase): aurora-wip's e9831e6 moved the host-alias trace fromASAHI_M5_HOST_ALIAS_TRACEtoASAHI_MESA_DEBUG=hktrace(still M5 only), and 68378cf removed theASAHI_M5_HOST_ALIAS_STATICoverride. This branch traces and patches on every chip with VA-tagged caches (hk_va_tagged_caches(), G17P and M5), so the merge takeshktracefor the trace and keeps this branch's chip condition without the removed override.hk_vulkan_event_aliasnow addshktracetoASAHI_MESA_DEBUG(keeping the caller's flags, as aurora-packtest does) instead of setting the old variable.At
265c547cf(2026-12-02, J616s, kernel 7.3.0-m4.219, release builds of the head and of aurora-wip31b9bb786, 0 GPU recoveries): dq-fastall(7106, -j 3) 6647 Pass / 459 NotSupported on both, 0 differ;mem(4745, -j 6) 3082 / 1663 on both, 0 differ (shared gpu-run 02:35-02:38 UTC);synchronization*.event*serial (chunk.sh, 200 per process, perf gpu-run 02:49-02:51 UTC) 6210 Pass / 3 NotSupported on both, 0 status differences; GLES3 texture+samplers 5926/5953 on both, 0 status differences (the 27 failures are 8-bit*_pbouploads and fail on aurora-wip31b9bb786itself, #1515); meson 386 Ok, 0 Fail, 1 Skipped.At
5a78251f9(J616s, kernel 7.3.0-m4.197, against a build of aurora-wipb15642289, gpu-run 16:45-17:10 UTC 11-28, 0 GPU recoveries): dq-fast 7106-case list at -j 3: 6647 P / 459 NS on base and head, 0 cases differ. GL (gallium asahi, EGL pbuffer): tex probe ok and GLES3 392/392 on both. meson--suite asahi --suite vulkan354/354. bt (same modes and shapes as below, gpu-run 17:45 UTC): baseb15642289stale in late 16/24, pending/simul/xsem 4/4, event 4/8, sparselate 4/12, hostlate 4/8, concrec/evalias 4/4, inflight 24/24; this head 0 in every mode butinflight12/24, as before. Event list: 6210 P / 3 NS on both, 0 differences. The rows below are from the previous head.Testing. J616s (M4 Pro, G17P), kernel 7.3.0-m4.190, this head
2785fdd19against its merge-base aurora-wip43beb2fc9, one gpu-run (00:45-00:50 UTC 11-26), 0 GPU recoveries: the bt alias modes, the 7106-case replay/descriptor-buffer/external-memory list, the 6213-casesynchronization*.event*list and the GL tex probe + GLES3 392. 0 cases differ, and bt has no stale rows on this head exceptinflight. meson--suite asahi --suite vulkan315/315. Theweakbarriercolumn, thememory.*list, the GLES31 subsets and the cost rows are from earlier heads with the same barrier code (f5577f472,2eaec513f,2644e788a). A18 Pro and M2: Ryan's rows oncb450e343(0 diffs). M5: Dj's J714s rows on7ebd619d1and26e87494a; the full event and BDA/descriptor_bufferlists have not run on M5 sincehk_event.candhk_buffer.cchanged. We have no M5, A18 Pro, M1 or M2.Device rule (
ASAHI_M5_HOST_ALIAS_TRACE=1): the DXVK and vkd3d-proton feature sets takerule=per-resource; a device enabling none takesrule=none.bt (#266's test plus sparselate, hostlate, concrec and evalias; 3 runs × 4 shapes per mode), rows with stale words, this head and merge-base
43beb2fc9(weakbarrieron2eaec513fagainst8e288e5db):HK_PERFTEST=weakbarrier2eaec513f: only ≤ 4 launches after the alias)xsemq (two queues behind a timeline semaphore) was left out after the 11-20 multi-queue firmware crash; it read 0/4 on an earlier head.
Cost (bt cost, µs per level with a compute→compute barrier, extra over a level without; one round on
2644e788a, same barrier code):So the DXVK and vkd3d sets cost what a device without aliasing features costs, until a sparse resource exists (the device-wide rule cost about +1.1 µs on the grid rows).
binding_model.descriptor_buffer,binding_model.buffer_device_addresswith every replay case,ray_tracing_pipeline.capture_replay,api.external.memory.{opaque_fd,dma_buf},memory.external_memory_host,sparse_resources.buffer) via dq-fast -j 3: 6647 P / 459 NS / 0 F on base and on this head, 0 cases differ. At -j 10 on m4.190, aurora-wip and this change alike showVK_ERROR_OUT_OF_DEVICE_MEMORYfromvkQueueSubmitin the BDA replay and descriptor-buffer sparse cases: the kernel's GPU-wide pool of 58 logical queues runs out (G17 capacity refusal LogicalQueues), as these multi-queue tests open one kernel queue per queue family. Not this PR.synchronization*.event*(6213, serial, one deqp-vk per 200 cases): 6210 P / 3 NS on both, 0 status differences.--suite asahi --suite vulkan: 315/315, includingbrl-g17p-event-alias, the capture/replay shim tests andhk_memory_oom's capture/replay case.Not re-measured on this head: the
memory.*list, the GLES31 subsets, the vkd3d-proton d3d12 suite, the recording-contention bench and bt cost.Not covered: a shader that polls host memory without an event (outside the memory model).