Allow setting of GL_CONTEXT_RELEASE_BEHAVIOR when creating the GL context when GLX_ARB_context_flush_control is available.
This extension allows the user to specify whether a full flush is performed when making a context not current. The only way to set this currently is at context creation, so this patch provides that functionality. Defualt behaviour is set at FLUSH, as per the spec. This patch does not contain the changes to WGL, appleGL or other platforms as I do not have access to GL 4.5 hardware on those platforms. Full details on the use of KHR_context_flush_control can be found here: https://www.opengl.org/registry/specs/KHR/context_flush_control.txtmain
parent
70191a9302
commit
f5d96416ad
|
@ -2988,6 +2988,11 @@ GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);
|
|||
#define GL_ARB_framebuffer_sRGB 1
|
||||
#endif /* GL_ARB_framebuffer_sRGB */
|
||||
|
||||
#ifndef GL_KHR_context_flush_control
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB
|
||||
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC
|
||||
#endif /* GL_KHR_context_flush_control */
|
||||
|
||||
#ifndef GL_ARB_geometry_shader4
|
||||
#define GL_ARB_geometry_shader4 1
|
||||
#define GL_LINES_ADJACENCY_ARB 0x000A
|
||||
|
|
|
@ -189,7 +189,8 @@ typedef enum
|
|||
SDL_GL_CONTEXT_FLAGS,
|
||||
SDL_GL_CONTEXT_PROFILE_MASK,
|
||||
SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
|
||||
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
|
||||
SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR
|
||||
} SDL_GLattr;
|
||||
|
||||
typedef enum
|
||||
|
@ -207,6 +208,12 @@ typedef enum
|
|||
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
|
||||
} SDL_GLcontextFlag;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
|
||||
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
|
||||
} SDL_GLcontextReleaseFlag;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
|
|
|
@ -303,6 +303,7 @@ struct SDL_VideoDevice
|
|||
int flags;
|
||||
int profile_mask;
|
||||
int share_with_current_context;
|
||||
int release_behavior;
|
||||
int framebuffer_srgb_capable;
|
||||
int retained_backing;
|
||||
int driver_loaded;
|
||||
|
|
|
@ -2637,6 +2637,7 @@ SDL_GL_ResetAttributes()
|
|||
#endif
|
||||
_this->gl_config.flags = 0;
|
||||
_this->gl_config.framebuffer_srgb_capable = 0;
|
||||
_this->gl_config.release_behavior = SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
|
||||
|
||||
_this->gl_config.share_with_current_context = 0;
|
||||
}
|
||||
|
@ -2743,6 +2744,9 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
|||
case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE:
|
||||
_this->gl_config.framebuffer_srgb_capable = value;
|
||||
break;
|
||||
case SDL_GL_CONTEXT_RELEASE_BEHAVIOR:
|
||||
_this->gl_config.release_behavior = value;
|
||||
break;
|
||||
default:
|
||||
retval = SDL_SetError("Unknown OpenGL attribute");
|
||||
break;
|
||||
|
@ -2843,6 +2847,13 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
|
|||
attrib = GL_SAMPLES_ARB;
|
||||
#else
|
||||
attrib = GL_SAMPLES;
|
||||
#endif
|
||||
break;
|
||||
case SDL_GL_CONTEXT_RELEASE_BEHAVIOR:
|
||||
#if SDL_VIDEO_OPENGL
|
||||
attrib = GL_CONTEXT_RELEASE_BEHAVIOR;
|
||||
#else
|
||||
attrib = GL_CONTEXT_RELEASE_BEHAVIOR_KHR;
|
||||
#endif
|
||||
break;
|
||||
case SDL_GL_BUFFER_SIZE:
|
||||
|
|
|
@ -122,6 +122,13 @@ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy,
|
|||
#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3
|
||||
#endif
|
||||
|
||||
#ifndef GLX_ARB_context_flush_control
|
||||
#define GLX_ARB_context_flush_control
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
|
||||
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#endif
|
||||
|
||||
#define OPENGL_REQUIRES_DLOPEN
|
||||
#if defined(OPENGL_REQUIRES_DLOPEN) && defined(SDL_LOADSO_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
|
@ -375,6 +382,11 @@ X11_GL_InitExtensions(_THIS)
|
|||
if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) {
|
||||
_this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check for GLX_ARB_context_flush_control */
|
||||
if (HasExtension("GLX_ARB_context_flush_control", extensions)) {
|
||||
_this->gl_data->HAS_GLX_ARB_context_flush_control = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* glXChooseVisual and glXChooseFBConfig have some small differences in
|
||||
|
@ -581,8 +593,8 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
context =
|
||||
_this->gl_data->glXCreateContext(display, vinfo, share_context, True);
|
||||
} else {
|
||||
/* max 8 attributes plus terminator */
|
||||
int attribs[9] = {
|
||||
/* max 10 attributes plus terminator */
|
||||
int attribs[11] = {
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB,
|
||||
_this->gl_config.major_version,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB,
|
||||
|
@ -603,6 +615,15 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
attribs[iattr++] = _this->gl_config.flags;
|
||||
}
|
||||
|
||||
/* only set if glx extension is available */
|
||||
if( _this->gl_data->HAS_GLX_ARB_context_flush_control ) {
|
||||
attribs[iattr++] = GLX_CONTEXT_RELEASE_BEHAVIOR_ARB;
|
||||
attribs[iattr++] =
|
||||
_this->gl_config.release_behavior ?
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB :
|
||||
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB;
|
||||
}
|
||||
|
||||
attribs[iattr++] = 0;
|
||||
|
||||
/* Get a pointer to the context creation function for GL 3.0 */
|
||||
|
|
|
@ -35,6 +35,7 @@ struct SDL_GLDriverData
|
|||
SDL_bool HAS_GLX_EXT_visual_info;
|
||||
SDL_bool HAS_GLX_EXT_swap_control_tear;
|
||||
SDL_bool HAS_GLX_EXT_create_context_es2_profile;
|
||||
SDL_bool HAS_GLX_ARB_context_flush_control;
|
||||
|
||||
Bool (*glXQueryExtension) (Display*,int*,int*);
|
||||
void *(*glXGetProcAddress) (const GLubyte*);
|
||||
|
|
Loading…
Reference in New Issue