Mesa (master): gallium/dri2: Support creating multi-planar modifier images
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Aug 13 08:18:07 UTC 2019
Module: Mesa
Branch: master
Commit: 2066966c10692a223271b471e733573df6c5b783
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2066966c10692a223271b471e733573df6c5b783
Author: Jordan Justen <jordan.l.justen at intel.com>
Date: Fri Aug 2 14:00:08 2019 -0700
gallium/dri2: Support creating multi-planar modifier images
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Acked-by: Eric Anholt <eric at anholt.net>
---
src/gallium/state_trackers/dri/dri2.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 126b8f4c0e2..98039555892 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -759,12 +759,18 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
for (i = num_handles - 1; i >= 0; i--) {
struct pipe_resource *tex;
- templ.width0 = width >> map->planes[i].width_shift;
- templ.height0 = height >> map->planes[i].height_shift;
- if (is_yuv)
- templ.format = dri2_get_pipe_format_for_dri_format(map->planes[i].dri_format);
- else
+ if (whandle[i].modifier == DRM_FORMAT_MOD_INVALID) {
+ templ.width0 = width >> map->planes[i].width_shift;
+ templ.height0 = height >> map->planes[i].height_shift;
+ if (is_yuv)
+ templ.format = dri2_get_pipe_format_for_dri_format(map->planes[i].dri_format);
+ else
+ templ.format = map->pipe_format;
+ } else {
+ templ.width0 = width;
+ templ.height0 = height;
templ.format = map->pipe_format;
+ }
assert(templ.format != PIPE_FORMAT_NONE);
tex = pscreen->resource_from_handle(pscreen,
@@ -862,19 +868,22 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
__DRIimage *img = NULL;
unsigned err = __DRI_IMAGE_ERROR_SUCCESS;
int i, expected_num_fds;
+ uint64_t mod_planes = dri2_get_modifier_num_planes(modifier);
- if (!map) {
+ if (!map || (modifier != DRM_FORMAT_MOD_INVALID && mod_planes == 0)) {
err = __DRI_IMAGE_ERROR_BAD_MATCH;
goto exit;
}
+ int num_handles = mod_planes > 0 ? mod_planes : map->nplanes;
+
switch (fourcc) {
case __DRI_IMAGE_FOURCC_YUYV:
case __DRI_IMAGE_FOURCC_UYVY:
expected_num_fds = 1;
break;
default:
- expected_num_fds = map->nplanes;
+ expected_num_fds = num_handles;
break;
}
@@ -885,9 +894,9 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
memset(whandles, 0, sizeof(whandles));
- for (i = 0; i < map->nplanes; i++) {
+ for (i = 0; i < num_handles; i++) {
int fdnum = i >= num_fds ? 0 : i;
- int index = map->planes[i].buffer_index;
+ int index = mod_planes > 0 ? i : map->planes[i].buffer_index;
if (fds[fdnum] < 0) {
err = __DRI_IMAGE_ERROR_BAD_ALLOC;
goto exit;
@@ -901,7 +910,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
}
img = dri2_create_image_from_winsys(_screen, width, height, map,
- map->nplanes, whandles, loaderPrivate);
+ num_handles, whandles, loaderPrivate);
if(img == NULL) {
err = __DRI_IMAGE_ERROR_BAD_ALLOC;
goto exit;
More information about the mesa-commit
mailing list