Mesa (master): gallium/vl: add 4:2:2 support

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 27 09:43:56 UTC 2020


Module: Mesa
Branch: master
Commit: c4197fbcdde55e93693e5687842605ff70ed3d15
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4197fbcdde55e93693e5687842605ff70ed3d15

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Tue Feb  4 18:57:08 2020 +0100

gallium/vl: add 4:2:2 support

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2363
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Acked-by: Leo Liu <leo.liu at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3738>

---

 src/gallium/auxiliary/vl/vl_compositor.c    |  2 +-
 src/gallium/auxiliary/vl/vl_compositor_cs.c | 25 +++++++++++++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index a381af108b3..d9d9237df78 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -813,7 +813,7 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
       pipe->screen,
       PIPE_BIND_CONSTANT_BUFFER,
       PIPE_USAGE_DEFAULT,
-      sizeof(csc_matrix) + 6*sizeof(float) + 6*sizeof(int)
+      sizeof(csc_matrix) + 6*sizeof(float) + 10*sizeof(int)
    );
 
    if (!s->shader_params)
diff --git a/src/gallium/auxiliary/vl/vl_compositor_cs.c b/src/gallium/auxiliary/vl/vl_compositor_cs.c
index 73576f066ee..eb19dd7b159 100644
--- a/src/gallium/auxiliary/vl/vl_compositor_cs.c
+++ b/src/gallium/auxiliary/vl/vl_compositor_cs.c
@@ -51,7 +51,7 @@ const char *compute_shader_video_buffer =
       "DCL SV[0], THREAD_ID\n"
       "DCL SV[1], BLOCK_ID\n"
 
-      "DCL CONST[0..5]\n"
+      "DCL CONST[0..6]\n"
       "DCL SVIEW[0..2], RECT, FLOAT\n"
       "DCL SAMP[0..2]\n"
 
@@ -59,7 +59,7 @@ const char *compute_shader_video_buffer =
       "DCL TEMP[0..7]\n"
 
       "IMM[0] UINT32 { 8, 8, 1, 0}\n"
-      "IMM[1] FLT32 { 1.0, 2.0, 0.0, 0.0}\n"
+      "IMM[1] FLT32 { 1.0, 0.0, 0.0, 0.0}\n"
 
       "UMAD TEMP[0].xy, SV[1].xyyy, IMM[0].xyyy, SV[0].xyyy\n"
 
@@ -74,7 +74,7 @@ const char *compute_shader_video_buffer =
          /* Translate */
          "UADD TEMP[2].xy, TEMP[0].xyyy, -CONST[5].xyxy\n"
          "U2F TEMP[2].xy, TEMP[2].xyyy\n"
-         "DIV TEMP[3].xy, TEMP[2].xyyy, IMM[1].yyyy\n"
+         "MUL TEMP[3].xy, TEMP[2].xyyy, CONST[6].xyyy\n"
 
          /* Scale */
          "DIV TEMP[2].xy, TEMP[2].xyyy, CONST[3].zwww\n"
@@ -646,7 +646,8 @@ calc_drawn_area(struct vl_compositor_state *s,
 
 static bool
 set_viewport(struct vl_compositor_state *s,
-             struct cs_viewport         *drawn)
+             struct cs_viewport         *drawn,
+             struct pipe_sampler_view **samplers)
 {
    struct pipe_transfer *buf_transfer;
 
@@ -674,7 +675,19 @@ set_viewport(struct vl_compositor_state *s,
 
    ptr_float = (float *)ptr_int;
    *ptr_float++ = drawn->sampler0_w;
-   *ptr_float = drawn->sampler0_h;
+   *ptr_float++ = drawn->sampler0_h;
+
+   /* compute_shader_video_buffer uses pixel coordinates based on the
+    * Y sampler dimensions. If U/V are using separate planes and are
+    * subsampled, we need to scale the coordinates */
+   if (samplers[1]) {
+      float h_ratio = samplers[1]->texture->width0 /
+                     (float) samplers[0]->texture->width0;
+      *ptr_float++ = h_ratio;
+      float v_ratio = samplers[1]->texture->height0 /
+                     (float) samplers[0]->texture->height0;
+      *ptr_float++ = v_ratio;
+   }
    pipe_buffer_unmap(s->pipe, buf_transfer);
 
    return true;
@@ -704,7 +717,7 @@ draw_layers(struct vl_compositor       *c,
          drawn.translate_y = (int)layer->viewport.translate[1];
          drawn.sampler0_w = (float)layer->sampler_views[0]->texture->width0;
          drawn.sampler0_h = (float)layer->sampler_views[0]->texture->height0;
-         set_viewport(s, &drawn);
+         set_viewport(s, &drawn, samplers);
 
          c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
                         num_sampler_views, layer->samplers);



More information about the mesa-commit mailing list