SFML community forums

General => Feature requests => Topic started by: feliwir on January 31, 2016, 03:40:43 pm

Title: Support robust context creation
Post by: feliwir on January 31, 2016, 03:40:43 pm
Hello everyone,

I'd like to see that SFML allows the creation of robust OpenGL contexts. This is related to the GL_ARB_robustness  (https://www.opengl.org/registry/specs/ARB/robustness.txt) extension, which got part of core OpenGL in 4.1. The thing SFML would need to add is GLX_ARB_create_context_robustness (for X11) and WGL_ARB_create_context_robustness (for windows). The benefit of a robust OpenGL context is that the programmer will get notified when a graphics reset happens and he can handle the behaviour of the program in that case. The glfw library does already allow to use this feature by adding new context creation flags, see here (http://www.glfw.org/docs/latest/window.html#window_hints_ctx) for reference. I think this would be a very useful feature for everyone using SFML with OpenGL.
Greetings
feliwir
Title: Re: Support robust context creation
Post by: zsbzsb on February 01, 2016, 05:58:22 am
Quote
The benefit of a robust OpenGL context is that the programmer will get notified when a graphics reset happens and he can handle the behaviour of the program in that case.

I'm not against something like this, but it begs the question - how? Say support is added for 'robust' contexts, how will a user be notified? Then say there is a way to get the notification, what will the user do then? SFML doesn't provide any way to easily recreate the context associated with a window without recreating the entire window.
Title: Re: Support robust context creation
Post by: Laurent on February 01, 2016, 07:30:20 am
Quote
when a graphics reset happens
In what circumstances can a graphics reset happen? It doesn't sound like a common issue.
Title: Re: Support robust context creation
Post by: Mario on February 01, 2016, 09:15:19 am
Not sure about latest versions of Windows, drivers, etc. but IIRC this could happen when Windows shows an UAC prompt or you hit Ctrl+Alt+Del. I only remember this happening on DirectX though, haven't used OpenGL back then.

Also how about switching displays, e.g. having two monitors, one on the onboard card, one on dedicated card, moving the Window between screens should(?) cause something, unless that's handled by drivers. Unfortunately can't test that right now.
Title: Re: Support robust context creation
Post by: feliwir on February 01, 2016, 09:24:39 am
There are a couple ways how a graphics reset could happen, and this extension is also part of OpenGL ES where graphics reset seem to happen way more frequently. However to check for a graphics reset the programmer must call GetGraphicsResetStatus which will then tell the programmer if a graphics reset happened (and if the current  context was responsible for it). I should also mention that this extension makes OpenGL safer for malware exploits by adding new fuctions with an additional bufSize parameter, see the specification for a list with new functions.
When a graphics reset happens a programmer must revalidate all buffers & textures and then can proceed like nothing ever happened.
Title: Re: Support robust context creation
Post by: Laurent on February 01, 2016, 11:24:40 am
Quote
There are a couple ways how a graphics reset could happen
Which are... ?
Title: Re: Support robust context creation
Post by: feliwir on February 01, 2016, 11:35:49 am
I always get a graphics resets on windows 10 with Nvidia 361.75 driver when using the NSight plugin for Visual Studio  :) But there are many other ways aswell when you missuse some OpenGL functions
Title: Re: Support robust context creation
Post by: Nexus on February 07, 2016, 03:15:12 am
But there are many other ways aswell
Being concrete would actually help. We're programmers, not politicians. ;)
Title: Re: Support robust context creation
Post by: feliwir on February 07, 2016, 09:20:22 am
I guess to convince anyone i need to write a sample program. Will do so within the next days