Skip to content

borealis: take the SSBO address format from the descriptor generation - #561

Closed
RyanTheTide wants to merge 3 commits into
aurora-wipfrom
fix/hk-ssbo-addr-format-one-source
Closed

RyanTheTide wants to merge 3 commits into
aurora-wipfrom
fix/hk-ssbo-addr-format-one-source

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 20, 2026 •

Copy link
Copy Markdown

What: Borealis uses the descriptor generation to choose the SSBO address format in every compiler path. On G18G, an MLX gather shader could assert because its SPIR-V and explicit-I/O paths built an address without the map word that descriptor lowering expected. Joshua Warren reported and diagnosed the mismatch in #560.

Tested: Native x86-64 Fedora build at b560cf7dee1e with assertions enabled. The SSBO address-format, byte stencil, binding base, aligned saturating add, and layered-store window tests passed 5/5. The affected Mac and shared Mac regression rows are pending.

Risk: two-way door · G18G SSBO shaders and shared storage-buffer compiler paths on other Macs.

Not yet: Exact G18G M6 MLX gather and Vulkan SSBO/robustness on a kernel with compatible G18 compute submission. Exact G13, G14, J616s and Neo regression rows.

Details

hk_ssbo_addr_format() takes the descriptor generation for SPIR-V translation, descriptor lowering, explicit NIR I/O and tiled byte stencils. Buffer descriptor writes use the same capability. The forward merge preserved the target branch's shared pre-lowering vectorization, per-buffer robustness selection and test registrations. Layered-image store handling follows the current target branch. The layer-operand capability is tracked in #362.

Evidence

Tested tree 396aaec35727191c74d75c434e74142864fd391e, based on aurora-wip 43beb2fc9e41. The SSBO test runs constant and dynamic descriptor indices with robustness enabled and disabled and validates NIR after both lowerings. The old M6 run was on an incompatible submission ABI and did not complete dEQP. See #560 for the original address-format diagnosis and #611 for the kernel/driver pairing.

spirv_to_nir builds SSBO derefs with hk_get_spirv_options()'s format,
hk_nir_lower_descriptors() rewrites their resource indices and
hk_lower_nir() lowers them with nir_lower_explicit_io(). The descriptor
pass picked the _map formats (five address components) for descriptor
generation 10, but the other two keyed the map word on
agx_chip_g17_m5(), which leaves out the G18G. On the M6 the descriptor
pass therefore produced five-component addresses for derefs that
nir_lower_explicit_io then lowered as four-component ones, and
lower_explicit_io_deref() asserted (addr->num_components ==
deref->def.num_components) on an MLX gather compute shader.

Add hk_storage_address_has_map() / hk_ssbo_addr_format(), keyed on the
descriptor generation the set layouts are built with, and use them in
all three places, plus the buffer descriptor writer that fills the map
word. Nothing changes on any chip but the G18G, where the three now
agree.

The M5 layered-store window had the same shape: the image view and the
store lowering each spelled out G17G/G17S. Give that one name too,
agx_chip_layered_store_is_3d(), and use it on both sides (no change).

New unit test hk_ssbo_addr_format: for every chip with a known
descriptor generation, the spirv_to_nir format equals the lowering
format, and an SSBO load/store at a constant and a dynamic index goes
through both lowerings and validates, with and without robustness.

Closes: #560
Reported-by: Joshua Warren <joshuaswarren@users.noreply.github.com>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

M4 Pro (J616s) no-change row. A = aurora-wip e7e9ef3, B = A + this PR (df8e991) + #559. Native release builds, user-space overlay, same kernel:

  • dEQP-VK ssbo.*, robustness.{robustness2,buffer_access,robustness1_vertex_access,pipeline_robustness}.*, binding_model.{descriptorset_random,descriptor_buffer}.*, descriptor_indexing.*, memory_model.message_passing.*, compute.pipeline.*: 169,809 cases, identical case by case (92,023 Pass / 77,786 NotSupported on both).
  • 0 GPU firmware crashes, no GPU errors in the kernel log.

Still to run: M1 Pro (G13) and M2 (G14) rows, and the M6 row.

@RyanTheTide

Copy link
Copy Markdown
Author

M1 Pro (G13S) row. A = aurora-wip 173d51d, B = A + #561 + #559 + #562. Native release builds, user-space overlay, same kernel (7.3.0-aurora-fleet74):

  • dEQP-VK ssbo.*, robustness.{robustness2,buffer_access,robustness1_vertex_access,pipeline_robustness}.*, binding_model.{descriptorset_random,descriptor_buffer}.*, descriptor_indexing.*, memory_model.message_passing.*, compute.pipeline.*: 169,809 cases, identical case by case (44,342 Pass / 125,467 NotSupported on both).
  • dEQP-GLES3/31 fragment_ops, fbo, shaders.{operator,indexing}, draw, texture.format, blend (every second case): 7,082 cases, identical (7,053 Pass on both).
  • No GPU errors in the kernel log.

@joshuaswarren

joshuaswarren commented Nov 20, 2026 •

Copy link
Copy Markdown

M6 (G18G B1), stock J873g kernel 7.1.12-aurora-m6usb-ARCH, boot 4044c587 unchanged. The per-process ICD reported git-df8e991e7b (exact source df8e991e7b44d783042fefc722e57612eb435127, default optimizations). libvulkan_asahi.so SHA-256: d143c81c877be855827e0ecc64740be93fffd27913e06babca0f09390567395f.

  • MLX mx.take: bf16, f16, and f32 each failed at vkQueueSubmit with VK_ERROR_DEVICE_LOST (exit 1). No NIR assertion was observed, but none of the gathers completed.
  • The kernel logged three PayloadTail admission rejections, each followed by submit EINVAL (submission IDs 18370–18372). GPU timeout delta: 0.
  • Stopped before dEQP: 0 cases ran. Neither the three pinned SSBO smoke cases nor the robustness suite ran.

Logs (SHA-256): guard.receipt 5f4b90a1c6b6c73debb4e5ada2f2170f3f36c42919aa3d06b5ce6453515fcfb6; gpu-faults.log 44737bad80a3f9d69f3ab91766cee377cac1f1586ea737b1f24acb46276644ce.

Ryan, which kernel commit or build do you expect us to pair with this ICD for the G18G row?

@RyanTheTide RyanTheTide changed the title hk: take the SSBO address format from the descriptor generation borealis: take the SSBO address format from the descriptor generation Nov 20, 2026
@RyanTheTide

RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Author

Thanks for the row. PayloadTail comes from the kernel's G18 command parser: it found non-zero bytes after the end of the compute command it knows. Since the G18G bring-up, aurora-wip sends every G18G compute command as the 264-byte drm_asahi_cmd_compute_g18 (the 200-byte command, then the versioned resource suffix, flagged with DRM_ASAHI_COMPUTE_G18_RESOURCES, bit 19): see hk_queue.c (the AGX_CHIP_G18G branch of the CDM submit) and agx_batch.c (agx_append_split_compute). A kernel whose G18 parser does not know that suffix rejects every compute submit exactly like this: three gathers, three rejections, EINVAL, no GPU timeout. This PR doesn't touch the submit path; it only changes which SSBO address format the shader lowering uses.

Kernel to pair with: aurora-silicon/linux integration/aurora (head today: cc145705c592c, 7.3). It parses both G18 suffixes (drivers/gpu/drm/asahi/g18/uapi/command.rs, since 22bb2ace308cd).

To keep 7.1.12-aurora-m6usb instead: the draft release now also has the base ICD, built with the same recipe: https://github.com/aurora-silicon/mesa/releases/tag/untagged-09937e7c4acbecac4e61

  • borealis-561base-11ee6231ee69-aarch64.tar.gz is aurora-wip 11ee6231ee69, the PR's only parent. Its .so sha256 is 2b404a1611ee0c5d756b48e9cb3a0a9cbd179c7f5900ad6cd6a033ce6c0fe153.

If the base ICD fails the same three mx.take runs the same way on your kernel, the cause is the kernel/ICD pairing, not this PR. Could you also post uname -v or the kernel commit, so I can check what its parser accepts?

The row that decides the PR is still the one on a matching kernel: mx.take bf16/f16/f32 with the head ICD, without the nir_lower_explicit_io.c:1779 assert, plus the SSBO smoke cases and robustness.

@RyanTheTide

Copy link
Copy Markdown
Author

Blockers: 1.

The change itself is correct. hk_storage_address_has_map() keyed on the descriptor generation makes spirv_to_nir, hk_nir_lower_descriptors and the explicit-I/O lowering agree. On G18G, filling the map word in get_buffer_address() (hk_descriptor_set.c:545) is still a no-op today, because sparse_map is only allocated on G17P/M5 (hk_buffer.c, aurora-wip).

  1. The PR no longer merges, and the rebase has a trap. aurora-wip 07c673e added two more nir_lower_explicit_io(nir_var_mem_ssbo, ...) sites in hk_lower_nir(), before and after the AGX3 SSBO pre-lowering vectorizer (aurora-wip hk_shader.c:3255 and :3283). Both still pass agx_chip_g17_m5(dev->dev.chip). G18G takes the first one (it is not in agx3_ssbo_vec), so if either site is missed the original lower_explicit_io_deref() assert comes back on the M6. The new test cannot catch this: test-hk-ssbo-addr-format.c:78 calls nir_lower_explicit_io() with the helper's own format, not through hk_lower_nir(). Please convert both sites. Ideally also make hk_lower_nir() call a single helper for its format, so that future sites cannot drift.
  2. Coordinate with borealis: enable descriptor buffers on the M5 family #456. Its hk_sparse_map_page_at() (hk_buffer.c:117 there) keys the same word on agx_chip_g17_m5(). Whichever PR lands second should use hk_storage_address_has_map().

The M4 Pro and M1 Pro no-change rows are on df8e991, before 07c673e. The rebase changes the same lowering block, so the G17P row needs running again.

HW row: rebased head with the integration/aurora kernel on the M6 (G18G): MLX mx.take bf16/f16/f32 complete with no assert, and dEQP-VK.ssbo.* plus robustness.robustness2.* storage cases give 0 Fail. M4 Pro and M2 (G14G) no-change rows on the same head: identical case by case against aurora-wip, 0 GPU faults.

Assisted-by: LLM (Claude:Opus 5.5)

aurora-wip now lowers SSBO access in two places in hk_lower_nir(): early
for chips without pre-lowering SSBO vectorization (G18G among them) and
after vectorization for G17P and M5. Both take their address format from
hk_ssbo_addr_format() and the descriptor generation, as the descriptor
lowering does.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Branch updated with one merge of aurora-wip (7ae7c531609); there was a conflict with #413 in hk_lower_nir(). aurora-wip now lowers SSBO access in two places: early for chips without pre-lowering SSBO vectorization (G18G is one of them), and after vectorization for G17P and M5. Both sites now take the address format from hk_ssbo_addr_format() and the descriptor generation, the same source as the descriptor lowering. That is the point of this PR. x86 asahi + poly suites at 7ae7c531609, including hk_ssbo_addr_format: 219/219.

The draft-release ICDs for the M6 row are still the pre-merge head df8e991e7b44 and its base. They carry the same fix for G18G, so a row on them still decides the PR.

@RyanTheTide RyanTheTide left a comment •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review at 7ae7c53. The descriptor writer, SPIR-V lowering and explicit-I/O lowering now select the same SSBO address shape, including the sparse map word. G14G stays on the non-map path. Please identify the exact head and case counts for the reported AGX2 sparse/robustness rows and confirm that dynamic SSBO offsets and linked pipeline libraries are both represented. These consume the shape through different call paths.

@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 adversarial pre-PR checklist (§1–§6) review at 7ae7c53160928b97723fa50b34f7a4f76fbad0cb: REQUEST_CHANGES.

Status Summary

  • Superseded? No — live aurora-wip (efabab38502d) still keys SSBO address format on agx_chip_g17_m5() in hk_shader.c (lines 232, 3309, 3342) and hk_descriptor_set.c (line 548), while hk_nir_lower_descriptors.c (line 2162) keys it on ctx.descriptor_generation == 10.
  • Code & §1–§4 Assessment: The core fix is sound and aligns with §1: unifying spirv_to_nir, hk_nir_lower_descriptors, nir_lower_explicit_io, and get_buffer_address() behind hk_storage_address_has_map() / hk_ssbo_addr_format() keyed on agx_chip_descriptor_generation(), plus consolidating the two G17G || G17S layered-store checks into agx_chip_layered_store_is_3d(). Both commits (df8e991e7b44, 7ae7c5316092) carry human author/committer + human Signed-off-by: only, zero AI commit trailers.
    • (Minor non-blocking note) In tests/test-hk-ssbo-addr-format.c:312, CHECK(map_chips == 4) hardcodes the current Gen-10 chip count and will break when another Gen-10 chip enum is added; consider checking map_chips >= 4 or asserting equivalence against agx_chip_descriptor_generation(c) == AGX_DESCRIPTOR_GENERATION_10.

Blockers

  1. Merge Conflicts against live aurora-wip (CONFLICTING):
    • src/asahi/lib/agx_chip.h (hunk at line 535): agx_chip_g17_m5() was rewritten via agx_chip_info(chip) and relocated to lines 868–874 (preceding agx_chip_m5_paths()) by recent aurora-wip refactors (90f9e2ec0843 / #768, 37e1939d960b / #576, bc7a7a70ca95 / #579).
    • src/asahi/vulkan/hk_shader.c (hunk at line 3237): hk_lower_nir() (lines 3283–3345) now tracks lowered_desc / lowered_global_io / lowered_buf_io / lowered_pre_vec (f22506371498 / #747) and uses agx_chip_g17p_or_m5(dev->dev.chip) at line 3303 (90f9e2ec0843 / #768).
    • Fix: Rebase cleanly onto current aurora-wip, converting both nir_lower_explicit_io(nir_var_mem_ssbo, ...) sites (lines 3306 and 3339) while preserving the lowered_* tracking and agx_chip_g17p_or_m5() call.
  2. Live CI missing on head 7ae7c5316092:
    • Zero check runs / workflow runs exist on 7ae7c5316092. After rebasing onto current aurora-wip, asahi and aurora-agent-policy must run green on the new head.
  3. §5 Hardware Evidence incomplete:
    • M6 (G18G) target hardware row not yet passing: The only M6 run (joshuaswarren on df8e991e7b44) hit kernel PayloadTail / EINVAL rejections on 7.1.12-aurora-m6usb-ARCH and executed 0 dEQP cases. A passing M6 row on a compatible integration/aurora kernel (MLX mx.take bf16/f16/f32 completing without the nir_lower_explicit_io assert + dEQP-VK.ssbo.* and robustness.robustness2.* storage subsets with 0 Fail + regression counts) is required to prove the fix on the affected hardware.
    • Post-rebase no-change rows: The M4 Pro (G17P) and M1 Pro (G13S) rows were taken on df8e991e7b44 before the split hk_lower_nir SSBO lowering landed on aurora-wip, and M2 (G14G) has no row yet. Re-verify exact-head no-change rows on G17P and AGX2 (G13S/G14G) with explicit head SHAs, case counts (including dynamic SSBO offsets and linked pipeline libraries), and regression counts (0 SELinux denials / 0 failed units / 0 new kernel errors).
  4. §6 Naming (on rebase):
    • Commit df8e991e7b44 still uses the hk: commit subject prefix (the PR title was updated to borealis:). When rebasing, rename the commit subject prefix to borealis: (existing hk_ code symbols remain per aurora-silicon/mesa#591).

Assisted-by: LLM (Gemini 4 Neon)

Keep the current vectorization and robustness ordering. Select the SSBO format from descriptor generation when lowering NIR and building tiled byte stencils. Preserve the live layered-image store handling and retain both branches’ test registrations.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested a review from a team as a code owner November 25, 2026 04:27

@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: FINISH, then merge at b560cf7

Blockers:

  • Target-hardware verification on G18G / M6 at b560cf7dee1e is still pending (Not yet in the PR description). Code review and shared Gen-10 hardware verification have no blockers.

Checked: diff review, release build with asserts enabled, unit tests, live Vulkan CTS and dynamic-offset draw verification on Apple M5 Max

Evidence
  • Audited all SSBO address-format and storage-descriptor lowering call sites in src/asahi/vulkan/ (hk_get_spirv_options, hk_nir_lower_descriptors, hk_lower_nir, hk_maybe_build_byte_stencil, get_buffer_address): every path consistently derives the SSBO address format and descriptor-map presence from agx_chip_descriptor_generation(), and the new hk_ssbo_addr_format unit test covers constant and dynamic descriptor indices with robustness off and on across every chip with a known descriptor generation.
  • Built b560cf7dee1e with -Dbuildtype=release -Db_ndebug=false (asahi Gallium + Borealis Vulkan + tests): clean (2642/2642), meson test --suite asahi --suite poly: 207/207 OK (0 failures, including hk_ssbo_addr_format and agx_tests).
  • Live shared-Gen-10 hardware regression row on Apple M5 Max (T6050 / J775c, G17C B1) with MESA_SHADER_CACHE_DISABLE=1 (0 GPU faults in dmesg):
    • dEQP-VK.ssbo.layout.single_basic_type.std430.*: 303/303 PASS (0 fail)
    • dEQP-VK.robustness.buffer_access.compute.*: 138/138 supported PASS (0 fail, 66 not supported)
    • dEQP-VK.robustness.robustness2.bind.notemplate.r32i.dontunroll.nonvolatile.storage_buffer.*: 128/128 supported PASS (0 fail, 64 not supported)
    • dEQP-VK.sparse_resources.buffer.ssbo.*: 31/31 supported PASS (0 fail, 38 not supported)
    • dEQP-VK.pipeline.pipeline_library.graphics_library.misc.other.*: 15/15 supported PASS (0 fail, 7 not supported)
    • vulkan-dynamic-offset-draws (1024 draws/pass, dyn/fixed/fsdyn/push): PASS (0 GPU faults)

@RyanTheTide

Copy link
Copy Markdown
Author

Verdict: CLOSE (superseded by #1006) at b560cf7dee1e.

Checked: The merged #1006 uses the descriptor generation for SPIR-V translation, descriptor lowering, explicit NIR I/O and tiled byte stencils on G18G. The selector is present on aurora-wip. The J873g A/B cleared the SSBO address-format assertion in all six targeted cases and the ARM64 asahi suite passed 201/201.

Evidence

The earlier draft’s descriptor write cleanup was prospective for G18G residency maps. The runtime fix and regression test are in #1006, merged at 6fdc973a601e.

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