asahi: honour discard_whole | persistent

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27616>
This commit is contained in:
Alyssa Rosenzweig 2024-01-19 08:40:25 -04:00 committed by Marge Bot
parent 793ac04077
commit 7825044c39

View file

@ -704,11 +704,11 @@ agx_shadow(struct agx_context *ctx, struct agx_resource *rsrc, bool needs_copy)
return false;
/* Do not shadow resources that are too large */
if (size > MAX_SHADOW_BYTES)
if (size > MAX_SHADOW_BYTES && needs_copy)
return false;
/* Do not shadow resources too much */
if (rsrc->shadowed_bytes >= MAX_TOTAL_SHADOW_BYTES)
if (rsrc->shadowed_bytes >= MAX_TOTAL_SHADOW_BYTES && needs_copy)
return false;
rsrc->shadowed_bytes += size;
@ -815,9 +815,14 @@ agx_prepare_for_map(struct agx_context *ctx, struct agx_resource *rsrc,
return;
}
/* There are readers. Try to shadow the resource to avoid a sync */
/* There are readers. Try to invalidate the resource to avoid a sync */
if ((usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE) &&
agx_shadow(ctx, rsrc, false))
return;
/* Or try to shadow it */
if (!(rsrc->base.flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) &&
agx_shadow(ctx, rsrc, !(usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE)))
agx_shadow(ctx, rsrc, true))
return;
/* Otherwise, we need to sync */