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 at collabora.com>
Since this is a mesa patch please resubmit to mesa-devel at 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 at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch