Skip to content

asahi: enable native shader preambles (Ioto CProg) on G16G - #716

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/g16g-cprog
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/g16g-cprog

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 22, 2026 •

Copy link
Copy Markdown

Summary

Brings AGX_CHIP_G16G (M4) into G17P / HAL200 parity for native shader preambles (Ioto CProg) and smaller shader binaries, while keeping G15* excluded:

  • src/asahi/lib/agx_chip.h: Add AGX_QUIRK_NATIVE_PREAMBLE to G16G and document the HAL200 (G16G/G17P) vs G15 (RTKit 2419) boundary — G15* uses cs_generation = G15 whose direct CDM launch lacks a TI spill field for agx_chip_query_ti_spill(), and native preambles have not been hardware-qualified on M3/J615.
  • src/asahi/lib/agx_ioto_load_core.c: Widen the two remaining AGX_CHIP_G17P guards in agx_ioto_cprog_input_offset() and agx_ioto_load_finish_worst_case_size_with_ops() to agx_chip_native_preamble().
  • src/asahi/lib/tests/test-chip.c & src/asahi/compiler/test/test-agx3-ioto-uniform-program.c: Update chip-matrix expectations (agx_chip_native_preamble, agx_chip_query_ti_spill) and CProg publication unit tests for G16G (retaining G15G refusal coverage).

Because agx_chip_query_ti_spill() follows agx_chip_native_preamble(), this enables:

  1. Vulkan VS/FS native Ioto CProg and monolithic FS uniform-export blend CProg (hk_shader.c, hk_cmd_draw.c),
  2. Gallium OpenGL FS native CProg (agx_state.c:2835), and
  3. Gallium OpenGL compute TI spill reservation on resource-info queries via agx_chip_query_ti_spill() (agx_state.c:8163, matching G17P and Vulkan hk_cmd_dispatch.c).

Verification (Apple M4 G16G B0, J773g, Linux 7.3)

Note: R2 (4e2f016cb76a) is comments-only in src/asahi/lib/agx_chip.h relative to the hardware-tested f67f15c3bb1d build (zero executable code changes).

  • Host unit tests: meson test --suite asahi 156 / 156 PASS; DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD clean.
  • Vulkan CProg proof & CTS:
    • Live AGX_MESA_DEBUG=shaders: 0 preamble=1 binaries on base c0b51ef24554 → 3 native preamble=1 binaries on f67f15c3bb1d (e.g. render.bindless_ubo VS shrunk 372 → 306 B, 110 B preamble; FS 60 B preamble).
    • Vulkan CTS (--jobs 8): 2,571 Pass / 429 NotSupported / 0 Fail / 0 Crash / 0 Timeout (vk-mustpass-short 87/87, cprog_sweep 2,484/0), 0 GPU faults.
  • Gallium OpenGL FS CProg & query_ti_spill proof:
    • GLES3.1 CTS: 1,029 Pass / 11 NotSupported / 0 Fail / 0 Crash / 0 Timeout (gles31-588-gl50 750/0, dEQP-GLES31.functional.compute.* 195/0, image_load_store.*image_size* 60/0, texture_size.* 24/0), plus projected.*_mirror 2/2 PASS, 0 GPU faults.
    • Live AGX_MESA_DEBUG=shaders: confirmed MESA_SHADER_FRAGMENT stage=4 preamble=1 encoding=1 size=328 (and size=228) and MESA_SHADER_COMPUTE uses_resource_info_query: true executing cleanly with 0 faults.
  • 4-Round ABBA gpubench-vk (f67f15c3bb1d vs c0b51ef24554, 14 rows):
    • Overall performance is neutral (+0.15% wall geomean / +1.27% gpu_us geomean; render.shadow -2.4% wall / -1.3% gpu_us), confirming the value is smaller shader binaries and G17P/HAL200 parity rather than a broad speedup.
    • 0 GPU faults, 0 recoveries, 0 hang kills across all runs.

@RyanTheTide

Copy link
Copy Markdown

Read at f67f15c. The two guard changes in agx_ioto_load_core.c (chip != AGX_CHIP_G17P -> !agx_chip_native_preamble(chip)) are equivalent for G17P and make the quirk the single source, which is the right shape. The test-chip matrix moves exactly the G16G bit for both native_preamble and query_ti_spill. The M4 row at the exact head is thorough: CTS 2,571/0 including the cprog sweep, 0 faults, the shaders dump showing native preamble=1 binaries, and an ABBA.

Two points:

  • G15 is still left out (the quirk goes on G16G only), and the description doesn't say why. G15G/G16G/G17P share the AGX3B encoding and the HAL200 records. If the M3 lacks the Ioto CProg path in hardware or firmware, please name that difference in a comment next to the quirk. If it just hasn't been run, a G15G row (J615, M3 Air) with the same cprog sweep would let the quirk sit on the whole native AGX3B set rather than a per-chip list.
  • Since query_ti_spill follows the same quirk, please mention in the commit message that G16G also changes its TI spill query path, and say which cases in the sweep exercise it.

Perf is neutral overall (+0.15% wall geomean, with render.shadow -2.4% wall), so the case for merging is the smaller binaries and parity with G17P rather than speed. The description could say that directly. Code-wise this is fine from my side.

Assisted-by: LLM (Claude:Opus 5.5)

Add AGX_QUIRK_NATIVE_PREAMBLE to the G16G chip entry, widen the two remaining
AGX_CHIP_G17P guards in agx_ioto_load_core.c to agx_chip_native_preamble(),
and update test-chip and agx3_ioto_uniform_program for G16G parity with G17P.

G16G and G17P share HAL200 (cs_generation = HAL200, sampler_generation =
GEN4_HAL200), AGX3B, and GPU0 Ioto; enabling native CProg on G16G brings
G17P/HAL200 parity and smaller shader binaries (overall ABBA performance is
neutral at +0.15% wall geomean). G15* remains excluded because it uses the
older G15 (RTKit 2419) command-stream generation whose direct CDM launch has
no TI spill field for agx_chip_query_ti_spill(), and native preambles have
not been hardware-qualified on M3/J615.

Because agx_chip_query_ti_spill() tracks agx_chip_native_preamble(), enabling
the quirk on G16G turns on:
- Vulkan VS/FS native Ioto CProg and monolithic FS uniform-export blend CProg
  (hk_shader.c, hk_cmd_draw.c),
- Gallium OpenGL FS native CProg (agx_state.c:2835), and
- Gallium OpenGL compute TI spill reservation on resource-info queries via
  agx_chip_query_ti_spill() (agx_state.c:8163, matching G17P and Vulkan
  hk_cmd_dispatch.c).

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

Copy link
Copy Markdown
Author

@RyanTheTide Thanks for the review — pushed R2 (4e2f016cb76a) addressing both points (comments-only diff in src/asahi/lib/agx_chip.h relative to the tested f67f15c3bb1d binary — zero executable code changes):

  1. Why G15* remains excluded (documented next to AGX_QUIRK_NATIVE_PREAMBLE and agx_chip_native_preamble()):
    • G16G and G17P share HAL200 (cs_generation = HAL200, sampler_generation = GEN4_HAL200), AGX3B, and GPU0 Ioto and are both hardware-qualified for native CProg.
    • G15* uses the older G15 (RTKit 2419) command-stream generation (its direct CDM launch has no TI spill field for agx_chip_query_ti_spill(), and native preambles have not been hardware-qualified on M3/J615), so G15* stays excluded.
  2. agx_chip_query_ti_spill() + Gallium GL hardware proof + PR framing:
    • Updated the commit message and PR description to note that agx_chip_query_ti_spill() (src/gallium/drivers/asahi/agx_state.c:8163, its sole call site) and Gallium GL FS CProg (agx_state.c:2835) also flip on for G16G, and reframed the PR around smaller shader binaries and G17P/HAL200 parity (with ABBA perf neutral overall at +0.15% wall geomean, render.shadow -2.4% wall).
    • Ran targeted Gallium OpenGL / GLES3.1 hardware verification on M4 G16G B0 (J773g, 7.3.0-ARCH-m4prod14, run dcp76b-pr-verify-batch) against the exact tested code (f67f15c3bb1d, identical object code to R2 4e2f016cb76a):
      • GLES3.1 CTS: 1,029 Pass / 11 NotSupported / 0 Fail / 0 Crash / 0 Timeout (0 GPU faults):
        • gles31-588-gl50: 750 Pass / 7 NS / 0 Fail
        • dEQP-GLES31.functional.compute.*: 195 Pass / 0 Fail
        • dEQP-GLES31.functional.image_load_store.*image_size*: 60 Pass / 0 Fail
        • dEQP-GLES31.functional.shaders.builtin_functions.*texture_size*: 24 Pass / 4 NS / 0 Fail
        • projected.*_mirror bisect: 2 / 2 Pass
      • Live AGX_MESA_DEBUG=shaders confirmation: confirmed MESA_SHADER_FRAGMENT stage=4 preamble=1 encoding=1 size=328 (and size=228) and MESA_SHADER_COMPUTE uses_resource_info_query: true passing with 0 GPU faults.

Assisted-by: LLM (Gemini:4 Neon)

@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 4e2f016cb76a

Approved.

Blockers

None.

Checked

  • Audited all 4 changed files (src/asahi/lib/agx_chip.h, src/asahi/lib/agx_ioto_load_core.c, src/asahi/lib/tests/test-chip.c, src/asahi/compiler/test/test-agx3-ioto-uniform-program.c).
  • Verified AGX_QUIRK_NATIVE_PREAMBLE is enabled on G16G in agx_chip.h with clear documentation of why G15* remains excluded, and the two remaining AGX_CHIP_G17P guards in agx_ioto_load_core.c are widened to agx_chip_native_preamble().
  • Verified build, 217/217 non-layout asahi tests (including asahi-agx-chip, agx3_ioto_uniform_program, and agx_tests), and live Borealis Vulkan compute smoke on Apple M5 Max (G17C B1), Linux 7.3 (MESA_SHADER_CACHE_DISABLE=1) confirming no M5 regression and 0 GPU faults in dmesg.
  • Untested scope: Live hardware execution on G16G (M4).
Evidence
  • meson test --suite asahi (non-layout): 217/217 OK (asahi-agx-chip, agx3_ioto_uniform_program, agx_tests all OK)
  • Live Apple M5 Max (G17C B1), Linux 7.3, MESA_SHADER_CACHE_DISABLE=1:
    • dEQP-VK.compute.pipeline.basic.*: 80/81 passed (0 failed, 1 not supported)
    • dmesg GPU fault delta: 0

@DjDeveloperr
DjDeveloperr merged commit 1abda6b into aurora-wip Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged into aurora-wip at 4e2f016cb76a.

Verification summary:

  • Peer review: approved at exact head 4e2f016cb76a (217/217 asahi unit tests + live Apple M5 Max G17C B1 Borealis Vulkan compute smoke, 0 GPU faults).
  • Prior review points resolved in comments-only R2 diff relative to Apple M4 G16G B0 hardware verification (Vulkan CTS 2,571/0, GLES3.1 CTS 1,029/0, live preamble=1 and uses_resource_info_query: true confirmation, 0 GPU faults).
  • Fork-mirror CI (DjDeveloperr/mesa): asahi run 45062446005 PASS; policy check PASS.

nameless312 pushed a commit to nameless312/mesa that referenced this pull request Nov 24, 2026
…bounds

PRs aurora-silicon#716 and aurora-silicon#760 updated the agx_chip_native_preamble() and
agx_chip_vdm_indirect_index_bounds() predicates in agx_chip.h from
pre-agx_chip_caps.h bases without updating the matching capability rows
in agx_chip_caps.h, breaking test-chip-caps on aurora-wip.

Add AGX_CAP_NATIVE_PREAMBLE to G16G and AGX_CAP_VDM_INDIRECT_INDEX_BOUNDS
to AGX_CAPS_G17P so agx_chip_has_cap() agrees with the predicates on all
chips.

Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide
RyanTheTide deleted the djdev/g16g-cprog branch November 27, 2026 13:20
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