Fix KHR_no_error support

This commit is contained in:
Ethan Lee 2017-08-24 22:57:42 -04:00
parent d8fc70ea1e
commit 685890a229
5 changed files with 41 additions and 26 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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.

View File

@ -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 */

View File

@ -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.