radeonsi/ngg: reuse the pipeline stats buffer when using atomics

To support PIPE_STAT_QUERY_GS_INVOCATIONS and PIPE_STAT_QUERY_GS_PRIMITIVES
being used at the same time we have to reuse the same buffer.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15861>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2022-04-19 13:13:51 +02:00
parent 0cb6fd0b00
commit 061f64f351
3 changed files with 12 additions and 1 deletions

View file

@ -218,6 +218,7 @@ static void si_destroy_context(struct pipe_context *context)
si_resource_reference(&sctx->wait_mem_scratch, NULL);
si_resource_reference(&sctx->wait_mem_scratch_tmz, NULL);
si_resource_reference(&sctx->small_prim_cull_info_buf, NULL);
si_resource_reference(&sctx->pipeline_stats_query_buf, NULL);
if (sctx->cs_preamble_state)
si_pm4_free_state(sctx, sctx->cs_preamble_state, ~0);

View file

@ -1268,6 +1268,8 @@ struct si_context {
int num_pipeline_stat_emulated_queries;
struct list_head active_queries;
unsigned num_cs_dw_queries_suspend;
/* Shared buffer for pipeline stats queries implemented with an atomic op */
struct si_resource *pipeline_stats_query_buf;
/* Render condition. */
struct pipe_query *render_cond;

View file

@ -890,9 +890,17 @@ static void si_query_hw_emit_start(struct si_context *sctx, struct si_query_hw *
{
uint64_t va;
if (!si_query_buffer_alloc(sctx, &query->buffer, query->ops->prepare_buffer, query->result_size))
if (!query->buffer.buf && query->flags & SI_QUERY_EMULATE_GS_COUNTERS)
si_resource_reference(&query->buffer.buf, sctx->pipeline_stats_query_buf);
/* Don't realloc pipeline_stats_query_buf */
if ((!(query->flags & SI_QUERY_EMULATE_GS_COUNTERS) || !sctx->pipeline_stats_query_buf) &&
!si_query_buffer_alloc(sctx, &query->buffer, query->ops->prepare_buffer, query->result_size))
return;
if (query->flags & SI_QUERY_EMULATE_GS_COUNTERS)
si_resource_reference(&sctx->pipeline_stats_query_buf, query->buffer.buf);
si_update_occlusion_query_state(sctx, query->b.type, 1);
si_update_prims_generated_query_state(sctx, query->b.type, 1);