gallium/auxiliary/vl: Set correct csc matrix in set_buffer_layer
authorDavid Rosca <nowrep@gmail.com>
Thu, 10 Aug 2023 20:05:12 +0000 (22:05 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 14 Aug 2023 18:18:16 +0000 (18:18 +0000)
Shaders used in set_buffer_layer will apply colorspace conversion,
so we need to set correct matrix depending on the input and output
surface formats.
Use BT.601 (default) for YUV to RGB and identity for RGB to RGB.

Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24626>

src/gallium/auxiliary/vl/vl_compositor.c

index 894df6dc295f56875148142d6c295ba0f4ffd637..cf2fdc08559a55fe88f7549a0ca1e5a93aedeeb2 100644 (file)
@@ -561,6 +561,7 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
 {
    struct pipe_sampler_view **sampler_views;
    unsigned i;
+   vl_csc_matrix csc_matrix;
 
    assert(s && c && buffer);
 
@@ -617,6 +618,12 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
       else if (c->pipe_gfx_supported)
          s->layers[layer].fs = c->fs_video_buffer;
    }
+
+   vl_csc_get_matrix(util_format_is_yuv(buffer->buffer_format) ?
+                     VL_CSC_COLOR_STANDARD_BT_601 :
+                     VL_CSC_COLOR_STANDARD_IDENTITY,
+                     NULL, true, &csc_matrix);
+   vl_compositor_set_csc_matrix(s, &csc_matrix, 1.0f, 0.0f);
 }
 
 void