Repository navigation
asahi: enable native AGX3 compute constant programs and persistent compute BOs - #895
Conversation
G17P B1 verification: base
|
| test | base (µs/submit) | head (µs/submit) | change |
|---|---|---|---|
compute.heavy kind=alu |
1476.0 / 1470.6 | 1384.1 / 1384.1 | −6.06% |
compute.uber kind=divergent |
1261.8 / 1261.8 | 1253.9 / 1257.9 | −0.47% |
compute.uber kind=uniform |
504.4 / 504.4 | 504.4 / 501.3 | −0.31% |
compute.light |
103.3 / 102.5 | 102.7 / 102.6 | −0.22% |
compute.image res=1080p |
264.2 / 259.1 | 263.2 / 264.7 | +0.88% |
compute.heavyandcompute.uber divergent: the base and head runs don't overlap.- The other three are within run-to-run spread.
GLES 3.1 CTS (aosp gles31-main, EGL pbuffer, head): dEQP-GLES31.functional.compute.*.
- 194 cases: 194 pass, 0 fail.
Kernel log over the run: 0 new GPU faults, 0 fault-pattern lines.
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf.
Reviewed exact head adc415a279480909a04f2b44dac9b6a13bf41b02 with an isolated Gallium Asahi build and runtime verification on J775c (Apple M5 Max / G17C B1, kernel 7.3.0-lobata-j775c+).
Blocking finding
agx_mip_filter_from_sampler_state()dropsmip_filtertoAGX_MIP_FILTER_NONEontextureQueryLodacross G15, AGX2, G18G, and M5 — and does not match Borealis:agx_mip_filter_from_sampler_state()(src/gallium/drivers/asahi/agx_state.c:596-604) rewritesPIPE_TEX_MIPFILTER_NEARESTwithmin_lod == 0.0f && max_lod == 0.0f && lod_bias == 0.0ftoAGX_MIP_FILTER_NONEacross all four sampler packing sites (agx_create_sampler_state()at line697,agx_pack_g17_api_sampler()at lines6298and6327, andagx_native_sampler_state()at line6356).- In
agx_upload_samplers(), thetextureQueryLodcompanion bank only restorescfg.mip_filter = agx_mip_filter_from_pipe(sampler->base.min_mip_filter)(agx_state.c:6524-6525) inside theSAMPLER_HAL200path (agx_chip_sampler_has_lod_bias(dev->chip)—G16G/G17P). Every other chip family retainsAGX_MIP_FILTER_NONEfor LOD queries:- G15 (
M3/ Gen4):agx_state.c:6519-6522takes the!agx_chip_sampler_has_lod_bias(dev->chip)earlymemcpy(query, ordinary, sampler_length); continue;, copyingAGX_MIP_FILTER_NONEstraight into thequery_lodbank without restoringmip_filter. - AGX2 (
G13/G14):agx_create_sampler_state()(agx_state.c:697) packsAGX_MIP_FILTER_NONEintoso->desc, and AGX2 has no separatequery_lodbank (agx_state.c:6595-6626copiessampler->descdirectly). - M5 (
G17G/G17S/G17C) and G18G:agx_pack_g17_api_sampler()(agx_state.c:6298) packsAGX_MIP_FILTER_NONEintoSAMPLER_GEN5, and neither path has aquery_lodcompanion bank (agx_state.c:6537,agx_nir_lower_bindings.c:460).
- G15 (
- Both the commit message and
agx_state.c:593justify this rewrite as "Match Borealis native sampler packing", but Borealis never emitsAGX_MIP_FILTER_NONE(src/asahi/vulkan/hk_sampler.c:69-79,183mapsVK_SAMPLER_MIPMAP_MODE_NEARESTunconditionally toAGX_MIP_FILTER_NEAREST, andsrc/asahi/vulkan/hk_native_sampler.c:72,93,115forwardsstate->mip_filterverbatim). - Suggested fix: Either drop the
AGX_MIP_FILTER_NONErewrite (matching Borealis and avoidingtextureQueryLodregressions on G15/AGX2/G18G/M5), or restrict it strictly to chips that populate a dedicatedquery_lodcompanion bank and also restoreagx_mip_filter_from_pipe()in the!agx_chip_sampler_has_lod_biasG15 branch (agx_state.c:6519-6522), leaving AGX2/G18G/M5 untouched.
Non-blocking note
- The commit message describes native compute constant programs as enabled on
G16G/G17P, whereasagx_chip_native_preamble()(AGX_QUIRK_NATIVE_PREAMBLE) is currentlyG17P-only (src/asahi/lib/tests/test-chip.c:159); persistentagx3_compute_boapplies across allagx_chip_native_agx3()chips (G15G/G15S/G15C/G16G/G17P). - Persistent
cs->agx3_compute_bolifetime, BO flags (AGX_BO_EXEC | AGX_BO_LOW_VA), cache sync (agx_bo_assert_range), batch retention (agx_batch_add_bofor bothcs->agx3_compute_boandconstant_bo), and teardown (agx_delete_compiled_shader) audited clean.
Verification performed on J775c (M5 Max / G17C B1, 7.3.0-lobata-j775c+, head adc415a279480909a04f2b44dac9b6a13bf41b02)
- Isolated Gallium build (
build-gallium):1884/1884(rc=0); verifiedeglinfo -BloadedOpenGL 4.6 (Core Profile) Mesa 26.3.0-devel (git-adc415a279)/OpenGL ES 3.2 Mesa 26.3.0-devel (git-adc415a279)onApple M5 Max (G17C B1). - Unit tests:
meson test -C build-gallium --suite asahi --print-errorlogs: 100/100 PASS (0 fail)src/gallium/drivers/asahi/asahi-native-descriptor: 468 checks passed
- Runtime CTS (
EGL_PLATFORM=surfaceless,--deqp-surface-type=fbo --deqp-surface-width=256 --deqp-surface-height=256,MESA_SHADER_CACHE_DISABLE=1):deqp-gles31dEQP-GLES31.functional.compute.basic.*: 41/41 PASS (0 fail)deqp-gles31dEQP-GLES31.functional.compute.shared_var.*: 136/136 PASS (0 fail)deqp-gles31dEQP-GLES31.functional.compute.indirect_dispatch.*: 18/18 PASS (0 fail)deqp-gles3dEQP-GLES3.functional.texture.mipmap.2d.basic.nearest_nearest*: 9/9 PASS (0 fail)deqp-gles3dEQP-GLES3.functional.texture.mipmap.2d.*_lod.*: 8/8 PASS (0 fail)deqp-gles3dEQP-GLES3.functional.texture.filtering.2d.sizes.*: 36/36 PASS (0 fail)deqp-gles3dEQP-GLES3.functional.texture.mipmap.2d.base_level.*: 4/4 PASS (0 fail)
- Kernel log (
dmesg): 0err,crit,alert,emergentries and 0 GPU faults/timeouts/resets. - Untested scope: On
J775c(G17C),agx_g17p_append_compute()takes the earlyif (g17g)branch andagx_chip_native_preamble(G17C)is false, so theG17Pcompute constant program (cs_cprog) and persistentagx3_compute_bopaths were verified by code audit and host unit tests (100/100), not executed live onG16G/G17Phardware. EmpiricaltextureQueryLodexecution onG17CGallium is also currently blocked byagx3_pack_binary.c:4578(texture operand gate), so thetextureQueryLodsampler defect is established by code inspection.
Assisted-by: LLM (Google:Gemini 4 Neon)
adc415a to
535d252
Compare
|
Thanks @satchlj for the review. Both findings are fixed in new head 1.
Sampler packing is now byte-identical to base on every chip, including G13/G14, G15, G16G, G17P, M5 and G18G. That matches Borealis, which maps NEAREST to 2. Commit message scope (non-blocking). The commit message, the PR description and the
No gating changed. The M4 numbers in the description are marked as measured on Checks on
Assisted-by: LLM (Claude:Opus 5.5) |
…mpute BOs Bring Gallium Asahi's native AGX3 compute path closer to Borealis: - On chips with a native preamble (agx_chip_native_preamble(), currently G17P only), compile non-internal compute shaders with a native constant program (agx3_native_cprog + g17p_native_uniforms), gated by agx_g17p_cs_cprog_qualified() with automatic fallback to no-preamble compilation when the launch contract is not met. Emit the external constant program and TPS input metadata in agx_g17p_append_compute(), hoisting UBO/SSBO parameter loads out of every compute thread. - On every native AGX3 chip (agx_chip_native_agx3(): G15G/G15S/G15C, G16G and G17P), cache the compute code container in a persistent executable BO on agx_compiled_shader (agx3_compute_bo) instead of reallocating and copying the shader binary into batch->pipeline_pool at a fresh GPU VA on every glDispatchCompute(), preserving USC instruction-cache locality and eliminating per-dispatch copy overhead. Signed-off-by: Diljit Singh <hey@djdev.me>
535d252 to
97b9230
Compare
|
I rebased this onto #895's own changes, including the post-review fix, are unchanged. The only conflict was in
Checks on
Assisted-by: LLM (Claude:Opus 5.5) |
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf.
Re-reviewed exact head 535d252358e04d1be84f65ed72a3bd471aab0e77 (asahi: enable native AGX3 compute constant programs and persistent compute BOs) on J775c (Apple M5 Max, G17C B1, kernel 7.3.0-lobata-j775c+).
Findings
- The previously flagged
AGX_MIP_FILTER_NONE/textureQueryLodcommit has been dropped; the PR is now scoped cleanly to the native AGX3 compute constant-program and persistentcs->agx3_compute_bochange inagx_state.c/agx_state.h. - Verified
agx_g17p_cs_cprog_qualified()gating (agx_chip_native_agx3(dev->chip) && agx_chip_native_preamble(dev->chip)),cs->agx3_compute_bolifecycle and cleanup inagx_delete_compiled_shader(),shader_boNULL handling whencs_cprogis active, and batch BO residency (agx_g17p_append_compute()pinscs->agx3_compute_bo,constant_bo/cs->bo, andlinked->bo). - Note: GitHub currently reports this PR as
CONFLICTINGagainst currentaurora-wip, so it will need a rebase before landing.
Verification (isolated build, no system Mesa install)
- Build:
ninja -C build-b4(Gallium Asahi + Borealis Vulkan + Zink + tests) — clean (0errors). - Unit tests:
meson test -C build-b4 --suite asahi --print-errorlogs— 165/165 PASS. - Runtime sanity (J775c / G17C B1, isolated
LIBGL_DRIVERS_PATH/LD_LIBRARY_PATH):eglinfo -B: confirmedApple M5 Max (G17C B1),OpenGL 4.6 (Core Profile) Mesa 26.3.0-devel (git-535d252358).deqp-gles3 --deqp-case="dEQP-GLES3.functional.fragment_ops.interaction.*": 100/100 PASS.dmesg:0GPU faults/hangs/errors.
- Untested scope: G17P/G16G live compute constant-program execution is not directly exercised on G17C (M5 Max), as
agx_chip_native_preamble()is false on M5; verified via code inspection + unit test suite + G17C regression sanity.
Assisted-by: LLM (Google:Gemini 4 Neon)
|
Merged onto Assisted-by: LLM (Google:Gemini 4 Neon) |
Summary
Brings Gallium Asahi's native AGX3 compute path closer to Borealis:
agx_chip_native_preamble(), currently G17P only): compiles non-internal native AGX3 compute shaders withagx3_native_cprog+g17p_native_uniforms, gated byagx_g17p_cs_cprog_qualified()with automatic fallback to no-preamble compilation when the launch contract is not met. Emits external constant program and TPS input metadata inagx_g17p_append_compute(), hoisting UBO/SSBO parameter loads out of every compute thread.agx3_compute_bo, everyagx_chip_native_agx3()chip: G15G/G15S/G15C, G16G, G17P): caches the AGX3 compute code container in a persistent executable BO onagx_compiled_shaderinstead of reallocating and copying the shader binary intobatch->pipeline_poolat a fresh GPU VA on everyglDispatchCompute(), preserving USC instruction-cache locality and eliminating per-dispatch copy overhead.AGX_MIP_FILTER_NONE; that was dropped because Borealis never emits it and it broketextureQueryLodon chips without a HAL200 query_lod bank.Verification
git diff --check: clean.G16G B0,26B123) silicon (measured on the earlier revisionadc415a2, which still had the dropped sampler change; G16G gets the persistent compute BO, not compute cprog):gpubench:gl-nativecompute.heavy alu+3.6%; overallgl-native70/70 PASS (1.100×vs Metal 4, up from1.019×); full suite 440/440 PASS (0faults,0bad CRCs).KHR-GL46.compute_shader.*: 42/42 PASSKHR-GL46.texture_query_lod.*: 3/3 PASSAssisted-by: LLM (Antigravity)
Assisted-by: LLM (Claude:Opus 5.5)