Skip to content

feat: install osmesa off-screen renderer on Windows runners #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ jobs:

You can also use `latest` to use the latest release version.

- `install-mesa3d-offscreen` (default `false`): set to `true` to install the
offscreen version of Mesa3D on Windows. This is only applicable for Windows.
This will also set the `VTK_DEFAULT_OPENGL_WINDOW` environment variable to
`vtkOSOpenGLRenderWindow` based on the [VTK Runtime settings](https://docs.vtk.org/en/latest/advanced/runtime_settings.html)
For example:

```yml
- uses: pyvista/setup-headless-display-action@v3
with:
install-mesa3d-offscreen: true
```

### 🖼️ PyVista Example

```yml
Expand Down
20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ inputs:
This is only used on Windows.
required: false
default: "24.3.0"
install-mesa3d-offscreen:
description: |
Install Mesa3D off-screen renderer on Windows (by default, it is not installed).
This is only used on Windows.
required: false
default: "false"
branding:
icon: "monitor"
color: "blue"
Expand Down Expand Up @@ -83,6 +89,14 @@ runs:
fi
echo "MESA3D_VERSION=${MESA3D_VERSION}" | tee -a $GITHUB_ENV

- name: Determine if off-screen renderer is needed on Windows
if: runner.os == 'Windows' && inputs.install-mesa3d-offscreen == 'true'
shell: bash
run: |
echo "Installing Mesa3D off-screen renderer..."
export MESA3D_OFFSCREEN="true"
echo "MESA3D_OFFSCREEN=${MESA3D_OFFSCREEN}" | tee -a $GITHUB_ENV

- name: Install OpenGL on Windows
if: runner.os == 'Windows'
shell: cmd
Expand All @@ -108,3 +122,9 @@ runs:
if: inputs.pyvista != 'false'
shell: bash
run: echo "PYVISTA_OFF_SCREEN=true" >> $GITHUB_ENV

- name: Configure Mesa3D for PyVista/VTK (on Windows)
if: runner.os == 'Windows' && inputs.install-mesa3d-offscreen == 'true'
shell: bash
run: |
echo "VTK_DEFAULT_OPENGL_WINDOW=vtkOSOpenGLRenderWindow" >> $GITHUB_ENV
12 changes: 11 additions & 1 deletion windows/install_opengl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ fi
NAME="mesa3d-${MESA3D_VERSION}-release-msvc"
curl -LO --retry 3 --ssl-no-revoke https://github.com/pal1000/mesa-dist-win/releases/download/${MESA3D_VERSION}/${NAME}.7z
7z x ${NAME}.7z -o./${NAME}
# Run systemwidedeploy.cmd file: option 1) Install OpenGL drivers & 7) Update system-wide deployment
# Run systemwidedeploy.cmd file:
# option 1) Install OpenGL drivers
# option 5) Mesa3D off-screen render driver gallium version (osmesa gallium)
# option 7) Update system-wide deployment
cmd.exe //c "${NAME}\systemwidedeploy.cmd 1"
if [ "${MESA3D_OFFSCREEN}" == "true" ]; then
echo "Installing off-screen render driver gallium version (osmesa gallium)"
cmd.exe //c "${NAME}\systemwidedeploy.cmd 5"
fi
cmd.exe //c "${NAME}\systemwidedeploy.cmd 7"
rm -Rf ${NAME}
# takeown "/f" "C:\Windows\System32\opengl32.dll"
# icacls "C:\Windows\System32\opengl32.dll" /grant "$USERNAME:F"
ls -alt /C/Windows/System32/opengl32.dll
if [ "${MESA3D_OFFSCREEN}" == "true" ]; then
ls -alt /C/Windows/System32/osmesa.dll
fi
Loading