zink: only uncommit sparse pages that have been committed
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 1 Apr 2022 12:01:32 +0000 (08:01 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Apr 2022 04:48:59 +0000 (04:48 +0000)
avoid spamming drivers unnecessary with submits since this is expensive

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15716>

src/gallium/drivers/zink/zink_bo.c

index 7c7a16ff1c2e8446f5330ba2ff10c9d851ba51f6..0131940cd3e1b725bea439426fb09dc7272ee2a0 100644 (file)
@@ -785,13 +785,8 @@ buffer_bo_commit(struct zink_screen *screen, struct zink_resource *res, uint32_t
          }
       }
    } else {
-      if (!buffer_commit_single(screen, res, NULL,
-                                (uint64_t)va_page * ZINK_SPARSE_BUFFER_PAGE_SIZE,
-                                (uint64_t)(end_va_page - va_page) * ZINK_SPARSE_BUFFER_PAGE_SIZE, false)) {
-         ok = false;
-         goto out;
-      }
-
+      bool done = false;
+      uint32_t base_page = va_page;
       while (va_page < end_va_page) {
          struct zink_sparse_backing *backing;
          uint32_t backing_start;
@@ -803,6 +798,14 @@ buffer_bo_commit(struct zink_screen *screen, struct zink_resource *res, uint32_t
             continue;
          }
 
+         if (!done && !buffer_commit_single(screen, res, NULL,
+                                            (uint64_t)base_page * ZINK_SPARSE_BUFFER_PAGE_SIZE,
+                                            (uint64_t)(end_va_page - base_page) * ZINK_SPARSE_BUFFER_PAGE_SIZE, false)) {
+            ok = false;
+            goto out;
+         }
+         done = true;
+
          /* Group contiguous spans of pages. */
          backing = comm[va_page].backing;
          backing_start = comm[va_page].page;