summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2022-06-08 13:42:33 -0400
committerMarge Bot <emma+marge@anholt.net>2022-06-11 11:14:16 +0000
commit0f48c581f90659183f6d8c3570c76f4510690950 (patch)
tree19706898aa46c74d49e1a817ef0908fe6c1464c8
parent4d4bd7cb5b68e81b9c5637855135a767c5857477 (diff)
radeonsi: allocate GDS only once per process
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16885>
-rw-r--r--src/gallium/drivers/radeonsi/si_gfx_cs.c21
-rw-r--r--src/gallium/drivers/radeonsi/si_pipe.c7
-rw-r--r--src/gallium/drivers/radeonsi/si_pipe.h9
3 files changed, 23 insertions, 14 deletions
diff --git a/src/gallium/drivers/radeonsi/si_gfx_cs.c b/src/gallium/drivers/radeonsi/si_gfx_cs.c
index d19225b0fc9..56fb36f7cb7 100644
--- a/src/gallium/drivers/radeonsi/si_gfx_cs.c
+++ b/src/gallium/drivers/radeonsi/si_gfx_cs.c
@@ -211,10 +211,10 @@ static void si_begin_gfx_cs_debug(struct si_context *ctx)
static void si_add_gds_to_buffer_list(struct si_context *sctx)
{
- if (sctx->gds) {
- sctx->ws->cs_add_buffer(&sctx->gfx_cs, sctx->gds, RADEON_USAGE_READWRITE, 0);
- if (sctx->gds_oa) {
- sctx->ws->cs_add_buffer(&sctx->gfx_cs, sctx->gds_oa, RADEON_USAGE_READWRITE, 0);
+ if (sctx->screen->gds) {
+ sctx->ws->cs_add_buffer(&sctx->gfx_cs, sctx->screen->gds, RADEON_USAGE_READWRITE, 0);
+ if (sctx->screen->gds_oa) {
+ sctx->ws->cs_add_buffer(&sctx->gfx_cs, sctx->screen->gds_oa, RADEON_USAGE_READWRITE, 0);
}
}
}
@@ -223,7 +223,7 @@ void si_allocate_gds(struct si_context *sctx)
{
struct radeon_winsys *ws = sctx->ws;
- if (sctx->gds)
+ if (sctx->screen->gds && sctx->screen->gds_oa)
return;
assert(sctx->screen->use_ngg_streamout);
@@ -231,10 +231,15 @@ void si_allocate_gds(struct si_context *sctx)
/* 4 streamout GDS counters.
* We need 256B (64 dw) of GDS, otherwise streamout hangs.
*/
- sctx->gds = ws->buffer_create(ws, 256, 4, RADEON_DOMAIN_GDS, RADEON_FLAG_DRIVER_INTERNAL);
- sctx->gds_oa = ws->buffer_create(ws, 4, 1, RADEON_DOMAIN_OA, RADEON_FLAG_DRIVER_INTERNAL);
+ simple_mtx_lock(&sctx->screen->gds_mutex);
+ if (!sctx->screen->gds)
+ sctx->screen->gds = ws->buffer_create(ws, 256, 4, RADEON_DOMAIN_GDS, RADEON_FLAG_DRIVER_INTERNAL);
+ if (!sctx->screen->gds_oa)
+ sctx->screen->gds_oa = ws->buffer_create(ws, 4, 1, RADEON_DOMAIN_OA, RADEON_FLAG_DRIVER_INTERNAL);
+ simple_mtx_unlock(&sctx->screen->gds_mutex);
+
+ assert(sctx->screen->gds && sctx->screen->gds_oa);
- assert(sctx->gds && sctx->gds_oa);
si_add_gds_to_buffer_list(sctx);
}
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 8122b61919e..98d93af749e 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -334,8 +334,6 @@ static void si_destroy_context(struct pipe_context *context)
si_resource_reference(&sctx->eop_bug_scratch, NULL);
si_resource_reference(&sctx->eop_bug_scratch_tmz, NULL);
si_resource_reference(&sctx->shadowed_regs, NULL);
- radeon_bo_reference(sctx->screen->ws, &sctx->gds, NULL);
- radeon_bo_reference(sctx->screen->ws, &sctx->gds_oa, NULL);
si_destroy_compiler(&sctx->compiler);
@@ -969,6 +967,10 @@ static void si_destroy_screen(struct pipe_screen *pscreen)
si_gpu_load_kill_thread(sscreen);
simple_mtx_destroy(&sscreen->gpu_load_mutex);
+ simple_mtx_destroy(&sscreen->gds_mutex);
+
+ radeon_bo_reference(sscreen->ws, &sscreen->gds, NULL);
+ radeon_bo_reference(sscreen->ws, &sscreen->gds_oa, NULL);
slab_destroy_parent(&sscreen->pool_transfers);
@@ -1188,6 +1190,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
(void)simple_mtx_init(&sscreen->aux_context_lock, mtx_plain);
(void)simple_mtx_init(&sscreen->async_compute_context_lock, mtx_plain);
(void)simple_mtx_init(&sscreen->gpu_load_mutex, mtx_plain);
+ (void)simple_mtx_init(&sscreen->gds_mutex, mtx_plain);
si_init_gs_info(sscreen);
if (!si_init_shader_cache(sscreen)) {
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 658ee5d608e..092f1f74ee7 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -710,6 +710,11 @@ struct si_screen {
struct util_vertex_state_cache vertex_state_cache;
struct si_resource *attribute_ring;
+
+ /* NGG streamout. */
+ simple_mtx_t gds_mutex;
+ struct pb_buffer *gds;
+ struct pb_buffer *gds_oa;
};
struct si_sampler_view {
@@ -1020,10 +1025,6 @@ struct si_context {
/* Current unaccounted memory usage. */
uint32_t memory_usage_kb;
- /* NGG streamout. */
- struct pb_buffer *gds;
- struct pb_buffer *gds_oa;
-
/* Atoms (direct states). */
union si_state_atoms atoms;
unsigned dirty_atoms; /* mask */