Bug 92869

Summary: OpenGL ES 3.0 context creation failure
Product: Mesa Reporter: Gustaf Ullberg <gustaf.ullberg>
Component: GLXAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: chadversary, idr, imirkin, jfonseca
Version: 11.0   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Gustaf Ullberg 2015-11-09 08:50:35 UTC
I am trying to create an OpenGL ES 3.0 context using GLX. But, when trying to create an OpenGL ES context with glXCreateContextAttribsARB the call fails if I request any version other that 2.0.

I think this part of the mesa code is responsible (src/glx/dri_common.c):
   /* The GLX_EXT_create_context_es2_profile spec says:
    *
    *     "... If the version requested is 2.0, and the
    *     GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the
    *     GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context
    *     returned will implement OpenGL ES 2.0. This is the only way in which
    *     an implementation may request an OpenGL ES 2.0 context."
    */
   if (*api == __DRI_API_GLES2 && (*major_ver != 2 || *minor_ver != 0)) {
      *error = __DRI_CTX_ERROR_BAD_API;
      return false;
   }

The code quotes the GLX_EXT_create_context_es2_profile spec but that quote is NOT in the spec (maybe it has been in the past).

The mentioned spec however says that:

... If the version requested is a valid and supported OpenGL-ES version,
    and the GLX_CONTEXT_ES_PROFILE_BIT_EXT bit is set in the
    GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context
    returned will implement the OpenGL ES version requested.

I interpret this as "If OpenGL ES 3.0 is requested and supported, a context of version 3.0 is returned". Since OpenGL ES 3.0 is supported, I expect a call requesting that version to succeed.

Please tell if you want me to provide more information.

Best regards,
Gustaf
Comment 1 Jose Fonseca 2015-11-09 10:54:45 UTC
At one point I tried to fix this.  See:

  http://cgit.freedesktop.org/~jrfonseca/mesa/commit/?h=es2_profile

  http://lists.freedesktop.org/archives/mesa-dev/2015-April/082010.html

but I don't usually develop this part of Mesa, and fixing the issue turned out to be trickier than I had foreseen, yet I didn't have time to test it properly, so I had to give up..
Comment 2 Gustaf Ullberg 2015-11-09 21:08:24 UTC
Thanks José,

Interesting to see that you have been working on this already. So, what is the current status? Is the patch ready to be merged after some testing or is it controversial or incomplete in any way?

If "only testing remains" I'll be happy to try to help out.
Comment 3 Jose Fonseca 2015-11-10 16:22:29 UTC
I believe that there was a problem with xserver's glx/createcontext.c Ian mentioned on 

  http://lists.freedesktop.org/archives/mesa-dev/2015-April/082010.html

but it has been fixed 

  http://lists.freedesktop.org/archives/mesa-dev/2015-April/081881.html

I've pushed an updated patch to the above branch.
 
  http://cgit.freedesktop.org/~jrfonseca/mesa/commit/?h=es2_profile&id=e15d1076aa455908674fe4ce0c998638320419ec

AFAIK, this is just a matter of testing to ensure it actually works.

It might require to get X Server to pick up the change too somehow.
Comment 5 Ilia Mirkin 2016-02-03 21:24:32 UTC
To be clear, an Xorg patch is also necessary:

http://cgit.freedesktop.org/xorg/xserver/commit/?id=bc415fb1e0031ad23bda6e9c3f4664532876a0e5

It appears to be included in the 1.18 backport list, not sure about 1.17.

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.