Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
45 changes: 43 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
compiler_version: "16.4"
python: 3.13
test_shaders: ON
test_render: ON

- name: MacOS_Xcode_26_Python313
os: macos-26
Expand Down Expand Up @@ -203,7 +204,13 @@ jobs:
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows"
fi
fi
cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_BUILD_TESTS=ON -DMATERIALX_TEST_RENDER=OFF -DMATERIALX_WARNINGS_AS_ERRORS=ON $EXTENDED_BUILD_CONFIG ${{matrix.cmake_config}}
TEST_RENDER_CONFIG="-DMATERIALX_TEST_RENDER=OFF"
if [ "${{ matrix.test_render }}" == "ON" ]; then
if [ "${{ runner.os }}" == "macOS" ]; then
TEST_RENDER_CONFIG="$TEST_RENDER_CONFIG -DMATERIALX_TEST_RENDER=ON -DMATERIALX_RENDER_MSL_ONLY=ON"
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.

Key change: Turn on test rendering for MSL but not GLSL.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps we can merge the existing EXTENDED_BUILD_CONFIG with your new TEST_RENDER_CONFIG, naming the combined variable ADDITIONAL_BUILD_CONFIG for generality?

That should help to keep the final cmake build call as compact and clear as possible, as it's becoming a bit hard to read!

fi
fi
cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_BUILD_TESTS=ON -DMATERIALX_WARNINGS_AS_ERRORS=ON $TEST_RENDER_CONFIG $EXTENDED_BUILD_CONFIG ${{matrix.cmake_config}}

- name: CMake Build
run: cmake --build build --target install --config Release --parallel 2
Expand Down Expand Up @@ -265,13 +272,23 @@ jobs:
fi
cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=normalCheckLevelMaxBranches --suppress=*:*/External/* --suppress=*:*/NanoGUI/*

- name: Initialize Virtual Framebuffer
- name: Initialize Virtual Framebuffer (Linux)
if: matrix.test_render == 'ON' && runner.os == 'Linux'
run: |
Xvfb :1 -screen 0 1280x960x24 &
echo "DISPLAY=:1" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV

- name: Initialize Headless Rendering (macOS)
if: matrix.test_render == 'ON' && runner.os == 'macOS'
run: |
# macOS can render headless with Metal backend without virtual display
# Force software rendering for Metal backend (more reliable in CI)
echo "MTL_HARDWARE_RENDERING=0" >> $GITHUB_ENV
# Enable Metal debug layer for better debugging in CI
echo "MTL_DEBUG_LAYER=1" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV

- name: Render Script Tests
if: matrix.test_render == 'ON'
run: |
Expand All @@ -284,6 +301,11 @@ jobs:
run: |
../installed/bin/MaterialXView --material brass_average_baked.mtlx --mesh ../../resources/Geometry/sphere.obj --screenWidth 128 --screenHeight 128 --cameraZoom 1.4 --shadowMap false --captureFilename Viewer_BrassAverage.png
../installed/bin/MaterialXView --material usd_preview_surface_carpaint.mtlx --mesh ../../resources/Geometry/sphere.obj --screenWidth 128 --screenHeight 128 --cameraZoom 1.4 --shadowMap false --captureFilename Viewer_CarpaintTranslated.png
working-directory: build/render

- name: Render Application Tests (GraphEditor - Linux only)
if: matrix.test_render == 'ON' && runner.os == 'Linux'
run: |
../installed/bin/MaterialXGraphEditor --material ../../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --viewWidth 128 --viewHeight 128 --captureFilename GraphEditor_MarbleSolid.png
working-directory: build/render

Expand Down Expand Up @@ -315,6 +337,25 @@ jobs:
name: Renders_${{ matrix.name }}
path: build/render/*.png

- name: Archive Resources (macOS)
if: matrix.test_render == 'ON' && runner.os == 'macOS'
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.

Post results.

run: |
mkdir -p build/artifacts
if [ ! -d build/bin/resources ]; then
echo "Missing build/bin/resources"
echo "Contents of build/bin (if present):"
ls -la build/bin || true
exit 1
fi
zip -r build/artifacts/resources.zip build/bin/resources
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the motivation for manually generating a zip archive of the folder, rather than leveraging the built-in zip functionality in actions/upload-artifact?

Would it make sense to align this with our other upload steps (e.g. Upload Reference Shaders, Upload Renders) and use the existing system in actions/upload-artifact?

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.

Good catch. I had this "cherry picking" images at one point but reverted that as it's better to produce a "results" folder as part of test. Will revert this to the simpler rule.


- name: Upload Resources Archive (macOS)
uses: actions/upload-artifact@v4
if: matrix.test_render == 'ON' && runner.os == 'macOS'
with:
name: Resources_${{ matrix.name }}
path: build/artifacts/resources.zip

- name: Upload Coverage Report
uses: actions/upload-artifact@v4
if: matrix.coverage_analysis == 'ON'
Expand Down
13 changes: 13 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_GEN_SLANG "Build the Slang shader generator back-end." ON)
option(MATERIALX_BUILD_RENDER "Build the MaterialX Render modules." ON)
option(MATERIALX_BUILD_RENDER_PLATFORMS "Build platform-specific render modules for each shader generator." ON)
option(MATERIALX_RENDER_MSL_ONLY "On macOS, use Metal Shading Language only for tests and viewer (skips GLSL render tests)." OFF)
option(MATERIALX_BUILD_OIIO "Build OpenImageIO support for MaterialXRender." OFF)
option(MATERIALX_BUILD_OCIO "Build OpenColorIO support for shader generators." OFF)
option(MATERIALX_BUILD_TESTS "Build unit tests." OFF)
Expand Down Expand Up @@ -112,6 +113,17 @@ if (MATERIALX_BUILD_JS)
set(MATERIALX_BUILD_TESTS OFF)
endif()

# Validate MSL-only rendering option
if(MATERIALX_RENDER_MSL_ONLY)
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.

Turn off GLSL rendering. For some reason there a renderGLSL module dependency for renderMSL. Not touching that dependency here.

if(NOT APPLE)
message(FATAL_ERROR "MATERIALX_RENDER_MSL_ONLY can only be enabled on Apple platforms")
endif()
if(NOT MATERIALX_BUILD_GEN_MSL)
message(FATAL_ERROR "MATERIALX_RENDER_MSL_ONLY requires MATERIALX_BUILD_GEN_MSL to be enabled")
endif()
message(STATUS "MSL-only testing mode enabled - MaterialXTest will not link MaterialXRenderGlsl")
endif()

# All hardware shading languages currently depend on the GLSL shader generator.
if(MATERIALX_BUILD_GEN_MSL)
set(MATERIALX_BUILD_GEN_GLSL ON)
Expand Down Expand Up @@ -178,6 +190,7 @@ mark_as_advanced(MATERIALX_BUILD_GEN_MSL)
mark_as_advanced(MATERIALX_BUILD_OSOS)
mark_as_advanced(MATERIALX_BUILD_RENDER)
mark_as_advanced(MATERIALX_BUILD_RENDER_PLATFORMS)
mark_as_advanced(MATERIALX_RENDER_MSL_ONLY)
mark_as_advanced(MATERIALX_BUILD_OIIO)
mark_as_advanced(MATERIALX_BUILD_OCIO)
mark_as_advanced(MATERIALX_BUILD_BENCHMARK_TESTS)
Expand Down
6 changes: 6 additions & 0 deletions source/MaterialXGraphEditor/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ int main(int argc, char* const argv[])
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
#endif

// For headless operation (when captureFilename is specified), make window invisible
if (!captureFilename.empty())
{
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
}

// Create window with graphics context
GLFWwindow* window = glfwCreateWindow(1280, 960, "MaterialX Graph Editor", NULL, NULL);
if (!window)
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ endif()
if(MATERIALX_BUILD_RENDER)
add_subdirectory(MaterialXRender)
target_link_libraries(MaterialXTest MaterialXRender)
if(MATERIALX_BUILD_GEN_GLSL)
if(MATERIALX_BUILD_GEN_GLSL AND NOT MATERIALX_RENDER_MSL_ONLY)
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.

Turn off GLSL rendering if want MSL only

add_subdirectory(MaterialXRenderGlsl)
target_link_libraries(MaterialXTest MaterialXRenderGlsl)
endif()
Expand Down
7 changes: 6 additions & 1 deletion source/MaterialXView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ if(APPLE)
set(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM ON)
endif()

if(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM)
# Force Metal backend if MSL-only rendering is enabled
if(MATERIALX_RENDER_MSL_ONLY)
set(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM OFF)
set(NANOGUI_PREFERRED_BACKEND Metal)
set(MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS "-DMATERIALXVIEW_METAL_BACKEND=1")
elseif(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM)
set(NANOGUI_PREFERRED_BACKEND OpenGL)
set(MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS "-DMATERIALXVIEW_OPENGL_BACKEND=1")
else()
Expand Down