opengl: add support for GL_KHR_no_error.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 24 Aug 2017 21:30:53 -0400
changeset 113464d2bf1b340cd
parent 11345 6120f75935f9
child 11347 7f254d0b7842
opengl: add support for GL_KHR_no_error.

This is completely untested!

Fixes Bugzilla #3721.
include/SDL_video.h
src/video/SDL_egl.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/windows/SDL_windowsopengl.c
src/video/x11/SDL_x11opengl.c
     1.1 --- a/include/SDL_video.h	Tue Aug 22 15:50:39 2017 -0400
     1.2 +++ b/include/SDL_video.h	Thu Aug 24 21:30:53 2017 -0400
     1.3 @@ -202,7 +202,8 @@
     1.4      SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
     1.5      SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
     1.6      SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
     1.7 -    SDL_GL_CONTEXT_RESET_NOTIFICATION
     1.8 +    SDL_GL_CONTEXT_RESET_NOTIFICATION,
     1.9 +    SDL_GL_CONTEXT_NO_ERROR
    1.10  } SDL_GLattr;
    1.11  
    1.12  typedef enum
     2.1 --- a/src/video/SDL_egl.c	Tue Aug 22 15:50:39 2017 -0400
     2.2 +++ b/src/video/SDL_egl.c	Thu Aug 24 21:30:53 2017 -0400
     2.3 @@ -463,6 +463,18 @@
     2.4          attribs[i++] = _this->gl_config.multisamplesamples;
     2.5      }
     2.6  
     2.7 +    if (_this->gl_config.no_error) {
     2.8 +#ifdef GL_KHR_no_error
     2.9 +        if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "GL_KHR_no_error")) {
    2.10 +            attribs[i++] = EGL_CONTEXT_OPENGL_NO_ERROR_KHR;
    2.11 +            attribs[i++] = _this->gl_config.no_error;
    2.12 +        } else
    2.13 +#endif
    2.14 +        {
    2.15 +            return SDL_SetError("EGL implementation does not support no_error contexts");
    2.16 +        }
    2.17 +    }
    2.18 +
    2.19      if (_this->gl_config.framebuffer_srgb_capable) {
    2.20  #ifdef EGL_KHR_gl_colorspace
    2.21          if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
     3.1 --- a/src/video/SDL_sysvideo.h	Tue Aug 22 15:50:39 2017 -0400
     3.2 +++ b/src/video/SDL_sysvideo.h	Thu Aug 24 21:30:53 2017 -0400
     3.3 @@ -331,6 +331,7 @@
     3.4          int release_behavior;
     3.5          int reset_notification;
     3.6          int framebuffer_srgb_capable;
     3.7 +        int no_error;
     3.8          int retained_backing;
     3.9          int driver_loaded;
    3.10          char driver_path[256];
     4.1 --- a/src/video/SDL_video.c	Tue Aug 22 15:50:39 2017 -0400
     4.2 +++ b/src/video/SDL_video.c	Thu Aug 24 21:30:53 2017 -0400
     4.3 @@ -2989,6 +2989,7 @@
     4.4  #endif
     4.5      _this->gl_config.flags = 0;
     4.6      _this->gl_config.framebuffer_srgb_capable = 0;
     4.7 +    _this->gl_config.no_error = 0;
     4.8      _this->gl_config.release_behavior = SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
     4.9      _this->gl_config.reset_notification = SDL_GL_CONTEXT_RESET_NO_NOTIFICATION;
    4.10  
    4.11 @@ -3103,6 +3104,9 @@
    4.12      case SDL_GL_CONTEXT_RESET_NOTIFICATION:
    4.13          _this->gl_config.reset_notification = value;
    4.14          break;
    4.15 +    case SDL_GL_CONTEXT_NO_ERROR:
    4.16 +        _this->gl_config.no_error = value;
    4.17 +        break;
    4.18      default:
    4.19          retval = SDL_SetError("Unknown OpenGL attribute");
    4.20          break;
    4.21 @@ -3307,6 +3311,11 @@
    4.22              *value = _this->gl_config.framebuffer_srgb_capable;
    4.23              return 0;
    4.24          }
    4.25 +    case SDL_GL_CONTEXT_NO_ERROR:
    4.26 +        {
    4.27 +            *value = _this->gl_config.no_error;
    4.28 +            return 0;
    4.29 +        }
    4.30      default:
    4.31          return SDL_SetError("Unknown OpenGL attribute");
    4.32      }
     5.1 --- a/src/video/windows/SDL_windowsopengl.c	Tue Aug 22 15:50:39 2017 -0400
     5.2 +++ b/src/video/windows/SDL_windowsopengl.c	Thu Aug 24 21:30:53 2017 -0400
     5.3 @@ -82,6 +82,11 @@
     5.4  #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB          0x2098
     5.5  #endif
     5.6  
     5.7 +#ifndef WGL_ARB_create_context_no_error
     5.8 +#define WGL_ARB_create_context_no_error
     5.9 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB                 0x31B3
    5.10 +#endif
    5.11 +
    5.12  typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
    5.13                                                              HGLRC
    5.14                                                              hShareContext,
    5.15 @@ -593,6 +598,11 @@
    5.16          *iAttr++ = _this->gl_config.framebuffer_srgb_capable;
    5.17      }
    5.18  
    5.19 +    if (_this->gl_config.no_error) {
    5.20 +        *iAttr++ = WGL_CONTEXT_OPENGL_NO_ERROR_ARB;
    5.21 +        *iAttr++ = _this->gl_config.no_error;
    5.22 +    }
    5.23 +
    5.24      /* We always choose either FULL or NO accel on Windows, because of flaky
    5.25         drivers. If the app didn't specify, we use FULL, because that's
    5.26         probably what they wanted (and if you didn't care and got FULL, that's
     6.1 --- a/src/video/x11/SDL_x11opengl.c	Tue Aug 22 15:50:39 2017 -0400
     6.2 +++ b/src/video/x11/SDL_x11opengl.c	Thu Aug 24 21:30:53 2017 -0400
     6.3 @@ -114,6 +114,13 @@
     6.4  #endif
     6.5  #endif
     6.6  
     6.7 +#ifndef GLX_ARB_create_context_no_error
     6.8 +#define GLX_ARB_create_context_no_error
     6.9 +#ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB
    6.10 +#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB                 0x31B3
    6.11 +#endif
    6.12 +#endif
    6.13 +
    6.14  #ifndef GLX_EXT_swap_control
    6.15  #define GLX_SWAP_INTERVAL_EXT              0x20F1
    6.16  #define GLX_MAX_SWAP_INTERVAL_EXT          0x20F2
    6.17 @@ -494,6 +501,11 @@
    6.18          attribs[i++] = True;  /* always needed, for_FBConfig or not! */
    6.19      }
    6.20  
    6.21 +    if (_this->gl_config.no_error) {
    6.22 +        attribs[i++] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB;
    6.23 +        attribs[i++] = _this->gl_config.no_error;
    6.24 +    }
    6.25 +
    6.26      if (_this->gl_config.accelerated >= 0 &&
    6.27          _this->gl_data->HAS_GLX_EXT_visual_rating) {
    6.28          attribs[i++] = GLX_VISUAL_CAVEAT_EXT;