diff --git a/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp b/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp index 848348066c..6dc24fc15c 100644 --- a/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp +++ b/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp @@ -316,8 +316,7 @@ void testUniqueNames(mx::GenContext& context, const std::string& stage) void shaderGenPerformanceTest(mx::GenContext& context) { mx::DocumentPtr nodeLibrary = mx::createDocument(); - mx::FilePath currentPath = mx::FilePath::getCurrentPath(); - const mx::FileSearchPath libSearchPath(currentPath); + const mx::FileSearchPath libSearchPath(mx::getDefaultDataSearchPath()); // Load the standard libraries. loadLibraries({ "libraries" }, libSearchPath, nodeLibrary); @@ -351,8 +350,9 @@ void shaderGenPerformanceTest(mx::GenContext& context) } // Read mtlx documents + mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath(); mx::FilePathVec testRootPaths; - testRootPaths.push_back("resources/Materials/Examples/StandardSurface"); + testRootPaths.push_back(searchPath.find("resources/Materials/Examples/StandardSurface")); std::vector loadedDocuments; mx::StringVec documentsPaths; @@ -367,7 +367,7 @@ void shaderGenPerformanceTest(mx::GenContext& context) REQUIRE(loadedDocuments.size() > 0); REQUIRE(loadedDocuments.size() == documentsPaths.size()); - // Shuffle the order of documents and perform document library import validatation and shadergen + // Shuffle the order of documents and perform document library import validation and shadergen std::mt19937 rng(0); std::shuffle(loadedDocuments.begin(), loadedDocuments.end(), rng); for (const auto& doc : loadedDocuments) diff --git a/source/MaterialXTest/README.md b/source/MaterialXTest/README.md index 8cd732f2cf..6de3064ec8 100644 --- a/source/MaterialXTest/README.md +++ b/source/MaterialXTest/README.md @@ -82,3 +82,13 @@ When rendering tests are enabled through the `MATERIALX_TEST_RENDER` option, the #### HTML Render Comparisons - A `tests_to_html` Python script is provided in the [`python/MaterialXTest`](../../python/MaterialXTest) folder, which can be run to generate an HTML file comparing the rendered results in each shading language. - Example render comparisons may be found in [commits to the MaterialX repository](https://github.com/AcademySoftwareFoundation/MaterialX/pull/1164), and we encourage developers to post their own results when making changes that have the potential to impact generated shaders. + +#### Benchmark Tests + +Processing MaterialX documents and generating shaders is an integral part of many pipelines. MaterialX benchmark testing using [Catch2 benchmark framework](https://github.com/catchorg/Catch2/blob/devel/docs/benchmarks.md) and can be enabled using `MATERIALX_BUILD_BENCHMARK_TESTS` CMake macro. + +Here is an example of how to run the benchmark test + + `MaterialXTest.exe "GenShader: GLSL Performance Test" --benchmark-samples 10` + +This will iterate and gather 10 samples of the test case and report low, mean and high timing results.