Skip to content

Commit 0a1b6df

Browse files
committed
glxdisplay: grab X11 lock around various GLX calls
1 parent 254cea6 commit 0a1b6df

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

panda/src/glxdisplay/glxGraphicsBuffer.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
7171

7272
glxGraphicsStateGuardian *glxgsg;
7373
DCAST_INTO_R(glxgsg, _gsg, false);
74-
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
74+
{
75+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
76+
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
77+
}
7578

7679
// Now that we have made the context current to a window, we can reset the
7780
// 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) {
125128
void glxGraphicsBuffer::
126129
close_buffer() {
127130
if (_gsg != nullptr) {
131+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
128132
glXMakeCurrent(_display, None, nullptr);
129133

130134
if (_pbuffer != None) {
@@ -179,6 +183,8 @@ open_buffer() {
179183

180184
nassertr(glxgsg->_supports_pbuffer, false);
181185

186+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
187+
182188
static const int max_attrib_list = 32;
183189
int attrib_list[max_attrib_list];
184190
int n = 0;

panda/src/glxdisplay/glxGraphicsPixmap.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ begin_frame(FrameMode mode, Thread *current_thread) {
7474

7575
glxGraphicsStateGuardian *glxgsg;
7676
DCAST_INTO_R(glxgsg, _gsg, false);
77-
glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
77+
{
78+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
79+
glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
80+
}
7881

7982
// Now that we have made the context current to a window, we can reset the
8083
// 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) {
127130
*/
128131
void glxGraphicsPixmap::
129132
close_buffer() {
133+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
130134
if (_gsg != nullptr) {
131135
glXMakeCurrent(_display, None, nullptr);
132136
_gsg.clear();
@@ -197,6 +201,7 @@ open_buffer() {
197201
}
198202
}
199203

204+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
200205
_x_pixmap = XCreatePixmap(_display, _drawable,
201206
get_x_size(), get_y_size(), visual_info->depth);
202207
if (_x_pixmap == None) {

panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
6464
*/
6565
glxGraphicsStateGuardian::
6666
~glxGraphicsStateGuardian() {
67+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
6768
destroy_temp_xwindow();
6869
if (_visuals != nullptr) {
6970
XFree(_visuals);
@@ -224,6 +225,7 @@ choose_pixel_format(const FrameBufferProperties &properties,
224225
X11_Display *display,
225226
int screen, bool need_pbuffer, bool need_pixmap) {
226227

228+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
227229
_display = display;
228230
_screen = screen;
229231
_context = nullptr;
@@ -457,6 +459,7 @@ gl_get_error() const {
457459
*/
458460
void glxGraphicsStateGuardian::
459461
query_gl_version() {
462+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
460463
PosixGraphicsStateGuardian::query_gl_version();
461464

462465
show_glx_client_string("GLX_VENDOR", GLX_VENDOR);
@@ -483,6 +486,7 @@ query_gl_version() {
483486
*/
484487
void glxGraphicsStateGuardian::
485488
get_extra_extensions() {
489+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
486490
save_extensions(glXQueryExtensionsString(_display, _screen));
487491
}
488492

@@ -497,6 +501,8 @@ do_get_extension_func(const char *name) {
497501
nassertr(name != nullptr, nullptr);
498502

499503
if (glx_get_proc_address) {
504+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
505+
500506
// First, check if we have glXGetProcAddress available. This will be
501507
// superior if we can get it.
502508

panda/src/glxdisplay/glxGraphicsWindow.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ end_flip() {
154154
*/
155155
void glxGraphicsWindow::
156156
close_window() {
157+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
158+
157159
if (_gsg != nullptr) {
158160
glXMakeCurrent(_display, None, nullptr);
159161
_gsg.clear();
@@ -204,6 +206,8 @@ open_window() {
204206
return false;
205207
}
206208

209+
LightReMutexHolder holder(glxGraphicsPipe::_x_mutex);
210+
207211
if (glxgsg->_fbconfig != None) {
208212
setup_colormap(glxgsg->_fbconfig);
209213
} else {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy