[Mesa-dev] [PATCH 07/10] intel: Improve the test for readpixels blit path format checking.

Eric Anholt eric at anholt.net
Mon Jan 28 21:00:35 PST 2013


We were allowing things like copying RG1616 to a user's ARGB8888
format, while we were denying anything that wasn't ARGB8888 or
RGB565.
---
 src/mesa/drivers/dri/intel/intel_pixel.c      |   32 -------------------------
 src/mesa/drivers/dri/intel/intel_pixel.h      |    4 ----
 src/mesa/drivers/dri/intel/intel_pixel_read.c |    7 +++++-
 3 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c
index bc70510..f58cb85 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel.c
@@ -123,38 +123,6 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
    return true;
 }
 
-/* The intel_region struct doesn't really do enough to capture the
- * format of the pixels in the region.  For now this code assumes that
- * the region is a display surface and hence is either ARGB8888 or
- * RGB565.
- * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
- * know the buffer's pixel format.
- *
- * \param format  as given to glDraw/ReadPixels
- * \param type  as given to glDraw/ReadPixels
- */
-bool
-intel_check_blit_format(struct intel_region * region,
-                        GLenum format, GLenum type)
-{
-   if (region->cpp == 4 &&
-       (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
-        type == GL_UNSIGNED_BYTE) && format == GL_BGRA) {
-      return true;
-   }
-
-   if (region->cpp == 2 &&
-       type == GL_UNSIGNED_SHORT_5_6_5_REV && format == GL_BGR) {
-      return true;
-   }
-
-   DBG("%s: bad format for blit (cpp %d, type %s format %s)\n",
-       __FUNCTION__, region->cpp,
-       _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
-
-   return false;
-}
-
 void
 intelInitPixelFuncs(struct dd_function_table *functions)
 {
diff --git a/src/mesa/drivers/dri/intel/intel_pixel.h b/src/mesa/drivers/dri/intel/intel_pixel.h
index 0438fca..7578e6f 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel.h
+++ b/src/mesa/drivers/dri/intel/intel_pixel.h
@@ -34,10 +34,6 @@ void intelInitPixelFuncs(struct dd_function_table *functions);
 bool intel_check_blit_fragment_ops(struct gl_context * ctx,
 					bool src_alpha_is_one);
 
-bool intel_check_blit_format(struct intel_region *region,
-                                  GLenum format, GLenum type);
-
-
 void intelReadPixels(struct gl_context * ctx,
                      GLint x, GLint y,
                      GLsizei width, GLsizei height,
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c
index bb9ce99..bb24b52 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c
@@ -39,6 +39,8 @@
 #include "intel_context.h"
 #include "intel_blit.h"
 #include "intel_buffers.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
 #include "intel_regions.h"
 #include "intel_pixel.h"
 #include "intel_buffer_objects.h"
@@ -95,9 +97,12 @@ do_blit_readpixels(struct gl_context * ctx,
       return false;
    }
 
+   struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
    if (ctx->_ImageTransferState ||
-       !intel_check_blit_format(src, format, type)) {
+       !_mesa_format_matches_format_and_type(irb->mt->format, format, type,
+                                             false)) {
       DBG("%s - bad format for blit\n", __FUNCTION__);
       return false;
    }
-- 
1.7.10.4



More information about the mesa-dev mailing list