Goal
Quantitatively compare the stock MaterialX Standard Surface implementation (flattened nodegraph) against the Metashade reimplementation (factored BSDF function) across shader quality and performance metrics.
Background
The Metashade Standard Surface generates a standalone mx_metashade_standard_surface_bsdf function that is called twice (for INDIRECT and TRANSMISSION closure types), while the stock codegen flattens the entire nodegraph into the surfaceshader function, duplicating all BSDF node calls for each closure type. The Metashade approach also uses inline arithmetic instead of graph-level composition operators (mx_add_bsdf, mx_layer_bsdf, etc.).
We already have 171 comparable GLSL baselines committed in the repo:
- Stock:
contrib/renders/{aswf,adsk}/.../*_ps.glsl (186 files)
- Metashade:
contrib/tests/metashade_ref/renders/standard_surface/{aswf,adsk}/.../*_ps.glsl (66 files)
Phase 1: Offline shader analysis (no test run needed)
Run diff_shaders.py on the committed GLSL baselines:
python python/MaterialXTest/diff_test_runs/diff_shaders.py \
contrib/renders \
contrib/tests/metashade_ref/renders/standard_surface \
-o stock_vs_metashade.html
Metrics:
- LOC (non-blank lines) — built-in
- SPIR-V binary size — requires
glslangValidator in PATH
- SPIR-V compile time — requires
glslangValidator in PATH
- spirv-opt output size and time — requires
spirv-opt in PATH
These metrics are deterministic and cache-independent.
Phase 2: Runtime comparison via Python render tests
Use the existing Python render test infrastructure (test_render_metashade.py) to compare:
- GPU render time — via GL timer queries
- Online shader compilation time — via
glBuildProgram timing
- Rendered image quality — FLIP scores (already verified in render tests)
Open questions for Phase 2
- Perfetto tracing from Python: The
MaterialXTrace module is C++-only; no Python bindings exist for PerfettoSink/Dispatcher. Need to either expose tracing to Python or use time.perf_counter() as an alternative.
- Driver cache: GPU compilation time comparisons are only representative with an empty driver cache. A per-test-case cache purge would be ideal but is incompatible with xdist parallelism. Consider running sequentially for profiling runs.
- Codegen time: Can be measured at the Python level around
MaterialX.GenShader calls.
Related
Goal
Quantitatively compare the stock MaterialX Standard Surface implementation (flattened nodegraph) against the Metashade reimplementation (factored BSDF function) across shader quality and performance metrics.
Background
The Metashade Standard Surface generates a standalone
mx_metashade_standard_surface_bsdffunction that is called twice (for INDIRECT and TRANSMISSION closure types), while the stock codegen flattens the entire nodegraph into the surfaceshader function, duplicating all BSDF node calls for each closure type. The Metashade approach also uses inline arithmetic instead of graph-level composition operators (mx_add_bsdf,mx_layer_bsdf, etc.).We already have 171 comparable GLSL baselines committed in the repo:
contrib/renders/{aswf,adsk}/.../*_ps.glsl(186 files)contrib/tests/metashade_ref/renders/standard_surface/{aswf,adsk}/.../*_ps.glsl(66 files)Phase 1: Offline shader analysis (no test run needed)
Run
diff_shaders.pyon the committed GLSL baselines:python python/MaterialXTest/diff_test_runs/diff_shaders.py \ contrib/renders \ contrib/tests/metashade_ref/renders/standard_surface \ -o stock_vs_metashade.htmlMetrics:
glslangValidatorin PATHglslangValidatorin PATHspirv-optin PATHThese metrics are deterministic and cache-independent.
Phase 2: Runtime comparison via Python render tests
Use the existing Python render test infrastructure (
test_render_metashade.py) to compare:glBuildProgramtimingOpen questions for Phase 2
MaterialXTracemodule is C++-only; no Python bindings exist forPerfettoSink/Dispatcher. Need to either expose tracing to Python or usetime.perf_counter()as an alternative.MaterialX.GenShadercalls.Related