[Mesa-dev] [PATCH] nv50,nvc0: fix clear buffer acceleration

Karol Herbst kherbst at redhat.com
Thu Feb 22 13:05:40 UTC 2018


Tested-by: Karol Herbst <kherbst at redhat.com>

On Wed, Feb 21, 2018 at 5:20 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Two things were off:
>  - valid range was not updated, which could affect waiting for future
>    maps
>  - fencing was done manually instead of using the *_resource_validate
>    helper, which resulted in a missed dirty buffer flag being set
>
> Fixes: KHR-GL45.direct_state_access.buffers_clear
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>
> Untested on pre-kepler paths. Pretty similar overall.
>
>  src/gallium/drivers/nouveau/nv50/nv50_surface.c | 20 ++++++++------------
>  src/gallium/drivers/nouveau/nvc0/nvc0_surface.c | 25 +++++++++----------------
>  2 files changed, 17 insertions(+), 28 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c
> index 908c534b92e..037e14a4d60 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c
> @@ -672,10 +672,7 @@ nv50_clear_buffer_push(struct pipe_context *pipe,
>        count -= nr;
>     }
>
> -   if (buf->mm) {
> -      nouveau_fence_ref(nv50->screen->base.fence.current, &buf->fence);
> -      nouveau_fence_ref(nv50->screen->base.fence.current, &buf->fence_wr);
> -   }
> +   nv50_resource_validate(buf, NOUVEAU_BO_WR);
>
>     nouveau_bufctx_reset(nv50->bufctx, 0);
>  }
> @@ -727,6 +724,8 @@ nv50_clear_buffer(struct pipe_context *pipe,
>        return;
>     }
>
> +   util_range_add(&buf->valid_buffer_range, offset, offset + size);
> +
>     assert(size % data_size == 0);
>
>     if (offset & 0xff) {
> @@ -747,10 +746,10 @@ nv50_clear_buffer(struct pipe_context *pipe,
>     assert(width > 0);
>
>     BEGIN_NV04(push, NV50_3D(CLEAR_COLOR(0)), 4);
> -   PUSH_DATAf(push, color.f[0]);
> -   PUSH_DATAf(push, color.f[1]);
> -   PUSH_DATAf(push, color.f[2]);
> -   PUSH_DATAf(push, color.f[3]);
> +   PUSH_DATA (push, color.ui[0]);
> +   PUSH_DATA (push, color.ui[1]);
> +   PUSH_DATA (push, color.ui[2]);
> +   PUSH_DATA (push, color.ui[3]);
>
>     if (nouveau_pushbuf_space(push, 64, 1, 0))
>        return;
> @@ -796,10 +795,7 @@ nv50_clear_buffer(struct pipe_context *pipe,
>     BEGIN_NV04(push, NV50_3D(COND_MODE), 1);
>     PUSH_DATA (push, nv50->cond_condmode);
>
> -   if (buf->mm) {
> -      nouveau_fence_ref(nv50->screen->base.fence.current, &buf->fence);
> -      nouveau_fence_ref(nv50->screen->base.fence.current, &buf->fence_wr);
> -   }
> +   nv50_resource_validate(buf, NOUVEAU_BO_WR);
>
>     if (width * height != elements) {
>        offset += width * height * data_size;
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
> index 9445c05f3ab..0f86c11b7f4 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c
> @@ -403,10 +403,7 @@ nvc0_clear_buffer_push_nvc0(struct pipe_context *pipe,
>        size -= nr * 4;
>     }
>
> -   if (buf->mm) {
> -      nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence);
> -      nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence_wr);
> -   }
> +   nvc0_resource_validate(buf, NOUVEAU_BO_WR);
>
>     nouveau_bufctx_reset(nvc0->bufctx, 0);
>  }
> @@ -453,10 +450,7 @@ nvc0_clear_buffer_push_nve4(struct pipe_context *pipe,
>        size -= nr * 4;
>     }
>
> -   if (buf->mm) {
> -      nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence);
> -      nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence_wr);
> -   }
> +   nvc0_resource_validate(buf, NOUVEAU_BO_WR);
>
>     nouveau_bufctx_reset(nvc0->bufctx, 0);
>  }
> @@ -540,6 +534,8 @@ nvc0_clear_buffer(struct pipe_context *pipe,
>        return;
>     }
>
> +   util_range_add(&buf->valid_buffer_range, offset, offset + size);
> +
>     assert(size % data_size == 0);
>
>     if (data_size == 12) {
> @@ -570,10 +566,10 @@ nvc0_clear_buffer(struct pipe_context *pipe,
>     PUSH_REFN (push, buf->bo, buf->domain | NOUVEAU_BO_WR);
>
>     BEGIN_NVC0(push, NVC0_3D(CLEAR_COLOR(0)), 4);
> -   PUSH_DATAf(push, color.f[0]);
> -   PUSH_DATAf(push, color.f[1]);
> -   PUSH_DATAf(push, color.f[2]);
> -   PUSH_DATAf(push, color.f[3]);
> +   PUSH_DATA (push, color.ui[0]);
> +   PUSH_DATA (push, color.ui[1]);
> +   PUSH_DATA (push, color.ui[2]);
> +   PUSH_DATA (push, color.ui[3]);
>     BEGIN_NVC0(push, NVC0_3D(SCREEN_SCISSOR_HORIZ), 2);
>     PUSH_DATA (push, width << 16);
>     PUSH_DATA (push, height << 16);
> @@ -600,10 +596,7 @@ nvc0_clear_buffer(struct pipe_context *pipe,
>
>     IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode);
>
> -   if (buf->mm) {
> -      nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence);
> -      nouveau_fence_ref(nvc0->screen->base.fence.current, &buf->fence_wr);
> -   }
> +   nvc0_resource_validate(buf, NOUVEAU_BO_WR);
>
>     if (width * height != elements) {
>        offset += width * height * data_size;
> --
> 2.16.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list