mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 03:18:08 +02:00
asahi: Fix occlusion query lifetime
Theoretical lifetime issue, now easy to hit with the batch sync changes. Fixes memory badness. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21857>
This commit is contained in:
parent
a74d2ef17d
commit
e6f9444567
1 changed files with 17 additions and 1 deletions
|
|
@ -17,8 +17,19 @@ agx_create_query(struct pipe_context *ctx, unsigned query_type, unsigned index)
|
|||
}
|
||||
|
||||
static void
|
||||
agx_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
|
||||
agx_destroy_query(struct pipe_context *ctx, struct pipe_query *pquery)
|
||||
{
|
||||
struct agx_query *query = (struct agx_query *)pquery;
|
||||
|
||||
/* It is legal for the query to be destroyed before its value is read,
|
||||
* particularly during application teardown. In this case, don't leave a
|
||||
* dangling reference to the query.
|
||||
*/
|
||||
if (query->writer) {
|
||||
*util_dynarray_element(&query->writer->occlusion_queries,
|
||||
struct agx_query *, query->writer_index) = NULL;
|
||||
}
|
||||
|
||||
free(query);
|
||||
}
|
||||
|
||||
|
|
@ -154,6 +165,11 @@ agx_finish_batch_occlusion_queries(struct agx_batch *batch)
|
|||
|
||||
util_dynarray_foreach(&batch->occlusion_queries, struct agx_query *, it) {
|
||||
struct agx_query *query = *it;
|
||||
|
||||
/* Skip queries that have since been destroyed */
|
||||
if (query == NULL)
|
||||
continue;
|
||||
|
||||
assert(query->writer == batch);
|
||||
|
||||
/* Get the result for this batch. If results is NULL, it means that no
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue