[Mesa-dev] [PATCH] radeonsi: add basic glClearBufferSubData acceleration
Ilia Mirkin
imirkin at alum.mit.edu
Wed Nov 4 12:01:53 PST 2015
On Wed, Nov 4, 2015 at 4:08 AM, Marek Olšák <maraeo at gmail.com> wrote:
> On Nov 4, 2015 4:02 AM, "Alex Deucher" <alexdeucher at gmail.com> wrote:
>>
>> On Tue, Nov 3, 2015 at 6:47 PM, Marek Olšák <maraeo at gmail.com> wrote:
>> > From: Marek Olšák <marek.olsak at amd.com>
>> >
>> > ---
>> > src/gallium/drivers/radeonsi/si_blit.c | 55
>> > ++++++++++++++++++++++++++++++++++
>> > 1 file changed, 55 insertions(+)
>> >
>> > diff --git a/src/gallium/drivers/radeonsi/si_blit.c
>> > b/src/gallium/drivers/radeonsi/si_blit.c
>> > index fce014a..e934146 100644
>> > --- a/src/gallium/drivers/radeonsi/si_blit.c
>> > +++ b/src/gallium/drivers/radeonsi/si_blit.c
>> > @@ -731,9 +731,64 @@ static void si_flush_resource(struct pipe_context
>> > *ctx,
>> > }
>> > }
>> >
>> > +static void si_pipe_clear_buffer(struct pipe_context *ctx,
>> > + struct pipe_resource *dst,
>> > + unsigned offset, unsigned size,
>> > + const void *clear_value,
>> > + int clear_value_size)
>> > +{
>> > + struct si_context *sctx = (struct si_context*)ctx;
>> > + const uint32_t *u32 = clear_value;
>> > + unsigned i;
>> > + bool clear_value_fits_dword = true;
>> > + uint8_t *map;
>> > +
>> > + if (clear_value_size > 4)
>> > + for (i = 1; i < clear_value_size / 4; i++)
>> > + if (u32[0] != u32[i]) {
>> > + clear_value_fits_dword = false;
>> > + break;
>> > + }
>> > +
>> > + /* Use CP DMA for the simple case. */
>> > + if (offset % 4 == 0 && size % 4 == 0 && clear_value_fits_dword)
>> > {
>> > + uint32_t value = u32[0];
>> > +
>> > + switch (clear_value_size) {
>> > + case 1:
>> > + value &= 0xff;
>> > + value |= (value << 8) | (value << 16) | (value
>> > << 24);
>> > + break;
>> > + case 2:
>> > + value &= 0xffff;
>> > + value |= value << 16;
>> > + break;
>> > + }
>> > +
>> > + sctx->b.clear_buffer(ctx, dst, offset, size, value,
>> > false);
>> > + return;
>> > + }
>> > +
>> > + /* TODO: use a compute shader for other cases. */
>>
>> What about using SDMA? It supports byte aligned constant fills at
>> least on CIK+.
>
> 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.
Just to briefly interject, don't forget abotu 96-bit fills for
tbo_rgb32 buffers. I assume this won't really matter if you're using a
shader.
Cheers,
-ilia
More information about the mesa-dev
mailing list