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

Submitted by Zhu, James on Feb. 7, 2019, 4:37 p.m.

Details

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

Not browsing as part of any series.

Commit Message

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

Signed-off-by: James Zhu <James.Zhu@amd.com>

Reviewed-by: Christian König <christian.koenig@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(-)

-- 
2.7.4

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 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 {

Comments

On Thu, 7 Feb 2019 at 16:37, Zhu, James <James.Zhu@amd.com> wrote:
>
> Add compute shader initilization, assign and cleanup in vl_compositor API.
>
> Signed-off-by: James Zhu <James.Zhu@amd.com>
> Reviewed-by: Christian König <christian.koenig@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;
> +   }
> +
This constructs compute shaders even when we don't need them.
Can we have this behind a flag - say cs_compositor_render_enable or
something else?

-Emil
On 2019-02-08 6:33 a.m., Emil Velikov wrote:
> On Thu, 7 Feb 2019 at 16:37, Zhu, James <James.Zhu@amd.com> wrote:

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

>>

>> Signed-off-by: James Zhu <James.Zhu@amd.com>

>> Reviewed-by: Christian König <christian.koenig@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;

>> +   }

>> +

> This constructs compute shaders even when we don't need them.

> Can we have this behind a flag - say cs_compositor_render_enable or

> something else?


Yeah, I can add PIPE_CAP_COMPUTE check.

James

>

> -Emil
If compute is used, graphics shaders don't need to be created.

Marek

On Fri, Feb 8, 2019 at 9:02 AM James Zhu <jamesz@amd.com> wrote:

>
> On 2019-02-08 6:33 a.m., Emil Velikov wrote:
> > On Thu, 7 Feb 2019 at 16:37, Zhu, James <James.Zhu@amd.com> wrote:
> >> Add compute shader initilization, assign and cleanup in vl_compositor
> API.
> >>
> >> Signed-off-by: James Zhu <James.Zhu@amd.com>
> >> Reviewed-by: Christian König <christian.koenig@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;
> >> +   }
> >> +
> > This constructs compute shaders even when we don't need them.
> > Can we have this behind a flag - say cs_compositor_render_enable or
> > something else?
>
> Yeah, I can add PIPE_CAP_COMPUTE check.
>
> James
>
> >
> > -Emil
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
I combined patch5 and 6 into one patch. create compute shader only when pipe support it.

James.

On 2019-02-08 12:29 p.m., Marek Olšák wrote:
If compute is used, graphics shaders don't need to be created.

Marek

On Fri, Feb 8, 2019 at 9:02 AM James Zhu <jamesz@amd.com<mailto:jamesz@amd.com>> wrote:

On 2019-02-08 6:33 a.m., Emil Velikov wrote:
> On Thu, 7 Feb 2019 at 16:37, Zhu, James <James.Zhu@amd.com<mailto:James.Zhu@amd.com>> wrote:

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

>>

>> Signed-off-by: James Zhu <James.Zhu@amd.com<mailto:James.Zhu@amd.com>>

>> Reviewed-by: Christian König <christian.koenig@amd.com<mailto:christian.koenig@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;

>> +   }

>> +

> This constructs compute shaders even when we don't need them.

> Can we have this behind a flag - say cs_compositor_render_enable or

> something else?


Yeah, I can add PIPE_CAP_COMPUTE check.

James

>

> -Emil

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org<mailto:mesa-dev@lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
On Fri, Feb 8, 2019, 2:09 PM James Zhu <jamesz@amd.com wrote:

> I combined patch5 and 6 into one patch. create compute shader only when
> pipe support it.
>
That's fine. I only requested additional changes.

Marek

James.
> On 2019-02-08 12:29 p.m., Marek Olšák wrote:
>
> If compute is used, graphics shaders don't need to be created.
>
> Marek
>
> On Fri, Feb 8, 2019 at 9:02 AM James Zhu <jamesz@amd.com> wrote:
>
>>
>> On 2019-02-08 6:33 a.m., Emil Velikov wrote:
>> > On Thu, 7 Feb 2019 at 16:37, Zhu, James <James.Zhu@amd.com> wrote:
>> >> Add compute shader initilization, assign and cleanup in vl_compositor
>> API.
>> >>
>> >> Signed-off-by: James Zhu <James.Zhu@amd.com>
>> >> Reviewed-by: Christian König <christian.koenig@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;
>> >> +   }
>> >> +
>> > This constructs compute shaders even when we don't need them.
>> > Can we have this behind a flag - say cs_compositor_render_enable or
>> > something else?
>>
>> Yeah, I can add PIPE_CAP_COMPUTE check.
>>
>> James
>>
>> >
>> > -Emil
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>