/* Set settings for driver-internal compute dispatches. */
sctx->flags &= ~SI_CONTEXT_START_PIPELINE_STATS;
- sctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS;
+ if (sctx->num_hw_pipestat_streamout_queries)
+ sctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS;
if (!(flags & SI_OP_CS_RENDER_COND_ENABLE))
sctx->render_cond_enabled = false;
/* Restore default settings. */
sctx->flags &= ~SI_CONTEXT_STOP_PIPELINE_STATS;
- sctx->flags |= SI_CONTEXT_START_PIPELINE_STATS;
+ if (sctx->num_hw_pipestat_streamout_queries)
+ sctx->flags |= SI_CONTEXT_START_PIPELINE_STATS;
+
sctx->render_cond_enabled = sctx->render_cond;
sctx->blitter_running = false;
*
* TODO: Do we also need to invalidate CB & DB caches?
*/
- ctx->flags |= SI_CONTEXT_INV_L2 | SI_CONTEXT_START_PIPELINE_STATS;
+ ctx->flags |= SI_CONTEXT_INV_L2;
if (ctx->gfx_level < GFX10)
ctx->flags |= SI_CONTEXT_INV_ICACHE | SI_CONTEXT_INV_SCACHE | SI_CONTEXT_INV_VCACHE;
- ctx->pipeline_stats_enabled = -1;
+ /* Disable pipeline stats if there are no active queries. */
+ ctx->flags &= ~SI_CONTEXT_START_PIPELINE_STATS & ~SI_CONTEXT_STOP_PIPELINE_STATS;
+ if (ctx->num_hw_pipestat_streamout_queries)
+ ctx->flags |= SI_CONTEXT_START_PIPELINE_STATS;
+ else
+ ctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS;
+
+ ctx->pipeline_stats_enabled = -1; /* indicate that the current hw state is unknown */
/* We don't know if the last draw used NGG because it can be a different process.
* When switching NGG->legacy, we need to flush VGT for certain hw generations.
int num_perfect_occlusion_queries;
int num_pipeline_stat_queries;
int num_pipeline_stat_emulated_queries;
+ int num_hw_pipestat_streamout_queries;
struct list_head active_queries;
unsigned num_cs_dw_queries_suspend;
/* Shared buffer for pipeline stats queries implemented with an atomic op */
RADEON_USAGE_WRITE | RADEON_PRIO_QUERY);
}
+static void si_update_hw_pipeline_stats(struct si_context *sctx, unsigned type, int diff)
+{
+ if (type == PIPE_QUERY_PIPELINE_STATISTICS ||
+ /* All streamout queries: */
+ type == PIPE_QUERY_PRIMITIVES_GENERATED ||
+ type == PIPE_QUERY_PRIMITIVES_EMITTED ||
+ type == PIPE_QUERY_SO_STATISTICS ||
+ type == PIPE_QUERY_SO_OVERFLOW_PREDICATE ||
+ type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE) {
+ if (type == PIPE_QUERY_PIPELINE_STATISTICS)
+ sctx->num_pipeline_stat_queries += diff;
+
+ /* Increment for pipeline statistics and streamout queries. */
+ sctx->num_hw_pipestat_streamout_queries += diff;
+
+ /* Enable/disable pipeline stats if we have any queries. */
+ if (diff == 1 && sctx->num_hw_pipestat_streamout_queries == 1) {
+ sctx->flags &= ~SI_CONTEXT_STOP_PIPELINE_STATS;
+ sctx->flags |= SI_CONTEXT_START_PIPELINE_STATS;
+ } else if (diff == -1 && sctx->num_hw_pipestat_streamout_queries == 0) {
+ sctx->flags &= ~SI_CONTEXT_START_PIPELINE_STATS;
+ sctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS;
+ }
+ }
+}
+
static void si_query_hw_emit_start(struct si_context *sctx, struct si_query_hw *query)
{
uint64_t va;
si_update_occlusion_query_state(sctx, query->b.type, 1);
si_update_prims_generated_query_state(sctx, query->b.type, 1);
-
- if (query->b.type == PIPE_QUERY_PIPELINE_STATISTICS)
- sctx->num_pipeline_stat_queries++;
+ si_update_hw_pipeline_stats(sctx, query->b.type, 1);
si_need_gfx_cs_space(sctx, 0);
si_update_occlusion_query_state(sctx, query->b.type, -1);
si_update_prims_generated_query_state(sctx, query->b.type, -1);
-
- if (query->b.type == PIPE_QUERY_PIPELINE_STATISTICS)
- sctx->num_pipeline_stat_queries--;
+ si_update_hw_pipeline_stats(sctx, query->b.type, -1);
}
static void emit_set_predicate(struct si_context *ctx, struct si_resource *buf, uint64_t va,
/* Pipeline stat & streamout queries. */
if (enable) {
- sctx->flags &= ~SI_CONTEXT_STOP_PIPELINE_STATS;
- sctx->flags |= SI_CONTEXT_START_PIPELINE_STATS;
+ /* Disable pipeline stats if there are no active queries. */
+ if (sctx->num_hw_pipestat_streamout_queries) {
+ sctx->flags &= ~SI_CONTEXT_STOP_PIPELINE_STATS;
+ sctx->flags |= SI_CONTEXT_START_PIPELINE_STATS;
+ }
} else {
- sctx->flags &= ~SI_CONTEXT_START_PIPELINE_STATS;
- sctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS;
+ if (sctx->num_hw_pipestat_streamout_queries) {
+ sctx->flags &= ~SI_CONTEXT_START_PIPELINE_STATS;
+ sctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS;
+ }
}
/* Occlusion queries. */