[Mesa-dev] [PATCH 65/70] Set preferred image datatype as GL_UNSIGNED_INT_8_8_8_8_REV for BGRx framebuffers

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


The preferred image datatype for MESA_FORMAT_B8G8R8X8_UNORM and
MESA_FORMAT_B8G8R8A8_UNORM textures (including framebuffers) should be
GL_UNSIGNED_INT_8_8_8_8_REV so that an application querying
GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES and
GL_IMPLEMENTATION_COLOR_READ_TYPE_OES supplies data in the desired
MESA_FORMAT_B8G8R8A8_UNORM format.

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

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index a34cefc..6ab88aa 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -889,10 +889,15 @@ _mesa_get_color_read_type(struct gl_context *ctx)
       return GL_NONE;
    }
    else {
-      const GLenum format = ctx->ReadBuffer->_ColorReadBuffer->Format;
+      GLenum format = ctx->ReadBuffer->_ColorReadBuffer->Format;
       const GLenum data_type = _mesa_get_format_datatype(format);
 
-      if (format == MESA_FORMAT_B5G6R5_UNORM)
+      format =_mesa_get_srgb_format_linear(format);
+      if (format == MESA_FORMAT_B8G8R8A8_UNORM ||
+          format == MESA_FORMAT_B8G8R8X8_UNORM) {
+         return GL_UNSIGNED_INT_8_8_8_8_REV;
+      }
+      else if (format == MESA_FORMAT_B5G6R5_UNORM)
          return GL_UNSIGNED_SHORT_5_6_5_REV;
 
       switch (data_type) {
-- 
2.5.0



More information about the mesa-dev mailing list