From 7399d6028f5363d9b90e57b95a539ce2476d8792 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 24 Jun 2021 14:48:32 +1000 Subject: [PATCH] crocus: Avoid replacing backing storage for buffers with no contents Ported 97e9de17952d1382512007e4745c25b9c9106a46 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: --- src/gallium/drivers/crocus/crocus_resource.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c index 612fc50510a..c2e96bc1ebb 100644 --- a/src/gallium/drivers/crocus/crocus_resource.c +++ b/src/gallium/drivers/crocus/crocus_resource.c @@ -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.