Skip to content

borealis: align SSBO address format with Gen10 descriptor lowering on G18G - #1006

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
fix/g18g-ssbo-addr-format
Nov 25, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
fix/g18g-ssbo-addr-format

Conversation

@sithglan

Copy link
Copy Markdown

Summary

Fixes an SSBO NIR address-format mismatch on G18G that triggered Assertion 'addr->num_components == deref->def.num_components' failed in lower_explicit_io_deref() (src/compiler/nir/nir_lower_explicit_io.c:1779) on every SSBO shader in -Db_ndebug=false builds (~1,930 crashes across the 22,222-case Vulkan CTS sweep on J873g).

Root Cause

hk_nir_lower_descriptors() selects the 5-component map-carrying SSBO address format whenever ctx.descriptor_generation == AGX_DESCRIPTOR_GENERATION_10 (which covers M5 and G18G). Meanwhile, hk_get_spirv_options(), hk_lower_nir(), and hk_maybe_build_byte_stencil() gated the same flag on agx_chip_g17_m5(), which returns false for AGX_CHIP_G18G, producing 4-component SSBO derefs against 5-component lowered SSBO descriptors.

Fix

  • Add hk_ssbo_addr_has_map(enum agx_chip chip) in src/asahi/vulkan/hk_shader.h keyed on agx_chip_descriptor_generation(chip) == AGX_DESCRIPTOR_GENERATION_10.
  • Use hk_ssbo_addr_has_map() in hk_get_spirv_options(), hk_lower_nir(), and hk_maybe_build_byte_stencil() (and AGX_DESCRIPTOR_GENERATION_10 in hk_nir_lower_descriptors.c).
  • Add check_ssbo_addr_format_matches_descriptor_gen() in src/asahi/vulkan/tests/test-hk-binding-base.c.

Verification

  • Unit tests (-Db_ndebug=false, aarch64 on J873g): meson test --suite asahi 201/201 OK.
  • Hardware A/B on Mac mini M6 (J873g, T8152, Apple M6 (G18G B1), Linux 7.3.0-aurora-j873-main+, -Db_ndebug=false, MESA_SHADER_CACHE_DISABLE=true):
    • Base (a0fd8033571): 6/6 representative SSBO CTS cases (ssbo.readonly.*, glsl.builtin.precision_fp16_storage32b.*, compute.shader_object_binary.*, synchronization.*buffer_16384, api.buffer_view.*, rasterization.depth_bias.d16_unorm_slope) aborted with SIGABRT (rc=134) at nir_lower_explicit_io.c:1779.
    • Head (0c5a2c23322): 0/6 lower_explicit_io_deref aborts (SSBO/compute/GLSL cases pass; depth_bias.d16_unorm_slope advances past NIR lowering into the separate agx_ilp_schedule bug fixed in asahi/compiler: allocate size16 for G18G compute sample hoisting in agx_ilp_schedule #1005; 0 GPU kernel faults).
  • Non-regression: M5 (G17G/G17S/G17C) already had descriptor_generation == 10 and agx_chip_g17_m5() == true; G17P and AGX2 are unchanged.

… G18G

hk_nir_lower_descriptors() selects the 5-component SSBO address format
(with the sparse map slot) whenever ctx.descriptor_generation == 10, which
includes both M5 (G17G/G17S/G17C) and G18G. However, hk_get_spirv_options(),
hk_lower_nir(), and hk_maybe_build_byte_stencil() checked agx_chip_g17_m5(),
which is false on G18G and selected the 4-component address format instead.

On G18G, that mismatch caused spirv_to_nir and nir_lower_explicit_io() to
expect 4-component SSBO derefs while hk_nir_lower_descriptors() emitted
5-component SSBO descriptor values, tripping the assertion
addr->num_components == deref->def.num_components in lower_explicit_io_deref()
on every SSBO shader in assertion-enabled builds.

Factor the Gen10 check into hk_ssbo_addr_has_map() in hk_shader.h and use it
across all four sites, matching hk_nir_lower_descriptors(). Add a unit test
covering Gen7, Gen9, M5, and G18G chips in test-hk-binding-base.c.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan requested review from a team and DjDeveloperr as code owners November 25, 2026 06:34

@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: MERGE at 0c5a2c233226
Blockers: none
Checked: full diff across hk_shader.h, hk_shader.c, hk_nir_lower_descriptors.c, and the binding-base unit test; all hk_buffer_addr_format() callers in src/asahi/vulkan/; -Db_ndebug=false Meson asahi test suite and Borealis Vulkan CTS on M5 Max (J775c / G17C)

Evidence
  • hk_ssbo_addr_has_map(enum agx_chip chip) aligns SPIR-V lowering (hk_get_spirv_options()), explicit I/O lowering (hk_lower_nir()), and byte-stencil lowering (hk_maybe_build_byte_stencil()) with hk_nir_lower_descriptors() via agx_chip_descriptor_generation(chip) == AGX_DESCRIPTOR_GENERATION_10.
  • Audited every hk_buffer_addr_format() call site in src/asahi/vulkan/; the remaining call at hk_nir_lower_descriptors.c:2182 is only the pre-loop struct initializer overwritten at line 2199 once ctx.descriptor_generation is resolved.
  • check_ssbo_addr_format_matches_descriptor_gen() covers Gen10 parts (G17G/G17S/G17C/G18G) vs non-Gen10 (G17P/G16G/G13G) and verifies the 5-component map-carrying format on G18G.
  • Local verification at 0c5a2c233226 on M5 Max (J775c / G17C, -Db_ndebug=false, MESA_SHADER_CACHE_DISABLE=1):
    • meson test --suite asahi: 201/201 OK (hk_binding_base OK, 0 failures).
    • Vulkan CTS 1.4.7.1 dEQP-VK.ssbo.layout.single_basic_type.std430.*: 303/303 passed (100.0%), 0 failed, 0 warnings, 0 GPU/MMU faults.

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.

3 participants