Merge ~smspillaz/compiz:buffer-age-egl into compiz:master

Proposed by Sam Spilsbury
Status: Merged
Approved by: Dmitry Shachnev
Approved revision: 6c9139e1c22684d915735aabe071c0d0abbf661c
Merged at revision: 061e8332b655ba35a03d905601b5f5866e2f4db8
Proposed branch: ~smspillaz/compiz:buffer-age-egl
Merge into: compiz:master
Diff against target: 136 lines (+74/-6)
2 files modified
plugins/opengl/include/opengl/opengl.h (+2/-0)
plugins/opengl/src/screen.cpp (+72/-6)
Reviewer Review Type Date Requested Status
Dmitry Shachnev Needs Fixing
Review via email: mp+412181@code.launchpad.net

Commit message

Enable EGL_EXT_buffer_age on USE_GLES where it is advertised.

Description of the change

Enable EGL_EXT_buffer_age on USE_GLES

buffer_age is long-since supported on GLES platforms, we can also use it there too with minimal changes. Tested on vc4 (Rasberry Pi 4).

A nice side-effect of this is that we don't have to draw the whole scene into an fbo and then redraw it later, just so that we can get double-buffering. Which should be nice on fillrate-bound GPUs.

Probably this should be tested on a few other platforms before merging, I am unsure if there are drivers for which this is broken. At least cogl appears to support it, so maybe its not too bad on other drivers: https://gitlab.gnome.org/GNOME/mutter/-/blob/main/cogl/cogl/winsys/cogl-onscreen-egl.c#L165 .

To post a comment you must log in.
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

> Probably this should be tested on a few other platforms before merging

I don’t have any GLES hardware to test this on. Code changes look good, so if it works for you, let’s just merge it.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

OK!

FWIW, I think most of the mesa drivers + nvidia should support running on GLES these days. I think you just need to build with USE_GLES. But GLES isn't really the default, so I think this won't affect most users. Haven't tested that path though.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Hi again Sam!

Unfortunately, this causes build failure when building without GLES.

I left an inline comment with error message.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi! Thanks for the catch. Wasn't able to build with the OpenGL config locally, but it was a simple fix of just putting another local in the right place.

Pushed + rebased.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

I tested the build with -DBUILD_GLES=ON on my laptop today, and it worked fine. So thanks again.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/plugins/opengl/include/opengl/opengl.h b/plugins/opengl/include/opengl/opengl.h
2index 6e59a48..497eddb 100644
3--- a/plugins/opengl/include/opengl/opengl.h
4+++ b/plugins/opengl/include/opengl/opengl.h
5@@ -44,7 +44,9 @@
6 * to GLX_BACK_BUFFER_AGE_EXT but this is the token as defined
7 * in the spec (https://www.opengl.org/registry/specs/EXT/glx_buffer_age.txt)
8 */
9+#ifndef GLX_BACK_BUFFER_AGE_EXT
10 #define GLX_BACK_BUFFER_AGE_EXT 0x20F4
11+#endif
12
13 #endif
14
15diff --git a/plugins/opengl/src/screen.cpp b/plugins/opengl/src/screen.cpp
16index 1ed7588..ef645aa 100644
17--- a/plugins/opengl/src/screen.cpp
18+++ b/plugins/opengl/src/screen.cpp
19@@ -372,7 +372,59 @@ class BufferAgeFrameProvider :
20 Display *mDisplay;
21 GLXDrawable mDrawable;
22 };
23+#else
24+class BufferAgeFrameProvider :
25+ public FrameProvider
26+{
27+ public:
28+
29+ BufferAgeFrameProvider (Display *disp,
30+ EGLSurface drawable) :
31+ mDisplay (disp),
32+ mDrawable (drawable)
33+ {
34+ }
35+
36+ unsigned int getCurrentFrame ()
37+ {
38+ EGLint age = 0;
39+ eglQuerySurface (eglGetDisplay (mDisplay),
40+ mDrawable,
41+ EGL_BUFFER_AGE_EXT,
42+ &age);
43+ return (unsigned int) age;
44+ }
45+
46+ void useCurrentFrame ()
47+ {
48+ }
49+
50+ void endFrame ()
51+ {
52+ }
53+
54+ void invalidateAll ()
55+ {
56+ }
57+
58+ bool providesPersistence ()
59+ {
60+ return true;
61+ }
62+
63+ bool alwaysPostprocess ()
64+ {
65+ return false;
66+ }
67+
68+ private:
69+
70+ Display *mDisplay;
71+ EGLSurface mDrawable;
72+};
73+#endif
74
75+#ifndef USE_GLES
76 namespace compiz
77 {
78 namespace opengl
79@@ -729,6 +781,13 @@ GLScreen::glInitContext (XVisualInfo *visinfo)
80 return false;
81 }
82
83+ if (strstr (eglExtensions, "EGL_EXT_buffer_age"))
84+ {
85+ compLogMessage ("opengl", CompLogLevelInfo,
86+ "EGL_EXT_buffer_age is supported");
87+ GL::bufferAge = true;
88+ }
89+
90 // work around efika supporting GL_BGRA directly instead of via this extension
91 #ifndef GL_BGRA
92 if (!strstr (glExtensions, "GL_EXT_texture_format_BGRA8888"))
93@@ -2663,15 +2722,18 @@ PrivateGLScreen::updateRenderMode ()
94 void
95 PrivateGLScreen::updateFrameProvider ()
96 {
97-#ifndef USE_GLES
98- const Window outputWindow = CompositeScreen::get (screen)->output ();
99-
100 if (GL::fboEnabled)
101 {
102 if (GL::bufferAge)
103 {
104+#ifndef USE_GLES
105+ const Window outputWindow = CompositeScreen::get (screen)->output ();
106 FrameProvider::Ptr back (new BufferAgeFrameProvider (screen->dpy (),
107 outputWindow));
108+#else
109+ FrameProvider::Ptr back (new BufferAgeFrameProvider (screen->dpy (),
110+ surface));
111+#endif
112 FrameProvider::Ptr scratch (new PostprocessFrameProvider (scratchFbo.get ()));
113 OptionalPostprocessFrameProvider::PostprocessRequired ppReq
114 (boost::bind (&PrivateGLScreen::postprocessRequiredForCurrentFrame,
115@@ -2689,14 +2751,18 @@ PrivateGLScreen::updateFrameProvider ()
116 else
117 {
118 if (GL::bufferAge)
119+ {
120+#ifndef USE_GLES
121+ const Window outputWindow = CompositeScreen::get (screen)->output ();
122 frameProvider.reset (new BufferAgeFrameProvider (screen->dpy (),
123 outputWindow));
124+#else
125+ frameProvider.reset (new BufferAgeFrameProvider (screen->dpy (), surface));
126+#endif
127+ }
128 else
129 frameProvider.reset (new UndefinedFrameProvider ());
130 }
131-#else
132- frameProvider.reset (new PostprocessFrameProvider (scratchFbo.get ()));
133-#endif
134 }
135
136 void

Subscribers

People subscribed via source and target branches