Skip to content

GPU async timing instrumentation via MX_TRACE_ASYNC#2824

Open
ppenenko wants to merge 2 commits intoAcademySoftwareFoundation:mainfrom
autodesk-forks:ppenenko/gpu_instrumentation
Open

GPU async timing instrumentation via MX_TRACE_ASYNC#2824
ppenenko wants to merge 2 commits intoAcademySoftwareFoundation:mainfrom
autodesk-forks:ppenenko/gpu_instrumentation

Conversation

@ppenenko
Copy link
Contributor

@ppenenko ppenenko commented Mar 13, 2026

Summary

Extends the MaterialXTrace API with support for async events with explicit timing, enabling GPU render-time-per-material analysis on a dedicated Perfetto track.

  • MX_TRACE_ASYNC macro: Records events with explicit start time and duration, rendered on a separate Perfetto track from the CPU thread slices
  • AsyncTrack enum: Identifies async tracks (currently GPU, extensible for future use cases like shader compilation)
  • Sink::asyncEvent(): New virtual method on the tracing sink interface, with a Perfetto implementation using custom track descriptors
  • GpuTimerQuery: Helper class wrapping GL_TIME_ELAPSED queries for measuring actual GPU execution time
  • Single-frame GPU timing: Wraps _renderer->render() with a timer query and emits the result as an async event

This enables visualizing GPU render time per material alongside CPU codegen/compilation traces in the Perfetto UI.

image

Test plan

  • Verified C++ build with MATERIALX_BUILD_PERFETTO_TRACING=ON on Windows (MSVC)
  • Verified C++ build with MATERIALX_BUILD_PERFETTO_TRACING=OFF (no-op macros)
  • Verified GPU async track events appear in Perfetto traces alongside CPU slices

Related


Assisted-by: Claude (Anthropic) via Cursor IDE
Signed-off-by: Pavlo Penenko <pavlo.penenko@autodesk.com>

New MX_TRACE_ASYNC macro and AsyncTrack infrastructure for emitting
GPU timer query results on a dedicated Perfetto track, enabling
per-material render time analysis.

- AsyncTrack enum and Sink::asyncEvent() in Tracing.h
- PerfettoSink implementation using custom track descriptors
- GpuTimerQuery helper class using GL_TIME_ELAPSED
- Single-frame GPU timing around _renderer->render()
@ppenenko ppenenko marked this pull request as ready for review March 20, 2026 19:26
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.

1 participant