I am trying to figure out which version of OpenGL my graphics card and driver currently support.
This answer suggests running glxinfo | grep OpenGL
which if fine, but here is (some) of that output:
OpenGL vendor string: NVIDIA Corporation OpenGL core profile version string: 4.5.0 NVIDIA 387.22 OpenGL version string: 4.6.0 NVIDIA 387.22
So it is hard to tell, is it 4.5 or 4.6?
Also the official documentation from nVidia does not mention the answer either!
Advertisement
Answer
OpenGL version string: 4.6.0 NVIDIA 387.22
That is the highest legacy version the implementation will support. There are several possibilities here:
- This number will be <= 3.1 for OpenGL implementations not supporting modern OpenGL profiles (introduced in 3.2).
- It might be the highest supported compatibility profile version if the implementation does support the compatibility profile and actually returns a compatiblity profile context when asked for a legacy context
- It might also be <= 3.1 even on implementations that do support GL >= 3.2 in a compatibility profile, but chose to not expose it when asked for a legacy context.
The nvidia proprietary driver falls in category 2.
For the core profile, there is simply no way to ask the implementation what it can support, as described in this answer:
OpenGL core profile version string: 4.5.0 NVIDIA 387.22
That glxinfo output does not mean that your driver can’t do 4.6 core. (It actually can). It just means that the glxinfo aren’t aware of the presence of GL 4.6 right now, only only check for up to 4.5.
The source code for glxinfo will reveal the following logic:
if (coreProfile) { /* Try to create a core profile, starting with the newest version of * GL that we're aware of. If we don't specify the version */ int i; for (i = 0; gl_versions[i].major > 0; i++) { /* don't bother below GL 3.0 */ if (gl_versions[i].major == 3 && gl_versions[i].minor == 0) return 0; ctx = create_context_flags(dpy, config, gl_versions[i].major, gl_versions[i].minor, 0x0, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, direct); if (ctx) return ctx; } /* couldn't get core profile context */ return 0; }
so it just iterates through an array gl_versions
and checks if a context with that version can be created.
And OpenGL 4.6 was added to that array in this commit on October 11, 2017:
diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h index 0024f85..4d07f66 100644 --- a/src/xdemos/glinfo_common.h +++ b/src/xdemos/glinfo_common.h @@ -86,6 +86,7 @@ struct options /** list of known OpenGL versions */ static const struct { int major, minor; } gl_versions[] = { + {4, 6}, {4, 5}, {4, 4}, {4, 3},
So if you use a glxinfo
which was compiled on a source code version before Oct 11 (which means basically every distro version right now), it simply will not show 4.6, even if your driver can do it.
So it is hard to tell, is it 4.5 or 4.6?
It is 4.6 for both compatibility and core profile. But I only know that because I know that driver.