After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 743746 - Add GLES 2.0 (and/or 3.0) profile
Add GLES 2.0 (and/or 3.0) profile
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkGLArea
3.14.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-01-30 16:50 UTC by Emmanuele Bassi (:ebassi)
Modified: 2016-04-25 19:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gl: Add 'use-es' flag (4.58 KB, patch)
2016-04-18 09:13 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
wayland: Implement asking for a GLES context (2.85 KB, patch)
2016-04-18 09:13 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
glarea: Relay the use-es flag to context creation (2.41 KB, patch)
2016-04-18 14:17 UTC, Emanuele Aina
none Details | Review

Description Emmanuele Bassi (:ebassi) 2015-01-30 16:50:47 UTC
the current GL machinery is pretty much tied to desktop GL. it would be good to have support for GLES 2.0+.

a quick way to handle this would be to add a GDK_GL_PROFILE_GLES2 value to the GdkGLProfile enumeration, and then check the profile type in the various internal call sites for GL API where the feature set of GL and GLES diverge.
Comment 1 Daniel Stone 2015-01-30 16:57:13 UTC
The primary failure I can see internally, context creation notwithstanding, is the use of GL_UNPACK_ROW_LENGTH, which isn't present in ES2 (it is in ES3, though this has much more narrow deployment). The relatively trivial, if unpleasant, workaround for that is:
  if (is_big_gl || is_es3) {
      glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
      glTexImage2D(...);
      glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
  }
  else {
      for (i = y; i < h; i++)
          glTexSubImage2D(x=x, y=i, width=w, height=1, data=(data + (i * stride));
  }
Comment 2 Emmanuele Bassi (:ebassi) 2015-01-30 17:41:03 UTC
for reference, there's also the EXT_unpack_subimage extension:

https://www.khronos.org/registry/gles/extensions/EXT/EXT_unpack_subimage.txt

which is implemented mostly by nvidia, and probably will be available on platforms support GLES 2.0 and 3.0.
Comment 3 Daniel Stone 2015-01-30 17:46:27 UTC
Yes, sorry; I was mostly too lazy to look the name up. Mesa does implement that, and I'm pretty sure Mali and PVR do too. This mostly leaves Vivante/Freescale, but their drivers are so dysfunctional that I wouldn't be too concerned.
Comment 4 Emmanuele Bassi (:ebassi) 2016-04-18 09:13:51 UTC
Created attachment 326227 [details] [review]
gl: Add 'use-es' flag

On some platforms we can ask the GL context machinery to create a GLES
context, instead of a GL one.

In order to ask for a GLES context at GdkGLContext realization time, we
use a bit field like we do for forward compatible, or debug contexts.

The 'use-es' bit also changes the way we select a default version,
because OpenGL and OpenGLES versions differ.
Comment 5 Emmanuele Bassi (:ebassi) 2016-04-18 09:13:56 UTC
Created attachment 326228 [details] [review]
wayland: Implement asking for a GLES context

Wayland uses EGL, which allows us to ask for a GLES context.
Comment 6 Emmanuele Bassi (:ebassi) 2016-04-18 09:16:18 UTC
These two patches are how I envision the public API for creating a GdkGLContext wrapping a GLES context created via EGL would work.

Missing:

 * documentation
 * errors/warnings
 * checking the GdkGLContext:use-es bit field when using GL API that potentially has no GLES equivalent
Comment 7 Emanuele Aina 2016-04-18 14:17:08 UTC
Created attachment 326262 [details] [review]
glarea: Relay the use-es flag to context creation
Comment 8 Emmanuele Bassi (:ebassi) 2016-04-22 13:00:12 UTC
I've pushed the current state of affairs to wip/ebassi/gles; I was able to get stuff on screen fairly easily.

Missing bits:

 * X11 implementation of GLES support using GLX_EXT_create_context_es2_profile
 * add a couple of branches checking for GLES extensions instead of GL ones
 * add a compile-time switch for platforms that have hw accelerated GLES but software GL
Comment 9 Emmanuele Bassi (:ebassi) 2016-04-23 09:52:29 UTC
Latest update of the wip/ebassi/gles:

 * GLX should be able to create a GLES context (still only lightly tested)
 * All uses of GL vs GLES API should have been fixed
 * No compile time switch, as it warrants some discussion

The branch is ready for review; it's about 20 commits, so I'm not sure whether to attach it to the bug as well or not.
Comment 10 Emmanuele Bassi (:ebassi) 2016-04-23 09:55:40 UTC
If you want to test it, then build wip/ebassi/gles and run:

  GDK_GL=gles ./tests/testglarea

and you should see the exact same thing as running ./tests/testglarea. I suggest using Wayland instead of X11.

I'll also port the GtkGLArea gtk3-demo, as it needs updated shaders.
Comment 11 Emmanuele Bassi (:ebassi) 2016-04-25 19:01:50 UTC
I've merged the wip/ebassi/gles branch in master, after testing that both Wayland and X11 backends worked.

This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.