Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2bebc60
Instrument `GlslProgram::build`
ppenenko Feb 9, 2026
6952584
Instrument `DumpGeneratedCode`
ppenenko Feb 9, 2026
246891c
Expose envSampleCount option in MaterialXTest for IBL sampling control
ppenenko Feb 6, 2026
8db8118
Add diff_test_runs package for comparing MaterialX test outputs
ppenenko Feb 13, 2026
d90ca04
Add framesPerMaterial and envSampleCount to _options.mtlx
ppenenko Feb 13, 2026
f50206f
Additional tracing markers in shader codegen
ppenenko Jan 28, 2026
07778a5
Add trace markers for emit and graph traversal functions
ppenenko Jan 30, 2026
a835eb6
Add GPU timing infrastructure and fix trace aliases in RenderGlsl.cpp
ppenenko Feb 13, 2026
fda5a18
Link MaterialXTrace to MaterialXGenShader when tracing is enabled
ppenenko Feb 13, 2026
0d253c2
Use MATERIALX_BUILD_PERFETTO_TRACING in RenderGlsl.cpp
ppenenko Feb 13, 2026
9e30232
Fix `MATERIALX_BUILD_PERFETTO_TRACING` in an XML comment
ppenenko Feb 13, 2026
611abfb
Add async event support for GPU timing in MaterialXTrace
ppenenko Feb 13, 2026
80209aa
Fix enableTracing default to true for CI trace generation
ppenenko Feb 13, 2026
99cbead
Make matplotlib a hard requirement for diff_test_runs reports
ppenenko Feb 17, 2026
846cdbd
Use directory names instead of Baseline/Optimized in diff_images.py
ppenenko Feb 18, 2026
6bcd9f6
Auto-open HTML report in diff_images.py
ppenenko Feb 18, 2026
c097db3
Fix _report import in diff_images.py to use try/except pattern
ppenenko Feb 18, 2026
b2456c4
Revert Python comparison scripts
ppenenko Mar 12, 2026
c66aaf9
Revert test suite options and reset unrelated UiNode changes
ppenenko Mar 12, 2026
72cb1af
Merge remote-tracking branch 'origin/main' into ppenenko/cpp_instrume…
ppenenko Mar 13, 2026
8d36921
Extract GPU/async instrumentation to a separate PR
ppenenko Mar 13, 2026
f7aab05
Merge branch 'main' into ppenenko/cpp_instrumentation
jstone-lucasfilm Apr 1, 2026
776ebba
Merge branch 'main' into ppenenko/cpp_instrumentation
jstone-lucasfilm Apr 1, 2026
e98bd58
Add newline for consistency
jstone-lucasfilm Apr 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/Materials/TestSuite/_options.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
-->
<input name="outputDirectory" type="string" value="" />

<!-- Enable Perfetto tracing during render tests (requires MATERIALX_BUILD_TRACING).
<!-- Enable Perfetto tracing during render tests (requires MATERIALX_BUILD_PERFETTO_TRACING).
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just fixing an oversight from #2774: we renamed this setting as part of the code review.

When enabled, generates .perfetto-trace files in outputDirectory.
Default is false to avoid overhead when not profiling.
-->
Expand Down
5 changes: 5 additions & 0 deletions source/MaterialXGenGlsl/GlslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <MaterialXGenShader/Shader.h>
#include <MaterialXGenShader/Nodes/MaterialNode.h>

#include <MaterialXTrace/Tracing.h>

MATERIALX_NAMESPACE_BEGIN

const string GlslShaderGenerator::TARGET = "genglsl";
Expand Down Expand Up @@ -128,6 +130,9 @@ GlslShaderGenerator::GlslShaderGenerator(TypeSystemPtr typeSystem) :

ShaderPtr GlslShaderGenerator::generate(const string& name, ElementPtr element, GenContext& context) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, name.c_str());

ShaderPtr shader = createShader(name, element, context);

// Request fixed floating-point notation for consistency across targets.
Expand Down
5 changes: 5 additions & 0 deletions source/MaterialXGenHw/HwShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <MaterialXCore/Definition.h>
#include <MaterialXCore/Document.h>

#include <MaterialXTrace/Tracing.h>

MATERIALX_NAMESPACE_BEGIN

//
Expand Down Expand Up @@ -97,6 +99,9 @@ void HwShaderGenerator::applyDefaultOptions(GenOptions& options) const

ShaderPtr HwShaderGenerator::createShader(const string& name, ElementPtr element, GenContext& context) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, name.c_str());

// Create the root shader graph
ShaderGraphPtr graph = ShaderGraph::create(nullptr, name, element, context);
ShaderPtr shader = std::make_shared<Shader>(name, graph);
Expand Down
8 changes: 6 additions & 2 deletions source/MaterialXGenShader/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
file(GLOB_RECURSE materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB_RECURSE materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")

set(GENSHADER_MTLX_MODULES MaterialXFormat MaterialXCore)
if(MATERIALX_BUILD_PERFETTO_TRACING)
list(APPEND GENSHADER_MTLX_MODULES MaterialXTrace)
endif()
Comment on lines +4 to +7
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional dependency on tracing - zero overhead if disabled. If enabled, this wouldn't create any additional linking dependencies for MaterialX's consumers because Perfetto is compiled into MaterialXTrace.


mx_add_library(MaterialXGenShader
SOURCE_FILES
${materialx_source}
HEADER_FILES
${materialx_headers}
MTLX_MODULES
MaterialXFormat
MaterialXCore
${GENSHADER_MTLX_MODULES}
EXPORT_DEFINE
MATERIALX_GENSHADER_EXPORTS)

Expand Down
11 changes: 11 additions & 0 deletions source/MaterialXGenShader/Nodes/CompoundNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <MaterialXCore/Document.h>
#include <MaterialXCore/Library.h>

#include <MaterialXTrace/Tracing.h>

MATERIALX_NAMESPACE_BEGIN

ShaderNodeImplPtr CompoundNode::create()
Expand All @@ -27,6 +29,9 @@ void CompoundNode::addClassification(ShaderNode& node) const

void CompoundNode::initialize(const InterfaceElement& element, GenContext& context)
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, element.getName().c_str());

ShaderNodeImpl::initialize(element, context);

if (!element.isA<NodeGraph>())
Expand Down Expand Up @@ -62,6 +67,9 @@ void CompoundNode::createVariables(const ShaderNode&, GenContext& context, Shade

void CompoundNode::emitFunctionDefinition(const ShaderNode& node, GenContext& context, ShaderStage& stage) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, _functionName.c_str());

DEFINE_SHADER_STAGE(stage, Stage::PIXEL)
{
const ShaderGenerator& shadergen = context.getShaderGenerator();
Expand Down Expand Up @@ -148,6 +156,9 @@ void CompoundNode::emitFunctionDefinition(const ShaderNode& node, GenContext& co

void CompoundNode::emitFunctionCall(const ShaderNode& node, GenContext& context, ShaderStage& stage) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, _functionName.c_str());

const ShaderGenerator& shadergen = context.getShaderGenerator();

DEFINE_SHADER_STAGE(stage, Stage::VERTEX)
Expand Down
11 changes: 11 additions & 0 deletions source/MaterialXGenShader/ShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <MaterialXCore/Node.h>
#include <MaterialXCore/Value.h>

#include <MaterialXTrace/Tracing.h>

#include <sstream>

MATERIALX_NAMESPACE_BEGIN
Expand Down Expand Up @@ -116,6 +118,9 @@ void ShaderGenerator::emitFunctionDefinitionParameter(const ShaderPort* shaderPo

void ShaderGenerator::emitFunctionDefinitions(const ShaderGraph& graph, GenContext& context, ShaderStage& stage) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, graph.getName().c_str());

// Emit function definitions for all nodes in the graph.
for (ShaderNode* node : graph.getNodes())
{
Expand All @@ -140,6 +145,9 @@ void ShaderGenerator::emitFunctionCall(const ShaderNode& node, GenContext& conte

void ShaderGenerator::emitFunctionCalls(const ShaderGraph& graph, GenContext& context, ShaderStage& stage, uint32_t classification) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, graph.getName().c_str());

for (ShaderNode* node : graph.getNodes())
{
if (!classification || node->hasClassification(classification))
Expand Down Expand Up @@ -307,6 +315,9 @@ ShaderNodeImplPtr ShaderGenerator::createShaderNodeImplForImplementation(const I

ShaderNodeImplPtr ShaderGenerator::getImplementation(const NodeDef& nodedef, GenContext& context) const
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, nodedef.getName().c_str());

InterfaceElementPtr implElement = nodedef.getImplementation(getTarget());
if (!implElement)
{
Expand Down
10 changes: 10 additions & 0 deletions source/MaterialXGenShader/ShaderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <MaterialXGenShader/ShaderGraphRefactor.h>
#include <MaterialXGenShader/Util.h>

#include <MaterialXTrace/Tracing.h>

#include <iostream>
#include <queue>

Expand Down Expand Up @@ -79,6 +81,8 @@ void ShaderGraph::createConnectedNodes(const ElementPtr& downstreamElement,
ElementPtr connectingElement,
GenContext& context)
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);

// Create the node if it doesn't exist.
NodePtr upstreamNode = upstreamElement->asA<Node>();
if (!upstreamNode)
Expand Down Expand Up @@ -170,6 +174,9 @@ void ShaderGraph::createConnectedNodes(const ElementPtr& downstreamElement,

void ShaderGraph::addUpstreamDependencies(const Element& root, GenContext& context)
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, root.getName().c_str());

std::set<ElementPtr> processedOutputs;

for (Edge edge : root.traverseGraph())
Expand Down Expand Up @@ -698,6 +705,9 @@ void ShaderGraph::applyInputTransforms(ConstNodePtr node, ShaderNode* shaderNode

ShaderNode* ShaderGraph::createNode(const string& name, const string& uniqueId, ConstNodeDefPtr nodeDef, GenContext& context)
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, name.c_str());

if (!nodeDef)
{
throw ExceptionShaderGenError("Could not find a nodedef for node '" + name + "'");
Expand Down
5 changes: 5 additions & 0 deletions source/MaterialXGenShader/ShaderNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <MaterialXGenShader/GenContext.h>
#include <MaterialXGenShader/Util.h>

#include <MaterialXTrace/Tracing.h>

MATERIALX_NAMESPACE_BEGIN

const string ShaderMetadataRegistry::USER_DATA_NAME = "ShaderMetadataRegistry";
Expand Down Expand Up @@ -172,6 +174,9 @@ ShaderNode::ShaderNode(const ShaderGraph* parent, const string& name) :

ShaderNodePtr ShaderNode::create(const ShaderGraph* parent, const string& name, const NodeDef& nodeDef, GenContext& context)
{
MX_TRACE_FUNCTION(Tracing::Category::ShaderGen);
MX_TRACE_SCOPE(Tracing::Category::ShaderGen, name.c_str());

ShaderNodePtr newNode = std::make_shared<ShaderNode>(parent, name);

const ShaderGenerator& shadergen = context.getShaderGenerator();
Expand Down
4 changes: 4 additions & 0 deletions source/MaterialXRenderGlsl/GlslProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <MaterialXGenHw/HwConstants.h>

#include <MaterialXTrace/Tracing.h>

#include <iostream>

MATERIALX_NAMESPACE_BEGIN
Expand Down Expand Up @@ -82,6 +84,8 @@ const string& GlslProgram::getStageSourceCode(const string& stage) const

void GlslProgram::build()
{
MX_TRACE_FUNCTION(Tracing::Category::Render);

clearBuiltData();

GLint glStatus = GL_FALSE;
Expand Down
4 changes: 4 additions & 0 deletions source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ bool GlslShaderRenderTester::runRenderer(const std::string& shaderName,

if (testOptions.dumpGeneratedCode)
{
MX_TRACE_SCOPE(mx::Tracing::Category::Render, "DumpGeneratedCode");
mx::ScopedTimer dumpTimer(&profileTimes.languageTimes.ioTime);
std::ofstream file;
file.open(shaderPath + "_vs.glsl");
Expand Down Expand Up @@ -291,6 +292,7 @@ bool GlslShaderRenderTester::runRenderer(const std::string& shaderName,

if (testOptions.dumpUniformsAndAttributes)
{
MX_TRACE_SCOPE(mx::Tracing::Category::Render, "DumpUniformsAndAttributes");
mx::ScopedTimer printTimer(&profileTimes.languageTimes.ioTime);
log << "* Uniform:" << std::endl;
program->printUniforms(log);
Expand Down Expand Up @@ -356,10 +358,12 @@ bool GlslShaderRenderTester::runRenderer(const std::string& shaderName,
unsigned int width = (unsigned int) testOptions.renderSize[0] * supersampleFactor;
unsigned int height = (unsigned int) testOptions.renderSize[1] * supersampleFactor;
_renderer->setSize(width, height);

_renderer->render();
}

{
MX_TRACE_SCOPE(mx::Tracing::Category::Render, "CaptureAndSaveImage");
mx::ScopedTimer ioTimer(&profileTimes.languageTimes.imageSaveTime);
std::string fileName = shaderPath + "_glsl.png";
mx::ImagePtr image = _renderer->captureImage();
Expand Down
Loading