Skip to content

Commit

Permalink
opengl: add support for GL_KHR_no_error.
Browse files Browse the repository at this point in the history
This is completely untested!

Fixes Bugzilla #3721.
  • Loading branch information
icculus committed Aug 25, 2017
1 parent a3890ff commit d8fc70e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/SDL_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ typedef enum
SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
SDL_GL_CONTEXT_RESET_NOTIFICATION
SDL_GL_CONTEXT_RESET_NOTIFICATION,
SDL_GL_CONTEXT_NO_ERROR
} SDL_GLattr;

typedef enum
Expand Down
12 changes: 12 additions & 0 deletions src/video/SDL_egl.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,18 @@ 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")) {
Expand Down
1 change: 1 addition & 0 deletions src/video/SDL_sysvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ struct SDL_VideoDevice
int release_behavior;
int reset_notification;
int framebuffer_srgb_capable;
int no_error;
int retained_backing;
int driver_loaded;
char driver_path[256];
Expand Down
9 changes: 9 additions & 0 deletions src/video/SDL_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -2989,6 +2989,7 @@ SDL_GL_ResetAttributes()
#endif
_this->gl_config.flags = 0;
_this->gl_config.framebuffer_srgb_capable = 0;
_this->gl_config.no_error = 0;
_this->gl_config.release_behavior = SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
_this->gl_config.reset_notification = SDL_GL_CONTEXT_RESET_NO_NOTIFICATION;

Expand Down Expand Up @@ -3103,6 +3104,9 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
case SDL_GL_CONTEXT_RESET_NOTIFICATION:
_this->gl_config.reset_notification = value;
break;
case SDL_GL_CONTEXT_NO_ERROR:
_this->gl_config.no_error = value;
break;
default:
retval = SDL_SetError("Unknown OpenGL attribute");
break;
Expand Down Expand Up @@ -3307,6 +3311,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
*value = _this->gl_config.framebuffer_srgb_capable;
return 0;
}
case SDL_GL_CONTEXT_NO_ERROR:
{
*value = _this->gl_config.no_error;
return 0;
}
default:
return SDL_SetError("Unknown OpenGL attribute");
}
Expand Down
10 changes: 10 additions & 0 deletions src/video/windows/SDL_windowsopengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#endif

#ifndef WGL_ARB_create_context_no_error
#define WGL_ARB_create_context_no_error
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
#endif

typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
HGLRC
hShareContext,
Expand Down Expand Up @@ -593,6 +598,11 @@ 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
Expand Down
12 changes: 12 additions & 0 deletions src/video/x11/SDL_x11opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy,
#endif
#endif

#ifndef GLX_ARB_create_context_no_error
#define GLX_ARB_create_context_no_error
#ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB
#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
#endif
#endif

#ifndef GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
Expand Down Expand Up @@ -494,6 +501,11 @@ 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;
Expand Down

0 comments on commit d8fc70e

Please sign in to comment.