[4/6] gallium\auxiliary\vl: Add compute shader initilization, assign and cleanup

Submitted by Zhu, James on Feb. 1, 2019, 4:28 p.m.

Details

Message ID 1549038496-10500-5-git-send-email-James.Zhu@amd.com
State New
Headers show
Series "Add compute shader support on video compositor render" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Zhu, James Feb. 1, 2019, 4:28 p.m.
Add compute shader initilization, assign and cleanup in vl_compositor API.

Signed-off-by: James Zhu <James.Zhu@amd.com>
---
 src/gallium/auxiliary/vl/vl_compositor.c | 30 +++++++++++++++++++++++++++++-
 src/gallium/auxiliary/vl/vl_compositor.h |  4 ++++
 2 files changed, 33 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index 6ab4a60..85fbab4 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -41,6 +41,7 @@ 
 #include "vl_csc.h"
 #include "vl_types.h"
 #include "vl_compositor.h"
+#include "vl_compositor_cs.h"
 
 enum VS_OUTPUT
 {
@@ -472,6 +473,24 @@  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_sub_pic = vl_compositor_cs_create_shader(c, compute_shader_sub_pic);
+   if (!c->cs_sub_pic) {
+      debug_printf("Unable to create sub-pictures compute shader.\n");
+      return false;
+   }
+
    c->vs = create_vert_shader(c);
    if (!c->vs) {
       debug_printf("Unable to create vertex shader.\n");
@@ -544,6 +563,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_sub_pic);
 }
 
 static bool
@@ -1062,6 +1084,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;
@@ -1186,6 +1209,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:
@@ -1193,6 +1217,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:
@@ -1200,11 +1225,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
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index d51b5f5..2fe70f3 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -72,6 +72,7 @@  struct vl_compositor_layer
    struct pipe_viewport_state viewport;
 
    void *fs;
+   void *cs;
    void *samplers[3];
    void *blend;
 
@@ -116,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_sub_pic;
 
    struct {
       struct {