+static bool
+intel_readpixels_blorp(struct gl_context *ctx,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing)
+{
+ struct brw_context *brw = brw_context(ctx);
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ if (!rb)
+ return false;
+
+ struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+ /* _mesa_get_readpixels_transfer_ops() includes the cases of read
+ * color clamping along with the ctx->_ImageTransferState.
+ */
+ if (_mesa_get_readpixels_transfer_ops(ctx, rb->Format, format,
+ type, GL_FALSE))
+ return false;
+
+ GLenum dst_base_format = _mesa_unpack_format_to_base_format(format);
+ if (_mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat,
+ dst_base_format))
+ return false;
+
+ unsigned swizzle;
+ if (irb->Base.Base._BaseFormat == GL_RGB) {
+ swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
+ } else {
+ swizzle = SWIZZLE_XYZW;
+ }
+
+ return brw_blorp_download_miptree(brw, irb->mt, rb->Format, swizzle,
+ irb->mt_level, x, y, irb->mt_layer,
+ w, h, 1, GL_TEXTURE_2D, format, type,
+ ctx->ReadBuffer->FlipY, pixels, packing);
+}
+