Looks good to me, if this did not introduce any regressions:

Reviewed-by: Iago Toral Quiroga <ito...@igalia.com>

On Tue, 2015-06-16 at 11:15 -0700, Anuj Phogat wrote:
> This allows us to handle cases when texImage->_BaseFormat doesn't match
> _mesa_format_get_base_format(texImage->Format). _BaseFormat is what we
> care about in this function.
> 
> Signed-off-by: Anuj Phogat <anuj.pho...@gmail.com>
> ---
>  src/mesa/drivers/common/meta_tex_subimage.c |  4 +++-
>  src/mesa/main/readpix.c                     | 28 +++++++++++++++-------------
>  src/mesa/main/readpix.h                     |  3 ++-
>  3 files changed, 20 insertions(+), 15 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c 
> b/src/mesa/drivers/common/meta_tex_subimage.c
> index 6d52014..43e1210 100644
> --- a/src/mesa/drivers/common/meta_tex_subimage.c
> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> @@ -262,6 +262,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>     int full_height, image_height;
>     struct gl_texture_image *pbo_tex_image;
>     struct gl_renderbuffer *rb = NULL;
> +   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
>     GLenum status, base_format;
>     bool success = false, clear_channels_to_zero = false;
>     float save_clear_color[4];
> @@ -284,7 +285,8 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, 
> GLuint dims,
>                                              type, GL_FALSE))
>           return false;
>  
> -      if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format))
> +      if (_mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat,
> +                                                 dstBaseFormat))
>           return false;
>  
>        if (_mesa_need_signed_unsigned_int_conversion(rb->Format, format, 
> type))
> diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
> index c98975f..3a9b766 100644
> --- a/src/mesa/main/readpix.c
> +++ b/src/mesa/main/readpix.c
> @@ -47,17 +47,14 @@
>   * Return true if the conversion L=R+G+B is needed.
>   */
>  GLboolean
> -_mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format)
> +_mesa_need_rgb_to_luminance_conversion(GLenum srcBaseFormat,
> +                                       GLenum dstBaseFormat)
>  {
> -   GLenum baseTexFormat = _mesa_get_format_base_format(texFormat);
> -
> -   return (baseTexFormat == GL_RG ||
> -           baseTexFormat == GL_RGB ||
> -           baseTexFormat == GL_RGBA) &&
> -          (format == GL_LUMINANCE ||
> -           format == GL_LUMINANCE_ALPHA ||
> -           format == GL_LUMINANCE_INTEGER_EXT ||
> -           format == GL_LUMINANCE_ALPHA_INTEGER_EXT);
> +   return (srcBaseFormat == GL_RG ||
> +           srcBaseFormat == GL_RGB ||
> +           srcBaseFormat == GL_RGBA) &&
> +          (dstBaseFormat == GL_LUMINANCE ||
> +           dstBaseFormat == GL_LUMINANCE_ALPHA);
>  }
>  
>  /**
> @@ -89,6 +86,8 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context 
> *ctx,
>                                    GLboolean uses_blit)
>  {
>     GLbitfield transferOps = ctx->_ImageTransferState;
> +   GLenum srcBaseFormat = _mesa_get_format_base_format(texFormat);
> +   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
>  
>     if (format == GL_DEPTH_COMPONENT ||
>         format == GL_DEPTH_STENCIL ||
> @@ -125,7 +124,7 @@ _mesa_get_readpixels_transfer_ops(const struct gl_context 
> *ctx,
>      * have any effect anyway.
>      */
>     if (_mesa_get_format_datatype(texFormat) == GL_UNSIGNED_NORMALIZED &&
> -       !_mesa_need_rgb_to_luminance_conversion(texFormat, format)) {
> +       !_mesa_need_rgb_to_luminance_conversion(srcBaseFormat, 
> dstBaseFormat)) {
>        transferOps &= ~IMAGE_CLAMP_BIT;
>     }
>  
> @@ -164,6 +163,7 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
> *ctx, GLenum format,
>  {
>     struct gl_renderbuffer *rb =
>           _mesa_get_read_renderbuffer_for_format(ctx, format);
> +   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
>  
>     assert(rb);
>  
> @@ -184,7 +184,8 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
> *ctx, GLenum format,
>  
>     default:
>        /* Color formats. */
> -      if (_mesa_need_rgb_to_luminance_conversion(rb->Format, format)) {
> +      if (_mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat,
> +                                                 dstBaseFormat)) {
>           return GL_TRUE;
>        }
>  
> @@ -458,6 +459,7 @@ read_rgba_pixels( struct gl_context *ctx,
>     uint8_t rebase_swizzle[4];
>     struct gl_framebuffer *fb = ctx->ReadBuffer;
>     struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
> +   GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format);
>  
>     if (!rb)
>        return;
> @@ -469,7 +471,7 @@ read_rgba_pixels( struct gl_context *ctx,
>     dst_stride = _mesa_image_row_stride(packing, width, format, type);
>     dst_format = _mesa_format_from_format_and_type(format, type);
>     convert_rgb_to_lum =
> -      _mesa_need_rgb_to_luminance_conversion(rb->Format, format);
> +      _mesa_need_rgb_to_luminance_conversion(rb->_BaseFormat, dstBaseFormat);
>     dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
>                                             format, type, 0, 0);
>  
> diff --git a/src/mesa/main/readpix.h b/src/mesa/main/readpix.h
> index b59decd..873b825 100644
> --- a/src/mesa/main/readpix.h
> +++ b/src/mesa/main/readpix.h
> @@ -38,7 +38,8 @@ _mesa_readpixels_needs_slow_path(const struct gl_context 
> *ctx, GLenum format,
>                                   GLenum type, GLboolean uses_blit);
>  
>  extern GLboolean
> -_mesa_need_rgb_to_luminance_conversion(mesa_format texFormat, GLenum format);
> +_mesa_need_rgb_to_luminance_conversion(GLenum srcBaseFormat,
> +                                       GLenum dstBaseFormat);
>  
>  extern GLboolean
>  _mesa_need_luminance_to_rgb_conversion(GLenum srcBaseFormat,


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to