summaryrefslogtreecommitdiff
path: root/src/mesa/main/framebuffer.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-12-09 10:08:07 -0800
committerEric Anholt <eric@anholt.net>2009-12-09 10:37:36 -0800
commitcd6b8dd9e82fedc55d033131fbc0f8ee950567c8 (patch)
treec9ac30b607861e22e77d8b0f526fc8c615d5a2a1 /src/mesa/main/framebuffer.c
parentdd9eb8774ad7918187afebf8cd3be6f4b80f0f3b (diff)
mesa: Move OES_read_format support from drivers into the core.
The assertion is that the correct read type to be using is the native type of the underlying read renderbuffer. For some fallback paths, this may be worse than GL_RGBA/GL_UNSIGNED_BYTE for reads today, but it gets all drivers the expected GL_BGRA/GL_UNSIGNED_BYTE for ARGB8888 or GL_BGR//GL_UNSIGNED_SHORT_5_6_5_REV for rgb565 with no work. This fixes the intel (and other) DRI drivers to report read formats that should hit blit PBO readpixels paths.
Diffstat (limited to 'src/mesa/main/framebuffer.c')
-rw-r--r--src/mesa/main/framebuffer.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 154dedacd5..d958dbf7d4 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -969,3 +969,29 @@ _mesa_dest_buffer_exists(GLcontext *ctx, GLenum format)
/* OK */
return GL_TRUE;
}
+
+GLenum
+_mesa_get_color_read_format(GLcontext *ctx)
+{
+ switch (ctx->ReadBuffer->_ColorReadBuffer->Format) {
+ case MESA_FORMAT_ARGB8888:
+ return GL_BGRA;
+ case MESA_FORMAT_RGB565:
+ return GL_BGR;
+ default:
+ return GL_RGBA;
+ }
+}
+
+GLenum
+_mesa_get_color_read_type(GLcontext *ctx)
+{
+ switch (ctx->ReadBuffer->_ColorReadBuffer->Format) {
+ case MESA_FORMAT_ARGB8888:
+ return GL_UNSIGNED_BYTE;
+ case MESA_FORMAT_RGB565:
+ return GL_UNSIGNED_SHORT_5_6_5_REV;
+ default:
+ return GL_UNSIGNED_BYTE;
+ }
+}