From b76ad3efa0c4b2be738ed7161dd5427eb08908e0 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 1 Apr 2022 08:01:32 -0400 Subject: [PATCH] zink: only uncommit sparse pages that have been committed avoid spamming drivers unnecessary with submits since this is expensive Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_bo.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c index 7c7a16ff1c2..0131940cd3e 100644 --- a/src/gallium/drivers/zink/zink_bo.c +++ b/src/gallium/drivers/zink/zink_bo.c @@ -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; -- 2.34.1