Skip to content

Commit c63855d

Browse files
committed
Try runnin MSL renders in CI.
1 parent 78b0e01 commit c63855d

4 files changed

Lines changed: 39 additions & 13 deletions

File tree

.github/workflows/main.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ jobs:
204204
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows"
205205
fi
206206
fi
207-
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}}
207+
TEST_RENDER_CONFIG="-DMATERIALX_TEST_RENDER=OFF"
208+
if [ "${{ matrix.test_render }}" == "ON" ]; then
209+
if [ "${{ runner.os }}" == "macOS" ]; then
210+
TEST_RENDER_CONFIG="$TEST_RENDER_CONFIG -DMATERIALX_TEST_RENDER=ON -DMATERIALX_RENDER_MSL_ONLY=ON"
211+
fi
212+
fi
213+
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}}
208214
209215
- name: CMake Build
210216
run: cmake --build build --target install --config Release --parallel 2
@@ -297,9 +303,8 @@ jobs:
297303
../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
298304
working-directory: build/render
299305

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

CMakeLists.txt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ option(MATERIALX_BUILD_GEN_MSL "Build the MSL shader generator back-end." ON)
4545
option(MATERIALX_BUILD_GEN_SLANG "Build the Slang shader generator back-end." ON)
4646
option(MATERIALX_BUILD_RENDER "Build the MaterialX Render modules." ON)
4747
option(MATERIALX_BUILD_RENDER_PLATFORMS "Build platform-specific render modules for each shader generator." ON)
48+
option(MATERIALX_RENDER_MSL_ONLY "On macOS, render with Metal Shading Language only (disables GLSL rendering)." OFF)
4849
option(MATERIALX_BUILD_OIIO "Build OpenImageIO support for MaterialXRender." OFF)
4950
option(MATERIALX_BUILD_OCIO "Build OpenColorIO support for shader generators." OFF)
5051
option(MATERIALX_BUILD_TESTS "Build unit tests." OFF)
@@ -112,6 +113,17 @@ if (MATERIALX_BUILD_JS)
112113
set(MATERIALX_BUILD_TESTS OFF)
113114
endif()
114115

116+
# Validate MSL-only rendering option
117+
if(MATERIALX_RENDER_MSL_ONLY)
118+
if(NOT APPLE)
119+
message(FATAL_ERROR "MATERIALX_RENDER_MSL_ONLY can only be enabled on Apple platforms")
120+
endif()
121+
if(NOT MATERIALX_BUILD_GEN_MSL)
122+
message(FATAL_ERROR "MATERIALX_RENDER_MSL_ONLY requires MATERIALX_BUILD_GEN_MSL to be enabled")
123+
endif()
124+
message(STATUS "MSL-only rendering mode enabled - GLSL rendering will be disabled")
125+
endif()
126+
115127
# All hardware shading languages currently depend on the GLSL shader generator.
116128
if(MATERIALX_BUILD_GEN_MSL)
117129
set(MATERIALX_BUILD_GEN_GLSL ON)
@@ -178,6 +190,7 @@ mark_as_advanced(MATERIALX_BUILD_GEN_MSL)
178190
mark_as_advanced(MATERIALX_BUILD_OSOS)
179191
mark_as_advanced(MATERIALX_BUILD_RENDER)
180192
mark_as_advanced(MATERIALX_BUILD_RENDER_PLATFORMS)
193+
mark_as_advanced(MATERIALX_RENDER_MSL_ONLY)
181194
mark_as_advanced(MATERIALX_BUILD_OIIO)
182195
mark_as_advanced(MATERIALX_BUILD_OCIO)
183196
mark_as_advanced(MATERIALX_BUILD_BENCHMARK_TESTS)
@@ -502,8 +515,11 @@ if(MATERIALX_BUILD_RENDER)
502515
if(MATERIALX_BUILD_RENDER_PLATFORMS)
503516
set(MATERIALX_BUILD_RENDER_HW OFF)
504517
if(MATERIALX_BUILD_GEN_GLSL AND NOT MATERIALX_BUILD_APPLE_EMBEDDED)
505-
set(MATERIALX_BUILD_RENDER_HW ON)
506-
add_subdirectory(source/MaterialXRenderGlsl)
518+
# Skip GLSL rendering on macOS if MSL-only mode is enabled
519+
if(NOT (APPLE AND MATERIALX_RENDER_MSL_ONLY))
520+
set(MATERIALX_BUILD_RENDER_HW ON)
521+
add_subdirectory(source/MaterialXRenderGlsl)
522+
endif()
507523
endif()
508524
if(MATERIALX_BUILD_GEN_MSL AND APPLE)
509525
set(MATERIALX_BUILD_RENDER_HW ON)
@@ -523,7 +539,12 @@ if(MATERIALX_BUILD_RENDER)
523539
add_subdirectory(source/MaterialXView)
524540
endif()
525541
if(MATERIALX_BUILD_GRAPH_EDITOR)
526-
add_subdirectory(source/MaterialXGraphEditor)
542+
# Graph Editor currently requires GLSL rendering
543+
if(APPLE AND MATERIALX_RENDER_MSL_ONLY)
544+
message(WARNING "MaterialXGraphEditor requires GLSL rendering and will not be built when MATERIALX_RENDER_MSL_ONLY is enabled on macOS")
545+
else()
546+
add_subdirectory(source/MaterialXGraphEditor)
547+
endif()
527548
endif()
528549
if(MATERIALX_INSTALL_RESOURCES AND NOT SKBUILD)
529550
add_subdirectory(resources)

source/MaterialXGraphEditor/Main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ int main(int argc, char* const argv[])
171171
if (!captureFilename.empty())
172172
{
173173
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
174-
#if defined(__APPLE__)
175-
// On macOS, when running headless we need to allow fallback to software rendering
176-
// to avoid "Failed to find a suitable pixel format" errors in CI environments
177-
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE);
178-
#endif
179174
}
180175

181176
// Create window with graphics context

source/MaterialXView/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ if(APPLE)
1111
set(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM ON)
1212
endif()
1313

14-
if(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM)
14+
# Force Metal backend if MSL-only rendering is enabled
15+
if(MATERIALX_RENDER_MSL_ONLY)
16+
set(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM OFF)
17+
set(NANOGUI_PREFERRED_BACKEND Metal)
18+
set(MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS "-DMATERIALXVIEW_METAL_BACKEND=1")
19+
elseif(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM)
1520
set(NANOGUI_PREFERRED_BACKEND OpenGL)
1621
set(MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS "-DMATERIALXVIEW_OPENGL_BACKEND=1")
1722
else()

0 commit comments

Comments
 (0)