mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 11:10:10 +01:00
st/dri: implement DRIimage creation from dmabufs with modifiers
support importing dmabufs into DRIimage while taking format modifiers in account, as per DRIimage extension version 15. v2: initialize winsys modifier to DRM_FORMAT_MOD_INVALID (Daniel Stone) v3: do not bump DRIimageExtension version. split out winsys changes. Signed-off-by: Varad Gautam <varad.gautam@collabora.com> Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
This commit is contained in:
parent
f61a8ba168
commit
82b3d1fa9a
1 changed files with 40 additions and 5 deletions
|
|
@ -888,8 +888,8 @@ dri2_create_image_from_name(__DRIscreen *_screen,
|
||||||
static __DRIimage *
|
static __DRIimage *
|
||||||
dri2_create_image_from_fd(__DRIscreen *_screen,
|
dri2_create_image_from_fd(__DRIscreen *_screen,
|
||||||
int width, int height, int fourcc,
|
int width, int height, int fourcc,
|
||||||
int *fds, int num_fds, int *strides,
|
uint64_t modifier, int *fds, int num_fds,
|
||||||
int *offsets, unsigned *error,
|
int *strides, int *offsets, unsigned *error,
|
||||||
int *dri_components, void *loaderPrivate)
|
int *dri_components, void *loaderPrivate)
|
||||||
{
|
{
|
||||||
struct winsys_handle whandles[3];
|
struct winsys_handle whandles[3];
|
||||||
|
|
@ -934,7 +934,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
|
||||||
whandles[i].handle = (unsigned)fds[i];
|
whandles[i].handle = (unsigned)fds[i];
|
||||||
whandles[i].stride = (unsigned)strides[i];
|
whandles[i].stride = (unsigned)strides[i];
|
||||||
whandles[i].offset = (unsigned)offsets[i];
|
whandles[i].offset = (unsigned)offsets[i];
|
||||||
whandles[i].modifier = DRM_FORMAT_MOD_INVALID;
|
whandles[i].modifier = modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fourcc == __DRI_IMAGE_FOURCC_YVU420) {
|
if (fourcc == __DRI_IMAGE_FOURCC_YVU420) {
|
||||||
|
|
@ -1311,7 +1311,8 @@ dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
|
||||||
int dri_components;
|
int dri_components;
|
||||||
|
|
||||||
img = dri2_create_image_from_fd(screen, width, height, fourcc,
|
img = dri2_create_image_from_fd(screen, width, height, fourcc,
|
||||||
fds, num_fds, strides, offsets, NULL,
|
DRM_FORMAT_MOD_INVALID, fds, num_fds,
|
||||||
|
strides, offsets, NULL,
|
||||||
&dri_components, loaderPrivate);
|
&dri_components, loaderPrivate);
|
||||||
if (img == NULL)
|
if (img == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1336,7 +1337,8 @@ dri2_from_dma_bufs(__DRIscreen *screen,
|
||||||
int dri_components;
|
int dri_components;
|
||||||
|
|
||||||
img = dri2_create_image_from_fd(screen, width, height, fourcc,
|
img = dri2_create_image_from_fd(screen, width, height, fourcc,
|
||||||
fds, num_fds, strides, offsets, error,
|
DRM_FORMAT_MOD_INVALID, fds, num_fds,
|
||||||
|
strides, offsets, error,
|
||||||
&dri_components, loaderPrivate);
|
&dri_components, loaderPrivate);
|
||||||
if (img == NULL)
|
if (img == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1351,6 +1353,37 @@ dri2_from_dma_bufs(__DRIscreen *screen,
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __DRIimage *
|
||||||
|
dri2_from_dma_bufs2(__DRIscreen *screen,
|
||||||
|
int width, int height, int fourcc,
|
||||||
|
uint64_t modifier, int *fds, int num_fds,
|
||||||
|
int *strides, int *offsets,
|
||||||
|
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,
|
||||||
|
modifier, fds, num_fds, strides, offsets,
|
||||||
|
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 img;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
|
dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
|
||||||
int dstx0, int dsty0, int dstwidth, int dstheight,
|
int dstx0, int dsty0, int dstwidth, int dstheight,
|
||||||
|
|
@ -1882,6 +1915,7 @@ dri2_init_screen(__DRIscreen * sPriv)
|
||||||
(cap & DRM_PRIME_CAP_IMPORT)) {
|
(cap & DRM_PRIME_CAP_IMPORT)) {
|
||||||
dri2ImageExtension.createImageFromFds = dri2_from_fds;
|
dri2ImageExtension.createImageFromFds = dri2_from_fds;
|
||||||
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
|
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
|
||||||
|
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1958,6 +1992,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
|
||||||
(cap & DRM_PRIME_CAP_IMPORT)) {
|
(cap & DRM_PRIME_CAP_IMPORT)) {
|
||||||
dri2ImageExtension.createImageFromFds = dri2_from_fds;
|
dri2ImageExtension.createImageFromFds = dri2_from_fds;
|
||||||
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
|
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
|
||||||
|
dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
|
||||||
}
|
}
|
||||||
|
|
||||||
sPriv->extensions = dri_screen_extensions;
|
sPriv->extensions = dri_screen_extensions;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue