Bug 91044 - piglit spec/egl_khr_create_context/valid debug flag gles* fail
Summary: piglit spec/egl_khr_create_context/valid debug flag gles* fail
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: EGL (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-21 14:27 UTC by Boyan Ding
Modified: 2015-10-03 11:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Boyan Ding 2015-06-21 14:27:21 UTC
When running piglit test on egl_x11 platform, I accidentally noticed that piglit test spec/egl_khr_create_context/valid debug flag gles{1,2,3} fail. The reason is that mesa EGL gives unexpected EGL_BAD_ATTRIBUTE. Digging into the EGL code, I found libEGL will give EGL_BAD_ATTRIBUTE when setting EGL_CONTEXT_FLAGS_KHR in non-OpenGL contexts (including OpenGL ES context), with the quote in comment:

 /* The EGL_KHR_create_context spec says:
  *
  *     "Flags are only defined for OpenGL context creation, and
  *     specifying a flags value other than zero for other types of
  *     contexts, including OpenGL ES contexts, will generate an
  *     error."
  */

However, I can't find the words quoted in the present EGL_KHR_create_context spec. On the other hand, it allows creating debug context in OpenGL ES (i.e. setting EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR in EGL_CONTEXT_FLAGS_KHR).

Should we just remove the non-OpenGL check or just allow EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR in OpenGL ES context?
Comment 1 Emil Velikov 2015-06-22 16:27:09 UTC
Based of the patch date (17 July 2012) and the extension revision history I'd say that things were changed/nuked in Version 12 or later. With Version 15 being the prime suspect.

As Intel is a Khronos member, you should have access to the SVN repo/history for the exact details. I'd assume that it would be the better option.
Comment 2 Boyan Ding 2015-06-23 02:37:17 UTC
(In reply to Emil Velikov from comment #1)
> As Intel is a Khronos member, you should have access to the SVN repo/history
> for the exact details. I'd assume that it would be the better option.

Sorry if I caused confusion, but I'm not affiliated with Intel (or any other Khronos member). So I seem not able to access the spec history.

I tried simply removing the non-OpenGL check, but it breaks another piglit test, namely spec/egl_khr_create_context/invalid flag gles, giving EGL_BAD_MATCH instead of EGL_BAD_ATTRIBUTE in some cases (I guess when the flag given is valid for OpenGL but not ES). And I saw that test was updated against version 15 of EGL_KHR_create_context_spec (commit 5f668b1 [1]). The comment there is explains

 /* According to the EGL_KHR_create_context spec, version 15, there
  * exists exactly one valid flag for OpenGL ES contexts: the debug
  * flag.
  *     If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in
  *     EGL_CONTEXT_FLAGS_KHR, then a <debug context> will be created.
  *     [...] This bit is supported for OpenGL and OpenGL ES contexts.
  */

So it seems allowing EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR in OpenGL ES is more reasonable. If so, I'll work out a patch and send it to the ML.

[1] http://cgit.freedesktop.org/piglit/commit/?id=5f668b118fed374a16d21ea1c0b2e82c0b658cc5
Comment 3 Boyan Ding 2015-06-23 04:27:22 UTC
Found the exact reason why EGL_BAD_MATCH instead of EGL_BAD_ATTRIBUTE is given for unknown flags in OpenGL ES context. src/mesa/drivers/dri/common/dri_util.c gives __DRI_CTX_ERROR_BAD_FLAG when hitting unknown flag in OpenGL ES but gives __DRI_CTX_ERROR_UNKNOWN_FLAG in OpenGL instead.

Looking into the history, some old comment seems to suggest that the error value has something to do with GLX_EXT_create_context_es2_profile. I don't know exactly what error should be given in that case.
Comment 4 Emil Velikov 2015-06-23 16:49:22 UTC
Got confused there thinking that you're with Intel, sorry about that Boyan.

As expected we're missing the v15 update of the spec in our libEGL. I will try to find some time and dig through the spec history late this week. This way we'll clearly see if there are other missing pieces ;-)

And yes, allowing EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR for GLES seems like the correct thing to do here (as per the spec quote below)

    If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in
    EGL_CONTEXT_FLAGS_KHR, then a <debug context> will be created...
    ... This bit is supported for OpenGL and OpenGL ES contexts.
Comment 5 Emil Velikov 2015-10-03 11:28:04 UTC
Fixed with

commit 11cabc45b7124e51d5ead42db6dceb5a3755266b
Author: Matthew Waters <ystreet00@gmail.com>
Date:   Mon Sep 14 18:35:45 2015 +0100

    egl: rework handling EGL_CONTEXT_FLAGS
    
    As of version 15 of the EGL_KHR_create_context spec, debug contexts
    are allowed for ES contexts.  We should allow creation instead of
    erroring.
    
    While we're here provide a more comprehensive checking for the other two
    flags - ROBUST_ACCESS_BIT_KHR and FORWARD_COMPATIBLE_BIT_KHR


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.