From 514097b0d4989f5f768d1888aa05c275b6df5e02 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 20 Feb 2008 01:47:04 +0000 Subject: [PATCH] reduce unnecessary calls to glxMakeCurrent() --- panda/src/glxdisplay/glxGraphicsWindow.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 26d0ac9b20..0103c777e2 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -156,7 +156,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { DCAST_INTO_R(glxgsg, _gsg, false); { ReMutexHolder holder(glxGraphicsPipe::_x_mutex); - glXMakeCurrent(_display, _xwindow, glxgsg->_context); + + if (glXGetCurrentDisplay() == _display && + glXGetCurrentDrawable() == _xwindow && + glXGetCurrentContext() == glxgsg->_context) { + // No need to make the context current again. Short-circuit + // this possibly-expensive call. + } else { + // Need to set the context. + glXMakeCurrent(_display, _xwindow, glxgsg->_context); + } } // Now that we have made the context current to a window, we can