Mesa (main): crocus: Avoid replacing backing storage for buffers with no contents

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 24 07:09:35 UTC 2021


Module: Mesa
Branch: main
Commit: 7399d6028f5363d9b90e57b95a539ce2476d8792
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7399d6028f5363d9b90e57b95a539ce2476d8792

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jun 24 14:48:32 2021 +1000

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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11567>

---

 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.



More information about the mesa-commit mailing list