From 3dbbd94ffd06ab5a19dd0b7cca141cdbdc262723 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 7 Apr 2026 10:49:39 +0200 Subject: [PATCH] radeonsi: Set multi plane format also for imported textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit multi_plane_format is used to correctly copy all planes for staging texture copies, otherwise only the first plane gets copied. It's now also used in si_video_dec, which doesn't work when decoding into imported surfaces if multi_plane_format is not set. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15232 Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_texture.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index d9535d70d87..da4762d1950 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -1928,6 +1928,7 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen, { struct si_screen *sscreen = (struct si_screen *)screen; struct pb_buffer_lean *buf = NULL; + unsigned format_num_planes = util_format_get_num_planes(whandle->format); buf = sscreen->ws->buffer_from_handle(sscreen->ws, whandle, sscreen->info.max_alignment, @@ -1938,7 +1939,7 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen, if (templ->target == PIPE_BUFFER) return si_buffer_from_winsys_buffer(screen, templ, buf, 0, true); - if (whandle->plane >= util_format_get_num_planes(whandle->format)) { + if (whandle->plane >= format_num_planes) { struct si_auxiliary_texture *tex = CALLOC_STRUCT_CL(si_auxiliary_texture); if (!tex) return NULL; @@ -1953,8 +1954,17 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen, return &tex->b.b; } - return si_texture_from_winsys_buffer(sscreen, templ, buf, whandle->stride, whandle->offset, - whandle->modifier, usage, true, true); + struct pipe_resource *texture = + si_texture_from_winsys_buffer(sscreen, templ, buf, whandle->stride, whandle->offset, + whandle->modifier, usage, true, true); + + if (texture && whandle->plane == 0 && format_num_planes >= 2) { + struct si_texture *tex = (struct si_texture *)texture; + + tex->multi_plane_format = whandle->format; + } + + return texture; } bool si_init_flushed_depth_texture(struct pipe_context *ctx, struct pipe_resource *texture)