Skip to content

asahi: ASAHI_MESA_DEBUG=stats: time every command and name each render pass - #419

Merged
RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/gl-stats-per-pass
Nov 19, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/gl-stats-per-pass

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 17, 2026 •

Copy link
Copy Markdown

stats printed vertex and fragment times per batch, but only when a timer query happened to request timestamps, and it didn't say which pass a batch was. With this:

  • every render and compute command gets timestamps while stats is on;
  • each completed command logs one AGXPROF line: start, GPU microseconds, framebuffer size, draw count, colour and depth/stencil formats, clear and load masks, and the source hash of the last fragment shader drawn (the first 4 bytes of shader_info::source_blake3, which match MESA_SHADER_DUMP_PATH file names);
  • the compute end timestamp goes to comp_end while stats is on, instead of overwriting comp_start.

With MESA_LOG_FILE, this gives a per-pass profile of a real game. It's how the texel-fetch cost in #417 showed up: three full-screen passes in a Minecraft shader pack took 43 % of the frame.

Benchmark

This is a debugging option and is off by default; without ASAHI_MESA_DEBUG=stats no code path changes, so there's no before/after to measure. With stats on, every command takes timestamps; that overhead wasn't measured.

Testing

On a MacBook Pro 16" M4 Max (J616C, T6041, 32-core GPU), GPU firmware 25G83, Linux 7.3 with the aurora-silicon GPU driver:

  • On our local branch (aurora-wip f22f090 plus local patches): a Sodium-style test prints one line per pass with plausible times. Minecraft with a shader pack produced a 38 MB log of about 350k commands that aggregated cleanly per frame.
  • This branch (aurora-wip db928e7 + this commit, tested as 68a7ce3, the same tree as 1b68358), release build: meson test --suite asahi 138 passed, 0 failed. sodiumpace ... game (100 frames, 3456x2234, source in asahi: compress private Z32F depth on G17P #418) with ASAHI_MESA_DEBUG=1queue,stats MESA_LOG_FILE=... logged 122 AGXPROF lines. 0 GPU recoveries.
Command and raw output (this branch, 17 Nov)
ASAHI_MESA_DEBUG=1queue,stats MESA_LOG_FILE=/tmp/prof.log \
  ./sodiumpace sodium.vert sodium.frag 4096 256 100 3456 2234 game
grep -c AGXPROF /tmp/prof.log
######## pr/gl-stats-per-pass 16:45:28
build ok
Ok:                138 
Fail:              0   
AGXPROF lines 122
MESA: warning: AGXPROF R start=6585295223791 us=51.1 512x512 draws=1 cb=r8g8b8a8_unorm zs=- clear=0 load=0 fs=3ba07db3
MESA: warning: AGXPROF R start=6585295275083 us=20.6 256x256 draws=1 cb=r8g8b8a8_unorm zs=- clear=0 load=0 fs=3ba07db3
recoveries new: 0

stats printed batch times only when a timer query had requested
timestamps, and did not say which pass a batch was. With stats on, give
every render and compute command timestamps, write the compute end to
comp_end, and log one AGXPROF line per command: GPU microseconds, size,
draw count, colour and depth/stencil formats, clear and load masks and the
last fragment shader's source hash (matching MESA_SHADER_DUMP_PATH names).
With MESA_LOG_FILE this is a per-pass profile of a real game.

Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown

Hardware test on an A18 Pro (G17P, J700), Fedora 45 arm64 release build, as a user-space overlay over Mesa 26.3.0-30 on kernel 7.3.0-40.

Arms: A = aurora-wip 57df4db. B = A + #417 #418 #419 #428 #429 #430 #435 at their current heads (one clean merge). Same machine, same boot.

  • deqp-vk, 575,809 cases (ray_query, ray_tracing_pipeline.misc, compute, copy_and_blit, glsl, subgroups, spirv compute, draw, renderpasses, query_pool, sync and more), case for case: A 319,552 Pass / 8 ResourceError, B 319,555 Pass / 5 ResourceError, rest NotSupported in both. 7 cases changed: 5 ResourceError->Pass and 2 Pass->ResourceError, all in copy_and_blit use_after_copy 1024x1024x2 msaa and ray_tracing_pipeline.misc.recursiveTraces_AABB, and those families flip both ways between arms. Each of the 7 run alone 3 times per arm: 42/42 Pass. No regression.
  • GLES2/3/31 + KHR-GL46 + KHR-GLES3, 106,812 cases: no new Fail. 3 flush_finish cases went Pass->CompatibilityWarning (a timing check, run with 4 jobs in parallel); all 5 flush_finish cases run alone 3 times per arm: 30/30 Pass.
  • dEQP-VK.wsi.wayland (4,028 cases), hardware and MESA_VK_WSI_DEBUG=sw paths: identical results in A and B.
  • glmark2 (1920x1080 offscreen, 12 scenes, interleaved runs gated on temperature): A 5018 mean (6 runs), B 6356 mean (4 runs), +27%. vkmark: A 8523, B 8577 (noise).
  • ASAHI_MESA_DEBUG=stats (asahi: ASAHI_MESA_DEBUG=stats: time every command and name each render pass #419) prints per-pass timing lines on glmark2 in B.
  • 0 GPU firmware crashes, 0 GPU timeouts, 0 new SELinux denials across the runs.

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