Module: Mesa Branch: staging/23.3 Commit: 00f316d0317e620563a27116a33f38e302b93ae8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=00f316d0317e620563a27116a33f38e302b93ae8
Author: Leo Liu <leo....@amd.com> Date: Fri Jan 5 21:26:21 2024 -0500 gallium/vl: match YUYV/UYVY swizzle with change of color channels Update the sampler views with the color channels, that fixes the issue caused by: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20815 It fixes the case: `gst-launch-1.0 -v -v filesrc location=file.jpg ! jpegparse ! vaapijpegdec ! imagefreeze ! vaapisink` Fixes: dc2119bf3f ("util/format: Fix wrong colors when importing YUYV and UYVY") Cc: mesa-stable Signed-off-by: Leo Liu <leo....@amd.com> Reviewed-by: Sathishkumar S <sathishkumar.sundarar...@amd.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-pra...@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26911> (cherry picked from commit 9eac06521a810ea5e2276cd82be1e21fedfe2710) --- .pick_status.json | 2 +- src/gallium/auxiliary/vl/vl_video_buffer.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7d4d1d2bd3a..c58b34ef8df 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -294,7 +294,7 @@ "description": "gallium/vl: match YUYV/UYVY swizzle with change of color channels", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "dc2119bf3fa9a7f18481b16b0b3e9e9900ad6d8e", "notes": null diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c index a3d6109c335..4d95f762510 100644 --- a/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -296,13 +296,19 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer) nr_components = 3; for (j = 0; j < nr_components && component < VL_NUM_COMPONENTS; ++j, ++component) { + unsigned pipe_swizzle; + if (buf->sampler_view_components[component]) continue; memset(&sv_templ, 0, sizeof(sv_templ)); u_sampler_view_default_template(&sv_templ, res, sampler_format[plane_order[i]]); - sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_X + j; + pipe_swizzle = (buf->base.buffer_format == PIPE_FORMAT_YUYV || buf->base.buffer_format == PIPE_FORMAT_UYVY) ? + (PIPE_SWIZZLE_X + j + 1) % 3 : + (PIPE_SWIZZLE_X + j); + sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = pipe_swizzle; sv_templ.swizzle_a = PIPE_SWIZZLE_1; + buf->sampler_view_components[component] = pipe->create_sampler_view(pipe, res, &sv_templ); if (!buf->sampler_view_components[component]) goto error;