crocus: Avoid replacing backing storage for buffers with no contents

Ported 97e9de1795 from iris

    We might get asked to pitch the storage on a buffer that already has
    no meaningful contents.  In this case, the existing buffer is as good
    as a new one.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11567>
This commit is contained in:
Dave Airlie
2021-06-24 14:48:32 +10:00
committed by Marge Bot
parent 0fa4b64f6c
commit 7399d6028f

View File

@@ -1130,6 +1130,10 @@ crocus_invalidate_resource(struct pipe_context *ctx,
if (resource->target != PIPE_BUFFER)
return;
/* If it's already invalidated, don't bother doing anything. */
if (res->valid_buffer_range.start > res->valid_buffer_range.end)
return;
if (!resource_is_busy(ice, res)) {
/* The resource is idle, so just mark that it contains no data and
* keep using the same underlying buffer object.