<p dir="ltr">On Nov 4, 2015 4:02 AM, "Alex Deucher" <<a href="mailto:alexdeucher@gmail.com">alexdeucher@gmail.com</a>> wrote:<br>
><br>
> On Tue, Nov 3, 2015 at 6:47 PM, Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br>
> > From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
> ><br>
> > ---<br>
> > src/gallium/drivers/radeonsi/si_blit.c | 55 ++++++++++++++++++++++++++++++++++<br>
> > 1 file changed, 55 insertions(+)<br>
> ><br>
> > diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c<br>
> > index fce014a..e934146 100644<br>
> > --- a/src/gallium/drivers/radeonsi/si_blit.c<br>
> > +++ b/src/gallium/drivers/radeonsi/si_blit.c<br>
> > @@ -731,9 +731,64 @@ static void si_flush_resource(struct pipe_context *ctx,<br>
> > }<br>
> > }<br>
> ><br>
> > +static void si_pipe_clear_buffer(struct pipe_context *ctx,<br>
> > + struct pipe_resource *dst,<br>
> > + unsigned offset, unsigned size,<br>
> > + const void *clear_value,<br>
> > + int clear_value_size)<br>
> > +{<br>
> > + struct si_context *sctx = (struct si_context*)ctx;<br>
> > + const uint32_t *u32 = clear_value;<br>
> > + unsigned i;<br>
> > + bool clear_value_fits_dword = true;<br>
> > + uint8_t *map;<br>
> > +<br>
> > + if (clear_value_size > 4)<br>
> > + for (i = 1; i < clear_value_size / 4; i++)<br>
> > + if (u32[0] != u32[i]) {<br>
> > + clear_value_fits_dword = false;<br>
> > + break;<br>
> > + }<br>
> > +<br>
> > + /* Use CP DMA for the simple case. */<br>
> > + if (offset % 4 == 0 && size % 4 == 0 && clear_value_fits_dword) {<br>
> > + uint32_t value = u32[0];<br>
> > +<br>
> > + switch (clear_value_size) {<br>
> > + case 1:<br>
> > + value &= 0xff;<br>
> > + value |= (value << 8) | (value << 16) | (value << 24);<br>
> > + break;<br>
> > + case 2:<br>
> > + value &= 0xffff;<br>
> > + value |= value << 16;<br>
> > + break;<br>
> > + }<br>
> > +<br>
> > + sctx->b.clear_buffer(ctx, dst, offset, size, value, false);<br>
> > + return;<br>
> > + }<br>
> > +<br>
> > + /* TODO: use a compute shader for other cases. */<br>
><br>
> What about using SDMA? It supports byte aligned constant fills at<br>
> least on CIK+.</p>
<p dir="ltr">I think CP DMA supports byte aligned constant fills as well, I just need to test it. The bigger problem is 64 and 128 bit fills. Those can only be done with a shader AFAIK.</p>
<p dir="ltr">><br>
><br>
> > +<br>
> > + /* Software fallback. */<br>
> > + map = r600_buffer_map_sync_with_rings(&sctx->b, r600_resource(dst),<br>
> > + PIPE_TRANSFER_WRITE);<br>
> > + if (!map)<br>
> > + return;<br>
> > +<br>
> > + map += offset;<br>
> > + size /= clear_value_size;<br>
> > + for (i = 0; i < size; i++) {<br>
> > + memcpy(map, clear_value, clear_value_size);<br>
> > + map += clear_value_size;<br>
> > + }<br>
> > +}<br>
> > +<br>
> > void si_init_blit_functions(struct si_context *sctx)<br>
> > {<br>
> > sctx->b.b.clear = si_clear;<br>
> > + sctx->b.b.clear_buffer = si_pipe_clear_buffer;<br>
> > sctx->b.b.clear_render_target = si_clear_render_target;<br>
> > sctx->b.b.clear_depth_stencil = si_clear_depth_stencil;<br>
> > sctx->b.b.resource_copy_region = si_resource_copy_region;<br>
> > --<br>
> > 2.1.4<br>
> ><br>
> > _______________________________________________<br>
> > mesa-dev mailing list<br>
> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>