diff options
author | Chad Versace <[email protected]> | 2018-04-07 14:23:48 -0700 |
---|---|---|
committer | Chad Versace <[email protected]> | 2018-08-07 11:11:05 -0700 |
commit | f48f9a78da24df762ffceab9c0c136a500a4e316 (patch) | |
tree | 11a4d37bc6df0e8f631b6668f31c46922839d510 /src/egl/main/eglsurface.c | |
parent | d145e33e7c1fecb48d72869b12f2ca02147dbebb (diff) |
egl: Simplify queries for EGL_RENDER_BUFFER
There exist *two* queryable EGL_RENDER_BUFFER states in EGL:
eglQuerySurface(EGL_RENDER_BUFFER) and
eglQueryContext(EGL_RENDER_BUFFER).
These changes eliminate potentially very fragile code in the upcoming
EGL_KHR_mutable_render_buffer implementation.
* eglQuerySurface(EGL_RENDER_BUFFER)
The implementation of eglQuerySurface(EGL_RENDER_BUFFER) contained
abstruse logic which required comprehending the specification
complexities of how the two EGL_RENDER_BUFFER states interact. The
function sometimes returned _EGLContext::WindowRenderBuffer, sometimes
_EGLSurface::RenderBuffer. Why? The function tried to encode the
actual logic from the EGL spec. When did the function return which
variable? Go study the EGL spec, hope you understand it, then hope
Mesa mutated the EGL_RENDER_BUFFER state in all the correct places.
Have fun.
To simplify eglQuerySurface(EGL_RENDER_BUFFER), and to improve
confidence in its correctness, flatten its indirect logic. For pixmap
and pbuffer surfaces, simply return a hard-coded literal value, as the
spec suggests. For window surfaces, simply return
_EGLSurface::RequestedRenderBuffer. Nothing difficult here.
* eglQueryContext(EGL_RENDER_BUFFER)
The implementation of this suffered from the same issues as
eglQuerySurface, and the solution is the same. confidence in its
correctness, flatten its indirect logic. For pixmap and pbuffer
surfaces, simply return a hard-coded literal value, as the spec
suggests. For window surfaces, simply return
_EGLSurface::ActiveRenderBuffer.
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/egl/main/eglsurface.c')
-rw-r--r-- | src/egl/main/eglsurface.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 3bd14a8cd03..73c31e11588 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -122,7 +122,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) err = EGL_BAD_ATTRIBUTE; break; } - surf->RenderBuffer = val; + surf->RequestedRenderBuffer = val; break; case EGL_POST_SUB_BUFFER_SUPPORTED_NV: if (!dpy->Extensions.NV_post_sub_buffer || @@ -285,7 +285,8 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, surf->TextureTarget = EGL_NO_TEXTURE; surf->MipmapTexture = EGL_FALSE; surf->LargestPbuffer = EGL_FALSE; - surf->RenderBuffer = renderBuffer; + surf->RequestedRenderBuffer = renderBuffer; + surf->ActiveRenderBuffer = renderBuffer; surf->VGAlphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; surf->VGColorspace = EGL_VG_COLORSPACE_sRGB; surf->GLColorspace = EGL_GL_COLORSPACE_LINEAR_KHR; @@ -358,7 +359,28 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, *value = surface->SwapBehavior; break; case EGL_RENDER_BUFFER: - *value = surface->RenderBuffer; + /* From the EGL 1.5 spec (2014.08.27): + * + * 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 + * surface, it is always EGL_SINGLE_BUFFER . To determine the actual + * buffer being rendered to by a context, call eglQueryContext. + */ + switch (surface->Type) { + default: + unreachable("bad EGLSurface type"); + case EGL_WINDOW_BIT: + *value = surface->RequestedRenderBuffer; + break; + case EGL_PBUFFER_BIT: + *value = EGL_BACK_BUFFER; + break; + case EGL_PIXMAP_BIT: + *value = EGL_SINGLE_BUFFER; + break; + } break; case EGL_PIXEL_ASPECT_RATIO: *value = surface->AspectRatio; |