Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions resources/Materials/TestSuite/_options.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,22 @@
Default is false to avoid overhead when not profiling.
-->
<input name="enableTracing" type="boolean" value="true" />

<!-- Number of frames to render per material for GPU timing.
Default is 1. Set higher (e.g., 5-10) for statistical validity.
First frame often includes driver shader compilation overhead;
use warm-up frame analysis to discard initial samples.
-->
<input name="framesPerMaterial" type="integer" value="1" />

<!-- envSampleCount (integer, default 1024):
Number of environment radiance samples for IBL lighting.
Lower values (1-16) are more representative of real-time
rendering and make shader complexity a larger fraction of
GPU time. When not set, enableReferenceQuality=true
overrides the default to 4096.
Uncomment to activate:
<input name="envSampleCount" type="integer" value="1024" />
-->
</nodedef>
</materialx>
24 changes: 24 additions & 0 deletions source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,8 @@ void TestSuiteOptions::print(std::ostream& output) const
output << "\tEnable Reference Quality: " << enableReferenceQuality << std::endl;
output << "\tOutput Directory: " << (outputDirectory.isEmpty() ? "(default)" : outputDirectory.asString()) << std::endl;
output << "\tEnable Tracing: " << enableTracing << std::endl;
output << "\tFrames Per Material: " << framesPerMaterial << std::endl;
output << "\tEnv Sample Count: " << envSampleCount << std::endl;
}

bool TestSuiteOptions::readOptions(const std::string& optionFile)
Expand Down Expand Up @@ -1033,6 +1035,8 @@ bool TestSuiteOptions::readOptions(const std::string& optionFile)
const std::string ENABLE_REFERENCE_QUALITY("enableReferenceQuality");
const std::string OUTPUT_DIRECTORY_STRING("outputDirectory");
const std::string ENABLE_TRACING_STRING("enableTracing");
const std::string FRAMES_PER_MATERIAL_STRING("framesPerMaterial");
const std::string ENV_SAMPLE_COUNT_STRING("envSampleCount");

overrideFiles.clear();
dumpGeneratedCode = false;
Expand All @@ -1041,6 +1045,8 @@ bool TestSuiteOptions::readOptions(const std::string& optionFile)
enableIndirectLighting = true;
enableReferenceQuality = false;

bool envSampleCountSet = false;

mx::DocumentPtr doc = mx::createDocument();
try
{
Expand Down Expand Up @@ -1148,10 +1154,28 @@ bool TestSuiteOptions::readOptions(const std::string& optionFile)
{
enableTracing = val->asA<bool>();
}
else if (name == FRAMES_PER_MATERIAL_STRING)
{
int frames = val->asA<int>();
framesPerMaterial = (frames >= 1) ? static_cast<unsigned int>(frames) : 1u;
}
else if (name == ENV_SAMPLE_COUNT_STRING)
{
int count = val->asA<int>();
envSampleCount = (count >= 1) ? count : 1024;
envSampleCountSet = true;
}
}
}
}

// If reference quality is enabled and envSampleCount wasn't explicitly
// overridden, use the higher sample count for reference-quality rendering.
if (enableReferenceQuality && !envSampleCountSet)
{
envSampleCount = 4096;
}

// Handle direct and indirect lighting toggles.
if (!enableDirectLighting)
{
Expand Down
9 changes: 9 additions & 0 deletions source/MaterialXTest/MaterialXGenShader/GenShaderUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ class TestSuiteOptions
// Default is false to avoid overhead when not profiling.
bool enableTracing = false;

// Number of frames to render per material for GPU timing.
// Default is 1. Set higher (e.g., 5-10) for statistical validity.
// First frame often includes driver shader compilation overhead.
unsigned int framesPerMaterial = 1;

// Number of environment radiance samples for IBL lighting.
// Default is 1024. Lower values (1-16) are more representative of real-time rendering.
int envSampleCount = 1024;

// Helper to resolve output path for an artifact.
// If outputDirectory is set, returns outputDirectory/filename.
// Otherwise returns the original path unchanged.
Expand Down
7 changes: 5 additions & 2 deletions source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void GlslShaderRenderTester::registerLights(mx::DocumentPtr document,
// Apply light settings for render tests.
_lightHandler->setEnvRadianceMap(envRadiance);
_lightHandler->setEnvIrradianceMap(envIrradiance);
_lightHandler->setEnvSampleCount(options.enableReferenceQuality ? 4096 : 1024);
_lightHandler->setEnvSampleCount(options.envSampleCount);
_lightHandler->setRefractionTwoSided(true);
}

Expand Down Expand Up @@ -356,7 +356,10 @@ 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();
for (unsigned int frame = 0; frame < testOptions.framesPerMaterial; frame++)
{
_renderer->render();
}
}

{
Expand Down
7 changes: 5 additions & 2 deletions source/MaterialXTest/MaterialXRenderMsl/RenderMsl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool runRenderer(const std::string& shaderName,
// Apply light settings for render tests.
_lightHandler->setEnvRadianceMap(envRadiance);
_lightHandler->setEnvIrradianceMap(envIrradiance);
_lightHandler->setEnvSampleCount(options.enableReferenceQuality ? 4096 : 1024);
_lightHandler->setEnvSampleCount(options.envSampleCount);
_lightHandler->setRefractionTwoSided(true);
}

Expand Down Expand Up @@ -357,7 +357,10 @@ bool 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();
for (unsigned int frame = 0; frame < testOptions.framesPerMaterial; frame++)
{
_renderer->render();
}
}

{
Expand Down
7 changes: 5 additions & 2 deletions source/MaterialXTest/MaterialXRenderSlang/RenderSlang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void SlangShaderRenderTester::registerLights(mx::DocumentPtr document,
// Apply light settings for render tests.
_lightHandler->setEnvRadianceMap(envRadiance);
_lightHandler->setEnvIrradianceMap(envIrradiance);
_lightHandler->setEnvSampleCount(options.enableReferenceQuality ? 4096 : 1024);
_lightHandler->setEnvSampleCount(options.envSampleCount);
_lightHandler->setRefractionTwoSided(true);
}

Expand Down Expand Up @@ -350,7 +350,10 @@ bool SlangShaderRenderTester::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();
for (unsigned int frame = 0; frame < testOptions.framesPerMaterial; frame++)
{
_renderer->render();
}
}

{
Expand Down
Loading