gallium/auxiliary/vl: Fix compute shader scale_y for interlaced videos
authorThong Thai <thong.thai@amd.com>
Tue, 19 May 2020 22:06:55 +0000 (18:06 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 20 May 2020 17:32:36 +0000 (17:32 +0000)
Signed-off-by: Thong Thai <thong.thai@amd.com>
Fixes: 494b7ef0c1a ("gallium/auxiliary/vl: Fix compute shader scaling for non-square pixels")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5121>

src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/auxiliary/vl/vl_compositor_cs.c

index d9d9237df78148c895ee3df5b7a5be607f71b2a2..f82c418009ee5cddb52bf10cc634986be52acb1a 100644 (file)
@@ -328,6 +328,7 @@ set_yuv_layer(struct vl_compositor_state *s, struct vl_compositor *c,
 
    assert(layer < VL_COMPOSITOR_MAX_LAYERS);
 
+   s->interlaced = buffer->interlaced;
    s->used_layers |= 1 << layer;
    sampler_views = buffer->get_sampler_view_components(buffer);
    for (i = 0; i < 3; ++i) {
@@ -435,7 +436,7 @@ vl_compositor_clear_layers(struct vl_compositor_state *s)
    unsigned i, j;
 
    assert(s);
-
+   s->interlaced = false;
    s->used_layers = 0;
    for ( i = 0; i < VL_COMPOSITOR_MAX_LAYERS; ++i) {
       struct vertex4f v_one = { 1.0f, 1.0f, 1.0f, 1.0f };
@@ -551,6 +552,7 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
 
    assert(layer < VL_COMPOSITOR_MAX_LAYERS);
 
+   s->interlaced = buffer->interlaced;
    s->used_layers |= 1 << layer;
    sampler_views = buffer->get_sampler_view_components(buffer);
    for (i = 0; i < 3; ++i) {
index 596e055cb09af8c63d0fab6753827d799744118c..cccee01623be0dd5bd7e6e6b277565d825ecb06d 100644 (file)
@@ -97,6 +97,7 @@ struct vl_compositor_state
 
    unsigned used_layers:VL_COMPOSITOR_MAX_LAYERS;
    struct vl_compositor_layer layers[VL_COMPOSITOR_MAX_LAYERS];
+   bool interlaced;
 };
 
 struct vl_compositor
index bc2055bd3e1e73fd28addb39a104316ffdf2db7a..0706cc84dad2760823e0c313df126c915d50cf0c 100644 (file)
@@ -713,7 +713,9 @@ draw_layers(struct vl_compositor       *c,
          drawn.scale_x = layer->viewport.scale[0] /
                   (float)layer->sampler_views[0]->texture->width0;
          drawn.scale_y = layer->viewport.scale[1] /
-                  (float)layer->sampler_views[0]->texture->height0;
+                  ((float)layer->sampler_views[0]->texture->height0 * 
+                   (s->interlaced ? 2.0 : 1.0));
+
          drawn.translate_x = (int)layer->viewport.translate[0];
          drawn.translate_y = (int)layer->viewport.translate[1];
          drawn.sampler0_w = (float)layer->sampler_views[0]->texture->width0;