[Mesa-dev] [PATCH 05/27] i965: Replace open coded with intel_miptree_get_image_offset()

Jason Ekstrand jason at jlekstrand.net
Mon Jan 16 17:13:59 UTC 2017


On Mon, Jan 16, 2017 at 1:13 AM, Topi Pohjolainen <
topi.pohjolainen at gmail.com> wrote:

> Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
>  src/mesa/drivers/dri/i965/intel_pixel_read.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_pixel_read.c
> b/src/mesa/drivers/dri/i965/intel_pixel_read.c
> index 2563897..ace94a0 100644
> --- a/src/mesa/drivers/dri/i965/intel_pixel_read.c
> +++ b/src/mesa/drivers/dri/i965/intel_pixel_read.c
> @@ -47,6 +47,19 @@
>
>  #define FILE_DEBUG_FLAG DEBUG_PIXEL
>
> +static void
> +adjust_image_offset(const struct intel_renderbuffer *irb,
> +                    int *xoffset, int *yoffset)
> +{
> +   unsigned x;
> +   unsigned y;
> +   intel_miptree_get_image_offset(irb->mt, irb->mt_level, irb->mt_layer,
> +                                  &x, &y);
> +
> +   *xoffset += x;
> +   *yoffset += y;
> +}
> +
>  /**
>   * \brief A fast path for glReadPixels
>   *
> @@ -153,8 +166,7 @@ intel_readpixels_tiled_memcpy(struct gl_context * ctx,
>        return false;
>     }
>
> -   xoffset += irb->mt->level[irb->mt_level].
> slice[irb->mt_layer].x_offset;
> -   yoffset += irb->mt->level[irb->mt_level].
> slice[irb->mt_layer].y_offset;
> +   adjust_image_offset(irb, &xoffset, &yoffset);
>

We do this a lot more places than just readpixels.  Maybe we want to just
add a intel_miptree_get_texel_xy_offset helper that takes a miptree, level,
slice, and x/y and returns the total x/y.  In any case, we really should
make such a helper a bit more global and use it all of the other random
places we do this calculation such as texsubimage_tiled_memcpy.


>
>     dst_pitch = _mesa_image_row_stride(pack, width, format, type);
>
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170116/83eaff31/attachment.html>


More information about the mesa-dev mailing list