Mesa (staging/19.2): gallium/dri2: Fix creation of multi-planar modifier images
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 10 17:54:27 UTC 2019
Module: Mesa
Branch: staging/19.2
Commit: 96b8f4261171139cf720807cfe0f323425c5dbd9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=96b8f4261171139cf720807cfe0f323425c5dbd9
Author: Nanley Chery <nanley.g.chery at intel.com>
Date: Thu Nov 14 13:59:58 2019 -0800
gallium/dri2: Fix creation of multi-planar modifier images
The commit noted below assumed and enforced that DRM_MOD_INVALID was the
only valid modifier for multi-planar imported images. Due to that, it
required that modifier on multi-planar images to:
1. Allow multiple planes.
2. Perform YUV format lowering and extent adjustments.
3. Use buffer_index to correctly map the given planes.
Fix these issues by removing or updating the code built on that
assumption.
Fixes: 2066966c106 ("gallium/dri2: Support creating multi-planar modifier images")
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
(cherry picked from commit d5c857837aae205c0e1fddee30300b4419e2bb3f)
---
src/gallium/state_trackers/dri/dri2.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 2c51508b4ac..2edbae79886 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -759,18 +759,12 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
for (i = num_handles - 1; i >= 0; i--) {
struct pipe_resource *tex;
- 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.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;
- }
assert(templ.format != PIPE_FORMAT_NONE);
tex = pscreen->resource_from_handle(pscreen,
@@ -826,8 +820,13 @@ dri2_create_image_from_name(__DRIscreen *_screen,
}
static unsigned
-dri2_get_modifier_num_planes(uint64_t modifier)
+dri2_get_modifier_num_planes(uint64_t modifier, int fourcc)
{
+ const struct dri2_format_mapping *map = dri2_get_mapping_by_fourcc(fourcc);
+
+ if (!map)
+ return 0;
+
switch (modifier) {
case I915_FORMAT_MOD_Y_TILED_CCS:
return 2;
@@ -849,8 +848,8 @@ dri2_get_modifier_num_planes(uint64_t modifier)
/* FD_FORMAT_MOD_QCOM_TILED is not in drm_fourcc.h */
case I915_FORMAT_MOD_X_TILED:
case I915_FORMAT_MOD_Y_TILED:
- return 1;
case DRM_FORMAT_MOD_INVALID:
+ return map->nplanes;
default:
return 0;
}
@@ -868,15 +867,13 @@ 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);
+ int num_handles = dri2_get_modifier_num_planes(modifier, fourcc);
- if (!map || (modifier != DRM_FORMAT_MOD_INVALID && mod_planes == 0)) {
+ if (!map || num_handles == 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:
@@ -896,7 +893,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen,
for (i = 0; i < num_handles; i++) {
int fdnum = i >= num_fds ? 0 : i;
- int index = mod_planes > 0 ? i : map->planes[i].buffer_index;
+ int index = i >= map->nplanes ? i : map->planes[i].buffer_index;
if (fds[fdnum] < 0) {
err = __DRI_IMAGE_ERROR_BAD_ALLOC;
goto exit;
@@ -1393,7 +1390,7 @@ dri2_query_dma_buf_format_modifier_attribs(__DRIscreen *_screen,
{
switch (attrib) {
case __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT: {
- uint64_t mod_planes = dri2_get_modifier_num_planes(modifier);
+ uint64_t mod_planes = dri2_get_modifier_num_planes(modifier, fourcc);
if (mod_planes > 0)
*value = mod_planes;
return mod_planes > 0;
More information about the mesa-commit
mailing list