Test comparison tooling and extended tracing instrumentation#2774
Open
ppenenko wants to merge 17 commits intoAcademySoftwareFoundation:mainfrom
Open
Test comparison tooling and extended tracing instrumentation#2774ppenenko wants to merge 17 commits intoAcademySoftwareFoundation:mainfrom
ppenenko wants to merge 17 commits intoAcademySoftwareFoundation:mainfrom
Conversation
Add configurable environment radiance sample count to test suite options, allowing game-representative performance testing (1-16 samples) vs reference quality (1024+ samples). Lower sample counts make shader complexity a larger fraction of GPU time, enabling meaningful runtime performance comparisons.
Python package (MaterialXTest.diff_test_runs) with three comparison
scripts and shared reporting utilities:
diff_images.py -- perceptual image comparison via NVIDIA FLIP,
with HTML side-by-side reports
diff_traces.py -- Perfetto trace comparison with per-material
CPU slice and GPU render time analysis,
multiple --slice filters, --warmup-frames
burn-in, inline SVG charts
diff_shaders.py -- offline shader analysis (LOC, SPIR-V size,
compile time, spirv-opt time); auto-discovers
Vulkan SDK tools in PATH
_report.py -- shared comparison tables, SVG chart generation,
and HTML report builder
Declare the new test suite options so the C++ test runner can read them from the options file. Also reset enableTracing default to false (opt-in for profiling runs).
Added MX_TRACE markers to key codegen functions for profiling: - ShaderGraph: createConnectedNodes, addUpstreamDependencies, createNode - ShaderGenerator: getImplementation, emitFunctionDefinitions, emitFunctionCalls - CompoundNode: initialize, emitFunctionDefinition, emitFunctionCall
- Add GpuTimerQuery helper class and getCurrentTimeNs() for GPU timing via GL_TIME_ELAPSED queries (guarded by MATERIALX_BUILD_TRACING) - Add multi-frame render loop using framesPerMaterial for statistical validity, emitting MX_TRACE_ASYNC events on the GPU track - Replace stale Cat:: alias with mx::Tracing::Category:: (the alias was removed in PR AcademySoftwareFoundation#2742)
Shader codegen source files (ShaderGraph.cpp, ShaderGenerator.cpp, etc.) include MaterialXTrace/Tracing.h and use MX_TRACE macros. When Perfetto tracing is enabled, MaterialXGenShader needs to link against MaterialXTrace for the trace event symbols.
The CMake flag was renamed from MATERIALX_BUILD_TRACING to MATERIALX_BUILD_PERFETTO_TRACING in PR AcademySoftwareFoundation#2742. Update all #ifdef guards in RenderGlsl.cpp to match.
Port AsyncTrack enum, Sink::asyncEvent(), and MX_TRACE_ASYNC macro from the pre-merge proto2 branch. This enables GPU timer query results to be emitted as events on a dedicated "GPU" track in Perfetto traces. Use std::numeric_limits<uint64_t>::max() for the GPU track ID to guarantee no collision with OS thread IDs.
The previous commit accidentally set enableTracing to false, which would prevent CI from producing Perfetto traces. Restore to true to match the behavior established in PR AcademySoftwareFoundation#2742.
Without matplotlib, the HTML reports are generated with no charts, making them essentially empty. Fail early with a clear install message, consistent with how perfetto and pandas are handled.
ppenenko
commented
Feb 18, 2026
Comment on lines
+4
to
+15
| set(GENSHADER_MTLX_MODULES MaterialXFormat MaterialXCore) | ||
| if(MATERIALX_BUILD_PERFETTO_TRACING) | ||
| list(APPEND GENSHADER_MTLX_MODULES MaterialXTrace) | ||
| endif() | ||
|
|
||
| mx_add_library(MaterialXGenShader | ||
| SOURCE_FILES | ||
| ${materialx_source} | ||
| HEADER_FILES | ||
| ${materialx_headers} | ||
| MTLX_MODULES | ||
| MaterialXFormat | ||
| MaterialXCore | ||
| ${GENSHADER_MTLX_MODULES} |
Contributor
Author
There was a problem hiding this comment.
Adding the dependency to use instrumentation in this module.
Derive display labels from the actual directory names passed on the command line, matching the convention already used by diff_traces.py. Affects console output, HTML report title, and per-image labels. Assisted-by: Claude (Anthropic) via Cursor IDE Signed-off-by: Pavlo Penenko <pavlo.penenko@autodesk.com>
Use the shared openReport() from _report.py, matching the behavior already present in diff_traces.py and diff_shaders.py. Assisted-by: Claude (Anthropic) via Cursor IDE Signed-off-by: Pavlo Penenko <pavlo.penenko@autodesk.com>
Use the same relative/fallback import pattern as diff_traces.py and diff_shaders.py so the script works both as a package and standalone. Assisted-by: Claude (Anthropic) via Cursor IDE Signed-off-by: Pavlo Penenko <pavlo.penenko@autodesk.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds test suite options, extended Perfetto tracing instrumentation, and Python-based test comparison tooling to MaterialX, building on the tracing infrastructure from PR #2742.
1. Test suite options
New options in
_options.mtlxthat control how the render test suite collects performance data:envSampleCount: Configurable IBL sample count (default unchanged). Lower values (1–16) make shader complexity a larger fraction of GPU time, enabling game-representative performance comparisons.framesPerMaterial: Number of render iterations per material for GPU timing stability. Higher values (100s) yield statistically meaningful averages when combined with warm-up frame analysis.2. Extended tracing instrumentation (C++)
Building on the Perfetto tracing from #2742, this PR adds instrumentation to additional codegen and rendering hot paths. This also required conditionally linking
MaterialXTracetoMaterialXGenShader, which was not needed by #2742 (tracing was only in test code) but is now required for the new codegen instrumentation.Shader codegen:
ShaderGraphtraversal (createConnectedNodes,addUpstreamDependencies,createNode),ShaderGeneratoremit functions (emitFunctionDefinitions,emitFunctionCalls,getImplementation), andCompoundNodeoperationsGLSL build:
GlslProgram::build()andDumpGeneratedCodeGPU timing: New
MX_TRACE_ASYNCmacro andAsyncTrackinfrastructure for emitting GPU timer query results on a dedicated Perfetto track, enabling render-time-per-material analysisMulti-frame rendering: Uses the
framesPerMaterialoption (see above) for repeated renders with GL timer queries3. Python comparison scripts (
MaterialXTest.diff_test_runs)A new Python package under
python/MaterialXTest/diff_test_runs/provides three scripts for comparing pairs of MaterialX test suite output directories (baseline vs. optimized). The trace comparison script (diff_traces.py) consumes the Perfetto traces and GPU track events produced by the instrumentation above.diff_images.pydiff_traces.py--slicefilters,--warmup-framesburn-in period, inline SVG charts in HTML reports, e.g.diff_shaders.pyglslangValidatorcompile time,spirv-optoptimization time; auto-discovers Vulkan SDK tools inPATH, e.g._report.pyKey features of the scripts:
--min-delta-ms,--min-delta-pct) to focus on significant changes--warmup-frames) to discard initial GPU frames for more stable averagesMotivation
This tooling was developed to measure and validate shader generation optimizations (early lobe pruning, dead code elimination) in a companion branch. The infrastructure is generally useful for:
Test plan
diff_traces.pycorrectly processes Perfetto traces with CPU slices (GenerateShader,CompileShader, etc.) and GPU async track eventsdiff_images.pyproduces FLIP-based perceptual difference reportsdiff_shaders.pycompiles dumped GLSL to SPIR-V and reports LOC/size/timing deltasMATERIALX_BUILD_PERFETTO_TRACING=ONon Windows (MSVC)MATERIALX_BUILD_PERFETTO_TRACING=OFF(no-op macros, no link dependencies)Related