Repository navigation
asahi: add parallel asynchronous shader compilation - #894
Conversation
3669872 to
a44fe64
Compare
26f6ce1 to
be4cf47
Compare
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>
a44fe64 to
c08a129
Compare
joshuaswarren
left a comment
There was a problem hiding this comment.
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.
|
Merged onto Assisted-by: LLM (Google:Gemini 4 Neon) |
Summary
Adds parallel asynchronous shader compilation to Gallium Asahi via
util_queueworker threads, reducing main-thread shader-compile stalls and improving pipeline creation throughput underu_threaded_context.Verification
git diff --check: clean.G16G B0,26B123) silicon:gpubench:gl-nativecompile.pso6.09×(compute) /5.45×(uber) /2.59×(graphics); overallgl-native70/70 PASS (1.100×vs Metal 4, up from1.019×); full suite 440/440 PASS (0faults,0bad CRCs).KHR-GL46.parallel_shader_compile.*3/3 PASS.Assisted-by: LLM (Antigravity)