Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ jobs:
- name: Install MDL SDK
if: env.IS_EXTENDED_BUILD == 'true' && matrix.extended_build_mdl_sdk == 'ON' && runner.os == 'Windows'
run: |
C:/vcpkg/vcpkg install mdl-sdk --triplet=x64-windows
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows/bin"
C:/vcpkg/vcpkg install mdl-sdk[dds,df-vulkan,openimageio] --triplet=x64-windows-release
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows-release/bin"

- name: Install Python ${{ matrix.python }}
if: matrix.python != 'None'
Expand All @@ -198,13 +198,13 @@ jobs:
EXTENDED_BUILD_CONFIG=""
if [ "${{ env.IS_EXTENDED_BUILD }}" == "true" ]; then
if [ "${{ runner.os }}" == "Windows" ]; then
EXTENDED_BUILD_CONFIG="-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows"
EXTENDED_BUILD_CONFIG="-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
fi
if [ "${{ matrix.extended_build_oiio }}" == "ON" ]; then
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_BUILD_OIIO=ON"
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DVCPKG_TARGET_TRIPLET=x64-windows -DMATERIALX_BUILD_OIIO=ON"
fi
if [ "${{ matrix.extended_build_mdl_sdk }}" == "ON" -a "${{ runner.os }}" == "Windows" ]; then
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows"
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DVCPKG_TARGET_TRIPLET=x64-windows-release -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows-release"
fi
fi
TEST_RENDER_CONFIG="-DMATERIALX_TEST_RENDER=OFF"
Expand Down
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ mark_as_advanced(MATERIALX_EMSDK_PATH)
mark_as_advanced(MATERIALX_BUILD_IOS)
mark_as_advanced(MATERIALX_BUILD_APPLE_FRAMEWORK)
mark_as_advanced(MATERIALX_MDL_BINARY_MDLC)
mark_as_advanced(MATERIALX_MDL_BINARY_TESTRENDER)
mark_as_advanced(MATERIALX_MDL_MODULE_PATHS)
mark_as_advanced(MATERIALX_MDL_SDK_DIR)
mark_as_advanced(MATERIALX_SLANG_RHI_SOURCE_DIR)
Expand Down Expand Up @@ -264,11 +265,23 @@ if (MATERIALX_BUILD_BENCHMARK_TESTS)
add_definitions(-DMATERIALX_BUILD_BENCHMARK_TESTS)
endif()

# GEN MDL does not have any additional dependencies. For loading and compiling MDL, e.g., in the test renderer, the MDL SDK is needed.
# MaterialXGenMdl does not have any additional dependencies.
# MaterialXTest/MaterialXGenMdl performs a syntax check if the mdlc binary is available.
# MaterialXTest/MaterialXRenderMdl needs the df_vulkan example, SDK library, and image plugins.
if(MATERIALX_MDL_SDK_DIR)
find_package(mdl QUIET CONFIG REQUIRED PATHS ${MATERIALX_MDL_SDK_DIR})
get_target_property(MATERIALX_MDL_BINARY_MDLC mdl::mdlc LOCATION)
set(MATERIALX_MDL_BINARY_MDLC ${MATERIALX_MDL_BINARY_MDLC} CACHE FILEPATH "Full path to the mdlc binary." FORCE)
if((${mdl_VERSION} VERSION_GREATER_EQUAL "2025.0.3") OR (${mdl_VERSION} STREQUAL "trunk"))
find_program(MATERIALX_MDL_BINARY_TESTRENDER
NAMES df_vulkan
HINTS
${MATERIALX_MDL_SDK_DIR}/examples/mdl_sdk/df_vulkan # regular install layout
${MATERIALX_MDL_SDK_DIR}/tools/mdl-sdk) # vcpkg layout
else()
message(WARNING "The MDL df_vulkan test renderer requires an MDL SDK >= 2025.0.3 (found ${mdl_VERSION}).")
set(MATERIALX_MDL_BINARY_TESTRENDER "" CACHE FILEPATH "Full path to the MDL df_vulkan test renderer.")
endif()
endif()

# Adjust the default installation path
Expand Down
2 changes: 1 addition & 1 deletion python/MaterialXTest/tests_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main(args=None):
langFiles1 = []
langPaths1 = []
for subdir, _, files in os.walk(args.inputdir1):
for curFile in files:
for curFile in sorted(files):
if curFile.endswith(args.lang1 + ".png"):
langFiles1.append(curFile)
langPaths1.append(subdir)
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenMdl/MdlShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ ShaderPtr MdlShaderGenerator::generate(const string& name, ElementPtr element, G
inputSocket->getType().getSemantic() == TypeDesc::SEMANTIC_CLOSURE ||
inputSocket->getType().getSemantic() == TypeDesc::SEMANTIC_MATERIAL))
{
const string& qualifier = inputSocket->isUniform() || inputSocket->getType() == Type::FILENAME
? uniformPrefix
const string& qualifier = inputSocket->isUniform() || inputSocket->getType() == Type::FILENAME
? uniformPrefix
: EMPTY_STRING;
const string& type = _syntax->getTypeName(inputSocket->getType());

Expand Down
3 changes: 3 additions & 0 deletions source/MaterialXTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ if(MATERIALX_BUILD_RENDER)
add_subdirectory(MaterialXRenderOsl)
target_link_libraries(MaterialXTest MaterialXRenderOsl)
endif()
if(MATERIALX_BUILD_GEN_MDL)
add_subdirectory(MaterialXRenderMdl)
endif()
if(APPLE AND MATERIALX_BUILD_GEN_MSL)
add_subdirectory(MaterialXRenderMsl)
target_link_libraries(MaterialXTest MaterialXRenderMsl)
Expand Down
13 changes: 10 additions & 3 deletions source/MaterialXTest/MaterialXGenMdl/GenMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@ void MdlStringResolver::initialize(
paths.append(addSp);
}

// use a set to remove duplicates while keeping the order
auto less = [](const mx::FilePath& lhs, const mx::FilePath& rhs)
{ return lhs.asString() < rhs.asString(); };
std::set<mx::FilePath, decltype(less)> unique_paths(less);

_mdl_searchPaths.clear();
for (const auto& path : paths)
{
// normalize all search paths, as we need this later in `resolve`
auto normalizedPath = path.getNormalized();
if (normalizedPath.exists())
if (normalizedPath.exists() && unique_paths.insert(normalizedPath).second)
{
_mdl_searchPaths.append(normalizedPath);
}
}

_logFile = logFile;
Expand Down Expand Up @@ -105,7 +112,7 @@ std::string MdlStringResolver::resolve(const std::string& str, const std::string
}
if (_logFile)
{
*_logFile << "MaterialX resource can not be accessed through an MDL search path. "
*_logFile << "Failed to resolve a MaterialX resource via the given search paths. "
<< "Dropping the resource from the Material. Resource Path: "
<< normalizedPath.asString().c_str() << std::endl;
}
Expand Down Expand Up @@ -244,7 +251,7 @@ void MdlShaderGeneratorTester::compileSource(const std::vector<mx::FilePath>& so
mdlcCommand += " ::" + moduleToTest;

// redirect output
mx::FilePath errorFile = moduleToTestPath / (moduleToTest + ".mdl_compile_errors.txt");
mx::FilePath errorFile = moduleToTestPath / (moduleToTest + "_log.txt");
mdlcCommand += " > " + errorFile.asString() + " 2>&1";

// execute the compiler and evaluate return code and the output stream
Expand Down
23 changes: 23 additions & 0 deletions source/MaterialXTest/MaterialXRenderMdl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
file(GLOB_RECURSE source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB_RECURSE headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")

target_sources(MaterialXTest PUBLIC ${source} ${headers})

if (NOT MATERIALX_BUILD_MONOLITHIC)
get_target_property(MaterialXGenMdl_SOURCE_DIR MaterialXGenMdl SOURCE_DIR)
else()
get_target_property(PROJECT_SOURCE_DIR ${MATERIALX_MONOLITHIC_TARGET} SOURCE_DIR)
set(MaterialXGenMdl_SOURCE_DIR "{PROJECT_SOURCE_DIR}/MaterialXGenMdl")
endif()

target_compile_definitions(MaterialXTest PRIVATE
MATERIALX_MDL_BINARY_TESTRENDER=\"${MATERIALX_MDL_BINARY_TESTRENDER}\"
MATERIALX_MDL_IMPL_MODULE_PATH=\"${MaterialXGenMdl_SOURCE_DIR}/mdl\"
MATERIALX_INSTALL_MDL_MODULE_PATH=\"${MATERIALX_INSTALL_STDLIB_PATH}\"
MATERIALX_MDL_MODULE_PATHS=\"${MATERIALX_MDL_MODULE_PATHS}\"
)

add_tests("${source}")

assign_source_group("Source Files" ${source})
assign_source_group("Header Files" ${headers})
Loading