All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Cc: dri-devel@lists.freedesktop.org,
	Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Subject: Re: [PATCH] dri2: Fix stride to pitch conversion
Date: Mon, 21 Dec 2015 16:26:34 +0100	[thread overview]
Message-ID: <20151221152634.GB30437@phenom.ffwll.local> (raw)
In-Reply-To: <1450710774.23313.2.camel@collabora.com>

On Mon, Dec 21, 2015 at 10:12:54AM -0500, Nicolas Dufresne wrote:
> Le samedi 19 décembre 2015 à 11:02 -0500, Nicolas Dufresne a écrit :
> > Not all color formats have a pixel stride of 4 bytes. This
> > fixes importation of RGB565 images.
> 
> 
> I just notice there is generic method to get the pixel stride (called
> block something size iirc). But worst then that, the underlying
> function will simply convert back to stride, better then this patch is
> to change this function to take a stride as parameter. I'll submit a
> new patch, please ignore this one.
> 
> > 
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

Since this is a mesa patch please resubmit to
mesa-devel@lists.freedesktop.org. This list here is for the drm component
(despite that it says dri-devel, I know confusing ...).

Thanks, Daniel

> > ---
> >  src/gallium/state_trackers/dri/dri2.c | 28 +++++++++++++++++------
> > -----
> >  1 file changed, 17 insertions(+), 11 deletions(-)
> > 
> > diff --git a/src/gallium/state_trackers/dri/dri2.c
> > b/src/gallium/state_trackers/dri/dri2.c
> > index a11a6cb..1373785 100644
> > --- a/src/gallium/state_trackers/dri/dri2.c
> > +++ b/src/gallium/state_trackers/dri/dri2.c
> > @@ -46,34 +46,40 @@
> >  #include "dri_query_renderer.h"
> >  #include "dri2_buffer.h"
> >  
> > -static int convert_fourcc(int format, int *dri_components_p)
> > +static int convert_fourcc(int format, int *dri_components_p, int
> > *pstride_p)
> >  {
> > -   int dri_components;
> > +   int dri_components, pstride;
> >     switch(format) {
> >     case __DRI_IMAGE_FOURCC_RGB565:
> >        format = __DRI_IMAGE_FORMAT_RGB565;
> >        dri_components = __DRI_IMAGE_COMPONENTS_RGB;
> > +      pstride = 2;
> >        break;
> >     case __DRI_IMAGE_FOURCC_ARGB8888:
> >        format = __DRI_IMAGE_FORMAT_ARGB8888;
> >        dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
> > +      pstride = 4;
> >        break;
> >     case __DRI_IMAGE_FOURCC_XRGB8888:
> >        format = __DRI_IMAGE_FORMAT_XRGB8888;
> >        dri_components = __DRI_IMAGE_COMPONENTS_RGB;
> > +      pstride = 4;
> >        break;
> >     case __DRI_IMAGE_FOURCC_ABGR8888:
> >        format = __DRI_IMAGE_FORMAT_ABGR8888;
> >        dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
> > +      pstride = 4;
> >        break;
> >     case __DRI_IMAGE_FOURCC_XBGR8888:
> >        format = __DRI_IMAGE_FORMAT_XBGR8888;
> >        dri_components = __DRI_IMAGE_COMPONENTS_RGB;
> > +      pstride = 4;
> >        break;
> >     default:
> >        return -1;
> >     }
> >     *dri_components_p = dri_components;
> > +   *pstride_p = pstride;
> >     return format;
> >  }
> >  
> > @@ -986,19 +992,19 @@ dri2_from_names(__DRIscreen *screen, int width,
> > int height, int format,
> >                  void *loaderPrivate)
> >  {
> >     __DRIimage *img;
> > -   int stride, dri_components;
> > +   int stride, pstride, dri_components;
> >  
> >     if (num_names != 1)
> >        return NULL;
> >     if (offsets[0] != 0)
> >        return NULL;
> >  
> > -   format = convert_fourcc(format, &dri_components);
> > +   format = convert_fourcc(format, &dri_components, &pstride);
> >     if (format == -1)
> >        return NULL;
> >  
> >     /* Strides are in bytes not pixels. */
> > -   stride = strides[0] /4;
> > +   stride = strides[0] / pstride;
> >  
> >     img = dri2_create_image_from_name(screen, width, height, format,
> >                                       names[0], stride, 
> > loaderPrivate);
> > @@ -1101,19 +1107,19 @@ dri2_from_fds(__DRIscreen *screen, int width,
> > int height, int fourcc,
> >                void *loaderPrivate)
> >  {
> >     __DRIimage *img;
> > -   int format, stride, dri_components;
> > +   int format, stride, pstride, dri_components;
> >  
> >     if (num_fds != 1)
> >        return NULL;
> >     if (offsets[0] != 0)
> >        return NULL;
> >  
> > -   format = convert_fourcc(fourcc, &dri_components);
> > +   format = convert_fourcc(fourcc, &dri_components, &pstride);
> >     if (format == -1)
> >        return NULL;
> >  
> >     /* Strides are in bytes not pixels. */
> > -   stride = strides[0] /4;
> > +   stride = strides[0] / pstride;
> >  
> >     img = dri2_create_image_from_fd(screen, width, height, format,
> >                                     fds[0], stride, loaderPrivate);
> > @@ -1137,21 +1143,21 @@ dri2_from_dma_bufs(__DRIscreen *screen,
> >                     void *loaderPrivate)
> >  {
> >     __DRIimage *img;
> > -   int format, stride, dri_components;
> > +   int format, stride, pstride, dri_components;
> >  
> >     if (num_fds != 1 || offsets[0] != 0) {
> >        *error = __DRI_IMAGE_ERROR_BAD_MATCH;
> >        return NULL;
> >     }
> >  
> > -   format = convert_fourcc(fourcc, &dri_components);
> > +   format = convert_fourcc(fourcc, &dri_components, &pstride);
> >     if (format == -1) {
> >        *error = __DRI_IMAGE_ERROR_BAD_MATCH;
> >        return NULL;
> >     }
> >  
> >     /* Strides are in bytes not pixels. */
> > -   stride = strides[0] /4;
> > +   stride = strides[0] / pstride;
> >  
> >     img = dri2_create_image_from_fd(screen, width, height, format,
> >                                     fds[0], stride, loaderPrivate);



> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2015-12-21 15:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-19 16:02 [PATCH] dri2: Fix stride to pitch conversion Nicolas Dufresne
2015-12-21 15:12 ` Nicolas Dufresne
2015-12-21 15:26   ` Daniel Vetter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151221152634.GB30437@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nicolas.dufresne@collabora.co.uk \
    --cc=nicolas.dufresne@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.