zink: preserve present resources during async presentation
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 19 Jan 2023 18:33:04 +0000 (13:33 -0500)
committerEric Engestrom <eric@engestrom.ch>
Thu, 26 Jan 2023 15:40:33 +0000 (15:40 +0000)
ensure that these have a lifetime great enough to be presented

fixes #7781

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20793>
(cherry picked from commit 020db79340a1932c5229574a9e5d1ccec4e5c9da)

.pick_status.json
src/gallium/drivers/zink/zink_kopper.c

index c4a39ab..c3971cc 100644 (file)
         "description": "zink: preserve present resources during async presentation",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
index 1df8c84..6070abb 100644 (file)
@@ -715,8 +715,11 @@ kopper_present(void *data, void *gdata, int thread_idx)
    }
    util_dynarray_append(arr, VkSemaphore, cpi->sem);
 out:
-   if (thread_idx != -1)
+   if (thread_idx != -1) {
       p_atomic_dec(&swapchain->async_presents);
+      struct pipe_resource *pres = &cpi->res->base.b;
+      pipe_resource_reference(&pres, NULL);
+   }
    free(cpi);
 }
 
@@ -760,6 +763,8 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res)
    }
    if (util_queue_is_initialized(&screen->flush_queue)) {
       p_atomic_inc(&cpi->swapchain->async_presents);
+      struct pipe_resource *pres = NULL;
+      pipe_resource_reference(&pres, &res->base.b);
       util_queue_add_job(&screen->flush_queue, cpi, &cdt->present_fence,
                          kopper_present, NULL, 0);
    } else {