glxdisplay: grab X11 lock around various GLX calls

This commit is contained in:
rdb 2018-11-22 23:14:29 +01:00
parent 254cea63bb
commit 0a1b6df648
4 changed files with 23 additions and 2 deletions

View File

@ -71,7 +71,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
glxGraphicsStateGuardian *glxgsg;
DCAST_INTO_R(glxgsg, _gsg, false);
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
{
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
}
// Now that we have made the context current to a window, we can reset the
// GSG state if this is the first time it has been used. (We can't just
@ -125,6 +128,7 @@ end_frame(FrameMode mode, Thread *current_thread) {
void glxGraphicsBuffer::
close_buffer() {
if (_gsg != nullptr) {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
glXMakeCurrent(_display, None, nullptr);
if (_pbuffer != None) {
@ -179,6 +183,8 @@ open_buffer() {
nassertr(glxgsg->_supports_pbuffer, false);
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
static const int max_attrib_list = 32;
int attrib_list[max_attrib_list];
int n = 0;

View File

@ -74,7 +74,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
glxGraphicsStateGuardian *glxgsg;
DCAST_INTO_R(glxgsg, _gsg, false);
glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
{
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
}
// Now that we have made the context current to a window, we can reset the
// GSG state if this is the first time it has been used. (We can't just
@ -127,6 +130,7 @@ end_frame(FrameMode mode, Thread *current_thread) {
*/
void glxGraphicsPixmap::
close_buffer() {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
if (_gsg != nullptr) {
glXMakeCurrent(_display, None, nullptr);
_gsg.clear();
@ -197,6 +201,7 @@ open_buffer() {
}
}
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
_x_pixmap = XCreatePixmap(_display, _drawable,
get_x_size(), get_y_size(), visual_info->depth);
if (_x_pixmap == None) {

View File

@ -64,6 +64,7 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
*/
glxGraphicsStateGuardian::
~glxGraphicsStateGuardian() {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
destroy_temp_xwindow();
if (_visuals != nullptr) {
XFree(_visuals);
@ -224,6 +225,7 @@ choose_pixel_format(const FrameBufferProperties &properties,
X11_Display *display,
int screen, bool need_pbuffer, bool need_pixmap) {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
_display = display;
_screen = screen;
_context = nullptr;
@ -457,6 +459,7 @@ gl_get_error() const {
*/
void glxGraphicsStateGuardian::
query_gl_version() {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
PosixGraphicsStateGuardian::query_gl_version();
show_glx_client_string("GLX_VENDOR", GLX_VENDOR);
@ -483,6 +486,7 @@ query_gl_version() {
*/
void glxGraphicsStateGuardian::
get_extra_extensions() {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
save_extensions(glXQueryExtensionsString(_display, _screen));
}
@ -497,6 +501,8 @@ do_get_extension_func(const char *name) {
nassertr(name != nullptr, nullptr);
if (glx_get_proc_address) {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
// First, check if we have glXGetProcAddress available. This will be
// superior if we can get it.

View File

@ -154,6 +154,8 @@ end_flip() {
*/
void glxGraphicsWindow::
close_window() {
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
if (_gsg != nullptr) {
glXMakeCurrent(_display, None, nullptr);
_gsg.clear();
@ -204,6 +206,8 @@ open_window() {
return false;
}
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
if (glxgsg->_fbconfig != None) {
setup_colormap(glxgsg->_fbconfig);
} else {