Skip to content

Commit fbb6100

Browse files
authored
Enable CI Rendering on Mac (#2673)
## Change - Turn on headless rendering on Mac for MaterialXView - Added to the MacOS_Xcode_16_Python313 workflow as that already does shader validation testing. Notes: - MaterialxGraphEditor rendering not enabled as it's using OpenGL which has issues running headless. (A[ new issue](#2672) has been logged to support Metal rendering here. If / when it is available then it can be turned on) - The Metal environment set up here is the same pre-requisite as for this [PR for full test suite enabling](#2675).
1 parent bf12e61 commit fbb6100

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
compiler_version: "16.4"
7979
python: 3.13
8080
test_shaders: ON
81+
test_render: ON
8182

8283
- name: MacOS_Xcode_26_Python313
8384
os: macos-26
@@ -265,25 +266,40 @@ jobs:
265266
fi
266267
cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=normalCheckLevelMaxBranches --suppress=*:*/External/* --suppress=*:*/NanoGUI/*
267268
268-
- name: Initialize Virtual Framebuffer
269+
- name: Setup Rendering Environment (Linux)
269270
if: matrix.test_render == 'ON' && runner.os == 'Linux'
270271
run: |
271272
Xvfb :1 -screen 0 1280x960x24 &
272273
echo "DISPLAY=:1" >> $GITHUB_ENV
273274
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
274275
276+
- name: Setup Rendering Environment (MacOS)
277+
if: matrix.test_render == 'ON' && runner.os == 'macOS'
278+
run: |
279+
# macOS can render headless with Metal backend without virtual display
280+
# Force software rendering for Metal backend (more reliable in CI)
281+
echo "MTL_HARDWARE_RENDERING=0" >> $GITHUB_ENV
282+
# Enable Metal debug layer for better debugging in CI
283+
echo "MTL_DEBUG_LAYER=1" >> $GITHUB_ENV
284+
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
285+
275286
- name: Render Script Tests
276287
if: matrix.test_render == 'ON'
277288
run: |
278289
mkdir build/render
279290
python python/Scripts/baketextures.py resources/Materials/Examples/StandardSurface/standard_surface_brass_tiled.mtlx build/render/brass_average_baked.mtlx --average
280291
python python/Scripts/translateshader.py resources/Materials/Examples/StandardSurface/standard_surface_carpaint.mtlx build/render/usd_preview_surface_carpaint.mtlx UsdPreviewSurface --hdr
281292
282-
- name: Render Application Tests
293+
- name: Viewer Tests
283294
if: matrix.test_render == 'ON'
284295
run: |
285296
../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
286297
../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
298+
working-directory: build/render
299+
300+
- name: Graph Editor Tests
301+
if: matrix.test_render == 'ON' && runner.os == 'Linux'
302+
run: |
287303
../installed/bin/MaterialXGraphEditor --material ../../resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --viewWidth 128 --viewHeight 128 --captureFilename GraphEditor_MarbleSolid.png
288304
working-directory: build/render
289305

source/MaterialXGraphEditor/Main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ int main(int argc, char* const argv[])
167167
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
168168
#endif
169169

170+
// When captureFilename is specified, make window invisible
171+
// to avoid issues with headless rendering.
172+
if (!captureFilename.empty())
173+
{
174+
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
175+
}
176+
170177
// Create window with graphics context
171178
GLFWwindow* window = glfwCreateWindow(1280, 960, "MaterialX Graph Editor", NULL, NULL);
172179
if (!window)

0 commit comments

Comments
 (0)