We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2898

Summary: [patch] X11: Support for GLX_ARB_context_flush_control
Product: SDL Reporter: Marc Di Luzio <mdiluzio>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: amaranth72, icculus, mdiluzio
Version: 2.0.3Keywords: triage-2.0.4
Hardware: All   
OS: All   
Attachments: proposed patch

Description Marc Di Luzio 2015-03-06 17:28:39 UTC
Created attachment 2057 [details]
proposed patch

Would it be possible to merge this patch? This extension will be very useful to reduce CPU load on games that utilise it with the latest drivers.

This patch proposal allows setting of GL_CONTEXT_RELEASE_BEHAVIOR when creating a GL context when GLX_ARB_context_flush_control is available.

GLX_ARB_context_flush_control 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.
Default behaviour is set at FLUSH, as per the spec.

The patch does not contain the changes to WGL, AppleGL or other platforms as I do not have access to drivers that implement this extension on platforms other than Linux X11.
It should however be trivial to implement those platforms when hardware is available to verify changes.

Full details on the use of KHR_context_flush_control can be found here:
https://www.opengl.org/registry/specs/KHR/context_flush_control.txt


Example usage might be -
> /* Set preferred context behavior */
> SDL_GL_SetAttribute(SDL_GL_CONTEXT_RELEASE_BEHAVIOR, SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE);
> SDL_GLContext context = SDL_GL_CreateContext(window)
> 
> /* Verify context behavior */
> int context_release;
> SDL_GL_GetAttribute(SDL_GL_CONTEXT_RELEASE_BEHAVIOR, &context_release)
> if( context_release == GL_NONE ) {
>    /* some appropriate behavior change */
> }
Comment 1 Ryan C. Gordon 2015-03-20 16:25:32 UTC
Your patch is now https://hg.libsdl.org/SDL/rev/8b1436ce1028 (thanks!), and I filled in the Windows equivalent in https://hg.libsdl.org/SDL/rev/eb50f63a5777 ...

--ryan.
Comment 2 Marc Di Luzio 2015-03-20 17:50:02 UTC
Awesome, thank you Ryan!