mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
c/util: Track and free native sync handle from semaphore
The layer above IPC & st/oxr doesn't consume this handle, instead it has dup semantics, so we need to keep track of the handle and free it once done.
This commit is contained in:
parent
6493564024
commit
064da71894
|
@ -7,6 +7,8 @@
|
|||
* @ingroup comp_util
|
||||
*/
|
||||
|
||||
#include "util/u_handles.h"
|
||||
|
||||
#include "util/comp_semaphore.h"
|
||||
|
||||
|
||||
|
@ -61,6 +63,10 @@ semaphore_destroy(struct xrt_compositor_semaphore *xcsem)
|
|||
csem->semaphore = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
// Does invalid checking and sets to invalid.
|
||||
u_graphics_sync_unref(&csem->handle);
|
||||
|
||||
// Do the final freeing.
|
||||
free(csem);
|
||||
}
|
||||
#endif
|
||||
|
@ -85,7 +91,8 @@ comp_semaphore_create(struct vk_bundle *vk,
|
|||
}
|
||||
|
||||
VkSemaphore semaphore;
|
||||
ret = vk_create_timeline_semaphore_and_native(vk, &semaphore, out_handle);
|
||||
xrt_graphics_sync_handle_t handle;
|
||||
ret = vk_create_timeline_semaphore_and_native(vk, &semaphore, &handle);
|
||||
if (ret != VK_SUCCESS) {
|
||||
return XRT_ERROR_VULKAN;
|
||||
}
|
||||
|
@ -97,9 +104,11 @@ comp_semaphore_create(struct vk_bundle *vk,
|
|||
csem->base.destroy = semaphore_destroy;
|
||||
csem->base.wait = semaphore_wait;
|
||||
csem->semaphore = semaphore;
|
||||
csem->handle = handle;
|
||||
csem->vk = vk;
|
||||
|
||||
*out_xcsem = &csem->base;
|
||||
*out_handle = handle;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
#else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2019-2022, Collabora, Ltd.
|
||||
// Copyright 2019-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
|
@ -32,6 +32,14 @@ struct comp_semaphore
|
|||
struct vk_bundle *vk;
|
||||
|
||||
VkSemaphore semaphore;
|
||||
|
||||
/*!
|
||||
* Shared handle, the layer above compositor, such as IPC & st/oxr,
|
||||
* doesn't consume this handle, instead it has dup semantics. So we
|
||||
* need to keep track of the handle and free it once done. This is
|
||||
* because the platform may be required by the platform.
|
||||
*/
|
||||
xrt_graphics_sync_handle_t handle;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue