asahi: Hold a reference to BOs in a batch

Fixes GPU-side use after frees, e.g. in dEQP-GLES2.functional.texture.vertex.2d.wrap.clamp_mirror

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19215>
This commit is contained in:
Alyssa Rosenzweig 2022-10-20 22:42:39 -04:00 committed by Marge Bot
parent 741dbadae0
commit ba551d293f
2 changed files with 10 additions and 0 deletions

View file

@ -567,6 +567,10 @@ agx_flush(struct pipe_context *pctx,
agxdecode_next_frame();
}
AGX_BATCH_FOREACH_BO_HANDLE(batch, handle) {
agx_bo_unreference(agx_lookup_bo(dev, handle));
}
memset(batch->bo_list.set, 0, batch->bo_list.word_count * sizeof(BITSET_WORD));
agx_pool_cleanup(&ctx->batch->pool);
agx_pool_cleanup(&ctx->batch->pipeline_pool);

View file

@ -369,6 +369,12 @@ agx_batch_add_bo(struct agx_batch *batch, struct agx_bo *bo)
batch->bo_list.word_count *= 2;
}
/* The batch holds a single reference to each BO in the batch, released when
* the batch finishes execution.
*/
if (!BITSET_TEST(batch->bo_list.set, bo->handle))
agx_bo_reference(bo);
BITSET_SET(batch->bo_list.set, bo->handle);
}