radeonsi/gfx10: fix issue with multiple overflow queries on the same context
authorIndrajit Kumar Das <indrajit-kumar.das@amd.com>
Mon, 14 Dec 2020 10:38:21 +0000 (16:08 +0530)
committerMarge Bot <eric+marge@anholt.net>
Wed, 23 Dec 2020 04:16:45 +0000 (04:16 +0000)
In gfx10_sh_query_end a new query buffer is being allocated if there are pending
shader queries. However since emit_shader_query is called only once per draw
command, this newly allocated buffer is not used subsequently.
So even though this newly allocated buffer is treated as the last query buffer,
it is never actually used by any of the queries. Essentially there is no need
to allocate a new query buffer on the same context i.e. draw command.
The existing query buffer can be used to provide the answers to multiple queries.
Allocating an extra buffer makes subsequent queries wait on a query buffer whose
fence will never be triggered since there are no subsequent draw commands to
trigger the same.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8083>

src/gallium/drivers/radeonsi/gfx10_query.c

index a8ba299..5bb4b82 100644 (file)
@@ -183,9 +183,7 @@ static bool gfx10_sh_query_end(struct si_context *sctx, struct si_query *rquery)
 
    sctx->num_active_shader_queries--;
 
-   if (sctx->num_active_shader_queries > 0) {
-      gfx10_alloc_query_buffer(sctx);
-   } else {
+   if (sctx->num_active_shader_queries <= 0 || !si_is_atom_dirty(sctx, &sctx->atoms.s.shader_query)) {
       si_set_rw_shader_buffer(sctx, GFX10_GS_QUERY_BUF, NULL);
       sctx->current_vs_state &= C_VS_STATE_STREAMOUT_QUERY_ENABLED;