mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-27 14:10:25 +01:00
zink: Use persistent semaphores for PIPE_FD_TYPE_SYNCOBJ
These are persistant objects that you can use to signal and wait over. We need to import without VK_SEMAPHORE_IMPORT_TEMPORARY_BIT and we can't throw away the Vulkan semaphore after each submit. Fixes:32597e116d("zink: implement GL semaphores") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33549> (cherry picked from commit651864151f)
This commit is contained in:
parent
3055ca6ff6
commit
275a14e3c8
3 changed files with 15 additions and 10 deletions
|
|
@ -294,7 +294,7 @@
|
|||
"description": "zink: Use persistent semaphores for PIPE_FD_TYPE_SYNCOBJ",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "32597e116d7317127ef8a7caf8dc75b50f48b8e1",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -147,15 +147,14 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs)
|
|||
bs->signal_semaphore = VK_NULL_HANDLE;
|
||||
bs->sparse_semaphore = VK_NULL_HANDLE;
|
||||
util_dynarray_clear(&bs->wait_semaphore_stages);
|
||||
util_dynarray_clear(&bs->wait_semaphores);
|
||||
|
||||
bs->present = VK_NULL_HANDLE;
|
||||
/* check the arrays first to avoid locking unnecessarily */
|
||||
if (util_dynarray_contains(&bs->acquires, VkSemaphore) || util_dynarray_contains(&bs->wait_semaphores, VkSemaphore) || util_dynarray_contains(&bs->tracked_semaphores, VkSemaphore)) {
|
||||
if (util_dynarray_contains(&bs->acquires, VkSemaphore) || util_dynarray_contains(&bs->tracked_semaphores, VkSemaphore)) {
|
||||
simple_mtx_lock(&screen->semaphores_lock);
|
||||
util_dynarray_append_dynarray(&screen->semaphores, &bs->acquires);
|
||||
util_dynarray_clear(&bs->acquires);
|
||||
util_dynarray_append_dynarray(&screen->semaphores, &bs->wait_semaphores);
|
||||
util_dynarray_clear(&bs->wait_semaphores);
|
||||
util_dynarray_append_dynarray(&screen->semaphores, &bs->tracked_semaphores);
|
||||
util_dynarray_clear(&bs->tracked_semaphores);
|
||||
simple_mtx_unlock(&screen->semaphores_lock);
|
||||
|
|
@ -893,6 +892,9 @@ zink_end_batch(struct zink_context *ctx)
|
|||
bs->has_work = true;
|
||||
}
|
||||
|
||||
util_dynarray_foreach(&bs->fences, struct zink_tc_fence*, mfence)
|
||||
(*mfence)->deferred_ctx = NULL;
|
||||
|
||||
if (screen->threaded_submit) {
|
||||
util_queue_add_job(&screen->flush_queue, bs, &bs->flush_completed,
|
||||
submit_queue, post_submit, 0);
|
||||
|
|
|
|||
|
|
@ -262,9 +262,6 @@ zink_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *pfen
|
|||
util_dynarray_append(&ctx->bs->wait_semaphore_stages, VkPipelineStageFlags, flag);
|
||||
pipe_reference(NULL, &mfence->reference);
|
||||
util_dynarray_append(&ctx->bs->fences, struct zink_tc_fence*, mfence);
|
||||
|
||||
/* transfer the external wait sempahore ownership to the next submit */
|
||||
mfence->sem = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -292,17 +289,23 @@ zink_create_fence_fd(struct pipe_context *pctx, struct pipe_fence_handle **pfenc
|
|||
if (dup_fd < 0)
|
||||
goto fail_fd_dup;
|
||||
|
||||
static const VkExternalSemaphoreHandleTypeFlagBits flags[] = {
|
||||
static const VkExternalSemaphoreHandleTypeFlagBits handle_type[] = {
|
||||
[PIPE_FD_TYPE_NATIVE_SYNC] = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
[PIPE_FD_TYPE_SYNCOBJ] = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT,
|
||||
};
|
||||
assert(type < ARRAY_SIZE(handle_type));
|
||||
|
||||
static const VkSemaphoreImportFlagBits flags[] = {
|
||||
[PIPE_FD_TYPE_NATIVE_SYNC] = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT,
|
||||
[PIPE_FD_TYPE_SYNCOBJ] = 0,
|
||||
};
|
||||
assert(type < ARRAY_SIZE(flags));
|
||||
|
||||
const VkImportSemaphoreFdInfoKHR sdi = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
|
||||
.semaphore = mfence->sem,
|
||||
.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT,
|
||||
.handleType = flags[type],
|
||||
.flags = flags[type],
|
||||
.handleType = handle_type[type],
|
||||
.fd = dup_fd,
|
||||
};
|
||||
result = VKSCR(ImportSemaphoreFdKHR)(screen->dev, &sdi);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue