Mesa (master): Use the magic behaviour of GL_BACK in GLES 1 and 2 as well as 3

Kristian Høgsberg krh at kemper.freedesktop.org
Wed Mar 12 21:48:06 UTC 2014


Module: Mesa
Branch: master
Commit: 0c58c96e540c86bdac52e8c61823bf14f4cd1fa0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c58c96e540c86bdac52e8c61823bf14f4cd1fa0

Author: Neil Roberts <neil at linux.intel.com>
Date:   Fri Mar  7 18:05:44 2014 +0000

Use the magic behaviour of GL_BACK in GLES 1 and 2 as well as 3

In GLES 3 it is not possible to select rendering to the front buffer and
instead selecting GL_BACK has the magic interpretation that it is either the
front buffer on single-buffered configs or the back buffer on double-buffered.
GLES 1 and 2 have no way of selecting the draw buffer at all. In that case we
were initialising the draw buffer to either GL_FRONT or GL_BACK depending on
the context's config and then leaving it at that.

When we switch to having configless contexts we ideally want Mesa to
automatically switch between the front and back buffer whenever a double-
or single-buffered surface is bound. To make this happen we can just allow
the magic behaviour from GLES 3 in GLES 1 and 2 as well. It shouldn't matter
what the internal value of the draw buffer is in GLES 1 and 2 because there
is no way to query it from the external API.

Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

---

 src/mesa/main/buffers.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 6cbce9d..b13a7af 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -101,7 +101,7 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
       case GL_FRONT:
          return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT;
       case GL_BACK:
-         if (_mesa_is_gles3(ctx)) {
+         if (_mesa_is_gles(ctx)) {
             /* Page 181 (page 192 of the PDF) in section 4.2.1 of the OpenGL
              * ES 3.0.1 specification says:
              *
@@ -111,6 +111,11 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
              *
              * Since there is no stereo rendering in ES 3.0, only return the
              * LEFT bits.  This also satisfies the "n must be 1" requirement.
+             *
+             * We also do this for GLES 1 and 2 because those APIs have no
+             * concept of selecting the front and back buffer anyway and it's
+             * convenient to be able to maintain the magic behaviour of
+             * GL_BACK in that case.
              */
             if (ctx->DrawBuffer->Visual.doubleBufferMode)
                return BUFFER_BIT_BACK_LEFT;




More information about the mesa-commit mailing list