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 - [patch] X11: Support for GLX_ARB_context_flush_control
Summary: [patch] X11: Support for GLX_ARB_context_flush_control
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.3
Hardware: All All
: P2 enhancement
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: triage-2.0.4
Depends on:
Blocks:
 
Reported: 2015-03-06 17:28 UTC by Marc Di Luzio
Modified: 2015-03-20 17:50 UTC (History)
3 users (show)

See Also:


Attachments
proposed patch (6.34 KB, patch)
2015-03-06 17:28 UTC, Marc Di Luzio
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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!