[v2,5/7] gallium/auxiliary/vl: Add compute shader initilization, assign and cleanup

Submitted by Zhu, James on Feb. 6, 2019, 7:44 p.m.

Details

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

Not browsing as part of any series.

Commit Message

Zhu, James Feb. 6, 2019, 7:44 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 | 31 ++++++++++++++++++++++++++++++-
 src/gallium/auxiliary/vl/vl_compositor.h |  3 +++
 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 7d701d5..5b6c3bd 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -28,6 +28,7 @@ 
 #include "util/u_sampler.h"
 
 #include "vl_compositor_gfx.h"
+#include "vl_compositor_cs.h"
 
 
 static bool
@@ -35,6 +36,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_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");
@@ -107,6 +126,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
@@ -410,6 +432,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;
@@ -534,6 +557,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:
@@ -541,6 +565,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:
@@ -548,11 +573,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
@@ -602,6 +630,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 e6549f0..e611c8c 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 {