asahi: Generalize query logic

We will need to do the same flushing dance for non-occlusion GPU queries.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24847>
This commit is contained in:
Alyssa Rosenzweig 2023-08-14 14:44:16 -04:00 committed by Marge Bot
parent 542a317a12
commit e72facab9a

View file

@ -48,34 +48,31 @@ agx_begin_query(struct pipe_context *pctx, struct pipe_query *pquery)
case PIPE_QUERY_OCCLUSION_PREDICATE:
case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
ctx->occlusion_query = query;
/* begin_query zeroes, flush so we can do that write. If anything (i.e.
* other than piglit) actually hits this, we could shadow the query to
* avoid the flush.
*/
if (query->writer) {
agx_flush_batch_for_reason(ctx, query->writer,
"Occlusion overwritten");
}
assert(query->writer == NULL);
query->value = 0;
return true;
break;
case PIPE_QUERY_PRIMITIVES_GENERATED:
ctx->prims_generated = query;
query->value = 0;
return true;
break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
ctx->tf_prims_generated = query;
query->value = 0;
return true;
break;
default:
return false;
}
/* begin_query zeroes, flush so we can do that write. If anything (i.e.
* other than piglit) actually hits this, we could shadow the query to
* avoid the flush.
*/
if (query->writer) {
agx_flush_batch_for_reason(ctx, query->writer, "Query overwritten");
}
assert(query->writer == NULL);
query->value = 0;
return true;
}
static bool