Skip to content

asahi: add parallel asynchronous shader compilation - #894

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/asahi-parallel-async-shader-compile
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/asahi-parallel-async-shader-compile

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Summary

Adds parallel asynchronous shader compilation to Gallium Asahi via util_queue worker threads, reducing main-thread shader-compile stalls and improving pipeline creation throughput under u_threaded_context.

Verification

  • git diff --check: clean.
  • Live Apple M4 (G16G B0, 26B123) silicon:
    • gpubench: gl-native compile.pso 6.09× (compute) / 5.45× (uber) / 2.59× (graphics); overall gl-native 70/70 PASS (1.100× vs Metal 4, up from 1.019×); full suite 440/440 PASS (0 faults, 0 bad CRCs).
    • OpenGL CTS: KHR-GL46.parallel_shader_compile.* 3/3 PASS.

Assisted-by: LLM (Antigravity)

@DjDeveloperr
DjDeveloperr force-pushed the djdev/asahi-parallel-async-shader-compile branch 2 times, most recently from 3669872 to a44fe64 Compare November 24, 2026 07:27
@DjDeveloperr
DjDeveloperr force-pushed the djdev/pr-asahi-tc-flush-sync branch 2 times, most recently from 26f6ce1 to be4cf47 Compare November 24, 2026 08:20
Add a screen-wide shader compiler thread pool (util_queue) and wire
pipe_screen::set_max_shader_compiler_threads and
pipe_screen::is_parallel_shader_compilation_finished so OpenGL
applications and st/mesa can compile and link programs asynchronously
(GL_ARB_parallel_shader_compile).

Offload NIR initialization (agx_shader_initialize) and default-variant
precompilation for both graphics and compute CSOs to the worker pool,
synchronizing on first draw, compute dispatch, compute state info
query, debug-callback change, or shader teardown (with job cancellation
and drop on early destroy). Keep compilation synchronous when
G18G requests link-time refusal reporting, when a synchronous GL debug
callback is installed, or when shader-dump/precompile debug flags are
enabled.

While wiring precompilation, fix two pre-existing redundant-compile
bugs:
- Key precompiled single-sample fragment variants with nr_samples = 1
  when agx_update_fs() keys nr_samples (native AGX3, M5, G18G, or
  sample-dependent shaders), avoiding an immediate cache miss and
  synchronous recompile on the first 1x draw.
- Look up uncompiled->variants in agx_get_compute_state_info() before
  falling back to agx_get_shader_variant().

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/asahi-parallel-async-shader-compile branch from a44fe64 to c08a129 Compare November 24, 2026 08:20
@DjDeveloperr
DjDeveloperr changed the base branch from djdev/pr-asahi-tc-flush-sync to aurora-wip November 24, 2026 09:04

@joshuaswarren joshuaswarren left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVED at c08a129 — parallel async shader compilation (shared AGX2 Gallium).

Source audit: standard util_queue async-compile pattern (same shape as radeonsi/iris). The one edge I went looking for checks out: util_queue_fence_init sets val=0 = already-signalled (src/util/u_queue.h), so sync-path shaders can't hang agx_shader_wait_ready and is_parallel_shader_compilation_finished reads true immediately. Draw-path variant misses recompile from serialized NIR correctly.

Hardware evidence (exact head c08a129, vs base be4cf47):

  • Release cross-build clean on x86_64 host (clang-19 + M1 sysroot).
  • asahi suite on M1 Max (G13C): 211/211 targets pass (binaries run directly — meson's runner self-skips cross-built binaries without an exe_wrapper; xmlconfig/process tests need meson's per-test env; symbol checks need meson's per-test workdir).
  • dEQP-VK.compute.* full set, 13,781 cases each arm, both laptops:
    • M1 (T8103, 13-inch): 0 per-case status diffs (10,759 Pass / 3,022 NotSupported, identical mix)
    • M1 Max (T6001, 16-inch): 0 per-case status diffs (10,759 Pass / 3,022 NotSupported, identical mix)
  • GL smoke: glmark2-es2-wayland under the PR's own gallium build (glvnd vendor-forced, GL_RENDERER "Apple M1 Max (G13C C0)", "OpenGL ES 3.2 Mesa 26.3.0-devel") — build/texture/shading ~1800 FPS, score 1837, no wedge, on a live Hyprland session.

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

Copy link
Copy Markdown
Author

Merged onto aurora-wip at b047578b8ced after exact-head @joshuaswarren approval (source audit, M1/M1 Max dEQP-VK.compute.* 13,781 cases with 0 diffs, 211/211 asahi targets, live GLES 3.2 smoke), exact-head mirror asahi CI pass (45355308692), and commit/policy checks.

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

@RyanTheTide
RyanTheTide deleted the djdev/asahi-parallel-async-shader-compile 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.

2 participants