<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<div class="moz-cite-prefix">On 2019-02-14 4:44 p.m., Marek Olšák wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAAxE2A51JgJavHJ85arR_GuBJcpdN4AW5RJFW3_KGbH0vMofaw@mail.gmail.com">
<div dir="auto">This still creates gfx shaders. If we switch MM to compute IBs, calling any gfx function will crash.</div>
</blockquote>
<p>Right now only fs_video_buffer/fs_weave_rgb/fs_rgba have compute shader replacement.
<br>
</p>
<p>The other gfx shader will be converted to compute shader later. <br>
</p>
<p> James.<br>
</p>
<blockquote type="cite" cite="mid:CAAxE2A51JgJavHJ85arR_GuBJcpdN4AW5RJFW3_KGbH0vMofaw@mail.gmail.com">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">Marek</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Feb 12, 2019, 2:53 PM Zhu, James <<a href="mailto:James.Zhu@amd.com" moz-do-not-send="true">James.Zhu@amd.com</a> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
Add compute shader initilization, assign and cleanup in vl_compositor API.<br>
Set video compositor compute shader render as default when pipe support it.<br>
<br>
Signed-off-by: James Zhu <<a href="mailto:James.Zhu@amd.com" target="_blank" rel="noreferrer" moz-do-not-send="true">James.Zhu@amd.com</a>><br>
Reviewed-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank" rel="noreferrer" moz-do-not-send="true">christian.koenig@amd.com</a>><br>
---<br>
 src/gallium/auxiliary/vl/vl_compositor.c | 106 +++++++++++++++++++++++--------<br>
 src/gallium/auxiliary/vl/vl_compositor.h |   5 ++<br>
 2 files changed, 83 insertions(+), 28 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c<br>
index 4509913..8731ad9 100644<br>
--- a/src/gallium/auxiliary/vl/vl_compositor.c<br>
+++ b/src/gallium/auxiliary/vl/vl_compositor.c<br>
@@ -28,6 +28,7 @@<br>
 #include "util/u_sampler.h"<br>
<br>
 #include "vl_compositor_gfx.h"<br>
+#include "vl_compositor_cs.h"<br>
<br>
 static bool<br>
 init_shaders(struct vl_compositor *c)<br>
@@ -40,18 +41,6 @@ init_shaders(struct vl_compositor *c)<br>
       return false;<br>
    }<br>
<br>
-   c->fs_video_buffer = create_frag_shader_video_buffer(c);<br>
-   if (!c->fs_video_buffer) {<br>
-      debug_printf("Unable to create YCbCr-to-RGB fragment shader.\n");<br>
-      return false;<br>
-   }<br>
-<br>
-   c->fs_weave_rgb = create_frag_shader_weave_rgb(c);<br>
-   if (!c->fs_weave_rgb) {<br>
-      debug_printf("Unable to create YCbCr-to-RGB weave fragment shader.\n");<br>
-      return false;<br>
-   }<br>
-<br>
    c->fs_yuv.weave.y = create_frag_shader_deint_yuv(c, true, true);<br>
    c->fs_yuv.weave.uv = create_frag_shader_deint_yuv(c, false, true);<br>
    c->fs_yuv.bob.y = create_frag_shader_deint_yuv(c, true, false);<br>
@@ -74,12 +63,6 @@ init_shaders(struct vl_compositor *c)<br>
       return false;<br>
    }<br>
<br>
-   c->fs_rgba = create_frag_shader_rgba(c);<br>
-   if (!c->fs_rgba) {<br>
-      debug_printf("Unable to create RGB-to-RGB fragment shader.\n");<br>
-      return false;<br>
-   }<br>
-<br>
    c->fs_rgb_yuv.y = create_frag_shader_rgb_yuv(c, true);<br>
    c->fs_rgb_yuv.uv = create_frag_shader_rgb_yuv(c, false);<br>
    if (!c->fs_rgb_yuv.y || !c->fs_rgb_yuv.uv) {<br>
@@ -87,6 +70,44 @@ init_shaders(struct vl_compositor *c)<br>
       return false;<br>
    }<br>
<br>
+   if (c->pipe_compute_supported) {<br>
+      c->cs_video_buffer = vl_compositor_cs_create_shader(c, compute_shader_video_buffer);<br>
+      if (!c->cs_video_buffer) {<br>
+         debug_printf("Unable to create video_buffer compute shader.\n");<br>
+         return false;<br>
+      }<br>
+<br>
+      c->cs_weave_rgb = vl_compositor_cs_create_shader(c, compute_shader_weave);<br>
+      if (!c->cs_weave_rgb) {<br>
+         debug_printf("Unable to create weave_rgb compute shader.\n");<br>
+         return false;<br>
+      }<br>
+<br>
+      c->cs_rgba = vl_compositor_cs_create_shader(c, compute_shader_rgba);<br>
+      if (!c->cs_rgba) {<br>
+         debug_printf("Unable to create RGB-to-RGB compute shader.\n");<br>
+         return false;<br>
+      }<br>
+   } else {<br>
+      c->fs_video_buffer = create_frag_shader_video_buffer(c);<br>
+      if (!c->fs_video_buffer) {<br>
+         debug_printf("Unable to create YCbCr-to-RGB fragment shader.\n");<br>
+         return false;<br>
+      }<br>
+<br>
+      c->fs_weave_rgb = create_frag_shader_weave_rgb(c);<br>
+      if (!c->fs_weave_rgb) {<br>
+         debug_printf("Unable to create YCbCr-to-RGB weave fragment shader.\n");<br>
+         return false;<br>
+      }<br>
+<br>
+      c->fs_rgba = create_frag_shader_rgba(c);<br>
+      if (!c->fs_rgba) {<br>
+         debug_printf("Unable to create RGB-to-RGB fragment shader.\n");<br>
+         return false;<br>
+      }<br>
+   }<br>
+<br>
    return true;<br>
 }<br>
<br>
@@ -95,17 +116,24 @@ static void cleanup_shaders(struct vl_compositor *c)<br>
    assert(c);<br>
<br>
    c->pipe->delete_vs_state(c->pipe, c->vs);<br>
-   c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer);<br>
-   c->pipe->delete_fs_state(c->pipe, c->fs_weave_rgb);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_yuv.weave.y);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_yuv.weave.uv);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_yuv.bob.y);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_yuv.bob.uv);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_palette.yuv);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_palette.rgb);<br>
-   c->pipe->delete_fs_state(c->pipe, c->fs_rgba);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_rgb_yuv.y);<br>
    c->pipe->delete_fs_state(c->pipe, c->fs_rgb_yuv.uv);<br>
+<br>
+   if (c->pipe_compute_supported) {<br>
+      c->pipe->delete_compute_state(c->pipe, c->cs_video_buffer);<br>
+      c->pipe->delete_compute_state(c->pipe, c->cs_weave_rgb);<br>
+      c->pipe->delete_compute_state(c->pipe, c->cs_rgba);<br>
+   } else {<br>
+      c->pipe->delete_fs_state(c->pipe, c->fs_video_buffer);<br>
+      c->pipe->delete_fs_state(c->pipe, c->fs_weave_rgb);<br>
+      c->pipe->delete_fs_state(c->pipe, c->fs_rgba);<br>
+   }<br>
 }<br>
<br>
 static bool<br>
@@ -409,6 +437,7 @@ vl_compositor_clear_layers(struct vl_compositor_state *s)<br>
       s->layers[i].clearing = i ? false : true;<br>
       s->layers[i].blend = NULL;<br>
       s->layers[i].fs = NULL;<br>
+      s->layers[i].cs = NULL;<br>
       s->layers[i].viewport.scale[2] = 1;<br>
       s->layers[i].viewport.translate[2] = 0;<br>
       s->layers[i].rotate = VL_COMPOSITOR_ROTATE_0;<br>
@@ -532,26 +561,39 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,<br>
       float half_a_line = 0.5f / s->layers[layer].zw.y;<br>
       switch(deinterlace) {<br>
       case VL_COMPOSITOR_WEAVE:<br>
-         s->layers[layer].fs = c->fs_weave_rgb;<br>
+         if (c->pipe_compute_supported)<br>
+            s->layers[layer].cs = c->cs_weave_rgb;<br>
+         else<br>
+            s->layers[layer].fs = c->fs_weave_rgb;<br>
          break;<br>
<br>
       case VL_COMPOSITOR_BOB_TOP:<br>
          s->layers[layer].zw.x = 0.0f;<br>
          s->layers[layer].src.tl.y += half_a_line;<br>
          s->layers[layer].src.br.y += half_a_line;<br>
-         s->layers[layer].fs = c->fs_video_buffer;<br>
+         if (c->pipe_compute_supported)<br>
+            s->layers[layer].cs = c->cs_video_buffer;<br>
+         else<br>
+            s->layers[layer].fs = c->fs_video_buffer;<br>
          break;<br>
<br>
       case VL_COMPOSITOR_BOB_BOTTOM:<br>
          s->layers[layer].zw.x = 1.0f;<br>
          s->layers[layer].src.tl.y -= half_a_line;<br>
          s->layers[layer].src.br.y -= half_a_line;<br>
-         s->layers[layer].fs = c->fs_video_buffer;<br>
+         if (c->pipe_compute_supported)<br>
+            s->layers[layer].cs = c->cs_video_buffer;<br>
+         else<br>
+            s->layers[layer].fs = c->fs_video_buffer;<br>
          break;<br>
       }<br>
<br>
-   } else<br>
-      s->layers[layer].fs = c->fs_video_buffer;<br>
+   } else {<br>
+      if (c->pipe_compute_supported)<br>
+         s->layers[layer].cs = c->cs_video_buffer;<br>
+      else<br>
+         s->layers[layer].fs = c->fs_video_buffer;<br>
+   }<br>
 }<br>
<br>
 void<br>
@@ -600,7 +642,10 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s,<br>
    assert(layer < VL_COMPOSITOR_MAX_LAYERS);<br>
<br>
    s->used_layers |= 1 << layer;<br>
-   s->layers[layer].fs = c->fs_rgba;<br>
+   if (c->pipe_compute_supported)<br>
+      s->layers[layer].cs = c->cs_rgba;<br>
+   else<br>
+      s->layers[layer].fs = c->fs_rgba;<br>
    s->layers[layer].samplers[0] = c->sampler_linear;<br>
    s->layers[layer].samplers[1] = NULL;<br>
    s->layers[layer].samplers[2] = NULL;<br>
@@ -701,7 +746,11 @@ vl_compositor_render(struct vl_compositor_state *s,<br>
                      bool                        clear_dirty)<br>
 {<br>
    assert(s);<br>
-   vl_compositor_gfx_render(s, c, dst_surface, dirty_area, clear_dirty);<br>
+<br>
+   if (s->layers->cs)<br>
+      vl_compositor_cs_render(s, c, dst_surface, dirty_area, clear_dirty);<br>
+   else<br>
+      vl_compositor_gfx_render(s, c, dst_surface, dirty_area, clear_dirty);<br>
 }<br>
<br>
 bool<br>
@@ -711,6 +760,7 @@ vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe)<br>
<br>
    memset(c, 0, sizeof(*c));<br>
<br>
+   c->pipe_compute_supported = pipe->screen->get_param(pipe->screen, PIPE_CAP_COMPUTE);<br>
    c->pipe = pipe;<br>
<br>
    if (!init_pipe_state(c)) {<br>
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h<br>
index 5fa1b6c..d426188 100644<br>
--- a/src/gallium/auxiliary/vl/vl_compositor.h<br>
+++ b/src/gallium/auxiliary/vl/vl_compositor.h<br>
@@ -117,6 +117,11 @@ struct vl_compositor<br>
    void *fs_video_buffer;<br>
    void *fs_weave_rgb;<br>
    void *fs_rgba;<br>
+   void *cs_video_buffer;<br>
+   void *cs_weave_rgb;<br>
+   void *cs_rgba;<br>
+<br>
+   bool pipe_compute_supported;<br>
<br>
    struct {<br>
       struct {<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank" rel="noreferrer" moz-do-not-send="true">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer noreferrer" target="_blank" moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote>
</div>
</blockquote>
</body>
</html>