Skip to content

borealis: trim compute root descriptor uploads to shader demand - #593

Merged
RyanTheTide merged 12 commits into
aurora-wipfrom
j716c/hk-m5-compute-root-trim
Nov 29, 2026
Merged

RyanTheTide merged 12 commits into
aurora-wipfrom
j716c/hk-m5-compute-root-trim

Conversation

@erikwb

@erikwb erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown

What: Measure, serialize, and trim compute root descriptor table uploads to each shader's measured demand on every GPU generation (including alternate compute variants via hk_cmd_buffer_upload_compute_root() and submit-time compute-pair fusion bounds), while keeping HAL200/M5 graphics root trimming intact and removing the generation gate between hk_shader_serialize() and hk_deserialize_shader().
Tested:

  • Host (x86_64) at e9a554a5b787 (merged with origin/aurora-wip ef132f590b25):
    • Targeted root/fusion/binary suite (hk_compute_pair_cache, hk_root_size, hk_cpu_upload, hk_execution_allowance, hk_fused_cprog, hk_compute_pair, hk_pack, hk-g13g-shader-binary-root with --expect-root-size, hk-g17p-shader-binary-root, hk-g17s-shader-binary-root): 10/10 passed (0 failed).
    • Prior-commit (dfdeeef3fd9, before the src/asahi/meson.build --expect-root-size flag commit e9a554a5b787) full meson test -C _build --suite asahi --suite poly: 340/341 passed (agx_tests 1,719 tests across 153 suites passed; the sole failure is hk_sync_stamps at test-hk-sync-stamps.c:1232, an unrelated origin/aurora-wip regression in hk_sync.c, untouched by this PR).
  • Exact-head hardware at e9a554a5b787 vs ef132f590b25 (Linux 7.3.0, Borealis release builds; dEQP-VK.compute.* + binding_model.* + descriptor_indexing.* = 207,868 cases, 3 passes x 2 arms on one shared on-disk shader cache per Mac):
    • J716c (M5 Max / G17C B1): per pass 131,145 Pass / 76,722 NotSupported / 1 Fail (the one descriptorset_random case fails on both arms in every pass), 0 diffs between arms and across the 3 passes (1,247,208 case executions); shared cache 892 -> 984 MiB, +0 files on pass 3; 0 GPU faults.
    • J713 (M4 Air / G16G B0): compute.* and descriptor_indexing.* 0 failures on both arms; at 2 workers 1,899 graphics cases (binding_model.shader_access.{primary,secondary}_cmd_buf, mutable_descriptor.*) failed intermittently on both arms at the same rate (base-vs-PR status diffs 569 / 822 / 610 per pass, against 573-763 base-vs-base and 596-685 PR-vs-PR across passes), and a single-worker rerun of all 1,899 passed on both arms in every pass (1,899/1,899, 0 diffs); 0 GPU faults. The CTS build here is not J313's (see Evidence).
    • J313 (M1 Air / G13G B1): full unstrided binding_model.*; per run 101,620 Pass / 106,236 NotSupported / 6 DeviceLost / 6 Crash identical on all 6 runs (the 12 are pre-existing descriptor_buffer.traditional_buffer.robust.null_descriptor.graphics_geom_* cases), 0 diffs, shared cache 0 -> 179 -> 318 MB and flat after pass 2; 0 GPU faults/timeouts/resets.
  • Earlier-head hardware runs (superseded by the exact-head rows above) (predate origin/aurora-wip merge 5fc79c28c89, dfdeeef3fd9, and e9a554a5b787):
    • J713 (M4 Air / G16G B0) at cd36f059a005 vs 262403b7bce1: dEQP-VK.compute.* + binding_model.* + descriptor_indexing.* (207,868 cases: 123,537 Pass / 84,331 NotSupported / 0 Fail) across 6 passes on one shared cache, 0 diffs, 0 GPU faults.
    • J716c (M5 Max / G17C B1) at cd36f059a005 vs 262403b7bce1: dEQP-VK.compute.* + binding_model.* + descriptor_indexing.* (207,868 cases: 127,222 Pass / 80,646 NotSupported / 0 Fail) across 3 passes on one shared cache, 0 diffs, 0 GPU errors; earlier fa5666793c06 run also checked 4,096 push-constant dispatches (1192 -> 832 root bytes/dispatch) and Cyberpunk T2 (28.11 -> 28.30 FPS).
    • J313 (M1 Air / G13G B1) at cd36f059a005 vs 262403b7bce1: compute.* + descriptor_indexing.* full (60,948 cases: 13,190 Pass / 47,758 NotSupported) and binding_model.* stride 5 (29,384 of 146,920 cases: 13,716 Pass / 11,689 NotSupported / 2,318 DeviceLost / 1,661 Fail identical on both arms), 3 passes on one shared cache, 0 diffs, 0 GPU faults.
    • A18 Pro (G17P B1) at 0c78e2ef7780 vs 8e288e5dbc3b: 67,553 dEQP-VK.compute.* cases (12,607 Pass / 54,946 NotSupported / 0 Fail) across 3 passes, 0 diffs, 0 GPU faults.

Risk: two-way door · all Macs running Borealis (M1–M6/G18G and Neo — enables compute root upload trimming across all generations and bumps shader binary versions on AGX2 38 -> 39 and classic 40 -> 41, while AGX3 stays at 53)

Not yet:

  • Runtime GPU workloads exercising depthwise_vec4, HK_COMPUTE_PAIR_FADD, and needs_root compute-pair fusion on hardware (currently covered by host unit tests only), and the push-constant root-bytes microbenchmark and Cyberpunk 2077 T2 A/B (last measured at fa5666793c06, not repeated at e9a554a5b787).
  • Exact-head hardware runs on external machines not present in this lab: J413 (M2 Air, G14G / AGX2 v39), M1 Pro (G13S / AGX2 v39), A18 Pro (G17P / AGX3 v53), and G18G (M6 / classic v41).
Details

Borealis on origin/aurora-wip (da93fbdb) already trims compute and graphics root uploads on HAL200 (G16G/G17P) and M5 (agx_chip_g17_m5()), while leaving AGX2 (G13*/G14*), G15*, and G18G uploading the full struct hk_root_descriptor_table on every compute dispatch and gating root_descriptor_size serialization separately from deserialization.

  • Unconditional compute measurement and serialization (hk_shader.c, hk_shader.h): hk_compile_nir() measures hk_shader_root_descriptor_size() for all MESA_SHADER_COMPUTE shaders across every chip generation (while preserving HAL200/M5 VS/FS graphics trimming), and hk_shader_serialize() / hk_deserialize_shader() unconditionally write and read root_descriptor_size (including alternate compute variants compiled via hk_compile_compute_alt_nir() such as depthwise_vec4), validated by hk_deserialized_root_valid().
  • Root readers stay within the measured prefix:
    • Shader loads: hk_nir_root_size() walks load_root_agx uses before uniform lowering and fails closed to sizeof(struct hk_root_descriptor_table) on unrecognized uses, non-constant offsets, depth > 8, or root_desc_addr reflection reads (offset < 8).
    • Launch-time preloads: hk_shader_root_descriptor_size() floors at offsetof(sets) + set_count * 8 (rounded to 16 B), covering both AGX2 USC root uniforms (hk_agx2_upload_usc_words()) and AGX3 Ioto root ranges.
    • Dispatched variant root upload (hk_cmd_upload.c, hk_cmd_buffer.c, hk_cmd_dispatch.c): hk_cmd_buffer_upload_compute_root(cmd, s) uses the actually dispatched shader variant s->root_descriptor_size across all compute dispatch paths (hk_dispatch_m5_native(), hk_dispatch_g17p_native(), hk_dispatch_g17g_native(), and hk_agx2_upload_usc_words()), preserving cmd->state.gfx.root for internal graphics dispatches on CDM (internal). Reuse requires desc->uploaded_root_size == root_size.
    • Compute-pair fusion root guard (hk_compute_pair.h, hk_cmd_dispatch.c, hk_queue.c): hk_record_compute_pair() and hk_record_copy4_pair() (HK_COMPUTE_PAIR_FADD) record desc->uploaded_root_size into record.root_size, and hk_fused_compute_shader_eligible_ranges() rejects fusion if the fused shader's required root prefix exceeds p->root_size. When hk_pack_runs() allocates a fresh full struct hk_root_descriptor_table for needs_root fusions (dual != HK_COMPUTE_PAIR_DUAL_NONE || has_im2col || has_dw_a), both the eligibility check (eff_p.root_size) and tmp_disp.root_size use sizeof(struct hk_root_descriptor_table).
    • Internal/graphics stages on CDM: Graphics stages dispatched on CDM (cmd->state.gfx.root) and the indirect grid helper keep their existing full/graphics root behavior.
  • Shader binary version bumps and test coverage (hk_agx3_vdm_decode.h, src/asahi/meson.build, test-hk-execution-allowance.c, test-hk-compute-pair-cache.c): Keeps origin/aurora-wip's AGX3 v53 (which already carries root_descriptor_size on G17P and M5) and bumps classic 40 -> 41 and AGX2 38 -> 39 for unconditional compute root prefix serialization across all chips. Enables --expect-root-size on hk-g13g-shader-binary-root alongside g17s and g17p in src/asahi/meson.build (the flag requires the root-size field to be present in the binary; it does not by itself require a trimmed value), and initializes p.root_size = sizeof(struct hk_root_descriptor_table) in check_fused_m5_dispatch() (test-hk-compute-pair-cache.c) and init_base_fixture() (test-hk-fused-cprog.c).
Evidence

Host verification at e9a554a5b787 (merged with origin/aurora-wip ef132f590b25)

  • Configure: meson setup _build -Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dtools=drm-shim -Dbuild-tests=true -Doptimization=2 -Ddebug=false -Db_ndebug=false
  • Targeted suite at e9a554a5b787 (meson test -C _build -v hk_compute_pair_cache hk_root_size hk_cpu_upload hk_execution_allowance hk_fused_cprog hk_compute_pair hk_pack hk-g13g-shader-binary-root hk-g17p-shader-binary-root hk-g17s-shader-binary-root): 10/10 passed, 0 failed (hk-g13g-shader-binary-root ran with --expect-root-size, which requires the serialized root-size field to be present but accepts any prefix from 16 B to the full table; it printed trimmed compute root prefixes of 176/2216 B and 832/2216 B on G13G, which is the evidence that the compiler trims).
  • Prior-commit (dfdeeef3fd9) full build & suite (ninja -C _build src/egl/libEGL_mesa.so.0.0.0 src/gallium/targets/dri/libgallium-26.3.0-devel.so src/asahi/vulkan/libvulkan_asahi.so and meson test -C _build --suite asahi --suite poly): 340/341 passed, 1 failed (agx_tests 1,719 tests across 153 suites passed; hk_sync_stamps failed at test-hk-sync-stamps.c:1232 due to unrelated origin/aurora-wip hk_sync.c changes in 7617c835cd8 / ef132f590b25).

Exact-head hardware at e9a554a5b787 vs ef132f590b25 (Linux 7.3.0)

Each Mac: dEQP-VK.compute.* 60,838 + dEQP-VK.binding_model.* 146,920 (full, unstrided) + dEQP-VK.descriptor_indexing.* 110 = 207,868 cases per run, 3 passes x 2 arms, one shared on-disk MESA_SHADER_CACHE_DIR per Mac.

J716c (M5 Max / G17C B1)

  • Native Borealis release builds: libvulkan_asahi.so sha256 50e9d0a2361d... base, 1c033af7d47c226485759a4fd8a79cf9dd8d812cb9108e760aa794511a233afc head. Shared cache capped at 4G, 4 shards.
Suite (per pass, both arms) Cases Pass NotSupported Fail
compute.* 60,838 15,525 45,313 0
binding_model.* 146,920 115,510 31,409 1 (descriptorset_random.sets8.runtimesize.noubo.nosbo.nosampledimg.storageimghigh.iublimitlow.uab.mesh.noia.0, identical on both arms in every pass)
descriptor_indexing.* 110 110 0 0
Total 207,868 131,145 76,722 1
  • 0 per-case diffs between 593 and base in each of the 3 passes, and 0 across passes for both arms (1,247,208 case executions); 0 GPU dmesg lines.
  • Shared cache: 166,059 files (892 MiB) after pass 1, 174,488 files (984 MiB) after pass 2, +0 new entries on pass 3 (warm reuse, no cross-arm corruption).

J713 (M4 Air / G16G B0)

  • Native Borealis release builds on the Mac, selected per arm through VK_DRIVER_FILES: libvulkan_asahi.so sha256 prefixes 1335dbdeee54 base, 1f39641ad11f head. The Vulkan CTS is a different build from J313's (copied from the J716c's CTS build, 7ba03cd; the 207,868 case count matches), driven by a chunked runner (2,000 cases per deqp-vk process, crash/timeout resume, results parsed from the .qpa logs). 3 interleaved passes, 2 workers, cache and results on disk.
Pass Arm Pass Fail NotSupported Wall time
1 base 123,320 277 84,271 303 s
1 593 123,287 310 84,271 303 s
2 base 123,146 451 84,271 255 s
2 593 123,204 393 84,271 255 s
3 base 123,271 326 84,271 252 s
3 593 123,283 314 84,271 252 s
  • Every failure is a graphics case: binding_model.shader_access.{primary,secondary}_cmd_buf (1,892) and binding_model.mutable_descriptor.* (7), 1,899 distinct cases; compute.* and descriptor_indexing.* had 0 failures. Base-vs-593 status diffs were 569 / 822 / 610 per pass, base-vs-base across passes 573-763 and 593-vs-593 596-685, so the arms are indistinguishable under concurrency.
  • Single-worker rerun of the 1,899-case failure union (1 worker, 3 passes per arm): every case passed on both arms in every pass (1,899/1,899 each time), 0 diffs.
  • System health: 0 GPU fault, timeout or recovery lines; 0 low-memory aborts in the final run (minimum MemAvailable about 5.8 GB).

J313 (M1 Air / G13G B1)

  • Borealis release ICDs cross-built per commit (-Doptimization=2 -Ddebug=false -Db_ndebug=false), Vulkan CTS vulkan-cts-1.4.6.2-4-gcbe875d1aa08, Apple M1 (G13G B1). Run order base,PR / PR,base / base,PR across the 3 passes on one shared on-disk cache (0 -> 179 -> 318 MB, flat after pass 2).
  • Full binding_model.* (146,920 cases, not strided): 101,620 Pass / 106,236 NotSupported / 6 DeviceLost / 6 Crash identical on all 6 runs; the 12 DeviceLost / Crash cases are the pre-existing descriptor_buffer.traditional_buffer.robust.null_descriptor.graphics_geom_* cases. 0 diffs across all 6 runs; 0 GPU faults, timeouts or resets.

Earlier-head hardware verification (superseded by the exact-head rows above; predates 5fc79c28c89 / dfdeeef3fd9 / e9a554a5b787)

  • J713 (M4 Air, Apple M4 (G16G B0), Linux 7.3.0, CTS vulkan-cts-1.4.6.2-4-gcbe875d1aa087) at cd36f059a005 vs 262403b7bce1:
    • 6 passes on one shared MESA_SHADER_CACHE_DIR (4 GiB cap, 6 shards), 207,868 vk-default mustpass cases (dEQP-VK.compute.* 60,838, dEQP-VK.binding_model.* 146,920, dEQP-VK.descriptor_indexing.* 110: 123,537 Pass / 84,331 NotSupported / 0 other, 0 diffs across all 6 passes); base (+63,528) and PR (+63,527) cache keys isolated; 0 GPU faults, 0 failed units.
  • J716c (M5 Max, Apple M5 Max (G17C B1), Linux 7.3.0, CTS 7ba03cd) at cd36f059a005 vs 262403b7bce1:
    • 3 passes on one shared MESA_SHADER_CACHE_DIR (4 GiB cap, 6 shards), 207,868 vk-default mustpass cases (127,222 Pass / 80,646 NotSupported / 0 other, 0 diffs); base (+63,177) and PR (+63,176) cache keys isolated; 0 GPU-error lines.
  • J313 (M1 Air, Apple M1 (G13G B1), Linux 7.3.0, CTS vulkan-cts-1.4.6.2-4-gcbe875d1aa087) at cd36f059a005 vs 262403b7bce1:
    • 3 passes on one shared MESA_SHADER_CACHE_DIR (4 GB cap, 6 shards): compute.* + descriptor_indexing.* full (60,948 cases: 13,190 Pass / 47,758 NotSupported) and binding_model.* stride 5 (29,384 of 146,920 cases: 13,716 Pass / 11,689 NotSupported / 2,318 DeviceLost / 1,661 Fail identical on both arms); 0 diffs; base (+23,220) and PR (+23,219, then +0) cache keys isolated; 0 GPU faults.
  • A18 Pro (G17P B1, MacBook Neo, Linux 7.3.0-41.fc44.aurora.aarch64) at 0c78e2ef7780 vs 8e288e5dbc3b:
    • 3-pass single MESA_SHADER_CACHE_DIR on full dEQP-VK.compute.* (67,553 cases: 12,607 Pass / 54,946 NotSupported / 0 Fail / 0 diffs, cache 0 -> 4,343 -> 8,685 -> 8,685), dEQP-VK.compute.pipeline.basic.* (79 Pass / 2 NotSupported / 0 Fail / 0 diffs), and gpubench-vk compute.light (depth 1–64 within 0.26%); kfault_delta=0, avc_delta=0.
  • J716c (M5 Max, G17C) at fa5666793c06:
    • 4,096 dispatches with new push constants each: root bytes per dispatch dropped 1192 -> 832, recording time 0.09–0.12 µs and GPU time unchanged; Cyberpunk 2077 (tier T2, 3 alternating passes): base mean 28.11 FPS vs head mean 28.30 FPS.

@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.

No hard blockers, but the trim needs a correctness run on M5, and the predicate should be a single helper.

  1. Correctness on M5 (hk_cmd_upload.c:30, hk_shader.c:5362). Uploading only the measured prefix is safe only if nothing reads past root_descriptor_size. That includes the M5-specific lowering (the M5 preamble and uniform paths in the compiler differ from G17P's), internal and meta compute shaders, and indirect dispatch fields that the driver writes into the root table. A missed reader does not fault. It reads stale root data from the previous upload, so a fault-free Cyberpunk run does not exercise it. Please run dEQP-VK.compute.*, dEQP-VK.binding_model.* and dEQP-VK.descriptor_indexing.* on M5, base against this commit. Pass: no new failures.

  2. One predicate for both cache directions. G17P || agx_chip_g17_m5() is now written in five places, including hk_shader_serialize() (hk_shader.c:9137) and hk_deserialize_shader() (:8518). If a later change updates one side and not the other, every cached shader on that chip is misparsed. Please put it in one helper (for example hk_trims_compute_root(dev)) and use it in all five places. Ideally key it on the compiler capability the measurement depends on rather than a chip list.

  3. Cache format. On M5 the serialized shader gains a uint32. Please confirm that pipelineCacheUUID and the disk-cache key change with this build, so that blobs written by an older driver are rejected rather than read with the new layout.

  4. Evidence: "up to 48.68 FPS" has no baseline and no measure of the upload saved. Please give an A/B on the same build, FPS or hk-cpu-upload-bench bytes per dispatch on M5.

  5. Disclosure: please move "Developed with Neon." from the commit message to an Assisted-by: LLM (<Vendor>:<Model>) line at the end of the pull request description. The commit should carry only your identity.

HW row: M5 only (your J716c); our lab Macs do not take the new path. On Neo (G17P), dEQP-VK.compute.* with a warm shader cache from the base build. Pass: no new failures, and cached shaders still load.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

Thanks for this. One more point on top of the earlier review, about how the trim is selected.

The trim is gated on dev->dev.chip == AGX_CHIP_G17P || agx_chip_g17_m5(dev->dev.chip) at src/asahi/vulkan/hk_cmd_upload.c:30 and src/asahi/vulkan/hk_shader.c:5362,5364,8518,9137. We select behaviour by a hardware or compiler property, not by the list of GPUs a change was measured on. Recording a compute shader's root descriptor footprint and uploading only that prefix is driver bookkeeping; nothing in the PR says why G13 to G16 or G18 would read past it, and of the M5 parts only G17C (J716c) was measured.

Could the five sites use one helper that is true wherever the compiler reports the footprint (i.e. every generation), so the serialize and deserialize sides can't drift? If a generation does read root data past the measured size, a code comment citing that reader keeps it excluded.

If you make it the default, we can run dEQP-VK.compute.*, binding_model.* and descriptor_indexing.* with a warm shader cache on our M1 Pro, M2, M4 Pro and A18 Pro.

@erikwb erikwb changed the title borealis: trim compute root descriptor uploads to shader demand on M5 borealis: trim compute root descriptor uploads to shader demand Nov 21, 2026
@erikwb
erikwb force-pushed the j716c/hk-m5-compute-root-trim branch from 9840c1f to fa56667 Compare November 21, 2026 16:26
@erikwb

erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown
Author

Thanks. Following your second comment, the trim is now the default on every generation. Point by point:

2 + the follow-up: one predicate, every generation. I looked for a reader that uses root bytes past the measured prefix on any generation and found none. What I checked:

  • Measurement point. It runs after every pass that adds root loads: descriptor and sysval lowering, ray-query group_count_addr, physical-sparse, the megakernel's trace_rays_addr, and hk_lower_uvs_index. Anything the walk does not recognise falls back to the full table. After it, only lower_uniforms and passes with no root loads run, and the backend vectorizer only combines adjacent loads; it never reads past the last of them.
  • Launch-time preloads. These are the AGX2 USC root uniform (hk_cmd_buffer.c, 4 * (1 + set_count) halves) and the AGX3 Ioto root range (hk_agx3_g17p_root_range, same size). Both cover only root_desc_addr plus the set bases, which the measured size always includes.
  • Uniform DMA spans over the root. This covers the native path and the M5 compute one. The spans are built from constant-offset loads that descend from measured root loads. Vectorization can combine adjacent loads, and a DMA window can cover gaps between loads and round its end to a dword, but it never extends past the last covered load, rounded within the 16-byte footprint alignment.
  • Internal and meta compute.
    • The G17P indirect grid helper allocates and fills a full root of its own.
    • libagx precompiled kernels don't use the root.
    • vk_meta, acceleration-structure and ray-tracing dispatches bind their shader first, so the measured shader is the one that runs.
    • Every compute dispatch path re-uploads the root for the shader it dispatches.
  • Driver writes. Indirect and conditional dispatch patch a separate group-count copy, not the root table.
  • Graphics stages on CDM. These are vertex, geometry, tess and task. They take their root from the graphics bind point and keep the whole table.

So the five checks are gone. All generations measure, serialize and trim, and the serialize and deserialize sides can't drift. hk_cpu_upload now checks that every chip trims to the measured prefix and that an unmeasured shader uploads the whole table.

3. Cache format.

  • UUIDs and disk cache. pipelineCacheUUID, shaderBinaryUUID and the disk-cache identity are BLAKE3 of the ELF build-id, the device generation, compiler flags, the codegen environment and the kernel features (hk_physical_device_init_pipeline_cache()). The disk-cache directory is named by the build-id, so blobs from another build are never looked up. On the J716c, base and head report different pipelineCacheUUIDs.
  • Binary versions. The payload now changes on every chip except G17P, so I bumped them too, following the rule in hk_agx3_vdm_decode.h: AGX3 43 → 44, classic 34 → 35, AGX2 36 → 37.

1. Correctness on M5 (J716c, G17C).

  • Sets: dEQP-VK.compute.* (60,838 cases), dEQP-VK.binding_model.* (146,920) and dEQP-VK.descriptor_indexing.* (110), base (aurora-wip at the merge base) against this commit: identical on all three passes, no GPU fault or recovery lines in dmesg: compute 15,525 Pass / 45,313 NotSupported, binding_model 109,717 Pass / 37,203 NotSupported, descriptor_indexing 110/110 Pass. The cache shows the builds kept separate entries and the head reused its own: on compute the first head pass wrote 11,470 new cache entries next to base's 11,469 and the second wrote none; on binding_model 48,315 and 29.
  • Cache passes: each set ran three times on one shader cache directory.
    1. Base filled the cache.
    2. The change ran on the base-filled cache. Its build identity differs, so it did not use base's entries and recompiled (cache isolation and rebuild).
    3. The change ran again on the cache it had filled itself, so it had to load entries in the new layout (reuse).

4. What it buys, same build with and without the commit.

  • Root bytes: 4096 dispatches, each with new push constants, measured with the driver's perf upload counters. Root bytes per dispatch fell from 1192 to 832. That shader reads push constants, which sit after the graphics arm of the table, so most of the table is still needed.
  • CPU and GPU time per dispatch: no measurable difference (0.09–0.12 µs recording on both).
  • Cyberpunk T2: 3 alternating passes each: base 27.85 / 28.04 / 28.45 FPS (mean 28.11), with this commit 28.17 / 28.53 / 28.21 (mean 28.30). The +0.2 FPS is inside the pass-to-pass spread of about 0.6 FPS, so no measurable change.
  • The old "up to 48.68 FPS" had no baseline and came from a combined stack, so I've replaced it with these numbers.

None of the other generations were run here. Your offered runs on the M1 Pro, M2, M4 Pro and A18 Pro would cover them, and the Neo with a warm cache from the base build is the G17P check you listed. Its first head pass on that cache tests isolation and recompilation (the build identity changes); a second head pass in the same directory tests loading the head's entries.

@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.

Thanks for the re-push. I compared 9840c1ff47 with fa5666793c and read your replies. All five earlier points are resolved, and I found nothing new that blocks.

  • 1 (stale root reads): resolved for M5. The compute.*, binding_model.* and descriptor_indexing.* results match base on the J716c, both on a base-filled cache and on the head's own cache.
  • 2 (one predicate): resolved by removing the gate. The serialize and deserialize sides (hk_shader.c:8521, :9139) now always agree, and hk_cpu_upload_bench.c checks the trim and the unmeasured fallback on every chip.
  • 3 (cache format): resolved. The UUIDs come from the build-id, the J716c reports a different pipelineCacheUUID, and all three binary versions are bumped. G17P's payload didn't change, so its bump to 44 only costs one recompile. That is fine.
  • 4 (baseline): resolved. Root upload drops from 1192 to 832 bytes per dispatch, with no measurable CPU, GPU or FPS change, and the description says so plainly.
  • 5 (disclosure): resolved.

What's left is the generations this push newly puts on the path. G17P already had the trim, so A18 Pro and M4 Pro only see the version bump. G13 and G14 (the AGX2 preload) are new, as are G15/G16. We will run the M1 Pro and M2 rows below and post the results here. Please don't merge before those are in.

HW rows:

  • M1 Pro (G13S) and M2 (G14G): dEQP-VK.compute.*, dEQP-VK.binding_model.* and dEQP-VK.descriptor_indexing.*, base against head. Run each head pass twice on one cache directory that base filled. Pass: no new failures, no GPU fault lines in dmesg, and the second head pass writes almost no new cache entries.
  • Neo (A18 Pro, G17P): dEQP-VK.compute.* on a cache warmed by base. Pass: no new failures; old entries are not reused.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the j716c/hk-m5-compute-root-trim branch from fa56667 to 0c78e2e Compare November 22, 2026 00:32
@erikwb

erikwb commented Nov 22, 2026 •

Copy link
Copy Markdown
Author

Rebased onto aurora-wip (8e288e5dbc3, commit 0c78e2ef778) to resolve the conflict with #446 bumping HK_AGX3_SHADER_BINARY_VERSION to 44.

  • Bumped HK_AGX3_SHADER_BINARY_VERSION to 45 (keeping the v44 note and adding v45 for the M5 compute root prefix), with classic at 35 and AGX2 at 37, and updated test-hk-execution-allowance.c accordingly.
  • Verified host meson test --suite asahi (154/154 pass, including hk_root_size, hk_cpu_upload, hk_execution_allowance, and asahi-agx-chip) and the aarch64 Borealis cross-build.
  • Confirmed no new unmeasured compute root readers landed on aurora-wip since the prior merge base.

Ready for the lab runs on M1 Pro (G13S), M2 (G14G), and Neo (G17P); holding merge until those results are in.

@RyanTheTide

Copy link
Copy Markdown

Re-review of 0c78e2e. The only change since fa56667 is the rebase over #446: the AGX3 binary version moves to 45 (hk_agx3_vdm_decode.h:31-36) and the test expects 45/37/35. The trim, the measurement and the serialize/deserialize sides are unchanged, and the five earlier points remain resolved. The new root writes on the base (group_count_addr via hk_cmd_upload_group_count()) are read through measured root loads, so they stay covered.

Rows at this head: we will run M1 Pro and M2 (dEQP-VK.compute.*, binding_model.*, descriptor_indexing.*, two head passes on a base-filled cache) and Neo (dEQP-VK.compute.* on a base-warmed cache). We will also add an M4 Air (G16G) row, because G16 uses the classic payload version (35), which none of the other rows cover. Please hold the merge until those are posted.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr 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.

Review of 0c78e2ef: 0 code, attribution, or policy blockers remain.

Verification

  • Unconditional across generations (hk_cmd_upload.c:31-36, hk_shader.c:5384-5392, :8553, :9170): removing all five G17P-only gates ensures hk_shader_serialize() and hk_deserialize_shader() cannot drift.
  • Footprint safety (hk_nir_root_size.c, hk_shader.c:5386, hk_cmd_upload.c:56-74): hk_nir_root_size() runs after hk_lower_uvs_index and before lower_uniforms, conservatively falling back to sizeof(struct hk_root_descriptor_table) on unrecognized uses, non-constant offsets, or self-pointer reads (offset < 8), and always retains offsetof(sets) + set_count * 8 (covering AGX2 USC root uniform and AGX3 Ioto root range preloads). hk_cmd_buffer_upload_root() checks desc->uploaded_root_size == root_size on reuse, falls back to the full table when root_descriptor_size == 0, and all compute dispatch paths bind the dispatched shader in cmd->state.cs.shader while graphics-on-CDM stages use cmd->state.gfx.root.
  • Binary version bumps & tests (hk_agx3_vdm_decode.h:36-39, test-hk-execution-allowance.c, hk_cpu_upload_bench.c): cleanly rebased over #446 with versions bumped to AGX3 45 / AGX2 37 / classic 35; hk_cpu_upload_bench.c tests both trimmed and unmeasured (0) compute root uploads across every chip enum. Host meson test --suite asahi (154/154) and aarch64 Borealis cross-build are green.
  • Attribution & naming: single human-signed commit (no AI trailers in commit), Borealis naming, and Assisted-by: in PR body.

Remaining before APPROVE (§5 HW evidence on 0c78e2ef)

Holding for the multi-generation lab runs at this head (as noted by both author and @RyanTheTide):

  • M1 Pro (G13S / AGX2) and M2 (G14G / AGX2): dEQP-VK.compute.*, binding_model.*, descriptor_indexing.* (base vs head, two head passes on a base-warmed shader cache; 0 new failures, 0 GPU faults, second pass reuses head cache entries).
  • M4 Air (G16G / classic payload v35): covers the classic binary version bump and trim.
  • Neo (A18 Pro / G17P / AGX3 payload v45): dEQP-VK.compute.* on a base-warmed cache (0 new failures, version isolation confirmed).

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr

Copy link
Copy Markdown

A18 Pro (G17P B1, MacBook Neo, Linux 7.3.0-41.fc44.aurora.aarch64, sleep_guard=active, pmu=30 00) rows at exact PR head 0c78e2ef7780 against base 8e288e5dbc3b:

  • Base libvulkan_asahi.so SHA-256: 33ff12cc599e0059c278e16bfc1543001c18d92a03789d4a486fb34e236ba2ab
  • Head libvulkan_asahi.so SHA-256: 35fccef77ee2414ef6b83c1cc58d72c6e7c089f25dbee2441bec9c0de9a620cb

3-pass single MESA_SHADER_CACHE_DIR (44 -> 45 cache-version isolation) on full dEQP-VK.compute.* (67,553 cases):

Pass Build Pass NotSupported Fail Diffs vs pass 1 Cache files (before -> after, delta)
1 (warm base cache) Base 8e288e5dbc3b (v44) 12,607 54,946 0 — 0 -> 4,343 (+4,343)
2 (head on base-filled cache) Head 0c78e2ef7780 (v45) 12,607 54,946 0 0 4,343 -> 8,685 (+4,342, clean miss on v44)
3 (head warm reuse) Head 0c78e2ef7780 (v45) 12,607 54,946 0 0 8,685 -> 8,685 (+0, 100% cache hit)

Also verified on dEQP-VK.compute.pipeline.basic.* (81 cases: 79 Pass, 2 NotSupported, 0 Fail, 0 diffs across all 3 passes, cache files 0 -> 157 -> 313 -> 313).

gpubench-vk compute.light (6 alternating rounds, MESA_SHADER_CACHE_DISABLE=true, median us_per_submit):

Depth Base (8e288e5dbc3b) Head (0c78e2ef7780) Delta
1 102.949 µs 103.136 µs +0.18%
4 20.269 µs 20.216 µs -0.26%
16 13.576 µs 13.572 µs -0.03%
64 13.177 µs 13.180 µs +0.03%

GPU faults: kfault_delta=0, avc_delta=0.

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

Native HAL200 (G16G / G17P) records each compute shader's root
descriptor table footprint in shader->root_descriptor_size, persists it
in the shader cache, and uploads only that prefix of the table at
dispatch. Nothing about compute root trimming is specific to HAL200:
the footprint comes from the shader's own root loads before uniform
lowering, and every other reader of a compute root stays inside it. A
compute launch preloads only the root address and the set bases (the
AGX2 USC root uniform and the AGX3 root range alike), which the
measured size always covers; root-backed uniform DMA spans come from
measured loads; the indirect grid helper uploads a full root of its
own; graphics stages dispatched on CDM keep the whole table.

Measure, serialize and trim compute roots on every generation instead
of gating compute measurement, upload and cache serialization on
agx_chip_native_hal200(), so the cache writer and reader cannot
disagree while keeping HAL200 graphics root trimming intact. The
serialized payload changes on every non-HAL200 chip, so bump the shader
binary versions (AGX3 44 -> 45, classic 34 -> 35, AGX2 36 -> 37);
pipelineCacheUUID and the disk cache key already change with the driver
build.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb force-pushed the j716c/hk-m5-compute-root-trim branch from 0c78e2e to 69fb5f5 Compare November 22, 2026 17:06
@erikwb

erikwb commented Nov 22, 2026 •

Copy link
Copy Markdown
Author

Rebased cleanly onto origin/aurora-wip (1fdf5396758f -> 69fb5f502522) over 6eaea736177 (HAL200 fast draw flush and graphics root trimming), and added @DjDeveloperr's A18 Pro (G17P) verification row to the PR body.

  • Rebase changes: preserved 6eaea736177's HAL200 (G16G/G17P) graphics root trimming (hk_gfx_root_descriptor_size() and hk_shader_root_descriptor_size() for HAL200 VS/FS, plus the graphics assertions in hk_cpu_upload_bench.c) while keeping compute root measurement, serialization, and upload trimming unconditional across every generation. Binary versions remain AGX3 45 / classic 35 / AGX2 37 (no bump occurred on aurora-wip since 8e288e5dbc3b), and no new unmeasured compute root readers landed.
  • Host verification at 69fb5f502522 (-Doptimization=2 -Db_ndebug=false): meson test --suite asahi 158/158 PASS (including hk_root_size, hk_cpu_upload, hk_execution_allowance, and asahi-agx-chip).
  • Thanks @DjDeveloperr for the A18 Pro (G17P B1) 3-pass 44 -> 45 cache-isolation and 67,553-case dEQP-VK.compute.* run (0 diffs, 100% warm hit on pass 3, 0 GPU faults); M1 Pro (G13S), M2 (G14G), and M4 Air (G16G) rows remain under Still to run.

@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.

Independent source review at 69fb5f502522. The compute upload now uses the measured prefix on AGX2 as well. The shader ABI version bump protects the old serialized layout. Please run J413 compute, descriptor indexing and binding tests from a cold cache and again from a cache populated by the candidate, including a dynamic descriptor and push constants at the end of the used prefix.

@DjDeveloperr DjDeveloperr 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.

Formal pre-PR checklist (§1–§6) re-review at 69fb5f5025228f89641cdfb498f899ddd0f45cb0 (base aurora-wip, live tip efabab38502d).

Code, Superseded & Policy Audit (§1–§4, §6) — PASS

  • Not superseded: aurora-wip (efabab38502d) still gates compute root measurement/upload/serialization on agx_chip_native_hal200() and keeps shader binary versions at 44/34/36.
  • Descriptor layout & upload safety (hk_cmd_upload.c, hk_shader.c, hk_agx3_vdm_decode.h):
    • Cleanly preserves #706 (6eaea736177) HAL200 graphics root trimming while enabling compute root trimming unconditionally on every generation and removing the serialization gate so hk_shader_serialize() and hk_deserialize_shader() cannot drift.
    • Verified all compute dispatch paths (hk_cmd_buffer.c:4037, hk_cmd_dispatch.c:1837,2122,2600) call hk_cmd_buffer_upload_root(cmd, VK_PIPELINE_BIND_POINT_COMPUTE), and root reuse checks desc->uploaded_root_size == root_size, preventing stale short-root reuse when a later compute shader needs a larger prefix.
    • hk_nir_root_size() fails closed to full_size on unknown uses, non-constant offsets, depth > 8, or self-pointer reads (offset < 8), and hk_shader_root_descriptor_size() floors at offsetof(sets) + set_count * 8 (covering AGX2 USC root uniform and AGX3 Ioto root range preloads) rounded to 16 B.
    • All three shader binary versions bump cleanly (AGX3 44 -> 45, classic 34 -> 35, AGX2 36 -> 37), with test-hk-execution-allowance.c and hk_cpu_upload_bench.c updated across every enum agx_chip.
  • §1–§4, §6: Removes model/generation gating on compute root trim; production-ready; human author/committer + human Signed-off-by: only on 69fb5f502522 (zero AI trailers); PR body uses Borealis naming and ends with Assisted-by:.

Actionable Blockers (§5 Multi-Generation & Live-Head Hardware Evidence)

Zero code blockers remain, but §5 hardware verification is still incomplete for the newly enabled paths and rebased head:

  1. AGX2 (G13S / M1 Pro, G14G / M2 — binary version 36 -> 37) hardware coverage missing: Zero hardware runs exist on AGX2 (where AGX2 USC root preload, compute root trimming, and the v36→37 cache format bump are newly active). Run dEQP-VK.compute.*, dEQP-VK.binding_model.*, and dEQP-VK.descriptor_indexing.* (base vs head, cold cache + candidate-populated warm cache, covering dynamic descriptors and push constants at the end of the used prefix) with 0 new failures, 0 GPU faults, and clean system health.
  2. Classic payload (G16G / M4 Air — binary version 34 -> 35) hardware coverage missing: Zero hardware runs cover the classic v34→35 serialization bump and compute root trim.
  3. No hardware run on exact live head 69fb5f502522: Existing J716c (fa5666793c06) and G17P (0c78e2ef7780) runs both predate the #706 (6eaea736177) rebase touching the same hk_cmd_upload.c / hk_shader.c blocks; confirm hardware rows against 69fb5f502522 (or a freshly rebased head) before merge.

Assisted-by: LLM (Gemini 4 Neon)

@erikwb

erikwb commented Nov 23, 2026 •

Copy link
Copy Markdown
Author

We do not have a J413 (G14G) in this test setup (framework host + J713 only), so #593 is held before merge and the requested J413 cold-cache and candidate-warmed dEQP-VK.compute.*, dEQP-VK.descriptor_indexing.*, and dEQP-VK.binding_model.* runs are recorded under Still to run for the lab.

Source and host checks at 69fb5f502522 (still CLEAN against current origin/aurora-wip efabab38502dc):

  • Dynamic descriptor + push constants at the end of the used prefix:
    • struct hk_root_descriptor_table (src/asahi/vulkan/hk_cmd_buffer.h:227-236) places push[HK_MAX_PUSH_SIZE] directly before dynamic_buffers[HK_MAX_DYNAMIC_BUFFERS] and set_dynamic_buffer_start[HK_MAX_SETS].
    • hk_compile_nir() (src/asahi/vulkan/hk_shader.c:5388-5397) computes hk_shader_root_descriptor_size() (src/asahi/vulkan/hk_nir_root_size.h:18-29) after hk_lower_uvs_index and constant folding, rounding MAX2(hk_nir_root_size(...), sets_offset + set_count * 8) up to 16 bytes (src/asahi/vulkan/hk_nir_root_size.c:11-71). Push-constant-only compute shaders retain through the aligned end of the highest read in push; constant-indexed dynamic descriptors with known set layouts measure through dynamic_buffers[idx] (covering push ahead of it); unknown set layouts (load_dynamic_buffer_start() reading set_dynamic_buffer_start in src/asahi/vulkan/hk_nir_lower_descriptors.c:187-207) or non-constant array indices fall back to sizeof(struct hk_root_descriptor_table).
    • hk_cmd_buffer_upload_root() (src/asahi/vulkan/hk_cmd_upload.c:53-57, :102-105) copies head_B = MIN2(root_size, offsetof(dynamic_buffers) + desc->dynamic_buffer_end * sizeof(root->dynamic_buffers[0])) (plus tail_B..root_size when root_size > offsetof(set_dynamic_buffer_start)), and hk_upload_usc_words_internal() (src/asahi/vulkan/hk_cmd_buffer.c:3992) preloads 4 * (1 + s->info.set_count) halves (root_desc_addr plus sets[0..set_count-1]) on AGX2.
  • Host tests (69fb5f502522, x86_64 -Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dtools=drm-shim -Dbuild-tests=true -Doptimization=2 -Ddebug=false -Db_ndebug=false): hk_root_size, hk_cpu_upload, hk_execution_allowance (45 / 37 / 35), and asahi-agx-chip (823 checks) all passed (4/4). Under --suite asahi in this configuration, 226/229 passed; the 3 failures were asahi-egl-priority-allow, asahi-egl-priority-deny, and asahi-egl-priority-once, failing eglInitialize() in the run-shim.py environment (no matching baseline --suite asahi run was performed in this configuration).

…pute-root-trim

Bump shader binary versions past aurora-wip (AGX3 49 -> 50, classic 37 -> 38, AGX2 38 -> 39) and update test-hk-execution-allowance to match.

Signed-off-by: Erik Bourget <erik@ebourget.net>
Compute dispatches that select an alternate variant (identity_copy4, im2col_vec4, or byte_stencil) kept reading the primary bound shader's root_descriptor_size via hk_only_variant(cmd->state.cs.shader). Pass the dispatched shader variant directly from each compute dispatch path via hk_cmd_buffer_upload_compute_root() so alternate variants use their own measured prefix.

Signed-off-by: Erik Bourget <erik@ebourget.net>
…pute-root-trim

Keep origin/aurora-wip's compute-pair state at AGX3 v50, bump shader binary versions past it (AGX3 50 -> 51, classic 37 -> 38, AGX2 38 -> 39), and update test-hk-execution-allowance to match.

Signed-off-by: Erik Bourget <erik@ebourget.net>
…oads

Record the uploaded compute root prefix size on compute-pair dispatches and require fused shaders to fit within that uploaded prefix in hk_fused_compute_shader_eligible(). Extend hk_cpu_upload_bench to cover depthwise_vec4 alternate root uploads and fused root-size rejection.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb requested review from a team as code owners November 24, 2026 21:29
@erikwb
erikwb requested a review from Acelogic November 24, 2026 21:29
@erikwb

erikwb commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Merged live origin/aurora-wip (cedf24806bcb) into j716c/hk-m5-compute-root-trim at 8a87c4523221 without force-pushing, and added a follow-up commit at f31f44f41f48 covering depthwise_vec4 and compute-pair fusion root-size bounds:

  1. Merge and version bump past origin/aurora-wip (8a87c4523221):
    • src/asahi/vulkan/hk_agx3_vdm_decode.h: preserved origin/aurora-wip's compute-pair state at AGX3 binary version 50, and bumped past it for unconditional compute root serialization (HK_AGX3_SHADER_BINARY_VERSION 50 -> 51, HK_CLASSIC_SHADER_BINARY_VERSION 37 -> 38, HK_AGX2_SHADER_BINARY_VERSION 38 -> 39).
    • src/asahi/vulkan/tests/test-hk-execution-allowance.c: updated hk_shader_binary_version() assertions to 51 / 39 / 38.
  2. Alternate compute variant & compute-pair fusion root coverage (104da570ab4c, f31f44f41f48):
    • hk_cmd_buffer_upload_compute_root(cmd, s) passes the dispatched shader variant (s, including identity_copy4, im2col_vec4, depthwise_vec4, and byte_stencil) from all four compute dispatch upload sites (src/asahi/vulkan/hk_cmd_dispatch.c, src/asahi/vulkan/hk_cmd_buffer.c).
    • hk_record_compute_pair() now records desc->uploaded_root_size into hk_compute_pair_dispatch.root_size (src/asahi/vulkan/hk_compute_pair.h, src/asahi/vulkan/hk_cmd_dispatch.c), and hk_fused_compute_shader_eligible() rejects fusion if the fused shader's required root prefix exceeds p->root_size.
    • Extended src/asahi/vulkan/tests/hk_cpu_upload_bench.c to exercise cs->depthwise_vec4 root uploads (growth, shrink, reuse, and unmeasured fallback) and hk_fused_compute_shader_eligible() root-size rejection.
  3. Host verification and pending hardware rows (f31f44f41f48):
    • Host (x86_64, -Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dtools=drm-shim -Dbuild-tests=true -Doptimization=2 -Ddebug=false -Db_ndebug=false, with src/egl/libEGL_mesa.so.0.0.0 and src/gallium/targets/dri/libgallium-26.3.0-devel.so built): meson test --suite asahi 291/291 passed, 0 failed (including hk_root_size, hk_cpu_upload, hk_execution_allowance, hk_compute_pair, hk_pack, asahi-agx-chip, hk_identity_copy4, hk_byte_stencil, and agx_tests 1,459 passed / 1 skipped NativeFMA.ExactDyadicOracle).
    • Updated the PR description to **What:** / **Tested:** / **Risk:** / **Not yet:** format. Exact-head (f31f44f41f48 vs cedf24806bcb) hardware runs (dEQP-VK.compute.*, dEQP-VK.binding_model.*, dEQP-VK.descriptor_indexing.*, cold cache and candidate-warmed cache covering dynamic descriptors, push constants at the end of the used prefix, depthwise_vec4, and compute-pair fusion) remain pending across J716c (G17C), J713 (G16G), and J313 (G13G) in our lab, plus J413 (G14G), M1 Pro (G13S), and A18 Pro (G17P).

@erikwb
erikwb requested a review from maralcbr November 24, 2026 21:29

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict at f31f44f41f48

Approve. Follow-up commits (104da570ab4c, 8a87c4523221, f31f44f41f48) cleanly resolve the prior review findings: compute root trimming now measures and uploads the actually dispatched shader variant's root_descriptor_size across all compute dispatch paths, guards compute-pair fusion when the uploaded root prefix is smaller than the fused shader's demand, bumps all three shader binary versions past aurora-wip (AGX3 50 -> 51, classic 37 -> 38, AGX2 38 -> 39), and extends unit test coverage for depthwise_vec4 alternate uploads and fusion rejection.

Blockers

None.

Checked

  • Audited all 10 changed files (hk_agx3_vdm_decode.h, hk_cmd_buffer.{c,h}, hk_cmd_dispatch.c, hk_cmd_upload.c, hk_compute_pair.h, hk_shader.{c,h}, tests/hk_cpu_upload_bench.c, tests/test-hk-execution-allowance.c) and commit history/trailers (Signed-off-by present across all 5 commits).
  • Verified hk_cmd_buffer_upload_compute_root(cmd, s) uploads the dispatched variant's measured prefix on all four compute dispatch paths (hk_dispatch_m5_native, hk_dispatch_g17p_native, hk_dispatch_g17g_native, hk_upload_usc_words_internal), hk_record_compute_pair() records desc->uploaded_root_size into record.root_size, and hk_fused_compute_shader_eligible() rejects fusion whenever p->root_size < required_root (with 0 interpreted as full sizeof(struct hk_root_descriptor_table)).
  • Built Borealis from f31f44f41f48 with -Dbuildtype=debugoptimized -Db_ndebug=false on Linux 7.3 (Apple M5 Max) and ran Meson suites:
    • meson test --suite asahi: 288/288 OK, 0 Fail (including mesa:hk_cpu_upload, mesa:hk_execution_allowance, mesa:hk_compute_pair, mesa:hk_root_size, mesa:hk_root_only_flush, mesa:hk_root_fragment).
    • meson test --suite poly: 5/5 OK, 0 Fail.
  • Ran live Vulkan CTS on Apple M5 Max (dEQP-VK.compute.pipeline.*, 22,533 cases): 5,086 Pass, 17,447 NotSupported, 0 Fail, 0 GPU faults.
  • Verified cold and warm shader disk cache serialization/deserialization (400 passing compute cases): 400/400 Pass cold (1,679 cache files written), 400/400 Pass warm, 0 GPU faults.
  • Untested scope: Live GPU execution on classic AGX / AGX2 / non-M5 AGX3 silicon (verified via unit tests across all enum agx_chip values in mesa:hk_cpu_upload), and full-suite Vulkan CTS beyond the compute pipeline slice.
Evidence
  • Guard: OPEN|false|MERGEABLE|f31f44f41f48
  • Build: -Dbuildtype=debugoptimized -Db_ndebug=false
  • Meson: asahi 288/288 OK, 0 Fail; poly 5/5 OK, 0 Fail
  • Live Vulkan CTS (Apple M5 Max, dEQP-VK.compute.pipeline.*): total 22533 {'NotSupported': 17447, 'Pass': 5086}, GPU_FAULTS=0
  • Cold/warm shader cache (400 compute cases, MESA_SHADER_CACHE_DISABLE=false): cold 400/400 Pass (1679 files), warm 400/400 Pass, CACHE_GPU_FAULTS=0

@erikwb

erikwb commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Added exact-head J713 (M4 Air, G16G, classic v38) sampled Borealis Vulkan CTS A/B results at f31f44f41f48 vs merge-base cedf24806bcb (Linux 7.3.0, Vulkan CTS 7ba03cdac7ae, same boot back-to-back):

  • dEQP-VK.compute.pipeline.* + compute.shader_object_spirv.* (stride 8, 5,071 cases): 1,089 Pass / 3,982 NotSupported / 0 Fail, identical to base (0 diffs, 0 crashes).
  • dEQP-VK.binding_model.shader_access.* (stride 60, 1,441 cases): 1,441/1,441 Pass, identical to base (0 diffs, 0 crashes).

Updated the PR body's Tested, Not yet, and Evidence sections (3-pass cache-isolation / descriptor_indexing.* / unsampled suites on J713, plus J716c, J313, and external Macs remain under Not yet). Head f31f44f41f48 is unchanged.

…pute-root-trim

Keep origin/aurora-wip's compute shader binary versions at AGX3 52 /
classic 40 / AGX2 38 and bump past them for unconditional compute root
prefix serialization (AGX3 53, classic 41, AGX2 39), updating
test-hk-execution-allowance to match.

Adapt to changes landed on origin/aurora-wip:
- Preserve internal graphics-root selection in hk_dispatch_g17g_native()
  while passing the dispatched compute shader variant to
  hk_cmd_buffer_upload_compute_root().
- Record desc->uploaded_root_size on HK_COMPUTE_PAIR_FADD dispatches in
  hk_record_copy4_pair(), and use sizeof(struct hk_root_descriptor_table)
  when hk_pack_runs() allocates a full root table for needs_root fusions.
- Initialize p->root_size in test-hk-fused-cprog and use alt_kind in
  hk_cpu_upload_bench.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb requested a review from a team as a code owner November 26, 2026 03:57
@erikwb

erikwb commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

Merged origin/aurora-wip (262403b7bce1) into j716c/hk-m5-compute-root-trim at cd36f059a005 to resolve conflicts and adapt compute-pair root-size checks to newly landed changes:

  1. Binary version bump past origin/aurora-wip (src/asahi/vulkan/hk_agx3_vdm_decode.h, src/asahi/vulkan/tests/test-hk-execution-allowance.c):
    • Preserved origin/aurora-wip's loop-bound binary bump at AGX3 52 / classic 40 / AGX2 38 and bumped all three for unconditional compute root prefix serialization: HK_AGX3_SHADER_BINARY_VERSION 52 -> 53, HK_CLASSIC_SHADER_BINARY_VERSION 40 -> 41, HK_AGX2_SHADER_BINARY_VERSION 38 -> 39, and updated hk_shader_binary_version() expectations in test-hk-execution-allowance.c.
  2. G18G internal dispatch and compute-pair fusion root sizing (src/asahi/vulkan/hk_cmd_dispatch.c, src/asahi/vulkan/hk_queue.c):
    • Kept internal ? cmd->state.gfx.root : hk_cmd_buffer_upload_compute_root(cmd, s) in hk_dispatch_g17g_native().
    • Recorded desc->uploaded_root_size into record->root_size for HK_COMPUTE_PAIR_FADD in hk_record_copy4_pair().
    • Set eff_p.root_size and tmp_disp.root_size to sizeof(struct hk_root_descriptor_table) in hk_pack_runs() when needs_root allocates a fresh full root table for dual-write, im2col, or dw_a fusions.
  3. Host test updates and verification (cd36f059a005):
    • Updated init_base_fixture() in src/asahi/vulkan/tests/test-hk-fused-cprog.c to set p->root_size = sizeof(struct hk_root_descriptor_table) and updated src/asahi/vulkan/tests/hk_cpu_upload_bench.c to use .alt_kind = HK_COMPUTE_PAIR_ALT_DEPTHWISE_VEC4.
    • Ran meson test -C _build --suite asahi --suite poly (-Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dtools=drm-shim -Dbuild-tests=true -Doptimization=2 -Ddebug=false -Db_ndebug=false with libEGL_mesa.so.0.0.0 and libgallium-26.3.0-devel.so built): 327/327 passed, 0 failed (322/322 asahi, 5/5 poly), with agx_tests reporting 1,612 passed, 1 skipped (NativeFMA.ExactDyadicOracle), 0 failed (1,613 total across 143 suites).
    • Reconciled the PR body counts (agx_tests 1,612 passed / 1 skipped / 0 failed; prior J716c fa5666793c06 suite sum 207,868 cases).
  4. Exact-head hardware verification (cd36f059a005 vs 262403b7bce1):
    • J713 (M4 Air / G16G B0): 207,868 cases (compute.*, binding_model.*, descriptor_indexing.*: 123,537 Pass / 84,331 NotSupported / 0 Fail) across 6 passes on one shared cache, 0 diffs: base cold +63,528, PR on base-warmed cache +63,527 (zero cache sharing), PR pass 3 +33,279, PR passes 4 & 6 +0, and base control pass 5 also +33,279 (proving the second-run cache growth is pre-existing Mesa behavior, not #593); 0 GPU faults, 0 failed units.
    • J716c (M5 Max / G17C B1): 207,868 cases (127,222 Pass / 80,646 NotSupported / 0 Fail) across 3 passes on one shared cache, 0 diffs (+63,177 base cold, +63,176 PR on base-warmed cache, +32,613 PR pass 3 — same pre-existing two-stage cache population pattern explained by the J713 base control); 0 GPU-error lines.
    • J313 (M1 Air / G13G B1): 3 passes on one shared cache, 0 diffs in each across compute.* + descriptor_indexing.* full (60,948 cases: 13,190 Pass / 47,758 NotSupported) and binding_model.* stride 5 (29,384 of 146,920 cases: 13,716 Pass / 11,689 NotSupported / 2,318 DeviceLost / 1,661 Fail identical on both arms from pre-existing kernel ENOTSUPP rejections and exit segfaults); base (+23,220) and PR (+23,219, then +0) cache keys isolated; 0 GPU faults.
    • Updated **Not yet:** to clear the completed J716c / J713 / J313 3-pass CTS & cache-isolation rows while keeping runtime GPU workloads for depthwise_vec4, HK_COMPUTE_PAIR_FADD, and needs_root fusion (host unit-test covered only), unstrided binding_model.* on J313, and external J413 / M1 Pro / A18 Pro / G18G (M6) hardware rows.

Signed-off-by: Erik Bourget <erik@ebourget.net>
Signed-off-by: Erik Bourget <erik@ebourget.net>
Signed-off-by: Erik Bourget <erik@ebourget.net>
Signed-off-by: Erik Bourget <erik@ebourget.net>
Compute shader objects now serialize and trim root_descriptor_size on every GPU generation, so pass --expect-root-size for g13g alongside g17s and g17p in src/asahi/meson.build.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb

erikwb commented Nov 27, 2026

Copy link
Copy Markdown
Author

Merged origin/aurora-wip (ef132f590b25) into j716c/hk-m5-compute-root-trim at 5fc79c28c89 to resolve conflicts, updated check_fused_m5_dispatch() at dfdeeef3fd9, and enforced --expect-root-size for G13G at e9a554a5b787:

  1. Merge conflict resolution (5fc79c28c89):
    • src/asahi/vulkan/hk_queue.c: preserved eff_p.root_size = sizeof(struct hk_root_descriptor_table) for needs_root fusions alongside gemm_dw_cfg.has_proj in hk_pack_runs(), and kept tmp_disp.root_size = sizeof(struct hk_root_descriptor_table) after tmp_disp.root_va = root_va + root_off following the pl->exp_idx_off path.
    • src/asahi/vulkan/tests/test-hk-execution-allowance.c: kept AGX_CHIP_G17D at AGX3 binary version 53 alongside G17P/G17G/G17S/G17C (since origin/aurora-wip already moved HK_AGX3_SHADER_BINARY_VERSION to 53 for HAL200/M5 root prefix serialization), while keeping AGX2 at 39 (38 -> 39) and classic at 41 (40 -> 41).
  2. Compute-pair cache test update (dfdeeef3fd9):
    • src/asahi/vulkan/tests/test-hk-compute-pair-cache.c: initialized p.root_size = sizeof(struct hk_root_descriptor_table) in check_fused_m5_dispatch() so the newly added M5 fused dispatch test satisfies hk_fused_compute_shader_eligible_ranges().
  3. G13G shader-binary root prefix check (e9a554a5b787):
    • src/asahi/meson.build: passed --expect-root-size to hk-g13g-shader-binary-root alongside g17s and g17p. The flag only requires the serialized root-size field to be present in the shader binary (hk_vulkan_shader_binary_root.c:264); the layout check that follows (hk_vulkan_shader_binary_root.c:307) accepts any value from 16 bytes up to the full table, so the flag alone does not enforce trimming. That the compiler trims is shown by the measured prefixes below (176/2216 B and 832/2216 B on G13G), not by the flag.
  4. Host verification at e9a554a5b787 (-Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dtools=drm-shim -Dbuild-tests=true -Doptimization=2 -Ddebug=false -Db_ndebug=false):
    • Targeted suite (hk_compute_pair_cache, hk_root_size, hk_cpu_upload, hk_execution_allowance, hk_fused_cprog, hk_compute_pair, hk_pack, hk-g13g-shader-binary-root, hk-g17p-shader-binary-root, hk-g17s-shader-binary-root): 10/10 passed (hk-g13g-shader-binary-root ran with --expect-root-size and printed 176/2216 B and 832/2216 B compute root prefixes on G13G).
    • Prior-commit (dfdeeef3fd9) full meson test -C _build --suite asahi --suite poly: 340/341 passed (agx_tests 1,719 tests across 153 suites passed; hk_sync_stamps failed at test-hk-sync-stamps.c:1232 from unrelated origin/aurora-wip hk_sync.c changes in 7617c835cd8 / ef132f590b25).
  5. Exact-head hardware runs (e9a554a5b787 vs ef132f590b25, Linux 7.3.0): dEQP-VK.compute.* + dEQP-VK.binding_model.* (full) + dEQP-VK.descriptor_indexing.*, 207,868 cases, 3 passes x 2 arms on one shared shader cache per Mac; the earlier-head rows are superseded and kept under Evidence.
    • J716c (M5 Max / G17C B1): 131,145 Pass / 76,722 NotSupported / 1 Fail per pass (the one Fail is identical on both arms), 0 diffs between arms and across passes, 0 GPU faults.
    • J713 (M4 Air / G16G B0): at 2 workers 1,899 graphics cases failed intermittently on both arms at the same rate; a single-worker rerun of all 1,899 passed on both arms in every pass, 0 diffs. The CTS there is a different build from J313's.
    • J313 (M1 Air / G13G B1): full unstrided binding_model.*, 101,620 Pass / 106,236 NotSupported / 6 DeviceLost / 6 Crash identical on all 6 runs (pre-existing descriptor_buffer cases), 0 diffs, 0 GPU faults; this closes the full-binding_model.* item on J313.

@aurora-silicon-review aurora-silicon-review Bot 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 e9a554a5

Blockers:

  1. Branch is CONFLICTING (DIRTY) with aurora-wip; forward-merge aurora-wip (no force push) and verify host tests pass on the merged head.

Checked:

  • dfdeeef3 (root_size initialization in check_fused_m5_dispatch()) and e9a554a5 (--expect-root-size enforcement for G13G) look sound; only the aurora-wip conflict blocks merge.
  • Checked for Apple material, tool attribution, private serials, and Borealis naming: clean.
Evidence
  • Head: e9a554a5b787 (base: aurora-wip, mergeable: CONFLICTING, +145/-48 across 14 files).

Bump shader binary versions past aurora-wip (AGX3 56->57, classic 43->44, AGX2 40->41).

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Author

Forward-merged aurora-wip into j716c/hk-m5-compute-root-trim at f60e0fa4a69 (bumped shader binary versions past aurora-wip: AGX3 56→57, classic 43→44, AGX2 40→41) and verified meson test --suite asahi passes 265/265 (0 failures, -Dbuildtype=release -Db_ndebug=false).

@aurora-silicon-review aurora-silicon-review Bot 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: MERGE at f60e0fa4 (note: prior DjDeveloperr CHANGES_REQUESTED at 69fb5f50 is superseded by follow-up fixes, satchlj approval at f31f44f4, and this clean aurora-wip merge).

Blockers: none.

Checked: Forward-merge resolution onto aurora-wip at f60e0fa4a69, shader binary version bumps (hk_agx3_vdm_decode.h, test-hk-execution-allowance.c), full 14-file diff (hk_cmd_upload.c, hk_cmd_buffer.{c,h}, hk_cmd_dispatch.c, hk_compute_pair.h, hk_queue.c, hk_shader.{c,h}, src/asahi/meson.build, and tests), and exact-head 265/265 asahi suite verification.

Evidence
  • Merge resolution (e9a554a5 -> f60e0fa4):
    • Resolves the sole prior blocker (CONFLICTING -> MERGEABLE on aurora-wip).
    • Bumps shader binary versions cleanly past aurora-wip: HK_AGX3_SHADER_BINARY_VERSION 56 -> 57, HK_CLASSIC_SHADER_BINARY_VERSION 43 -> 44, HK_AGX2_SHADER_BINARY_VERSION 40 -> 41, with matching assertions in test-hk-execution-allowance.c.
    • Preserves hk_cmd_buffer_upload_compute_root() across AGX2, G17P, G17G, and M5 dispatch paths, root_size fusion guards in hk_queue.c, unconditional root_descriptor_size serialization in hk_shader.c, and --expect-root-size for g13g in src/asahi/meson.build.
  • Verification: meson test --suite asahi passes 265/265 (0 failures, -Dbuildtype=release -Db_ndebug=false) at exact head f60e0fa4a69, alongside multi-generation J716c (1,247,208 case executions, 0 diffs, 0 faults) and J713 hardware CTS rows on unchanged compute-root runtime code.

@RyanTheTide
RyanTheTide dismissed DjDeveloperr’s stale review November 29, 2026 02:09

The AGX2 coverage is now recorded on J313 and on the current integration preview e2df2316e171 (J413 cold and warm compute readback). The unchanged compute-root path also has J713 and J716c CTS coverage, and the App verified the new binary-version bump and 265/265 host tests at the current head. f60e0fa

@RyanTheTide
RyanTheTide merged commit ac25143 into aurora-wip Nov 29, 2026
@RyanTheTide
RyanTheTide deleted the j716c/hk-m5-compute-root-trim branch November 29, 2026 02:10
@RyanTheTide

Copy link
Copy Markdown

Thanks, Erik. This landed in ac25143. On J413, both drivers passed 39,600 compute readback checks in each cold and warm run, with no new kernel messages. We will take the G18G and compute-fusion coverage in #1323. You are welcome to open the follow-up PR with those results if you run it first.

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.

4 participants