Repository navigation
asahi/lib: add a declarative chip capability table - #824
Merged
Merged
Conversation
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
approved these changes
Nov 24, 2026
satchlj
left a comment
Member
There was a problem hiding this comment.
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 andAGX_CHIPSrow ordering insrc/asahi/lib/agx_chip.h: every chip row matches its existing predicate exactly, and unknown/out-of-range chips orcap == 0cleanly evaluate tofalse. AGX_CHIP_CAP_ROW_TESTexpands to pure comparisons (no static table indirection), preserving OpenCL precompiled-kernel compatibility matchingagx_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_extensionssmoke 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.has an included header was not exercised directly since no OpenCL kernel includes it yet.
Assisted-by: LLM (Google:Gemini 4 Neon)
Author
|
Merged into
Assisted-by: LLM (Google:Gemini 4 Neon) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
agx_chip.hdescribes 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 inAGX_CHIPSorder;agx_chip_has_cap(), which expands to comparisons likeagx_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:
AGX_CAP_NATIVE_INDIRECT_COMPUTEagx_chip_native_indirect_compute()AGX_CAP_NATIVE_IMAGEBLOCKagx_chip_native_imageblock()AGX_CAP_NATIVE_PREAMBLEagx_chip_native_preamble()AGX_CAP_ELIDE_APP_DISPATCH_BARRIERagx_chip_elide_app_dispatch_barrier()AGX_CAP_VDM_INDIRECT_INDEX_BOUNDSagx_chip_vdm_indirect_index_bounds()AGX_CAP_HW_TXF_BOUNDSagx_chip_hw_texel_fetch_bounds()AGX_CAP_TRI_MERGE_ACROSS_SIDE_EFFECTSagx_chip_tri_merge_across_side_effects()AGX_CAP_COOPERATIVE_MATRIXagx_chip_cooperative_matrix_supported()The new
asahi-agx-chip-capstest checks that:Only the test includes the new header, so no driver code changes.
agx_chip.his 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.-Wall -Wextra -Werror.src/.clang-format.-Db_ndebug=false, Gallium asahi and Vulkan asahi, withlibvulkan_asahi.soandlibasahi.arebuilt. 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)