[Mesa-dev] [PATCH] gallium/dri2: Avoid uneeded stride to pitch conversion

Nicolas Dufresne nicolas.dufresne at collabora.com
Tue Jan 5 07:58:18 PST 2016


Le me know if this patch needs an update.

cheers,
Nicolas

Le jeudi 24 décembre 2015 à 15:15 -0500, Nicolas Dufresne a écrit :
> In order to convert from stride to pitch, few functions were diving
> by 4
> the stride. This is not valid for RGB565 and this conversion was not
> needed anyway in this context.
> 
> Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
> ---
>  src/gallium/state_trackers/dri/dri2.c | 33 ++++++++++++-------------
> --------
>  1 file changed, 12 insertions(+), 21 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/dri/dri2.c
> b/src/gallium/state_trackers/dri/dri2.c
> index a11a6cb..9f07a45 100644
> --- a/src/gallium/state_trackers/dri/dri2.c
> +++ b/src/gallium/state_trackers/dri/dri2.c
> @@ -708,7 +708,7 @@ dri2_lookup_egl_image(struct dri_screen *screen,
> void *handle)
>  static __DRIimage *
>  dri2_create_image_from_winsys(__DRIscreen *_screen,
>                                int width, int height, int format,
> -                              struct winsys_handle *whandle, int
> pitch,
> +                              struct winsys_handle *whandle, int
> stride,
>                                void *loaderPrivate)
>  {
>     struct dri_screen *screen = dri_screen(_screen);
> @@ -753,7 +753,7 @@ dri2_create_image_from_winsys(__DRIscreen
> *_screen,
>     templ.depth0 = 1;
>     templ.array_size = 1;
>  
> -   whandle->stride = pitch * util_format_get_blocksize(pf);
> +   whandle->stride = stride;
>  
>     img->texture = screen->base.screen->resource_from_handle(screen-
> >base.screen,
>           &templ, whandle);
> @@ -773,7 +773,7 @@ dri2_create_image_from_winsys(__DRIscreen
> *_screen,
>  static __DRIimage *
>  dri2_create_image_from_name(__DRIscreen *_screen,
>                              int width, int height, int format,
> -                            int name, int pitch, void
> *loaderPrivate)
> +                            int name, int stride, void
> *loaderPrivate)
>  {
>     struct winsys_handle whandle;
>  
> @@ -782,13 +782,13 @@ dri2_create_image_from_name(__DRIscreen
> *_screen,
>     whandle.handle = name;
>  
>     return dri2_create_image_from_winsys(_screen, width, height,
> format,
> -                                        &whandle, pitch,
> loaderPrivate);
> +                                        &whandle, stride,
> loaderPrivate);
>  }
>  
>  static __DRIimage *
>  dri2_create_image_from_fd(__DRIscreen *_screen,
>                            int width, int height, int format,
> -                          int fd, int pitch, void *loaderPrivate)
> +                          int fd, int stride, void *loaderPrivate)
>  {
>     struct winsys_handle whandle;
>  
> @@ -800,7 +800,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
>     whandle.handle = (unsigned)fd;
>  
>     return dri2_create_image_from_winsys(_screen, width, height,
> format,
> -                                        &whandle, pitch,
> loaderPrivate);
> +                                        &whandle, stride,
> loaderPrivate);
>  }
>  
>  static __DRIimage *
> @@ -986,7 +986,7 @@ dri2_from_names(__DRIscreen *screen, int width,
> int height, int format,
>                  void *loaderPrivate)
>  {
>     __DRIimage *img;
> -   int stride, dri_components;
> +   int dri_components;
>  
>     if (num_names != 1)
>        return NULL;
> @@ -997,11 +997,8 @@ dri2_from_names(__DRIscreen *screen, int width,
> int height, int format,
>     if (format == -1)
>        return NULL;
>  
> -   /* Strides are in bytes not pixels. */
> -   stride = strides[0] /4;
> -
>     img = dri2_create_image_from_name(screen, width, height, format,
> -                                     names[0], stride,
> loaderPrivate);
> +                                     names[0], strides[0],
> loaderPrivate);
>     if (img == NULL)
>        return NULL;
>  
> @@ -1101,7 +1098,7 @@ dri2_from_fds(__DRIscreen *screen, int width,
> int height, int fourcc,
>                void *loaderPrivate)
>  {
>     __DRIimage *img;
> -   int format, stride, dri_components;
> +   int format, dri_components;
>  
>     if (num_fds != 1)
>        return NULL;
> @@ -1112,11 +1109,8 @@ dri2_from_fds(__DRIscreen *screen, int width,
> int height, int fourcc,
>     if (format == -1)
>        return NULL;
>  
> -   /* Strides are in bytes not pixels. */
> -   stride = strides[0] /4;
> -
>     img = dri2_create_image_from_fd(screen, width, height, format,
> -                                   fds[0], stride, loaderPrivate);
> +                                   fds[0], strides[0],
> loaderPrivate);
>     if (img == NULL)
>        return NULL;
>  
> @@ -1137,7 +1131,7 @@ dri2_from_dma_bufs(__DRIscreen *screen,
>                     void *loaderPrivate)
>  {
>     __DRIimage *img;
> -   int format, stride, dri_components;
> +   int format, dri_components;
>  
>     if (num_fds != 1 || offsets[0] != 0) {
>        *error = __DRI_IMAGE_ERROR_BAD_MATCH;
> @@ -1150,11 +1144,8 @@ dri2_from_dma_bufs(__DRIscreen *screen,
>        return NULL;
>     }
>  
> -   /* Strides are in bytes not pixels. */
> -   stride = strides[0] /4;
> -
>     img = dri2_create_image_from_fd(screen, width, height, format,
> -                                   fds[0], stride, loaderPrivate);
> +                                   fds[0], strides[0],
> loaderPrivate);
>     if (img == NULL) {
>        *error = __DRI_IMAGE_ERROR_BAD_ALLOC;
>        return NULL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20160105/2bb6c3be/attachment-0001.sig>


More information about the mesa-dev mailing list