From e6a0f243ea1435e7435e78441184903e84fdcbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 11 Feb 2021 15:00:01 -0500 Subject: [PATCH] radeonsi: update pipe_screen::num_contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows skipping mutex locking. Don't take the aux context into account. Reviewed-by: Zoltán Böszörményi Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_pipe.c | 19 ++++++++++++++----- src/gallium/drivers/radeonsi/si_pipe.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index f802e6739d9..86536aac305 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -330,6 +330,10 @@ static void si_destroy_context(struct pipe_context *context) util_dynarray_fini(&sctx->resident_tex_needs_color_decompress); util_dynarray_fini(&sctx->resident_img_needs_color_decompress); util_dynarray_fini(&sctx->resident_tex_needs_depth_decompress); + + if (!(sctx->context_flags & SI_CONTEXT_FLAG_AUX)) + p_atomic_dec(&context->screen->num_contexts); + FREE(sctx); } @@ -466,6 +470,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign sctx->b.destroy = si_destroy_context; sctx->screen = sscreen; /* Easy accessing of screen/winsys. */ sctx->is_debug = (flags & PIPE_CONTEXT_DEBUG) != 0; + sctx->context_flags = flags; slab_create_child(&sctx->pool_transfers, &sscreen->pool_transfers); slab_create_child(&sctx->pool_transfers_unsync, &sscreen->pool_transfers); @@ -603,9 +608,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign si_init_draw_functions(sctx); - /* If aux_context == NULL, we are initializing aux_context right now. */ - bool is_aux_context = !sscreen->aux_context; - si_initialize_prim_discard_tunables(sscreen, is_aux_context, + si_initialize_prim_discard_tunables(sscreen, flags & SI_CONTEXT_FLAG_AUX, &sctx->prim_discard_vertex_count_threshold, &sctx->index_ring_size_per_ib); } else { @@ -736,6 +739,9 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign &clear_value, 4, SI_COHERENCY_SHADER, SI_CP_DMA_CLEAR_METHOD); } + if (!(flags & SI_CONTEXT_FLAG_AUX)) + p_atomic_inc(&screen->num_contexts); + sctx->initial_gfx_cs_size = sctx->gfx_cs.current.cdw; return &sctx->b; fail: @@ -1320,8 +1326,11 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws, /* Create the auxiliary context. This must be done last. */ sscreen->aux_context = si_create_context( - &sscreen->b, (sscreen->options.aux_debug ? PIPE_CONTEXT_DEBUG : 0) | - (sscreen->info.has_graphics ? 0 : PIPE_CONTEXT_COMPUTE_ONLY)); + &sscreen->b, + SI_CONTEXT_FLAG_AUX | + (sscreen->options.aux_debug ? PIPE_CONTEXT_DEBUG : 0) | + (sscreen->info.has_graphics ? 0 : PIPE_CONTEXT_COMPUTE_ONLY)); + if (sscreen->options.aux_debug) { struct u_log_context *log = CALLOC_STRUCT(u_log_context); u_log_context_init(log); diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index bc9afd30dae..483156edb78 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -112,6 +112,8 @@ extern "C" { #define SI_MAP_BUFFER_ALIGNMENT 64 #define SI_MAX_VARIABLE_THREADS_PER_BLOCK 1024 +#define SI_CONTEXT_FLAG_AUX (1u << 31) + #define SI_RESOURCE_FLAG_FORCE_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0) #define SI_RESOURCE_FLAG_FLUSHED_DEPTH (PIPE_RESOURCE_FLAG_DRV_PRIV << 1) #define SI_RESOURCE_FLAG_FORCE_MSAA_TILING (PIPE_RESOURCE_FLAG_DRV_PRIV << 2) @@ -1304,6 +1306,8 @@ struct si_context { struct pipe_fence_handle *last_sqtt_fence; enum rgp_sqtt_marker_event_type sqtt_next_event; bool thread_trace_enabled; + + unsigned context_flags; }; /* si_blit.c */