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.liu@amd.com>
Reviewed-by: Sathishkumar S <sathishkumar.sundararaju@amd.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26911>
(cherry picked from commit 9eac06521a)
This commit is contained in:
Leo Liu 2024-01-05 21:26:21 -05:00 committed by Eric Engestrom
parent ee4740fe29
commit 884ca57174
2 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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;