<div dir="ltr"><div dir="ltr"><div>Instead of querying PIPE_CAP_COMPUTE multiple times, you can save the returned value at initialization once and use that.</div><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 8, 2019 at 2:22 PM Zhu, James <<a href="mailto:James.Zhu@amd.com">James.Zhu@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);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">James.Zhu@amd.com</a>><br>
Reviewed-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
---<br>
src/gallium/auxiliary/vl/vl_compositor.c | 105 ++++++++++++++++++++++---------<br>
src/gallium/auxiliary/vl/vl_compositor.h | 3 +<br>
2 files changed, 80 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..2d624c8 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></blockquote><div><br></div><div>If compute is used, I wouldn't like any graphics shaders to be created.</div><div><br></div><div>Marek<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
@@ -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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE)) {<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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE)) {<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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE))<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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE))<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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE))<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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE))<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->screen->get_param(c->pipe->screen, PIPE_CAP_COMPUTE))<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>
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h<br>
index 5fa1b6c..b0ed7f5 100644<br>
--- a/src/gallium/auxiliary/vl/vl_compositor.h<br>
+++ b/src/gallium/auxiliary/vl/vl_compositor.h<br>
@@ -117,6 +117,9 @@ 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>
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">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>