From a3325fbcffe43915067a5fc73eabb0ea48eee0ec Mon Sep 17 00:00:00 2001 From: baldurk Date: Sat, 2 Apr 2016 16:26:08 +0200 Subject: [PATCH] Fix scarily broken iteration of GL context creation attribs list. --- renderdoc/driver/gl/gl_hooks_linux.cpp | 15 ++++----------- renderdoc/driver/gl/gl_hooks_win32.cpp | 15 ++++----------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/renderdoc/driver/gl/gl_hooks_linux.cpp b/renderdoc/driver/gl/gl_hooks_linux.cpp index 2998f6ebe..5903e8772 100644 --- a/renderdoc/driver/gl/gl_hooks_linux.cpp +++ b/renderdoc/driver/gl/gl_hooks_linux.cpp @@ -636,17 +636,15 @@ GLXContext glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, GLXConte // modify attribs to our liking { - bool flagsNext = false; bool flagsFound = false; const int *a = attribs; while(*a) { - int val = *a; + int name = *a++; + int val = *a++; - if(flagsNext) + if(name == GLX_CONTEXT_FLAGS_ARB) { - flagsNext = false; - if(RenderDoc::Inst().GetCaptureOptions().DebugDeviceMode) val |= GLX_CONTEXT_DEBUG_BIT_ARB; else @@ -654,17 +652,12 @@ GLXContext glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, GLXConte // remove NO_ERROR bit val &= ~GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR; - } - if(val == GLX_CONTEXT_FLAGS_ARB) - { - flagsNext = true; flagsFound = true; } + attribVec.push_back(name); attribVec.push_back(val); - - a++; } if(!flagsFound && RenderDoc::Inst().GetCaptureOptions().DebugDeviceMode) diff --git a/renderdoc/driver/gl/gl_hooks_win32.cpp b/renderdoc/driver/gl/gl_hooks_win32.cpp index bef12a27f..b78eb1a96 100644 --- a/renderdoc/driver/gl/gl_hooks_win32.cpp +++ b/renderdoc/driver/gl/gl_hooks_win32.cpp @@ -463,17 +463,15 @@ class OpenGLHook : LibraryHook // modify attribs to our liking { - bool flagsNext = false; bool flagsFound = false; const int *a = attribs; while(*a) { - int val = *a; + int name = *a++; + int val = *a++; - if(flagsNext) + if(name == WGL_CONTEXT_FLAGS_ARB) { - flagsNext = false; - if(RenderDoc::Inst().GetCaptureOptions().DebugDeviceMode) val |= WGL_CONTEXT_DEBUG_BIT_ARB; else @@ -481,17 +479,12 @@ class OpenGLHook : LibraryHook // remove NO_ERROR bit val &= ~GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR; - } - if(val == WGL_CONTEXT_FLAGS_ARB) - { - flagsNext = true; flagsFound = true; } + attribVec.push_back(name); attribVec.push_back(val); - - a++; } if(!flagsFound && RenderDoc::Inst().GetCaptureOptions().DebugDeviceMode)