# HG changeset patch # User Ethan Lee # Date 1503629862 14400 # Thu Aug 24 22:57:42 2017 -0400 # Node ID 7f254d0b784212973afe4ce76bf95fd1397a0552 # Parent 4d2bf1b340cd6e631f0b780ed4efaf1306f40003 Fix KHR_no_error support diff -r 4d2bf1b340cd -r 7f254d0b7842 src/video/SDL_egl.c --- a/src/video/SDL_egl.c Thu Aug 24 21:30:53 2017 -0400 +++ b/src/video/SDL_egl.c Thu Aug 24 22:57:42 2017 -0400 @@ -463,18 +463,6 @@ attribs[i++] = _this->gl_config.multisamplesamples; } - if (_this->gl_config.no_error) { -#ifdef GL_KHR_no_error - if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "GL_KHR_no_error")) { - attribs[i++] = EGL_CONTEXT_OPENGL_NO_ERROR_KHR; - attribs[i++] = _this->gl_config.no_error; - } else -#endif - { - return SDL_SetError("EGL implementation does not support no_error contexts"); - } - } - if (_this->gl_config.framebuffer_srgb_capable) { #ifdef EGL_KHR_gl_colorspace if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) { @@ -618,6 +606,19 @@ } } + if (_this->gl_config.no_error) { +#ifdef EGL_KHR_create_context_no_error + if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context_no_error")) { + attribs[attr++] = EGL_CONTEXT_OPENGL_NO_ERROR_KHR; + attribs[attr++] = _this->gl_config.no_error; + } else +#endif + { + SDL_SetError("EGL implementation does not support no_error contexts"); + return NULL; + } + } + attribs[attr++] = EGL_NONE; /* Bind the API */ diff -r 4d2bf1b340cd -r 7f254d0b7842 src/video/windows/SDL_windowsopengl.c --- a/src/video/windows/SDL_windowsopengl.c Thu Aug 24 21:30:53 2017 -0400 +++ b/src/video/windows/SDL_windowsopengl.c Thu Aug 24 22:57:42 2017 -0400 @@ -468,6 +468,11 @@ _this->gl_data->HAS_WGL_ARB_create_context_robustness = SDL_TRUE; } + /* Check for WGL_ARB_create_context_no_error */ + if (HasExtension("WGL_ARB_create_context_no_error", extensions)) { + _this->gl_data->HAS_WGL_ARB_create_context_no_error = SDL_TRUE; + } + _this->gl_data->wglMakeCurrent(hdc, NULL); _this->gl_data->wglDeleteContext(hglrc); ReleaseDC(hwnd, hdc); @@ -598,11 +603,6 @@ *iAttr++ = _this->gl_config.framebuffer_srgb_capable; } - if (_this->gl_config.no_error) { - *iAttr++ = WGL_CONTEXT_OPENGL_NO_ERROR_ARB; - *iAttr++ = _this->gl_config.no_error; - } - /* We always choose either FULL or NO accel on Windows, because of flaky drivers. If the app didn't specify, we use FULL, because that's probably what they wanted (and if you didn't care and got FULL, that's @@ -728,8 +728,8 @@ SDL_SetError("GL 3.x is not supported"); context = temp_context; } else { - /* max 12 attributes plus terminator */ - int attribs[13] = { + /* max 14 attributes plus terminator */ + int attribs[15] = { WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version, 0 @@ -764,6 +764,12 @@ WGL_NO_RESET_NOTIFICATION_ARB; } + /* only set if wgl extension is available */ + if (_this->gl_data->HAS_WGL_ARB_create_context_no_error) { + attribs[iattr++] = WGL_CONTEXT_OPENGL_NO_ERROR_ARB; + attribs[iattr++] = _this->gl_config.no_error; + } + attribs[iattr++] = 0; /* Create the GL 3.x context */ diff -r 4d2bf1b340cd -r 7f254d0b7842 src/video/windows/SDL_windowsopengl.h --- a/src/video/windows/SDL_windowsopengl.h Thu Aug 24 21:30:53 2017 -0400 +++ b/src/video/windows/SDL_windowsopengl.h Thu Aug 24 22:57:42 2017 -0400 @@ -31,6 +31,7 @@ SDL_bool HAS_WGL_EXT_swap_control_tear; SDL_bool HAS_WGL_ARB_context_flush_control; SDL_bool HAS_WGL_ARB_create_context_robustness; + SDL_bool HAS_WGL_ARB_create_context_no_error; /* Max version of OpenGL ES context that can be created if the implementation supports WGL_EXT_create_context_es2_profile. diff -r 4d2bf1b340cd -r 7f254d0b7842 src/video/x11/SDL_x11opengl.c --- a/src/video/x11/SDL_x11opengl.c Thu Aug 24 21:30:53 2017 -0400 +++ b/src/video/x11/SDL_x11opengl.c Thu Aug 24 22:57:42 2017 -0400 @@ -406,6 +406,11 @@ if (HasExtension("GLX_ARB_create_context_robustness", extensions)) { _this->gl_data->HAS_GLX_ARB_create_context_robustness = SDL_TRUE; } + + /* Check for GLX_ARB_create_context_no_error */ + if (HasExtension("GLX_ARB_create_context_no_error", extensions)) { + _this->gl_data->HAS_GLX_ARB_create_context_no_error = SDL_TRUE; + } } /* glXChooseVisual and glXChooseFBConfig have some small differences in @@ -501,11 +506,6 @@ attribs[i++] = True; /* always needed, for_FBConfig or not! */ } - if (_this->gl_config.no_error) { - attribs[i++] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB; - attribs[i++] = _this->gl_config.no_error; - } - if (_this->gl_config.accelerated >= 0 && _this->gl_data->HAS_GLX_EXT_visual_rating) { attribs[i++] = GLX_VISUAL_CAVEAT_EXT; @@ -638,8 +638,8 @@ context = _this->gl_data->glXCreateContext(display, vinfo, share_context, True); } else { - /* max 12 attributes plus terminator */ - int attribs[13] = { + /* max 14 attributes plus terminator */ + int attribs[15] = { GLX_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, GLX_CONTEXT_MINOR_VERSION_ARB, @@ -678,6 +678,12 @@ GLX_NO_RESET_NOTIFICATION_ARB; } + /* only set if glx extension is available */ + if( _this->gl_data->HAS_GLX_ARB_create_context_no_error ) { + attribs[iattr++] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB; + attribs[iattr++] = _this->gl_config.no_error; + } + attribs[iattr++] = 0; /* Get a pointer to the context creation function for GL 3.0 */ diff -r 4d2bf1b340cd -r 7f254d0b7842 src/video/x11/SDL_x11opengl.h --- a/src/video/x11/SDL_x11opengl.h Thu Aug 24 21:30:53 2017 -0400 +++ b/src/video/x11/SDL_x11opengl.h Thu Aug 24 22:57:42 2017 -0400 @@ -36,6 +36,7 @@ SDL_bool HAS_GLX_EXT_swap_control_tear; SDL_bool HAS_GLX_ARB_context_flush_control; SDL_bool HAS_GLX_ARB_create_context_robustness; + SDL_bool HAS_GLX_ARB_create_context_no_error; /* Max version of OpenGL ES context that can be created if the implementation supports GLX_EXT_create_context_es2_profile.