Skip to content

Commit

Permalink
FIX: Better
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Dec 7, 2024
1 parent 9382dcb commit e8753d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 2 additions & 6 deletions mne/viz/backends/_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ def _is_osmesa(plotter):
)
gpu_info = " ".join(gpu_info).lower()
is_osmesa = "mesa" in gpu_info.split()
print(is_osmesa)
if is_osmesa:
# Try to warn if it's ancient
version = re.findall("mesa ([0-9.]+)[ -].*", gpu_info) or re.findall(
Expand All @@ -1346,12 +1347,7 @@ def _is_osmesa(plotter):
"surface rendering, consider upgrading to 18.3.6 or "
"later."
)
renderer = re.findall(
r"OpenGL renderer string: ([0-9.a-zA-Z\-])+",
gpu_info_full,
)
if renderer:
is_osmesa = renderer[0] == "llvmpipe"
is_osmesa = "via llvmpipe" in gpu_info
return is_osmesa


Expand Down
9 changes: 5 additions & 4 deletions mne/viz/backends/tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,18 @@ def test_3d_warning(renderer_pyvistaqt, monkeypatch):
from mne.viz.backends._pyvista import _is_osmesa

plotter = fig.plotter
good = "OpenGL renderer string: OpenGL 3.3 (Core Profile) Mesa 20.0.8 via llvmpipe (LLVM 10.0.0, 256 bits)\n" # noqa
bad = "OpenGL renderer string: OpenGL 3.3 (Core Profile) Mesa 18.3.4 via llvmpipe (LLVM 7.0, 256 bits)\n" # noqa
pre = "OpenGL renderer string: "
good = f"{pre}OpenGL 3.3 (Core Profile) Mesa 20.0.8 via llvmpipe (LLVM 10.0.0, 256 bits)\n" # noqa
bad = f"{pre}OpenGL 3.3 (Core Profile) Mesa 18.3.4 via llvmpipe (LLVM 7.0, 256 bits)\n" # noqa
monkeypatch.setattr(platform, "system", lambda: "Linux") # avoid short-circuit
monkeypatch.setattr(plotter.ren_win, "ReportCapabilities", lambda: good)
assert _is_osmesa(plotter)
monkeypatch.setattr(plotter.ren_win, "ReportCapabilities", lambda: bad)
with pytest.warns(RuntimeWarning, match=r"18\.3\.4 is too old"):
assert _is_osmesa(plotter)
non = "OpenGL 4.1 Metal - 76.3 via Apple M1 Pro\n"
non = f"{pre}OpenGL 4.1 Metal - 76.3 via Apple M1 Pro\n"
monkeypatch.setattr(plotter.ren_win, "ReportCapabilities", lambda: non)
assert not _is_osmesa(plotter)
non = "OpenGL renderer string: llvmpipe\n"
non = f"{pre}OpenGL 4.5 (Core Profile) Mesa 24.2.3-1ubuntu1 via NVE6\n"
monkeypatch.setattr(plotter.ren_win, "ReportCapabilities", lambda: non)
assert not _is_osmesa(plotter)

0 comments on commit e8753d4

Please sign in to comment.