Fix KHR_no_error support
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 6241c49..1e0aacf 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -463,18 +463,6 @@ SDL_EGL_ChooseConfig(_THIS)
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 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
}
}
+ 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 --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c
index a46c4e4..9398ded 100644
--- a/src/video/windows/SDL_windowsopengl.c
+++ b/src/video/windows/SDL_windowsopengl.c
@@ -468,6 +468,11 @@ WIN_GL_InitExtensions(_THIS)
_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 @@ WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window)
*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 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
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 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
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 --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h
index 87e4689..1d9fa23 100644
--- a/src/video/windows/SDL_windowsopengl.h
+++ b/src/video/windows/SDL_windowsopengl.h
@@ -31,6 +31,7 @@ struct SDL_GLDriverData
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 --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c
index 37267ed..9bbcb05 100644
--- a/src/video/x11/SDL_x11opengl.c
+++ b/src/video/x11/SDL_x11opengl.c
@@ -406,6 +406,11 @@ X11_GL_InitExtensions(_THIS)
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 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si
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 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
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 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
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 --git a/src/video/x11/SDL_x11opengl.h b/src/video/x11/SDL_x11opengl.h
index dd3c7e5..8e0b0f3 100644
--- a/src/video/x11/SDL_x11opengl.h
+++ b/src/video/x11/SDL_x11opengl.h
@@ -36,6 +36,7 @@ struct SDL_GLDriverData
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.