[Mesa-dev] [RFC] gallium/u_queue: add barrier function

Nicolai Hähnle nhaehnle at gmail.com
Mon Jul 18 20:34:28 UTC 2016


On 18.07.2016 22:25, Rob Clark wrote:
> Helper to block until all previous jobs are complete.
> ---
> So I think this might end up being useful to me in some cases.. but
> the implementation only works for a single threaded queue (which is
> all I need).  I could also just put a helper in my driver code.
>
> Opinions?

What do you need it for? ISTR Marek had a half-finished patch for 
dependencies, maybe that does what you need and is more expressive?

Cheers,
Nicolai

>
>   src/gallium/auxiliary/util/u_queue.c | 12 ++++++++++++
>   src/gallium/auxiliary/util/u_queue.h |  2 ++
>   2 files changed, 14 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
> index 838464f..861faca 100644
> --- a/src/gallium/auxiliary/util/u_queue.c
> +++ b/src/gallium/auxiliary/util/u_queue.c
> @@ -242,3 +242,15 @@ util_queue_add_job(struct util_queue *queue,
>      pipe_condvar_signal(queue->has_queued_cond);
>      pipe_mutex_unlock(queue->lock);
>   }
> +
> +static void dummy_execute(void *job, int thread_index) {}
> +
> +/* blocks until all previously queued jobs complete: */
> +void util_queue_barrier(struct util_queue *queue)
> +{
> +   struct util_queue_fence fence;
> +   util_queue_fence_init(&fence);
> +   util_queue_add_job(queue, &fence /*dummy*/, &fence, dummy_execute, NULL);
> +   util_queue_job_wait(&fence);
> +   util_queue_fence_destroy(&fence);
> +}
> diff --git a/src/gallium/auxiliary/util/u_queue.h b/src/gallium/auxiliary/util/u_queue.h
> index 59646cc..8a22ee0 100644
> --- a/src/gallium/auxiliary/util/u_queue.h
> +++ b/src/gallium/auxiliary/util/u_queue.h
> @@ -85,6 +85,8 @@ void util_queue_add_job(struct util_queue *queue,
>
>   void util_queue_job_wait(struct util_queue_fence *fence);
>
> +void util_queue_barrier(struct util_queue *queue);
> +
>   /* util_queue needs to be cleared to zeroes for this to work */
>   static inline bool
>   util_queue_is_initialized(struct util_queue *queue)
>


More information about the mesa-dev mailing list