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.
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.
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.
f48f9a78da egl: Simplify queries for EGL_RENDER_BUFFER
src/egl/drivers/dri2/egl_dri2.c | 6 ------
src/egl/main/eglcontext.c | 40 +++++++++++++++++++++++++++++++++-------
src/egl/main/eglcontext.h | 3 ---
src/egl/main/eglsurface.c | 28 +++++++++++++++++++++++++---
src/egl/main/eglsurface.h | 28 +++++++++++++++++++++++++++-
5 files changed, 85 insertions(+), 20 deletions(-)