i965: Fix crash in do_blit_readpixels()
authorAnuj Phogat <anuj.phogat@gmail.com>
Wed, 19 Mar 2014 18:55:50 +0000 (11:55 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Thu, 1 May 2014 17:58:40 +0000 (10:58 -0700)
Fixes a crash in Khronos CTS packed_pixels tests.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/intel_pixel_read.c

index 600d288994bcf8ee8d5daf9c620c51cd409f435a..8cd7579142aa115bdae72f5d613cb9a25c669317 100644 (file)
@@ -34,6 +34,7 @@
 #include "main/bufferobj.h"
 #include "main/readpix.h"
 #include "main/state.h"
+#include "main/glformats.h"
 
 #include "brw_context.h"
 #include "intel_screen.h"
@@ -89,6 +90,12 @@ do_blit_readpixels(struct gl_context * ctx,
    struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
+   /* Currently this function only supports reading from color buffers. */
+   if (!_mesa_is_color_format(format))
+      return false;
+
+   assert(irb != NULL);
+
    if (ctx->_ImageTransferState ||
        !_mesa_format_matches_format_and_type(irb->mt->format, format, type,
                                              false)) {