+ /* Do the conversion.
+ *
+ * If the dst format is Luminance, we need to do the conversion by computing
+ * L=R+G+B values.
+ */
+ if (!convert_rgb_to_lum) {
+ _mesa_format_convert(dst, dst_format, dst_stride,
+ src, src_format, src_stride,
+ width, height,
+ needs_rebase ? rebase_swizzle : NULL);
+ } else if (!dst_is_integer) {
+ /* Compute float Luminance values from RGBA float */
+ int luminance_stride, luminance_bytes;
+ void *luminance;
+ uint32_t luminance_format;
+
+ luminance_stride = width * sizeof(GLfloat);
+ if (format == GL_LUMINANCE_ALPHA)
+ luminance_stride *= 2;
+ luminance_bytes = height * luminance_stride;
+ luminance = malloc(luminance_bytes);
+ if (!luminance) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
+ free(rgba);
+ goto done_unmap;
+ }
+ _mesa_pack_luminance_from_rgba_float(width * height, src,
+ luminance, format, transferOps);
+
+ /* Convert from Luminance float to dst (this will hadle type conversion
+ * from float to the type of dst if necessary)
+ */
+ luminance_format = _mesa_format_from_format_and_type(format, GL_FLOAT);
+ _mesa_format_convert(dst, dst_format, dst_stride,
+ luminance, luminance_format, luminance_stride,
+ width, height, NULL);
+ free(luminance);
+ } else {
+ _mesa_pack_luminance_from_rgba_integer(width * height, src, !src_is_uint,
+ dst, format, type);
+ }