From d2f27d282f2ece300ae1703a83a1d2af53cccf3a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 2 Dec 2022 09:48:21 -0500 Subject: [PATCH] asahi: Avoid reloads with staging blits Noticed by inspection. Not likely to matter unless these staging blits are in a hot path, but it's an easy win. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 50fc31cf754..2143c9d139f 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -891,9 +891,6 @@ agx_transfer_unmap(struct pipe_context *pctx, struct pipe_resource *prsrc = transfer->resource; struct agx_resource *rsrc = (struct agx_resource *) prsrc; - if (transfer->usage & PIPE_MAP_WRITE) - BITSET_SET(rsrc->data_valid, transfer->level); - if (trans->staging.rsrc && (transfer->usage & PIPE_MAP_WRITE)) { agx_blit_from_staging(pctx, trans); agx_flush_readers(agx_context(pctx), agx_resource(trans->staging.rsrc), @@ -914,6 +911,12 @@ agx_transfer_unmap(struct pipe_context *pctx, } } + /* The level we wrote is now initialized. We do this at the end so + * blit_from_staging can avoid reloading existing contents. + */ + if (transfer->usage & PIPE_MAP_WRITE) + BITSET_SET(rsrc->data_valid, transfer->level); + /* Free the transfer */ free(trans->map); pipe_resource_reference(&transfer->resource, NULL);