Skip to content

asahi/lib: add a declarative chip capability table - #824

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
cleanup/agx-chip-caps-table
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
cleanup/agx-chip-caps-table

Conversation

@DjDeveloperr

Copy link
Copy Markdown

agx_chip.h describes what each chip is: its ISA, encodings, command-stream, descriptor and sampler generations, and command path. What a chip can do is answered by one predicate per feature, and many of those predicates test a set of chips rather than a property.

This adds src/asahi/lib/agx_chip_caps.h:

  • enum agx_chip_cap, one bit per hardware feature;
  • AGX_CHIP_CAPS(), one row of capabilities per chip in AGX_CHIPS order;
  • agx_chip_has_cap(), which expands to comparisons like agx_chip_has_record() does, so the OpenCL units can call it too.

Hardware defects stay in enum agx_chip_quirk.

The first eight capabilities take exactly the chips of the predicate each one comes from:

Capability Predicate
AGX_CAP_NATIVE_INDIRECT_COMPUTE agx_chip_native_indirect_compute()
AGX_CAP_NATIVE_IMAGEBLOCK agx_chip_native_imageblock()
AGX_CAP_NATIVE_PREAMBLE agx_chip_native_preamble()
AGX_CAP_ELIDE_APP_DISPATCH_BARRIER agx_chip_elide_app_dispatch_barrier()
AGX_CAP_VDM_INDIRECT_INDEX_BOUNDS agx_chip_vdm_indirect_index_bounds()
AGX_CAP_HW_TXF_BOUNDS agx_chip_hw_texel_fetch_bounds()
AGX_CAP_TRI_MERGE_ACROSS_SIDE_EFFECTS agx_chip_tri_merge_across_side_effects()
AGX_CAP_COOPERATIVE_MATRIX agx_chip_cooperative_matrix_supported()

The new asahi-agx-chip-caps test checks that:

  • the table has one row per chip, in enum order;
  • no row sets an unknown bit;
  • every capability matches its predicate on every chip;
  • unknown and out-of-range chips have no capabilities.

Only the test includes the new header, so no driver code changes. agx_chip.h is not modified. Follow-ups will move the predicates onto the table and let new per-chip features land as one capability bit.

Testing:

  • meson test asahi-agx-chip-caps: 366/366 checks pass.
  • meson test asahi-agx-chip: 831/831 checks pass.
  • The header compiles as C11, C++17 and OpenCL C 3.0 with -Wall -Wextra -Werror.
  • Both new files are clean under src/.clang-format.
  • Build: release, -Db_ndebug=false, Gallium asahi and Vulkan asahi, with libvulkan_asahi.so and libasahi.a rebuilt. No new warnings.

Hardware: no hardware path changes, because no driver code includes the header. Hardware row: not applicable.

Assisted-by: LLM (Claude:Opus 5.5)

agx_chip.h describes what each chip is: its instruction set, encodings,
command-stream and descriptor generations and command path. What a chip
can do is answered today by one predicate per feature, many of which
test a set of chips rather than a property, so enabling a feature on
another chip means adding or widening a predicate.

Add agx_chip_caps.h: enum agx_chip_cap, one bit per hardware feature a
driver may use, and AGX_CHIP_CAPS(), one row of capabilities per chip of
AGX_CHIPS in the same order. agx_chip_has_cap() tests the table the way
agx_chip_has_record() does, as an expansion of comparisons, so the
OpenCL units can call it too. Hardware defects stay quirks.

The first eight capabilities take exactly the chips of the predicate
each one is introduced from:

  AGX_CAP_NATIVE_INDIRECT_COMPUTE       agx_chip_native_indirect_compute
  AGX_CAP_NATIVE_IMAGEBLOCK             agx_chip_native_imageblock
  AGX_CAP_NATIVE_PREAMBLE               agx_chip_native_preamble
  AGX_CAP_ELIDE_APP_DISPATCH_BARRIER    agx_chip_elide_app_dispatch_barrier
  AGX_CAP_VDM_INDIRECT_INDEX_BOUNDS     agx_chip_vdm_indirect_index_bounds
  AGX_CAP_HW_TXF_BOUNDS                 agx_chip_hw_texel_fetch_bounds
  AGX_CAP_TRI_MERGE_ACROSS_SIDE_EFFECTS agx_chip_tri_merge_across_side_effects
  AGX_CAP_COOPERATIVE_MATRIX            agx_chip_cooperative_matrix_supported

test-chip-caps checks that the table has one row per chip in enum
order, that no row sets an unknown bit, that every capability answers
what its predicate answers on every chip, and that unknown chips and
out-of-range values have none.

Nothing includes the new header outside its test yet, so no driver
behaviour changes. Moving the predicates onto the table is left to
follow-up changes.

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

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

Gemini 4 Neon on @satchlj's behalf:

Reviewed and verified a70cf23a302670226ebd5d87661ddaa0085ddd7d via full diff/source audit, meson test --suite asahi, and live Vulkan smoke on J775c (Apple M5 Max, G17C B1) running Linux 7.3 (MESA_SHADER_CACHE_DISABLE=1, Borealis).

Code audit

  • Checked all 8 capability flags in src/asahi/lib/agx_chip_caps.h (AGX_CAP_NATIVE_INDIRECT_COMPUTE, AGX_CAP_NATIVE_IMAGEBLOCK, AGX_CAP_NATIVE_PREAMBLE, AGX_CAP_ELIDE_APP_DISPATCH_BARRIER, AGX_CAP_VDM_INDIRECT_INDEX_BOUNDS, AGX_CAP_HW_TXF_BOUNDS, AGX_CAP_TRI_MERGE_ACROSS_SIDE_EFFECTS, AGX_CAP_COOPERATIVE_MATRIX) against the corresponding predicates and AGX_CHIPS row ordering in src/asahi/lib/agx_chip.h: every chip row matches its existing predicate exactly, and unknown/out-of-range chips or cap == 0 cleanly evaluate to false.
  • AGX_CHIP_CAP_ROW_TEST expands to pure comparisons (no static table indirection), preserving OpenCL precompiled-kernel compatibility matching agx_chip_has_record().

Verification

  • meson test -v asahi-agx-chip asahi-agx-chip-caps: 2/2 PASS (agx_chip: all 831 checks passed, agx_chip_caps: all 366 checks passed).
  • meson test --suite asahi: 237/237 PASS.
  • Live dEQP-VK.info.device_extensions smoke on J775c (G17C B1): 1/1 PASS, new_dmesg_errors=0.

Untested scope

  • This PR introduces the declarative table and unit test without migrating call sites yet; OpenCL/libagx compilation of agx_chip_caps.h as an included header was not exercised directly since no OpenCL kernel includes it yet.

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

@DjDeveloperr
DjDeveloperr merged commit 55e3e45 into aurora-wip Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged into aurora-wip at 55e3e45a3011 (exact head a70cf23a3026, verified merge tree 174dae3533d8).

  • Review: @satchlj exact-head APPROVED (agx_chip 831 checks + agx_chip_caps 366 checks + asahi 237/237 + live J775c M5 Max G17C B1 VK smoke, 0 dmesg errors).
  • CI: Exact-head asahi (45155991058) & aurora-agent-policy (45155991163) PASS; Gate-3 clean (1/1 SOB, empty .github/ diff, agent-policy clean).

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

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.

2 participants