[Mesa-dev] [PATCH 64/70] Set preferred image format as BGRA for BGRx framebuffers

Chris Wilson chris at chris-wilson.co.uk
Fri Aug 7 13:14:08 PDT 2015


Since the introduction of reporting alphaless winsys buffers, the
GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query started reporting GL_RGBA
instead of the preferred GL_BGRA format (demos/readpix reports a
difference of almost 1000x for picking the wrong format).

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 src/mesa/main/framebuffer.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 37e2c29..a34cefc 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -852,15 +852,17 @@ _mesa_get_color_read_format(struct gl_context *ctx)
       return GL_NONE;
    }
    else {
-      const GLenum format = ctx->ReadBuffer->_ColorReadBuffer->Format;
-      const GLenum data_type = _mesa_get_format_datatype(format);
+      GLenum format = ctx->ReadBuffer->_ColorReadBuffer->Format;
 
-      if (format == MESA_FORMAT_B8G8R8A8_UNORM)
+      format =_mesa_get_srgb_format_linear(format);
+      if (format == MESA_FORMAT_B8G8R8A8_UNORM ||
+          format == MESA_FORMAT_B8G8R8X8_UNORM) {
          return GL_BGRA;
+      }
       else if (format == MESA_FORMAT_B5G6R5_UNORM)
          return GL_BGR;
 
-      switch (data_type) {
+      switch (_mesa_get_format_datatype(format)) {
       case GL_UNSIGNED_INT:
       case GL_INT:
          return GL_RGBA_INTEGER;
-- 
2.5.0



More information about the mesa-dev mailing list