I need to capture and encode the screen contents continuously even when the X-Server is grabbed with XGrabServer. (capturing is done using GLX, encoding is done using NVENC)
The documented way to do this in X is to use the XTestGrabControl function which can make an application impervious to server grabs.
However this does not work with the NVidia driver and GLX direct rendering. (it works with the Nouveau driver and GLX direct rendering, but Nouveau does not support NVENC and my customer probably will insist on using the NVidia drivers anyway.)
This seems to be a bug in the NVidia driver.
I have reported it at
- I'd appreciate when you can fix this in one of the next driver releases. (the sooner the better of course) This is important for a project with a big customer who plans to use hundreds of NVIdia cards.
- Or Is there a workaround? Or does NVidia provide another API for making an application impervious to a server grab? Or is it possible to access some NVidia APIs directly, without any intervention or control by the X-Server? (e.g. NVENC and OpenGL, or the Capture API, ...)
Any help or pointers where to continue looking at are appreciated.
To reproduce, run the attached program. (ImperviousToServerGrabsGLX2.c, built with the included Makefile)
Then grab the server, e.g. using (GrabServer.c )
Then the program ImperviousToServerGrabsGLX2 stops drawing while the server is grabbed.
If you switch to indirect drawing by changing the /* direct = / True to / direct = */ False in the call to glXCreateContext line 78 of ImperviousToServerGrabsGLX2.c, then it works correctly, i.e., the drawing continues even when the server is grabbed.
(Be sure to enable indirect drawing in xorg.conf for testing that.)
I.e. XTestGrabControl works for indirect GLX rendering, but it doesn’t work for direct GLX rendering (but should work for direct rendering, too)
This has been reproduced on CentOS7 64bit with Xorg 1.20.1 and Nvidia driver 410.78.
and on RHEL 7.7 with Xorg 1.20.4 and Nvidia driver 430.50, 64 bit.
I am not sure whether the cause is in Xorg or in the Nvidia driver or in some other component of the DRI infrastructure.
This problem does not occur when using the Nouveau driver instead of the NVidia driver.
This probably means that the bug is in the NVidia driver and not in the X-Server.
I reproduced it with a Quadro P600 card, but I guess that it also will happen with other cards.