Module: Mesa Branch: main Commit: 9eac06521a810ea5e2276cd82be1e21fedfe2710 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9eac06521a810ea5e2276cd82be1e21fedfe2710
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> --- src/gallium/auxiliary/vl/vl_video_buffer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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;