summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarad Gautam <varadgautam@gmail.com>2016-10-20 08:01:29 (GMT)
committerVarad Gautam <varadgautam@gmail.com>2016-10-20 08:06:42 (GMT)
commit8ac319d4a0e3eef4a479dbcc2ada53531cef5c7b (patch)
treebd0b1a9817f96d50e7f8986a5aee7ab7c307f4a3
parent2a139678bd77a373781d85a5e6ec88bd94c069f3 (diff)
downloadmesa-8ac319d4a0e3eef4a479dbcc2ada53531cef5c7b.tar.gz
mesa-8ac319d4a0e3eef4a479dbcc2ada53531cef5c7b.tar.xz
dri2: support format modifiers
Signed-off-by: Varad Gautam <varadgautam@gmail.com>
-rw-r--r--src/gallium/include/state_tracker/drm_driver.h2
-rw-r--r--src/gallium/state_trackers/dri/dri2.c43
2 files changed, 41 insertions, 4 deletions
diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h
index fefab11..8e1dcc5 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 64d9c3e..6b1e24c 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -883,7 +883,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];
@@ -928,6 +928,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[i];
}
if (fourcc == __DRI_IMAGE_FOURCC_YVU420) {
@@ -1247,7 +1248,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;
@@ -1272,7 +1273,39 @@ 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;
+
+ 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 __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;
@@ -1390,7 +1423,7 @@ dri2_get_capabilities(__DRIscreen *_screen)
/* The extension is modified during runtime if DRI_PRIME is detected */
static __DRIimageExtension dri2ImageExtension = {
- .base = { __DRI_IMAGE, 12 },
+ .base = { __DRI_IMAGE, 14 },
.createImageFromName = dri2_create_image_from_name,
.createImageFromRenderbuffer = dri2_create_image_from_renderbuffer,
@@ -1901,6 +1934,7 @@ dri2_init_screen(__DRIscreen * sPriv)
(cap & DRM_PRIME_CAP_IMPORT)) {
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
+ dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
}
}
@@ -1973,6 +2007,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
(cap & DRM_PRIME_CAP_IMPORT)) {
dri2ImageExtension.createImageFromFds = dri2_from_fds;
dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
+ dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
}
sPriv->extensions = dri_screen_extensions;