Skip to content

borealis: order whole-tile load hazards in the fragment half only - #1144

Merged
DjDeveloperr merged 5 commits into
aurora-wipfrom
perf/borealis-tile-hazard-frag
Nov 27, 2026
Merged

DjDeveloperr merged 5 commits into
aurora-wipfrom
perf/borealis-tile-hazard-frag

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 26, 2026 •

Copy link
Copy Markdown

What: A render pass instance that loads whole tiles an earlier render stored now waits for that render in its fragment half only, where the kernel orders a render's fragment work, partial renders included, after the previous render's (DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS, bit 45, aurora-silicon/linux#3268, merged). Its tiling no longer waits for the earlier render to finish, so consecutive passes on the same targets overlap as Metal's do. Partly covered tiles, sparse multiview layers, compute producers (including clears the empty-render optimizer runs on compute) and resumed instances keep waiting in both halves; without the kernel capability nothing changes.
Tested: J714s (MacBook Pro 14" M5 Pro, G17S) at b6f5316 against aurora-wip 41fe336, isolated Mesa kits, one-shot boots of 7.3.0-m5-nots (linux main 2094ccb, which carries linux#3268; feature word 0x3d3e7cfe7c07, bit 45 set), the default kernel restored after each. Measured on a main-based kernel with bit 45, whose J714s devicetree disables the SLC; the default 7.3.0-m5-cdirect16 (SLC on) does not advertise bit 45. Both arms ran on the same kernel, so the comparison holds; the absolute FPS are lower than on cdirect16 for that reason.

GTA V Enhanced native benchmark (3024x1964, ResScalingType=0, muted, settings restored), one boot, A B B A:

pass base this PR this PR base change (mean)
P4 51.82 54.27 53.98 53.07 +3.2 %
P3 51.97 54.09 54.16 52.58 +3.5 %
P2 46.95 47.90 47.73 45.98 +2.8 %
P0 55.07 56.15 55.71 55.13 +1.5 %
P1 48.74 49.27 48.20 47.46 +1.3 %

FPS; both runs of this PR beat both base runs on P4, P3 and P2. 0 GPU faults. BeamNG.drive (West Coast USA, 3024x1964, 5 x 170 s windows) on the same kernel, A B B A: 34.35 / 35.94 / 35.97 / 35.66 FPS. Both runs of this PR are above both base runs; the first run after the test boot runs low, so against the second base run alone it is +0.8 % (flat or better). Settings restored, 0 GPU faults. Frame anatomy: renders that load an attachment and whose tiling half waits on an earlier command than their fragment half, 65.5 / 66.3 % (base) -> 76.4 / 76.3 %.

VK CTS on the same kernel, render passes, draw, conditional rendering, synchronization{,2} single_queue/implicit/basic/none_set_reset/internally_synchronized_objects, api.command_buffers, multiview renderpass2/dynamic_rendering, 136,374 cases: this PR 104,896 pass, 31,478 not supported, 0 other; base identical. --suite asahi on the M5 332/332; mirror CI asahi green.

Rows at 932b35f ran with the capability unset (b6f5316 fixes reading it before the device was opened) and are not counted.
J700 (MacBook Neo, G17P, HAL200) at b6f5316 against 41fe336, stock 7.3.0-41 without bit 45, so the fallback path (row: #1144 (comment)): VK CTS on the same list, 136,374 cases: 100,194 pass, 36,180 not supported, 0 fail, 0 recoveries; Fedora CI 215/0; gpubench render.pass_split, deferred, postfx, msaa_merge, render.heavy and sync.signal CRCs equal to base; 0 GPU faults.
J773g (Mac mini M4, G16G, HAL200) at b6f5316 against 41fe336, stock kernel, isolated overlays (M4 mini row lane, row comment on this PR): --suite asahi (host) 212/0; VK CTS at 1 worker, list 1 (136,374 cases, the fallback path) 99,946 pass / 36,426 not supported / 2 fail, the same on base: each fail a different synchronization{,2}.op.single_queue.*buffer_262144 case per arm, all passing when rerun alone; gpubench render rows and render.pass_split A B B A with CRCs equal to base and every row flat; 0 GPU faults or recoveries.
Risk: two-way door · Borealis tile-hazard tracking shared by every generation; behaviour changes only where the kernel reports the capability.
Not yet: none.

Details

Hazard source (hk_sync.h, hk_sync.c, hk_cmd_draw.c): struct hk_sync_footprint gains partial, set when the footprint preserves pixels or layers because of its area (a partly covered 32x32 cell) or a sparse view mask. A footprint that preserves only because the instance loads its attachment (preserve_load) covers whole tiles of every layer it names. Two footprints that share a tile share it only through a load when neither is partial (footprints_whole_tiles()): neither pass writes back a tile it does not own whole, and the later one reads what the earlier one stored, which needs the earlier render's fragment work before the later one's, not before its tiling.

In the command buffer: hk_sync_pass_footprints_done() splits the earlier producers into those both halves wait for (pass_tile_wait) and the latest render that only the fragment half waits for (pass_tile_wait_frag, through stream_wait_frag()). A render replaced by compute is promoted back to a both-halves wait (records_replace_stream()).

At submission: conflicts with earlier command buffers of the submission (submitted) and with possibly still running earlier submissions (recent_conflict(), which now also reports the engines whose conflicts are all such loads) raise the render's whole-render barrier or prior and, unless every conflict on that subqueue is a whole-tile load of an earlier render, its tiling barrier or prior. Exact-prior queues keep naming earlier submissions by ordinal.

Capability: hk_device::load_hazard_frag, set from DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS (the definition follows linux#3268's uapi header) and copied into hk_sync_queue::load_hazard_frag at queue creation. The kernel reports it where every fragment pass of a render, partial renders included, starts after the fragment work its fragment half is ordered after (single render pair).

Tests: test-hk-sync-prior test_load_hazard_frag: in the command buffer, across command buffers of a submission and across submissions (exact and legacy priors), with and without the capability; a partly covered tile and a compute clear keep both halves.

A render pass instance that loads an attachment an earlier render stored
shares every tile with it (its footprint preserves the loaded contents),
and the tile hazard made the whole later render wait: its tiling could
not start until the earlier render had finished. GTA V's consecutive
full-screen passes on the same targets ran one after another this way.

When the kernel runs a render's fragment work after the previous
render's, partial renders included, a later instance that only loads
whole tiles an earlier render stored needs the fragment half ordered,
not the tiling: tiling never writes a tile back. Footprints now record
whether they preserve because of their area or layers (a partly covered
tile, a sparse view mask) or only because they load, and a conflict
between two whole-tile footprints whose earlier producer is a render
raises only the fragment half's wait: in the command buffer
(pass_tile_wait_frag, stream_wait_frag()), against earlier command
buffers of the submission and against possibly running earlier
submissions. Partly covered tiles, sparse multiview, compute producers
(including clears the empty-render optimizer replaced) and resumed
instances keep waiting in both halves.

The device flag that enables it, hk_device::load_hazard_frag, is set
from the kernel's capability; without it nothing changes.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Set hk_device::load_hazard_frag from
DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS, which the kernel reports where
every fragment pass of a render, partial renders included, starts after
the fragment work its fragment half is ordered after (single render pair).
Without the bit the tile hazards keep waiting in both halves.

The bit's definition follows the kernel's uapi header.

Signed-off-by: DjDeveloperr <hey@djdev.me>
aurora-wip was rebuilt from 9ca2b09, so its new tip (41fe336)
no longer descends from 58e636c, the tip this branch merged last.
The merge was resolved against 58e636c: this branch's changes over
it, applied onto the new tip. In hk_begin_rendering() the tip renamed the
attachment load-preserve flags (preserve_loaded, now also set for depth
and stencil loads); the footprint call keeps this branch's separate
layer and load arguments with the new flags.

Signed-off-by: DjDeveloperr <hey@djdev.me>
…he device

hk_CreateDevice() set hk_device::load_hazard_frag from the kernel's
feature word before agx_open_device() had read it, so the flag was
always false and whole-tile load hazards kept waiting in both halves
even on kernels that report DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS.
Read it once the device is open, before the queues copy it.

Found on J714s with 7.3.0-m5-nots (feature word 0x3d3e7cfe7c07): GTA V
frame anatomy showed loading renders' tiling waits unchanged from the
base.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Author

J700 (MacBook Neo, A18 Pro G17P B1) at exact head b6f531697ff6, against base 41fe336dffae: PASS, no regression.

Both arms are release Borealis Vulkan overlays, cross-built off the Mac with the same options and loaded from private prefixes through VK_DRIVER_FILES, on the stock kernel 7.3.0-41.fc44.aurora.aarch64 with no reboot. System Mesa wasn't touched. Each arm's driver id shows its git SHA. Head libvulkan_asahi.so SHA-256 77c47505…, base 0a304f30….

On the stock -41 kernel (no bit-45 capability), this row covers the fallback path.

VK CTS on head, deqp-vk --jobs 6: 136,374 cases from renderpasses, draw, conditional_rendering, synchronization{,2}.{op.single_queue,implicit,basic,none_set_reset,internally_synchronized_objects}, api.command_buffers and multiview.{renderpass2,dynamic_rendering}. Results: 100,194 Pass, 36,180 NotSupported, 0 Fail, 0 recoveries.

gpubench-vk smoke (A1 B1 B2 A2, same boot): CRCs match base on every row (render.pass_split d1/d4 18acb8e1, render.deferred tile/dram msaa4, render.postfx msaa1/msaa4, render.msaa_merge 4x rgba16f/rgba8). render.pass_split timing is identical (4347.8 / 3846.2 µs per submit at d1 / d4 on both arms). sync.signal latency is flat at 145.5–147.8 µs. Thermals rose through the sequence, and every head run on all 17 rows falls between the two base runs. This was a smoke check, not a perf measurement.

Fedora 44 Mesa Asahi CI (fedora-mesaci.sh): 215/0, and --suite poly passes 5/5. A first run on a loaded fedora box hit 30 s timeouts in agx_tests, hk_pack and hk_compute_pair (other PRs' runs showed the same three). The rerun passes 215/0, and those three also pass with a 10x timeout.

Health: 0 GPU faults, 0 recoveries, 0 driver warnings, 0 AVC denials, failed 0, SELinux Enforcing. stock.sh is the same before and after.

@DjDeveloperr

Copy link
Copy Markdown
Author

J773g (M4 Mac mini, G16G B0, HAL200, second generation) at b6f531697ff6, against aurora-wip 41fe336dffae: PASS, no regression. No case fails on the head only. On this Mac the head runs the fallback path, because no kernel here reports bit 45.

Both arms are release Borealis Vulkan overlays loaded from private prefixes through VK_DRIVER_FILES, on the stock kernel 7.3.0-ARCH-m4mainefed1ae3. System Mesa wasn't touched. Each arm's vulkaninfo shows its git SHA.

  • meson test --suite asahi (host build) at base and head: 212 Ok, 0 Fail on both.
  • VK CTS at 1 worker (render-heavy lists stay at 1 worker on this Mac's stock kernel), resumable in ≤8 min pieces:
    • List 1 is 136,374 cases: renderpasses.* (81,687), draw.* (29,475), conditional_rendering.*, synchronization{,2}.{op.single_queue,implicit,basic,none_set_reset,internally_synchronized_objects}.*, api.command_buffers.* and multiview.{renderpass2,dynamic_rendering}.*.
    • Base and head each give 99,946 Pass, 36,426 NotSupported and 2 Fail.
    • The fails are different synchronization{,2}.op.single_queue.*buffer_262144* cases on each arm (tess/vertex/compute SSBO, event and timeline variants).
    • Every case whose status differs passes 5 times out of 5 alone on both arms.

gpubench-vk ABBA, render rows plus render.pass_split (us_per_submit, head/base; lower is better; CRCs equal on all four runs of every row):

row A1 / B1 / B2 / A2 head/base
render.deferred, d1 487.01 / 473.93 / 474.68 / 489.40 0.972
render.deferred, d2 236.03 / 236.03 / 236.59 / 235.66 1.002
render.deferred mode=tile msaa=4 res=1080p, d2 348.03 / 348.84 / 346.82 / 348.03 0.999
render.light, d16 59.80 / 58.94 / 58.82 / 59.04 0.991
render.mdi, d4 161.90 / 159.74 / 160.09 / 159.32 0.996
render.msaa_merge fmt=rgba16f samples=4, d4 588.24 / 590.55 / 597.61 / 591.72 1.007
render.pass_split gap=decay, d1 2189.78 / 2189.78 / 2189.78 / 2189.78 1.000
render.pass_split gap=uav, d1 2173.91 / 2173.91 / 2189.78 / 2189.78 1.000
render.pass_split mode=multi_cb splits=1, d1 2112.68 / 2112.68 / 2127.66 / 2112.68 1.004
render.pass_split mode=multi_cb splits=22, d1 2307.69 / 2290.08 / 2307.69 / 2290.08 1.000
render.pass_split mode=multi_cb splits=8, d1 2173.91 / 2173.91 / 2173.91 / 2173.91 1.000
render.pass_split mode=one_cb splits=8, d1 2112.68 / 2112.68 / 2112.68 / 2112.68 1.000
render.postfx, d1 867.05 / 857.14 / 862.07 / 879.77 0.984
render.postfx, d2 765.31 / 765.31 / 765.31 / 765.31 1.000

GPU health: 0 faults, 0 recoveries and failed 0 errno 0 degraded 0 across every CTS piece and the ABBA.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 27, 2026 09:36
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 09:36
@DjDeveloperr

Copy link
Copy Markdown
Author

Verdict at b6f531697ff6: ready

Blockers

None.

Checked

  • Fragment-only tile waits.
    • Footprints now record partial (a partly covered tile or a sparse view mask) separately from preserving because of a load.
    • A conflict waits in the fragment half only when both footprints cover whole tiles and the earlier producer is a render. That is the case DRM_ASAHI_FEATURE_ORDERED_PARTIAL_RENDERS covers, since its fragment passes, partial renders included, run after that work.
    • Partial tiles, sparse multiview, compute producers (including clears turned into compute) and resumed instances still wait in both halves. A render replaced by compute moves pass_tile_wait_frag into the both-halves wait.
    • A both-halves wait on a later render covers the fragment-only one.
    • Across command buffers and earlier submissions, the vertex half waits only on whole-render conflicts. recent_conflict() reports frag-only engines separately, and exact-prior queues set prior_ta only when a whole-tile wait is needed.
  • The capability. load_hazard_frag comes from bit 45, read after agx_open_device() (b6f53169 fixes the earlier read) and copied by hk_queue_create() and hk_queue_restart_sync(). Nothing else in the merged UAPI header uses bit 45, and it doesn't clash with borealis: use 48 KiB tile buffers where the kernel admits them #1194's bit 46. Without the bit nothing changes, which is the path the J700 and J773g rows ran (stock kernels). Only the J714s row exercises the new waits.
  • Merge and build.
  • Mutations.
    • Treating partial footprints as whole fails "a partly covered tile keeps both halves".
    • Letting a compute producer wait fragment-only fails "a compute producer keeps both halves".
    • Dropping the render-subqueue check in the cross-submission load_hazard_frag() is not caught: no test covers an earlier submission's compute producer.
  • Policy. agent-policy.sh pr HEAD: PR is clean. The three code commits are signed off; the two merge commits from aurora-wip carry no sign-off, which the policy accepts. No attribution lines, no new environment options.

Merge-order note. hk_sync_pass_footprint() gains a preserve_load argument. #1195 adds a call for the merged resolve target with the old argument list, so whichever lands second needs , false there. The compiler will flag it, so it can't slip through silently.

@DjDeveloperr
DjDeveloperr merged commit 4b87e99 into aurora-wip Nov 27, 2026
DjDeveloperr added a commit that referenced this pull request Nov 27, 2026
…d-draw-hotpath

Resolve hk_sync_pass_footprints_done() conflict against #1144 by keeping
#1144's frag_ok setup and clearing st->pass_tile_wait_frag = NULL in the
empty sync_pass_records early return.

Signed-off-by: DjDeveloperr <hey@djdev.me>
DjDeveloperr added a commit that referenced this pull request Nov 27, 2026
…_load

Pass preserve_layers (matching hk_begin_rendering()) and preserve_load=false
to hk_sync_pass_footprint() in hk_m5_pass_merge_begin() after #1144 added
the preserve_load parameter.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@RyanTheTide
RyanTheTide deleted the perf/borealis-tile-hazard-frag branch November 27, 2026 13:21
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.

1 participant