mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-30 05:00:32 +01:00
venus: refactor wsi acquire to use semaphore and fence SYNC_FD import
This drops separate vn_fence_signal_wsi and vn_semaphore_signal_wsi helpers for consistency and robustness. The behavior now aligns with the Android WSI vkAcquireImageANDROID impl. This is to prepare for installing an actual payload from the compositor side. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35079>
This commit is contained in:
parent
b19e470802
commit
a312bb4285
3 changed files with 55 additions and 37 deletions
|
|
@ -1427,17 +1427,6 @@ vn_fence_init_payloads(struct vn_device *dev,
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
vn_fence_signal_wsi(struct vn_device *dev, struct vn_fence *fence)
|
||||
{
|
||||
struct vn_sync_payload *temp = &fence->temporary;
|
||||
|
||||
vn_sync_payload_release(dev, temp);
|
||||
temp->type = VN_SYNC_TYPE_IMPORTED_SYNC_FD;
|
||||
temp->fd = -1;
|
||||
fence->payload = temp;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
vn_fence_feedback_init(struct vn_device *dev,
|
||||
struct vn_fence *fence,
|
||||
|
|
@ -1908,17 +1897,6 @@ vn_semaphore_wait_external(struct vn_device *dev, struct vn_semaphore *sem)
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
vn_semaphore_signal_wsi(struct vn_device *dev, struct vn_semaphore *sem)
|
||||
{
|
||||
struct vn_sync_payload *temp = &sem->temporary;
|
||||
|
||||
vn_sync_payload_release(dev, temp);
|
||||
temp->type = VN_SYNC_TYPE_IMPORTED_SYNC_FD;
|
||||
temp->fd = -1;
|
||||
sem->payload = temp;
|
||||
}
|
||||
|
||||
struct vn_semaphore_feedback_cmd *
|
||||
vn_semaphore_get_feedback_cmd(struct vn_device *dev, struct vn_semaphore *sem)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -152,10 +152,4 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vn_event,
|
|||
VkEvent,
|
||||
VK_OBJECT_TYPE_EVENT)
|
||||
|
||||
void
|
||||
vn_fence_signal_wsi(struct vn_device *dev, struct vn_fence *fence);
|
||||
|
||||
void
|
||||
vn_semaphore_signal_wsi(struct vn_device *dev, struct vn_semaphore *sem);
|
||||
|
||||
#endif /* VN_QUEUE_H */
|
||||
|
|
|
|||
|
|
@ -290,17 +290,63 @@ vn_AcquireNextImage2KHR(VkDevice device,
|
|||
vk_Result_to_str(result));
|
||||
}
|
||||
|
||||
/* XXX this relies on implicit sync */
|
||||
if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) {
|
||||
struct vn_semaphore *sem =
|
||||
vn_semaphore_from_handle(pAcquireInfo->semaphore);
|
||||
if (sem)
|
||||
vn_semaphore_signal_wsi(dev, sem);
|
||||
if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR)
|
||||
return vn_error(dev->instance, result);
|
||||
|
||||
struct vn_fence *fence = vn_fence_from_handle(pAcquireInfo->fence);
|
||||
if (fence)
|
||||
vn_fence_signal_wsi(dev, fence);
|
||||
/* XXX this relies on implicit sync */
|
||||
int sync_fd = -1;
|
||||
|
||||
int sem_fd = -1, fence_fd = -1;
|
||||
if (sync_fd >= 0) {
|
||||
if (pAcquireInfo->semaphore != VK_NULL_HANDLE &&
|
||||
pAcquireInfo->fence != VK_NULL_HANDLE) {
|
||||
sem_fd = sync_fd;
|
||||
fence_fd = dup(sync_fd);
|
||||
if (fence_fd < 0) {
|
||||
result = errno == EMFILE ? VK_ERROR_TOO_MANY_OBJECTS
|
||||
: VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
close(sync_fd);
|
||||
return vn_error(dev->instance, result);
|
||||
}
|
||||
} else if (pAcquireInfo->semaphore != VK_NULL_HANDLE) {
|
||||
sem_fd = sync_fd;
|
||||
} else {
|
||||
assert(pAcquireInfo->fence != VK_NULL_HANDLE);
|
||||
fence_fd = sync_fd;
|
||||
}
|
||||
}
|
||||
|
||||
if (pAcquireInfo->semaphore != VK_NULL_HANDLE) {
|
||||
/* venus waits on the driver side when this semaphore is submitted */
|
||||
const VkImportSemaphoreFdInfoKHR info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
|
||||
.semaphore = pAcquireInfo->semaphore,
|
||||
.flags = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT,
|
||||
.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
.fd = sem_fd,
|
||||
};
|
||||
result = vn_ImportSemaphoreFdKHR(device, &info);
|
||||
if (result == VK_SUCCESS)
|
||||
sem_fd = -1;
|
||||
}
|
||||
|
||||
if (result == VK_SUCCESS && pAcquireInfo->fence != VK_NULL_HANDLE) {
|
||||
const VkImportFenceFdInfoKHR info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR,
|
||||
.fence = pAcquireInfo->fence,
|
||||
.flags = VK_FENCE_IMPORT_TEMPORARY_BIT,
|
||||
.handleType = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT,
|
||||
.fd = fence_fd,
|
||||
};
|
||||
result = vn_ImportFenceFdKHR(device, &info);
|
||||
if (result == VK_SUCCESS)
|
||||
fence_fd = -1;
|
||||
}
|
||||
|
||||
if (sem_fd >= 0)
|
||||
close(sem_fd);
|
||||
if (fence_fd >= 0)
|
||||
close(fence_fd);
|
||||
|
||||
return vn_result(dev->instance, result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue