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>
This commit is contained in:
Marek Olšák 2022-06-08 13:42:33 -04:00 committed by Marge Bot
parent 4d4bd7cb5b
commit 0f48c581f9
3 changed files with 23 additions and 14 deletions

View file

@ -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);
}

View file

@ -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)) {

View file

@ -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 */