[Mesa-dev] [PATCH v3 5/6] gallium/auxiliary/vl: Add compute shader initilization, assign and cleanup

Zhu, James James.Zhu at amd.com
Thu Feb 7 16:37:31 UTC 2019


Add compute shader initilization, assign and cleanup in vl_compositor API.

Signed-off-by: James Zhu <James.Zhu at amd.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/auxiliary/vl/vl_compositor.c | 31 ++++++++++++++++++++++++++++++-
 src/gallium/auxiliary/vl/vl_compositor.h |  3 +++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index 4509913..da4b02d 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -28,12 +28,31 @@
 #include "util/u_sampler.h"
 
 #include "vl_compositor_gfx.h"
+#include "vl_compositor_cs.h"
 
 static bool
 init_shaders(struct vl_compositor *c)
 {
    assert(c);
 
+   c->cs_video_buffer = vl_compositor_cs_create_shader(c, compute_shader_video_buffer);
+   if (!c->cs_video_buffer) {
+      debug_printf("Unable to create video_buffer compute shader.\n");
+      return false;
+   }
+
+   c->cs_weave_rgb = vl_compositor_cs_create_shader(c, compute_shader_weave);
+   if (!c->cs_weave_rgb) {
+      debug_printf("Unable to create weave_rgb compute shader.\n");
+      return false;
+   }
+
+   c->cs_rgba = vl_compositor_cs_create_shader(c, compute_shader_rgba);
+   if (!c->cs_rgba) {
+      debug_printf("Unable to create RGB-to-RGB compute shader.\n");
+      return false;
+   }
+
    c->vs = create_vert_shader(c);
    if (!c->vs) {
       debug_printf("Unable to create vertex shader.\n");
@@ -106,6 +125,9 @@ static void cleanup_shaders(struct vl_compositor *c)
    c->pipe->delete_fs_state(c->pipe, c->fs_rgba);
    c->pipe->delete_fs_state(c->pipe, c->fs_rgb_yuv.y);
    c->pipe->delete_fs_state(c->pipe, c->fs_rgb_yuv.uv);
+   c->pipe->delete_compute_state(c->pipe, c->cs_video_buffer);
+   c->pipe->delete_compute_state(c->pipe, c->cs_weave_rgb);
+   c->pipe->delete_compute_state(c->pipe, c->cs_rgba);
 }
 
 static bool
@@ -409,6 +431,7 @@ vl_compositor_clear_layers(struct vl_compositor_state *s)
       s->layers[i].clearing = i ? false : true;
       s->layers[i].blend = NULL;
       s->layers[i].fs = NULL;
+      s->layers[i].cs = NULL;
       s->layers[i].viewport.scale[2] = 1;
       s->layers[i].viewport.translate[2] = 0;
       s->layers[i].rotate = VL_COMPOSITOR_ROTATE_0;
@@ -533,6 +556,7 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
       switch(deinterlace) {
       case VL_COMPOSITOR_WEAVE:
          s->layers[layer].fs = c->fs_weave_rgb;
+         s->layers[layer].cs = c->cs_weave_rgb;
          break;
 
       case VL_COMPOSITOR_BOB_TOP:
@@ -540,6 +564,7 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
          s->layers[layer].src.tl.y += half_a_line;
          s->layers[layer].src.br.y += half_a_line;
          s->layers[layer].fs = c->fs_video_buffer;
+         s->layers[layer].cs = c->cs_video_buffer;
          break;
 
       case VL_COMPOSITOR_BOB_BOTTOM:
@@ -547,11 +572,14 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
          s->layers[layer].src.tl.y -= half_a_line;
          s->layers[layer].src.br.y -= half_a_line;
          s->layers[layer].fs = c->fs_video_buffer;
+         s->layers[layer].cs = c->cs_video_buffer;
          break;
       }
 
-   } else
+   } else {
       s->layers[layer].fs = c->fs_video_buffer;
+      s->layers[layer].cs = c->cs_video_buffer;
+   }
 }
 
 void
@@ -601,6 +629,7 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s,
 
    s->used_layers |= 1 << layer;
    s->layers[layer].fs = c->fs_rgba;
+   s->layers[layer].cs = c->cs_rgba;
    s->layers[layer].samplers[0] = c->sampler_linear;
    s->layers[layer].samplers[1] = NULL;
    s->layers[layer].samplers[2] = NULL;
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index 5fa1b6c..b0ed7f5 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -117,6 +117,9 @@ struct vl_compositor
    void *fs_video_buffer;
    void *fs_weave_rgb;
    void *fs_rgba;
+   void *cs_video_buffer;
+   void *cs_weave_rgb;
+   void *cs_rgba;
 
    struct {
       struct {
-- 
2.7.4



More information about the mesa-dev mailing list