[Mesa-dev] [PATCH 1/2] gallium: add PIPE_FLUSH_DEFERRED

Rob Clark robdclark at gmail.com
Mon Jul 18 12:25:09 UTC 2016


On Mon, Jul 18, 2016 at 8:16 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> There are 2 uses:
> - Asynchronous flushing for multithreaded drivers.
> - Return a fence without flushing (mid-command-buffer fence). The driver
>   can defer flushing until fence_finish is called.

This should also be useful to me when I get a chance to rebase the
gallium bits of the egl fence-fd patchset.  I guess the one question
is what the behaviour is in screen->fence_finish().  I think I have a
solution for that in freedreno (if I end up going the
flush-from-u_queue route, since I'd end up with enough locking to
flush without a ctx), although maybe that isn't the most general
solution for other drivers.  I wonder if we should add an optional
pipe_context ptr to fence_finish() for the cases when there is a
context bound?

Either way, I guess we need a bit more documentation about that.  With
that resolved, r-b

> This is required to make Bioshock Infinite faster, which creates
> 1000 fences (flushes) per frame.

*ouch*

BR,
-R

> ---
>  src/gallium/docs/source/context.rst    | 5 +++++
>  src/gallium/include/pipe/p_defines.h   | 3 ++-
>  src/mesa/state_tracker/st_cb_syncobj.c | 2 +-
>  3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
> index 05c6f11..2f803ac 100644
> --- a/src/gallium/docs/source/context.rst
> +++ b/src/gallium/docs/source/context.rst
> @@ -463,6 +463,11 @@ Flushing
>
>  ``flush``
>
> +PIPE_FLUSH_END_OF_FRAME: Whether the flush marks the end of frame.
> +PIPE_FLUSH_DEFERRED: It is not required to flush right away, but it is required
> +to return a valid fence.
> +
> +
>
>  ``flush_resource``
>
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index 62fa673..a2f5193 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -348,7 +348,8 @@ enum pipe_transfer_usage
>   */
>  enum pipe_flush_flags
>  {
> -   PIPE_FLUSH_END_OF_FRAME = (1 << 0)
> +   PIPE_FLUSH_END_OF_FRAME = (1 << 0),
> +   PIPE_FLUSH_DEFERRED = (1 << 1),
>  };
>
>  /**
> diff --git a/src/mesa/state_tracker/st_cb_syncobj.c b/src/mesa/state_tracker/st_cb_syncobj.c
> index ec2687f..69f2a28 100644
> --- a/src/mesa/state_tracker/st_cb_syncobj.c
> +++ b/src/mesa/state_tracker/st_cb_syncobj.c
> @@ -73,7 +73,7 @@ static void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj,
>     assert(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0);
>     assert(so->fence == NULL);
>
> -   pipe->flush(pipe, &so->fence, 0);
> +   pipe->flush(pipe, &so->fence, PIPE_FLUSH_DEFERRED);
>  }
>
>  static void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj)
> --
> 2.7.4
>
> _______________________________________________
> 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