[PATCH] etnaviv: Don't flush on transfer when UNSYNCHRONIZED

Lucas Stach l.stach at pengutronix.de
Mon Oct 30 13:18:44 UTC 2017


Am Samstag, den 28.10.2017, 16:01 +0200 schrieb Wladimir J. van der Laan:
> Structure code to only flush when we will potentially call cpu_prep. This
> prevents spurious flushes in applications that heavily rely on u_uploader.
> 
> > Signed-off-by: Wladimir J. van der Laan <laanwj at gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_transfer.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> I'm not 100% sure about this, but if this isn't correct please explain to me what
> use is a flush if we don't synchronize.

This change is fine as-is. Flushes are only necessary for GPU/CPU sync and to actually
fill temporary resources with data, the latter case is handled by the trans->rsc part
of the condition.

Reviewed-by: Lucas Stach <l.stach at pengutronix.de>

> diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> index 08ec198..c389920 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c
> @@ -243,18 +243,6 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc,
>  
>     struct etna_resource_level *res_level = &rsc->levels[level];
>  
> -   /*
> -    * Always flush if we have the temporary resource and have a copy to this
> -    * outstanding. Otherwise infer flush requirement from resource access and
> -    * current GPU usage (reads must wait for GPU writes, writes must have
> -    * exclusive access to the buffer).
> -    */
> -   if ((trans->rsc && (etna_resource(trans->rsc)->status & ETNA_PENDING_WRITE)) ||
> -       (!trans->rsc &&
> -        (((usage & PIPE_TRANSFER_READ) && (rsc->status & ETNA_PENDING_WRITE)) ||
> -        ((usage & PIPE_TRANSFER_WRITE) && rsc->status))))
> -      pctx->flush(pctx, NULL, 0);
> -
>     /* XXX we don't handle PIPE_TRANSFER_FLUSH_EXPLICIT; this flag can be ignored
>      * when mapping in-place,
>      * but when not in place we need to fire off the copy operation in
> @@ -312,6 +300,18 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc,
>     if (trans->rsc || !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
>        uint32_t prep_flags = 0;
>  
> +      /*
> +       * Always flush if we have the temporary resource and have a copy to this
> +       * outstanding. Otherwise infer flush requirement from resource access and
> +       * current GPU usage (reads must wait for GPU writes, writes must have
> +       * exclusive access to the buffer).
> +       */
> +      if ((trans->rsc && (etna_resource(trans->rsc)->status & ETNA_PENDING_WRITE)) ||
> +          (!trans->rsc &&
> +           (((usage & PIPE_TRANSFER_READ) && (rsc->status & ETNA_PENDING_WRITE)) ||
> +           ((usage & PIPE_TRANSFER_WRITE) && rsc->status))))
> +         pctx->flush(pctx, NULL, 0);
> +
>        if (usage & PIPE_TRANSFER_READ)
>           prep_flags |= DRM_ETNA_PREP_READ;
>        if (usage & PIPE_TRANSFER_WRITE)


More information about the etnaviv mailing list