diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 616290a4b1..818d0d5302 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -265,13 +266,23 @@ jobs: fi cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=normalCheckLevelMaxBranches --suppress=*:*/External/* --suppress=*:*/NanoGUI/* - - name: Initialize Virtual Framebuffer + - name: Setup Rendering Environment (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: Setup Rendering Environment (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: | @@ -279,11 +290,16 @@ jobs: python python/Scripts/baketextures.py resources/Materials/Examples/StandardSurface/standard_surface_brass_tiled.mtlx build/render/brass_average_baked.mtlx --average python python/Scripts/translateshader.py resources/Materials/Examples/StandardSurface/standard_surface_carpaint.mtlx build/render/usd_preview_surface_carpaint.mtlx UsdPreviewSurface --hdr - - name: Render Application Tests + - name: Viewer Tests if: matrix.test_render == 'ON' 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: Graph Editor Tests + 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 diff --git a/source/MaterialXGraphEditor/Main.cpp b/source/MaterialXGraphEditor/Main.cpp index 6001f222b4..59d3022ede 100644 --- a/source/MaterialXGraphEditor/Main.cpp +++ b/source/MaterialXGraphEditor/Main.cpp @@ -167,6 +167,13 @@ int main(int argc, char* const argv[]) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); #endif + // When captureFilename is specified, make window invisible + // to avoid issues with headless rendering. + if (!captureFilename.empty()) + { + glfwWindowHint(GLFW_VISIBLE, GL_FALSE); + } + // Create window with graphics context GLFWwindow* window = glfwCreateWindow(1280, 960, "MaterialX Graph Editor", NULL, NULL); if (!window)