Skip to content

Commit

Permalink
Introduce MaterialX Benchmarks
Browse files Browse the repository at this point in the history
Adds a new benchmarking macro MATERIALX_BUILD_BENCHMARK_TESTS to enable GenShader Performance Tests using Catch2 Benchmarking system.
  • Loading branch information
ashwinbhat committed Oct 19, 2023
1 parent 9d3fda9 commit d801b8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ option(MATERIALX_BUILD_GEN_MSL "Build the MSL shader generator back-end." ON)
option(MATERIALX_BUILD_RENDER "Build the MaterialX Render modules." ON)
option(MATERIALX_BUILD_OIIO "Build OpenImageIO support for MaterialXRender." OFF)
option(MATERIALX_BUILD_TESTS "Build unit tests." ON)
option(MATERIALX_BUILD_BENCHMARK_TESTS "Build benchmark tests." OFF)

option(MATERIALX_BUILD_SHARED_LIBS "Build MaterialX libraries as shared rather than static." OFF)
option(MATERIALX_PYTHON_LTO "Enable link-time optimizations for MaterialX Python." ON)
Expand Down Expand Up @@ -131,6 +132,7 @@ mark_as_advanced(MATERIALX_BUILD_GEN_MSL)
mark_as_advanced(MATERIALX_BUILD_RENDER)
mark_as_advanced(MATERIALX_BUILD_OIIO)
mark_as_advanced(MATERIALX_BUILD_TESTS)
mark_as_advanced(MATERIALX_BUILD_BENCHMARK_TESTS)
mark_as_advanced(MATERIALX_BUILD_SHARED_LIBS)
mark_as_advanced(MATERIALX_NAMESPACE_SUFFIX)
mark_as_advanced(MATERIALX_LIBNAME_SUFFIX)
Expand Down Expand Up @@ -180,6 +182,9 @@ endif()
if (MATERIALX_DYNAMIC_ANALYSIS)
add_definitions(-DMATERIALX_DYNAMIC_ANALYSIS)
endif()
if (MATERIALX_BUILD_BENCHMARK_TESTS)
add_definitions(-DMATERIALX_BUILD_BENCHMARK_TESTS)
endif()

if (MATERIALX_BUILD_GEN_MDL)
add_definitions(-DMATERIALX_MDLC_EXECUTABLE=\"${MATERIALX_MDLC_EXECUTABLE}\")
Expand Down
6 changes: 3 additions & 3 deletions source/MaterialXTest/MaterialXGenGlsl/GenGlsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ TEST_CASE("GenShader: Bind Light Shaders", "[genglsl]")

TEST_CASE("GenShader: Performance Test", "[genglsl]")
{
#ifdef MATERIALX_DYNAMIC_ANALYSIS
SUCCEED("Skipping performance test in dynamic analysis build");
#else
#ifdef MATERIALX_BUILD_BENCHMARK_TESTS
mx::GenContext context(mx::GlslShaderGenerator::create());
BENCHMARK("Load documents, validate and generate shader")
{
return GenShaderUtil::shaderGenPerformanceTest(context);
};
#else
SUCCEED("Performance tests are disabled");
#endif
}

Expand Down

0 comments on commit d801b8a

Please sign in to comment.