summaryrefslogtreecommitdiffstats
path: root/src/glx/dri2_glx.c
diff options
context:
space:
mode:
authorGregory Hainaut <[email protected]>2017-05-29 13:18:25 +0200
committerEmil Velikov <[email protected]>2017-05-29 17:06:37 +0100
commitfa84f6225b1342dbe564962f639de50c5e9029d3 (patch)
treeaf2a0ecf59e778d0add6a14fabcd59b2f37cfae7 /src/glx/dri2_glx.c
parent5cb16e07ab9fc9a2e3d900ed4e978c787314c8ba (diff)
dri: Extend __DRIbackgroundCallableExtensionRec to include a callback that checks for thread safety
DRI-drivers could call Xlib functions, for example to allocate a new back buffer. When glthread is enabled, the driver runs mostly on a separate thread. Therefore we need to guarantee the thread safety between libX11 calls from the applications (not aware of the extra thread) and the ones from the driver. See discussion thread: https://lists.freedesktop.org/archives/mesa-dev/2017-April/152547.html Fortunately, Xlib allows to lock display to ensure thread safety but XInitThreads must be called first by the application to initialize the lock function pointer. This patch will allow to check XInitThreads was called to allow glthread on GLX or EGL platform. Note: a tentative was done to port libX11 code to XCB but it didn't solve fully thread safety. See discussion thread: https://lists.freedesktop.org/archives/mesa-dev/2017-April/153137.html Note: Nvidia forces the driver to call XInitThreads. Quoting their manpage: "The NVIDIA OpenGL driver will automatically attempt to enable Xlib thread-safe mode if needed. However, it might not be possible in some situations, such as when the NVIDIA OpenGL driver library is dynamically loaded after Xlib has been loaded and initialized. If that is the case, threaded optimizations will stay disabled unless the application is modified to call XInitThreads() before initializing Xlib or to link directly against the NVIDIA OpenGL driver library. Alternatively, using the LD_PRELOAD environment variable to include the NVIDIA OpenGL driver library should also achieve the desired result." v2: based on Nicolai and Matt feedback Use C style comment v3: based on Emil feedback split the patch in 3 s/isGlThreadSafe/isThreadSafe/ v5: based on Marek comment Add a comment that isThreadSafe is supported by extension v2 Signed-off-by: Gregory Hainaut <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/glx/dri2_glx.c')
0 files changed, 0 insertions, 0 deletions