Bump VTK minimum OpenGL version to 4.1

Posting this in Slicer3D forum for better visibility. Please feel free to move it to appropriate category where it’s more visible.

We’re looking to update the minimum required OpenGL version in VTK from 3.2 to 4.1 for the desktop platforms. I’m cross posting here to gather feedback because Slicer3D uses VTK and also has a large community.

Since VTK uses a core profile context and asks for the highest available version of OpenGL from the OS, chances are you’re already using 4.6. Please let us know if your team requires VTK to support GPUs with OpenGL 4.0 or lower. We could look into the use case if needed and make necessary updates.

This backward compatibility is starting to hamper the introduction of newer robust rendering capabilities like tessellation shaders, compute shaders, etc. In the future, VTK will move over to WebGPU, however, that is a long term goal, best discussed in another post.

Here are some resources to get the general idea of systems supporting OpenGL 4.1

  1. https://developer.apple.com/opengl/OpenGL-Capabilities-Tables.pdf (pg 34 onwards)
  2. https://www.phoronix.com/news/Zink-OpenGL-4.1-Mesa-21.0

Rational for choosing 4.1 instead of a newer version:

  • macOS only supports up to 4.1
  • Mesa 12 onward support OpenGL 4.3 (Ubuntu 20.04 has mesa 21.2.6, Debian 10 has 18.3.6, many distributions considered ‘old’ have a mesa version > 18.)

For more details, see https://gitlab.kitware.com/vtk/vtk/-/issues/19291

How you can help us?

Please speak up in this post or over at Survey about updating minimum OpenGL version to 4.1 - Support - VTK if you really need to support desktop OpenGL < 4.1

In order to know the OpenGL version used by VTK, simply execute vtkProbeOpenGLVersion executable found in the bin folder of your VTK installation.

Thanks for the heads-up! I don’t expect that this will cause an issue when Slicer is running on physical hardware that is not older than 5 years, but it might cause incompatibility issues in virtualized environments (virtualGL, VirtualBox, Parallels, etc.).

It would be difficult to test all environments where Slicer is used. If you want to ensure a smooth transition for every applications then you could do something like this:

  • change VTK now to require OpenGL 4.1 by default
  • add a CMake flag that allows using VTK with just OpenGL 3.2 (it is OK to disable any new VTK features in this mode)
  • remove OpenGL 3.2 support in 2 years

These can use mesa3d (on windows too [1]). It provides software implementation for OpenGL 4.1+

Yes, this is possible. VTK can force the OpenGL context to 3.2 and it can be controlled with a compile-time setting. (also possible at runtime, just need a new Set/Get macro)


  1. How to run ParaView (including the binary release) using Mesa on Windows - Tips and Tricks - ParaView ↩︎

@jspanchu thanks for posting this :+1:

Can you suggest a test program (e.g. glxgears, blender, maybe a game or something) that people could run to see if this change will break something for them? If there isn’t something already could we make one? I don’t think most people know or care what OpenGL version they use unless it breaks.

There is one already. vtkProbeOpenGLVersion can be found inside bin/ directory of a VTK installation. When you run it, it will print lots of information or show a dialog on windows. So look for this line:

OpenGL version string:  4.5 (Core Profile) Mesa 24.0.1-arch1.1

This works too:

import vtk

renderer = vtk.vtkRenderer()
renderWindow  = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindow.Render()
print(renderWindow.ReportCapabilities())

In C++, you can also use

vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->Render()
int major, minor;
renderWindow->GetOpenGLVersion(major, minor);
std::cout << "OpenGL version" << major << '.' << minor << '\n'

Thanks @jspanchu - just trying to make sure this is clear for people who aren’t in the weeds of OpenGL.

So if I run the python script you provided in Slicer 5.6.1 my mac pro, I get the following, which is consistent with the expectation that 4.1 should be supported.

...
OpenGL version string:  4.1 ATI-4.12.7
... 

So what we need is for people to check this out and report back if they see a version string less than 4.1. It’s possible this might happen with older machines, virtualized environments, or specific remote desktop systems.

it will be helpful to know if those systems exist, but it may also be the case that we move ahead anyway and just let people know that they may need to use older Slicer/VTK versions with those systems.

Could you set up a build with this 3.2 option enabled so that you know what is broken - and if it is not too much trouble then keep most things working with OpenGL 3.2 for a transition period of 2 years? I would expect that most incompatibilities will be introduced accidentally and should be easy to avoid (maybe by adding a few #ifdefs, which can be all wiped out once the transition period is over).