From c9c51b5a3eb16c8fe07234fe7feedc58b6153bc1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 10 Sep 2018 10:49:54 +0100 Subject: [PATCH] Don't update context parameters when MakeCurrent is called with NULL --- renderdoc/driver/gl/cgl_hooks.cpp | 9 ++++++--- renderdoc/driver/gl/egl_hooks.cpp | 29 ++++++++++++++++------------- renderdoc/driver/gl/glx_hooks.cpp | 3 +++ renderdoc/driver/gl/wgl_hooks.cpp | 2 +- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/renderdoc/driver/gl/cgl_hooks.cpp b/renderdoc/driver/gl/cgl_hooks.cpp index 5fe609ef0..c7b7aba07 100644 --- a/renderdoc/driver/gl/cgl_hooks.cpp +++ b/renderdoc/driver/gl/cgl_hooks.cpp @@ -126,9 +126,12 @@ CGLError GL_EXPORT_NAME(CGLSetCurrentContext)(CGLContextObj ctx) cglhook.driver.ActivateContext(data); - GLInitParams ¶ms = cglhook.driver.GetInitParams(data); - params.width = 400; - params.height = 200; + if(data.ctx) + { + GLInitParams ¶ms = cglhook.driver.GetInitParams(data); + params.width = 400; + params.height = 200; + } } return ret; diff --git a/renderdoc/driver/gl/egl_hooks.cpp b/renderdoc/driver/gl/egl_hooks.cpp index b92c2c95f..ffd467285 100644 --- a/renderdoc/driver/gl/egl_hooks.cpp +++ b/renderdoc/driver/gl/egl_hooks.cpp @@ -295,23 +295,26 @@ HOOK_EXPORT EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay display, EGLSurface eglhook.driver.ActivateContext(data); - GLInitParams ¶ms = eglhook.driver.GetInitParams(data); + if(ctx && draw) + { + GLInitParams ¶ms = eglhook.driver.GetInitParams(data); - int height, width; - EGL.QuerySurface(display, draw, EGL_HEIGHT, &height); - EGL.QuerySurface(display, draw, EGL_WIDTH, &width); + int height, width; + EGL.QuerySurface(display, draw, EGL_HEIGHT, &height); + EGL.QuerySurface(display, draw, EGL_WIDTH, &width); - int colorspace = 0; - EGL.QuerySurface(display, draw, EGL_GL_COLORSPACE, &colorspace); - // GL_SRGB8_ALPHA8 is specified as color-renderable, unlike GL_SRGB8. - bool isSRGB = params.colorBits == 32 && colorspace == EGL_GL_COLORSPACE_SRGB; + int colorspace = 0; + EGL.QuerySurface(display, draw, EGL_GL_COLORSPACE, &colorspace); + // GL_SRGB8_ALPHA8 is specified as color-renderable, unlike GL_SRGB8. + bool isSRGB = params.colorBits == 32 && colorspace == EGL_GL_COLORSPACE_SRGB; - bool isYFlipped = eglhook.IsYFlipped(display, draw); + bool isYFlipped = eglhook.IsYFlipped(display, draw); - params.width = width; - params.height = height; - params.isSRGB = isSRGB; - params.isYFlipped = isYFlipped; + params.width = width; + params.height = height; + params.isSRGB = isSRGB; + params.isYFlipped = isYFlipped; + } } return ret; diff --git a/renderdoc/driver/gl/glx_hooks.cpp b/renderdoc/driver/gl/glx_hooks.cpp index 2d00071a8..b939a51cd 100644 --- a/renderdoc/driver/gl/glx_hooks.cpp +++ b/renderdoc/driver/gl/glx_hooks.cpp @@ -64,6 +64,9 @@ public: void UpdateWindowSize(GLWindowingData data, Display *dpy, GLXDrawable drawable) { + if(!data.ctx || !drawable) + return; + // if we use the GLXDrawable in XGetGeometry and it's a GLXWindow, then we get // a BadDrawable error and things go south. Instead we track GLXWindows created // in glXCreateWindow/glXDestroyWindow and look up the source window it was diff --git a/renderdoc/driver/gl/wgl_hooks.cpp b/renderdoc/driver/gl/wgl_hooks.cpp index 13d3162e3..35803e6f9 100644 --- a/renderdoc/driver/gl/wgl_hooks.cpp +++ b/renderdoc/driver/gl/wgl_hooks.cpp @@ -369,7 +369,7 @@ static BOOL WINAPI wglMakeCurrent_hooked(HDC dc, HGLRC rc) data.wnd = WindowFromDC(dc); data.ctx = rc; - if(wglhook.haveContextCreation) + if(wglhook.haveContextCreation && data.ctx && data.wnd) { RECT r; GetClientRect(data.wnd, &r);