Re: [Mesa-dev] [PATCH v13 12/36] st/dri: implement DRIimage creation from dmabufs with modifiers
Am Freitag, den 19.05.2017, 10:37 +0100 schrieb Daniel Stone: > From: Varad Gautam > > support importing dmabufs into DRIimage while taking format modifiers > in account, as per DRIimage extension version 15. > > bump __DRIimageExtension to 15. > > v2: initialize winsys modifier to DRM_FORMAT_MOD_INVALID (Daniel Stone) > > Signed-off-by: Varad Gautam > Signed-off-by: Daniel Stone Reviewed-by: Lucas Stach > --- > src/gallium/include/state_tracker/drm_driver.h | 2 ++ > src/gallium/state_trackers/dri/dri2.c | 48 > +++--- > 2 files changed, 45 insertions(+), 5 deletions(-) > > diff --git a/src/gallium/include/state_tracker/drm_driver.h > b/src/gallium/include/state_tracker/drm_driver.h > index c80fb09dbc..8b9d6bc621 100644 > --- a/src/gallium/include/state_tracker/drm_driver.h > +++ b/src/gallium/include/state_tracker/drm_driver.h > @@ -45,6 +45,8 @@ struct winsys_handle > * Output for texture_get_handle. > */ > unsigned offset; > + > + uint64_t modifier; > }; > > > diff --git a/src/gallium/state_trackers/dri/dri2.c > b/src/gallium/state_trackers/dri/dri2.c > index 713f482181..3f83cc96cc 100644 > --- a/src/gallium/state_trackers/dri/dri2.c > +++ b/src/gallium/state_trackers/dri/dri2.c > @@ -878,7 +878,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, > img->layer = 0; > img->dri_format = format; > img->use = 0; > - img->modifier = DRM_FORMAT_MOD_INVALID; > + img->modifier = whandle[0].modifier; > img->loader_private = loaderPrivate; > > return img; > @@ -895,6 +895,7 @@ dri2_create_image_from_name(__DRIscreen *_screen, > memset(&whandle, 0, sizeof(whandle)); > whandle.type = DRM_API_HANDLE_TYPE_SHARED; > whandle.handle = name; > + whandle.modifier = DRM_FORMAT_MOD_INVALID; > > pf = dri2_format_to_pipe_format (format); > if (pf == PIPE_FORMAT_NONE) > @@ -910,7 +911,7 @@ static __DRIimage * > dri2_create_image_from_fd(__DRIscreen *_screen, >int width, int height, int fourcc, >int *fds, int num_fds, int *strides, > - int *offsets, unsigned *error, > + int *offsets, uint64_t *modifiers, unsigned *error, >int *dri_components, void *loaderPrivate) > { > struct winsys_handle whandles[3]; > @@ -941,6 +942,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen, >whandles[i].handle = (unsigned)fds[i]; >whandles[i].stride = (unsigned)strides[i]; >whandles[i].offset = (unsigned)offsets[i]; > + whandles[i].modifier = modifiers ? modifiers[i] : > DRM_FORMAT_MOD_INVALID; > } > > if (fourcc == __DRI_IMAGE_FOURCC_YVU420) { > @@ -1219,6 +1221,7 @@ dri2_from_names(__DRIscreen *screen, int width, int > height, int format, > whandle.handle = names[0]; > whandle.stride = strides[0]; > whandle.offset = offsets[0]; > + whandle.modifier = DRM_FORMAT_MOD_INVALID; > > img = dri2_create_image_from_winsys(screen, width, height, > f->planes[0].dri_format, > @@ -1331,7 +1334,7 @@ dri2_from_fds(__DRIscreen *screen, int width, int > height, int fourcc, > int dri_components; > > img = dri2_create_image_from_fd(screen, width, height, fourcc, > - fds, num_fds, strides, offsets, NULL, > + fds, num_fds, strides, offsets, NULL, > NULL, > &dri_components, loaderPrivate); > if (img == NULL) >return NULL; > @@ -1356,7 +1359,7 @@ dri2_from_dma_bufs(__DRIscreen *screen, > int dri_components; > > img = dri2_create_image_from_fd(screen, width, height, fourcc, > - fds, num_fds, strides, offsets, error, > + fds, num_fds, strides, offsets, NULL, > error, > &dri_components, loaderPrivate); > if (img == NULL) >return NULL; > @@ -1371,6 +1374,38 @@ dri2_from_dma_bufs(__DRIscreen *screen, > return img; > } > > +static __DRIimage * > +dri2_from_dma_bufs2(__DRIscreen *screen, > +int width, int height, int fourcc, > +int *fds, int num_fds, > +int *strides, int *offsets, > +uint64_t *modifiers, > +enum __DRIYUVColorSpace yuv_color_space, > +enum __DRISampleRange sample_range, > +enum __DRIChromaSiting horizontal_siting, > +enum __DRIChromaSiting vertical_siting, > +unsigned *error, > +void *loaderPrivate) > +{ > + __DRIimage *img; > + int dri_components; > + > + img = dri2_create_image_from_fd(screen, width, height, fourcc, > + fds, num_fds, strides, offsets, modifiers, > + error, &dri
[Mesa-dev] [PATCH v13 12/36] st/dri: implement DRIimage creation from dmabufs with modifiers
From: Varad Gautam support importing dmabufs into DRIimage while taking format modifiers in account, as per DRIimage extension version 15. bump __DRIimageExtension to 15. v2: initialize winsys modifier to DRM_FORMAT_MOD_INVALID (Daniel Stone) Signed-off-by: Varad Gautam Signed-off-by: Daniel Stone --- src/gallium/include/state_tracker/drm_driver.h | 2 ++ src/gallium/state_trackers/dri/dri2.c | 48 +++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h index c80fb09dbc..8b9d6bc621 100644 --- a/src/gallium/include/state_tracker/drm_driver.h +++ b/src/gallium/include/state_tracker/drm_driver.h @@ -45,6 +45,8 @@ struct winsys_handle * Output for texture_get_handle. */ unsigned offset; + + uint64_t modifier; }; diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 713f482181..3f83cc96cc 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -878,7 +878,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, img->layer = 0; img->dri_format = format; img->use = 0; - img->modifier = DRM_FORMAT_MOD_INVALID; + img->modifier = whandle[0].modifier; img->loader_private = loaderPrivate; return img; @@ -895,6 +895,7 @@ dri2_create_image_from_name(__DRIscreen *_screen, memset(&whandle, 0, sizeof(whandle)); whandle.type = DRM_API_HANDLE_TYPE_SHARED; whandle.handle = name; + whandle.modifier = DRM_FORMAT_MOD_INVALID; pf = dri2_format_to_pipe_format (format); if (pf == PIPE_FORMAT_NONE) @@ -910,7 +911,7 @@ static __DRIimage * dri2_create_image_from_fd(__DRIscreen *_screen, int width, int height, int fourcc, int *fds, int num_fds, int *strides, - int *offsets, unsigned *error, + int *offsets, uint64_t *modifiers, unsigned *error, int *dri_components, void *loaderPrivate) { struct winsys_handle whandles[3]; @@ -941,6 +942,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen, whandles[i].handle = (unsigned)fds[i]; whandles[i].stride = (unsigned)strides[i]; whandles[i].offset = (unsigned)offsets[i]; + whandles[i].modifier = modifiers ? modifiers[i] : DRM_FORMAT_MOD_INVALID; } if (fourcc == __DRI_IMAGE_FOURCC_YVU420) { @@ -1219,6 +1221,7 @@ dri2_from_names(__DRIscreen *screen, int width, int height, int format, whandle.handle = names[0]; whandle.stride = strides[0]; whandle.offset = offsets[0]; + whandle.modifier = DRM_FORMAT_MOD_INVALID; img = dri2_create_image_from_winsys(screen, width, height, f->planes[0].dri_format, @@ -1331,7 +1334,7 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc, int dri_components; img = dri2_create_image_from_fd(screen, width, height, fourcc, - fds, num_fds, strides, offsets, NULL, + fds, num_fds, strides, offsets, NULL, NULL, &dri_components, loaderPrivate); if (img == NULL) return NULL; @@ -1356,7 +1359,7 @@ dri2_from_dma_bufs(__DRIscreen *screen, int dri_components; img = dri2_create_image_from_fd(screen, width, height, fourcc, - fds, num_fds, strides, offsets, error, + fds, num_fds, strides, offsets, NULL, error, &dri_components, loaderPrivate); if (img == NULL) return NULL; @@ -1371,6 +1374,38 @@ dri2_from_dma_bufs(__DRIscreen *screen, return img; } +static __DRIimage * +dri2_from_dma_bufs2(__DRIscreen *screen, +int width, int height, int fourcc, +int *fds, int num_fds, +int *strides, int *offsets, +uint64_t *modifiers, +enum __DRIYUVColorSpace yuv_color_space, +enum __DRISampleRange sample_range, +enum __DRIChromaSiting horizontal_siting, +enum __DRIChromaSiting vertical_siting, +unsigned *error, +void *loaderPrivate) +{ + __DRIimage *img; + int dri_components; + + img = dri2_create_image_from_fd(screen, width, height, fourcc, + fds, num_fds, strides, offsets, modifiers, + error, &dri_components, loaderPrivate); + if (img == NULL) + return NULL; + + img->yuv_color_space = yuv_color_space; + img->sample_range = sample_range; + img->horizontal_siting = horizontal_siting; + img->vertical_siting = vertical_siting; + img->dri_components = dri_components; + + *error = __DRI_IMAGE_ERROR_SUCCESS; + return