[Mesa-dev] [PATCH 03/13] winsys/amdgpu: add support for const IB

Marek Olšák maraeo at gmail.com
Fri Apr 15 18:36:08 UTC 2016


On Thu, Apr 14, 2016 at 3:34 AM, Bas Nieuwenhuizen
<bas at basnieuwenhuizen.nl> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> v2: use the correct IB to update request (Bas Nieuwenhuizen)
> ---
>  src/gallium/drivers/radeon/radeon_winsys.h | 18 +++++++++++
>  src/gallium/winsys/amdgpu/drm/amdgpu_cs.c  | 48 +++++++++++++++++++++++++++---
>  src/gallium/winsys/amdgpu/drm/amdgpu_cs.h  |  9 +++++-
>  3 files changed, 70 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h
> index aa94df6..04ce2fb 100644
> --- a/src/gallium/drivers/radeon/radeon_winsys.h
> +++ b/src/gallium/drivers/radeon/radeon_winsys.h
> @@ -603,6 +603,24 @@ struct radeon_winsys {
>                                            void *flush_ctx);
>
>      /**
> +     * Add a constant engine IB to a graphics CS. This makes the graphics CS
> +     * from "cs_create" a group of two IBs that share a buffer list and are
> +     * flushed together.
> +     *
> +     * The returned constant CS is only a stream for writing packets to the new
> +     * IB. Calling other winsys functions with it is not allowed, not even
> +     * "cs_destroy".
> +     *
> +     * In order to add buffers and check memory usage, use the graphics CS.
> +     * In order to flush it, use the graphics CS, which will flush both IBs.
> +     * Destroying the graphics CS will destroy both of them.
> +     *
> +     * \param cs  The graphics CS from "cs_create" that will hold the buffer
> +     *            list and will be used for flushing.
> +     */
> +    struct radeon_winsys_cs *(*cs_add_const_ib)(struct radeon_winsys_cs *cs);
> +
> +    /**
>       * Destroy a command stream.
>       *
>       * \param cs        A command stream to destroy.
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> index b0fe8b9..b0c80c6 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> @@ -350,19 +350,39 @@ amdgpu_cs_create(struct radeon_winsys_ctx *rwctx,
>        return NULL;
>     }
>
> -   if (!amdgpu_get_new_ib(&ctx->ws->base, &cs->main, &cs->ib)) {
> +   if (!amdgpu_get_new_ib(&ctx->ws->base, &cs->main, &cs->ib[IB_MAIN])) {
>        amdgpu_destroy_cs_context(cs);
>        FREE(cs);
>        return NULL;
>     }
>
>     cs->request.number_of_ibs = 1;
> -   cs->request.ibs = &cs->ib;
> +   cs->request.ibs = &cs->ib[IB_MAIN];
>
>     p_atomic_inc(&ctx->ws->num_cs);
>     return &cs->main.base;
>  }
>
> +static struct radeon_winsys_cs *
> +amdgpu_cs_add_const_ib(struct radeon_winsys_cs *rcs)
> +{
> +   struct amdgpu_cs *cs = (struct amdgpu_cs*)rcs;
> +   struct amdgpu_winsys *ws = cs->ctx->ws;
> +
> +   /* only one const IB can be added */
> +   if (cs->ring_type != RING_GFX || cs->const_ib.ib_mapped)
> +      return NULL;
> +
> +   if (!amdgpu_get_new_ib(&ws->base, &cs->const_ib, &cs->ib[IB_CONST]))
> +      return NULL;
> +
> +   cs->request.number_of_ibs = 2;
> +   cs->request.ibs = &cs->ib[IB_CONST];
> +   cs->ib[IB_CONST].flags = AMDGPU_IB_FLAG_CE;
> +
> +   return &cs->const_ib.base;
> +}
> +
>  #define OUT_CS(cs, value) (cs)->buf[(cs)->cdw++] = (value)
>
>  int amdgpu_lookup_buffer(struct amdgpu_cs *cs, struct amdgpu_winsys_bo *bo)
> @@ -621,6 +641,12 @@ static void amdgpu_cs_flush(struct radeon_winsys_cs *rcs,
>        /* pad GFX ring to 8 DWs to meet CP fetch alignment requirements */
>        while (rcs->cdw & 7)
>           OUT_CS(rcs, 0xffff1000); /* type3 nop packet */
> +
> +      /* Also pad the const IB. */
> +      /* TODO: is this the correct packet for the const IB? */

This TODO can be removed.

Marek


More information about the mesa-dev mailing list