From c025cb9ee9d79ebfb66a577556e04deecfe012ed Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 28 Apr 2022 15:50:40 -0400 Subject: [PATCH] zink: fix dmabuf plane returns use the actual drm format plane count, not the resource format cc: mesa-stable Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_resource.c | 7 +++++-- src/gallium/drivers/zink/zink_resource.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 8474f840514..7fdbb4e52c4 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1052,7 +1052,7 @@ zink_resource_get_param(struct pipe_screen *pscreen, struct pipe_context *pctx, switch (param) { case PIPE_RESOURCE_PARAM_NPLANES: if (screen->info.have_EXT_image_drm_format_modifier) - *value = pscreen->get_dmabuf_modifier_planes(pscreen, obj->modifier, pres->format); + *value = util_format_get_num_planes(res->drm_format); else *value = 1; break; @@ -1200,7 +1200,10 @@ zink_resource_from_handle(struct pipe_screen *pscreen, modifier = whandle->modifier; modifier_count = 1; } - return resource_create(pscreen, &templ2, whandle, usage, &modifier, modifier_count, NULL); + struct pipe_resource *pres = resource_create(pscreen, &templ2, whandle, usage, &modifier, modifier_count, NULL); + if (pres) + zink_resource(pres)->drm_format = whandle->format; + return pres; #else return NULL; #endif diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h index 3381463aa35..4ea411c56c7 100644 --- a/src/gallium/drivers/zink/zink_resource.h +++ b/src/gallium/drivers/zink/zink_resource.h @@ -158,6 +158,7 @@ struct zink_resource { uint8_t modifiers_count; uint64_t *modifiers; + enum pipe_format drm_format; }; struct zink_transfer {