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 3721

Summary: [OpenGL] Add KHR_no_error support
Product: SDL Reporter: Ethan Lee <flibitijibibo>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: amaranth72
Version: HG 2.0Keywords: target-2.0.6
Hardware: All   
OS: All   
Attachments: EGL KHR_no_error fix
KHR_no_error fix

Description Ethan Lee 2017-08-01 15:17:34 UTC
The KHR_no_error extension was formally included in OpenGL 4.6:

https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_no_error.txt

On the surface it's pretty easy, we just add to SDL_GLcontextFlag to support the new value. We may want to check for conflicts with the DEBUG flag though...?
Comment 1 Ryan C. Gordon 2017-08-02 21:55:18 UTC
Wait, how does this work? The new context flag has the same value as GLX_CONTEXT_RESET_ISOLATION_BIT_ARB; is there a non-glX interface for creating contexts we need to make this work? Is this EGL only or something?

I'm confused.

--ryan.
Comment 2 Ethan Lee 2017-08-02 22:05:11 UTC
It looks like part of the extension also includes another extension for WGL/GLX called ARB_create_context_no_error and an EGL extension called EGL_KHR_create_context_no_error:

https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_create_context_no_error.txt

https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_create_context_no_error.txt

So that's what we're actually adding, I think.
Comment 3 Alex Szpakowski 2017-08-02 22:50:31 UTC
FWIW the nvidia driver (the only one to implement this currently) currently just doesn't post the error it detects, rather than running a separate codepath that doesn't bother checking errors, so performance gains are (right now) negligible.

https://www.slideshare.net/Mark_Kilgard/nvgl17/49
Comment 4 Ryan C. Gordon 2017-08-25 01:31:32 UTC
I've implemented this in https://hg.libsdl.org/SDL/rev/4d2bf1b340cd, but it's totally untested as I have nothing here that can use this extension at the moment. Please test and report back!!

--ryan.
Comment 5 Ethan Lee 2017-08-25 02:31:56 UTC
I still need to try this out as well but it looks like the EGL implementation needs to use "EGL_KHR_create_context_no_error" for both the ifdef and SDL_EGL_HasExtension check, rather than GL_KHR_no_error. Will report back once I've actually tested it on a supported driver.
Comment 6 Ethan Lee 2017-08-25 02:44:52 UTC
Created attachment 2887 [details]
EGL KHR_no_error fix

Right, so the current revision doesn't work but the fix is really simple: Just move the attrib check to CreateContext rather than CreateVisual (or whatever the equivalent is). Attached is the EGL version of that fix, along with that extension check fix I mentioned earlier.
Comment 7 Ethan Lee 2017-08-25 03:01:23 UTC
Created attachment 2888 [details]
KHR_no_error fix

Sorry for posting a whole bunch at once but it turns out this was easier to work on that I was expecting. Here's a patch for EGL/WGL/GLX, works on my NVIDIA PC just fine!
Comment 8 Ryan C. Gordon 2017-08-25 05:29:55 UTC
(In reply to Ethan Lee from comment #7)
> Here's a patch for EGL/WGL/GLX, works on my NVIDIA PC just fine!

This patch is now https://hg.libsdl.org/SDL/rev/7f254d0b7842, thanks!

--ryan.