[PATCH v2 0/2] MR11175: win32u: A couple of d3d12 shared fences improvements.
-- v2: win32u: Force timeline semaphore type when importing d3d12 fence. win32u: Support D3D12_FENCE_SUBMIT_INFO in win32u_vkQueueSubmit(). https://gitlab.winehq.org/wine/wine/-/merge_requests/11175
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/vulkan.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 00f85243a3f..1518cdd909a 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -2196,9 +2196,18 @@ static VkResult win32u_vkQueueSubmit( VkQueue client_queue, uint32_t count, cons switch ((*next)->sType) { case VK_STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR: - FIXME( "VK_STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR not implemented!\n" ); + { + VkD3D12FenceSubmitInfoKHR *info = (VkD3D12FenceSubmitInfoKHR *)*next; + + if (timeline->sType) ERR( "Duplicated timeline sync info.\n" ); + timeline->sType = info->sType; + timeline->waitSemaphoreValueCount = info->waitSemaphoreValuesCount; + timeline->pWaitSemaphoreValues = info->pWaitSemaphoreValues; + timeline->signalSemaphoreValueCount = info->signalSemaphoreValuesCount; + timeline->pSignalSemaphoreValues = info->pSignalSemaphoreValues; *next = (*next)->pNext; next = &prev; break; + } case VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO: device_group = (VkDeviceGroupSubmitInfo *)*next; break; @@ -2208,7 +2217,7 @@ static VkResult win32u_vkQueueSubmit( VkQueue client_queue, uint32_t count, cons case VK_STRUCTURE_TYPE_PERFORMANCE_QUERY_SUBMIT_INFO_KHR: break; case VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO: break; case VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO: - if (timeline->sType) ERR( "Duplicated timeline semaphore submit info!\n" ); + if (timeline->sType) ERR( "Duplicated timeline sync info.\n" ); *timeline = *(VkTimelineSemaphoreSubmitInfo *)*next; *next = (*next)->pNext; next = &prev; /* remove it from the chain, we'll add it back below */ break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11175
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/vulkan.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 1518cdd909a..310ce8923c9 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -2559,6 +2559,7 @@ static VkResult win32u_vkImportSemaphoreWin32HandleKHR( VkDevice client_device, VkImportSemaphoreFdInfoKHR fd_info = {.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR}; struct vulkan_device *device = vulkan_device_from_handle( client_device ); struct semaphore *semaphore = semaphore_from_handle( handle_info->semaphore ); + struct vulkan_instance *instance = device->physical_device->instance; D3DKMT_HANDLE local, global = 0; VkResult res = VK_SUCCESS; HANDLE shared = NULL; @@ -2591,7 +2592,35 @@ static VkResult win32u_vkImportSemaphoreWin32HandleKHR( VkDevice client_device, } if ((fd_info.fd = d3dkmt_object_get_fd( local )) < 0) res = VK_ERROR_INVALID_EXTERNAL_HANDLE; - else + if (!res && handle_info->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT) + { + /* Recreate semaphore to make sure it has timeline type. */ + VkSemaphoreTypeCreateInfo type_info = + { + .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO, + .semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE, + }; + VkSemaphoreCreateInfo create_info = + { + .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, + .pNext = &type_info, + }; + VkSemaphore new_semaphore; + + if ((res = device->p_vkCreateSemaphore( device->host.device, &create_info, NULL, &new_semaphore ))) + { + ERR( "Failed to create timeline semaphore, vr %d.\n", res ); + } + else + { + instance->p_remove_object( instance, &semaphore->obj.obj ); + device->p_vkDestroySemaphore( device->host.device, semaphore->obj.host.semaphore, NULL ); + vulkan_object_init( &semaphore->obj.obj, new_semaphore ); + instance->p_insert_object( instance, &semaphore->obj.obj ); + } + } + + if (!res) { fd_info.handleType = get_host_external_semaphore_type(); fd_info.semaphore = semaphore->obj.host.semaphore; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11175
v2: - print the same ERR on duplicated d3d12 fence or semaphore timeline info; - use vulkan_object_init(). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11175#note_143639
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11175
participants (3)
-
Paul Gofman -
Paul Gofman (@gofman) -
Rémi Bernon (@rbernon)