[Mesa-dev] [PATCH] gallium/u_threaded: replace pipe_resource_reference with atomic_inc
Timothy Arceri
tarceri at itsqueeze.com
Tue Jun 13 01:53:39 UTC 2017
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
On 13/06/17 02:31, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/auxiliary/util/u_threaded_context.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
> index 3038fc6..a97f016 100644
> --- a/src/gallium/auxiliary/util/u_threaded_context.c
> +++ b/src/gallium/auxiliary/util/u_threaded_context.c
> @@ -195,22 +195,27 @@ _tc_sync(struct threaded_context *tc, const char *info, const char *func)
>
> tc_debug_check(tc);
> }
>
> #define tc_sync(tc) _tc_sync(tc, "", __func__)
> #define tc_sync_msg(tc, info) _tc_sync(tc, info, __func__)
>
> static void
> tc_set_resource_reference(struct pipe_resource **dst, struct pipe_resource *src)
> {
> - *dst = NULL;
> - pipe_resource_reference(dst, src);
> + /* Unexpectedly, pipe_resource_reference is a bottleneck here, taking 3.7%
> + * of CPU time in a state-heavy microbenchmark. The problem here is that
> + * pipe_resource_reference isn't inlined here.
> + */
> + *dst = src;
> + if (src)
> + p_atomic_inc(&src->reference.count);
> }
>
> void
> threaded_resource_init(struct pipe_resource *res)
> {
> struct threaded_resource *tres = threaded_resource(res);
>
> tres->latest = &tres->b;
> util_range_init(&tres->valid_buffer_range);
> tres->base_valid_buffer_range = &tres->valid_buffer_range;
>
More information about the mesa-dev
mailing list