st/mesa: Only pause queries if there are any active queries to pause.

Previously, ReadPixels, PBO upload/download, and clears would call
cso_save_state with CSO_PAUSE_QUERIES, causing cso_context to call
pipe->set_active_query_state() twice for each operation.  This can
potentially cause driver work to enable/disable statistics counters.

But often, there are no queries happening which need to be paused.
By keeping a simple tally of active queries, we can skip this work.

Reviewed-by: Tapani Pälli <>
Reviewed-by: Marek Olšák <>
22 jobs for !1913 with st-pausequeries in 21 seconds (queued for 16 seconds)
merge request