Mesa (staging/19.1): mesa: Fix ReadBuffers with pbuffers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 23 11:52:26 UTC 2019
Module: Mesa
Branch: staging/19.1
Commit: be1217482099ff3255d57a8458bdba6437b16e76
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be1217482099ff3255d57a8458bdba6437b16e76
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Fri Jun 28 12:56:38 2019 -0700
mesa: Fix ReadBuffers with pbuffers
pbuffers are internally single-buffered. Marek fixed DrawBuffers to
handle this case, but we need to fix ReadBuffers too. Otherwise,
pretty much every conformance test fails because glReadPixels breaks.
v2: Refactor the switch into a helper (suggested by Eric Anholt)
Fixes: 35294f2eca8 ("mesa: fix pbuffers because internally they are front buffers")
Acked-by: Eric Engestrom <eric.engestrom at intel.com> (v1)
Reviewed-by: Eric Anholt <eric at anholt.net>
(cherry picked from commit 78164a3a6c278adcbb93e21b64a575c3f8598327)
---
src/mesa/main/buffers.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index a46599a2872..4e48b76fcb8 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -84,14 +84,8 @@ supported_buffer_bitmask(const struct gl_context *ctx,
return mask;
}
-
-/**
- * Helper routine used by glDrawBuffer and glDrawBuffersARB.
- * Given a GLenum naming one or more color buffers (such as
- * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
- */
-static GLbitfield
-draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
+static GLenum
+back_to_front_if_single_buffered(const struct gl_context *ctx, GLenum buffer)
{
/* If the front buffer is the only buffer, GL_BACK and all other flags
* that include BACK select the front buffer for drawing. There are
@@ -129,6 +123,19 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
}
}
+ return buffer;
+}
+
+/**
+ * Helper routine used by glDrawBuffer and glDrawBuffersARB.
+ * Given a GLenum naming one or more color buffers (such as
+ * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
+ */
+static GLbitfield
+draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
+{
+ buffer = back_to_front_if_single_buffered(ctx, buffer);
+
switch (buffer) {
case GL_NONE:
return 0;
@@ -192,20 +199,12 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
static gl_buffer_index
read_buffer_enum_to_index(const struct gl_context *ctx, GLenum buffer)
{
+ buffer = back_to_front_if_single_buffered(ctx, buffer);
+
switch (buffer) {
case GL_FRONT:
return BUFFER_FRONT_LEFT;
case GL_BACK:
- if (_mesa_is_gles(ctx)) {
- /* In draw_buffer_enum_to_bitmask, when GLES contexts draw to
- * GL_BACK with a single-buffered configuration, we actually end
- * up drawing to the sole front buffer in our internal
- * representation. For consistency, we must read from that
- * front left buffer too.
- */
- if (!ctx->DrawBuffer->Visual.doubleBufferMode)
- return BUFFER_FRONT_LEFT;
- }
return BUFFER_BACK_LEFT;
case GL_RIGHT:
return BUFFER_FRONT_RIGHT;
More information about the mesa-commit
mailing list