summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglsurface.c
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2018-04-30 22:32:25 -0700
committerChad Versace <[email protected]>2018-08-07 11:11:05 -0700
commit3dc22381fa6ae6e5964908490f65e2903bd1b38d (patch)
treed62a0959eff96e4416bca0860c82a8af00f07fb9 /src/egl/main/eglsurface.c
parent5c6d6eedb3c550dfe74f0e6349aaed99fc23f70d (diff)
egl/main: Add bits for EGL_KHR_mutable_render_buffer
A follow-up patch enables EGL_KHR_mutable_render_buffer for Android. This patch is separate from the Android patch because I think it's easier to review the platform-independent bits separately. Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/egl/main/eglsurface.c')
-rw-r--r--src/egl/main/eglsurface.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 73c31e11588..926b7ab569a 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -123,6 +123,12 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
break;
}
surf->RequestedRenderBuffer = val;
+ if (surf->Config->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR) {
+ /* Unlike normal EGLSurfaces, one with a mutable render buffer
+ * uses the application-chosen render buffer.
+ */
+ surf->ActiveRenderBuffer = val;
+ }
break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
if (!dpy->Extensions.NV_post_sub_buffer ||
@@ -359,12 +365,19 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
*value = surface->SwapBehavior;
break;
case EGL_RENDER_BUFFER:
- /* From the EGL 1.5 spec (2014.08.27):
+ /* From the EGL_KHR_mutable_render_buffer spec (v12):
*
* Querying EGL_RENDER_BUFFER returns the buffer which client API
* rendering is requested to use. For a window surface, this is the
- * same attribute value specified when the surface was created. For
- * a pbuffer surface, it is always EGL_BACK_BUFFER . For a pixmap
+ * attribute value specified when the surface was created or last set
+ * via eglSurfaceAttrib.
+ *
+ * In other words, querying a window surface returns the value most
+ * recently *requested* by the user.
+ *
+ * The paragraph continues in the EGL 1.5 spec (2014.08.27):
+ *
+ * For a pbuffer surface, it is always EGL_BACK_BUFFER . For a pixmap
* surface, it is always EGL_SINGLE_BUFFER . To determine the actual
* buffer being rendered to by a context, call eglQueryContext.
*/
@@ -472,6 +485,31 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
break;
surface->MultisampleResolve = value;
break;
+ case EGL_RENDER_BUFFER:
+ if (!dpy->Extensions.KHR_mutable_render_buffer) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (value != EGL_BACK_BUFFER && value != EGL_SINGLE_BUFFER) {
+ err = EGL_BAD_PARAMETER;
+ break;
+ }
+
+ /* From the EGL_KHR_mutable_render_buffer spec (v12):
+ *
+ * If attribute is EGL_RENDER_BUFFER, and the EGL_SURFACE_TYPE
+ * attribute of the EGLConfig used to create surface does not contain
+ * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR, [...] an EGL_BAD_MATCH error is
+ * generated [...].
+ */
+ if (!(surface->Config->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR)) {
+ err = EGL_BAD_MATCH;
+ break;
+ }
+
+ surface->RequestedRenderBuffer = value;
+ break;
case EGL_SWAP_BEHAVIOR:
switch (value) {
case EGL_BUFFER_DESTROYED:
@@ -573,3 +611,18 @@ _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
{
return EGL_TRUE;
}
+
+EGLBoolean
+_eglSurfaceHasMutableRenderBuffer(_EGLSurface *surf)
+{
+ return surf->Type == EGL_WINDOW_BIT &&
+ surf->Config &&
+ (surf->Config->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR);
+}
+
+EGLBoolean
+_eglSurfaceInSharedBufferMode(_EGLSurface *surf)
+{
+ return _eglSurfaceHasMutableRenderBuffer(surf) &&
+ surf->ActiveRenderBuffer == EGL_SINGLE_BUFFER;
+}