Module: Mesa
Branch: staging/22.3
Commit: 90ed904e99be2d4c3db79645fb152aadd1e341c7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=90ed904e99be2d4c3db79645fb152aadd1e341c7

Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Feb  3 08:40:25 2023 -0500

zink: fix max acquired image count

according to spec, the maximum number of acquired images can be calculated with

swapchain_size - VkSurfaceCapabilitiesKHR::minImageCount + 1

the previous calculation was both wrong and occurring in the wrong place,
so this corrects both issues

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21095>
(cherry picked from commit 89cf0a3bdc9949c54d8d7965a2d51bed91b6d10a)

---

 .pick_status.json                      | 2 +-
 src/gallium/drivers/zink/zink_kopper.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index d55aa3ee2b3..a35642423f5 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -283,7 +283,7 @@
         "description": "zink: fix max acquired image count",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/zink/zink_kopper.c 
b/src/gallium/drivers/zink/zink_kopper.c
index 6070abb3921..a67b7566af7 100644
--- a/src/gallium/drivers/zink/zink_kopper.c
+++ b/src/gallium/drivers/zink/zink_kopper.c
@@ -297,7 +297,6 @@ kopper_CreateSwapchain(struct zink_screen *screen, struct 
kopper_displaytarget *
        *result = error;
        return NULL;
    }
-   cswap->max_acquires = cswap->scci.minImageCount - cdt->caps.minImageCount;
    cswap->last_present = UINT32_MAX;
 
    *result = VK_SUCCESS;
@@ -320,6 +319,7 @@ kopper_GetSwapchainImages(struct zink_screen *screen, 
struct kopper_swapchain *c
       for (unsigned i = 0; i < cswap->num_images; i++)
          cswap->images[i].image = images[i];
    }
+   cswap->max_acquires = cswap->num_images - cswap->scci.minImageCount + 1;
    return error;
 }
 
@@ -490,7 +490,7 @@ kopper_acquire(struct zink_screen *screen, struct 
zink_resource *res, uint64_t t
          res->obj->access_stage = 0;
       }
       if (timeout == UINT64_MAX && 
util_queue_is_initialized(&screen->flush_queue) &&
-          p_atomic_read_relaxed(&cdt->swapchain->num_acquires) > 
cdt->swapchain->max_acquires) {
+          p_atomic_read_relaxed(&cdt->swapchain->num_acquires) >= 
cdt->swapchain->max_acquires) {
          util_queue_fence_wait(&cdt->present_fence);
       }
       VkSemaphoreCreateInfo sci = {

Reply via email to