From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 85 +++++++++- dlls/winevulkan/make_vulkan | 3 + dlls/winevulkan/vulkan_thunks.c | 267 +++++++++++++++++++++++++++----- include/wine/vulkan_driver.h | 12 +- 4 files changed, 325 insertions(+), 42 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 21e91de36ce..e091016bbcb 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -92,6 +92,17 @@ static struct swapchain *swapchain_from_handle( VkSwapchainKHR handle ) return CONTAINING_RECORD( obj, struct swapchain, obj ); }
+struct semaphore +{ + struct vulkan_semaphore obj; +}; + +static inline struct semaphore *semaphore_from_handle( VkSemaphore handle ) +{ + struct vulkan_semaphore *obj = vulkan_semaphore_from_handle( handle ); + return CONTAINING_RECORD( obj, struct semaphore, obj ); +} + static VkResult allocate_external_host_memory( struct vulkan_device *device, VkMemoryAllocateInfo *alloc_info, uint32_t mem_flags, VkImportMemoryHostPointerInfoEXT *import_info ) { @@ -918,6 +929,7 @@ void win32u_vkDestroySwapchainKHR( VkDevice client_device, VkSwapchainKHR client static VkResult win32u_vkAcquireNextImage2KHR( VkDevice client_device, const VkAcquireNextImageInfoKHR *acquire_info, uint32_t *image_index ) { + struct vulkan_semaphore *semaphore = acquire_info->semaphore ? vulkan_semaphore_from_handle( acquire_info->semaphore ) : NULL; struct swapchain *swapchain = swapchain_from_handle( acquire_info->swapchain ); struct vulkan_device *device = vulkan_device_from_handle( client_device ); VkAcquireNextImageInfoKHR acquire_info_host = *acquire_info; @@ -926,7 +938,7 @@ static VkResult win32u_vkAcquireNextImage2KHR( VkDevice client_device, const VkA VkResult res;
acquire_info_host.swapchain = swapchain->obj.host.swapchain; - + acquire_info_host.semaphore = semaphore ? semaphore->host.semaphore : 0; res = device->p_vkAcquireNextImage2KHR( device->host.device, &acquire_info_host, image_index );
if (!res && NtUserGetClientRect( surface->hwnd, &client_rect, NtUserGetDpiForWindow( surface->hwnd ) ) && @@ -941,8 +953,9 @@ static VkResult win32u_vkAcquireNextImage2KHR( VkDevice client_device, const VkA }
static VkResult win32u_vkAcquireNextImageKHR( VkDevice client_device, VkSwapchainKHR client_swapchain, uint64_t timeout, - VkSemaphore semaphore, VkFence fence, uint32_t *image_index ) + VkSemaphore client_semaphore, VkFence fence, uint32_t *image_index ) { + struct vulkan_semaphore *semaphore = client_semaphore ? vulkan_semaphore_from_handle( client_semaphore ) : NULL; struct swapchain *swapchain = swapchain_from_handle( client_swapchain ); struct vulkan_device *device = vulkan_device_from_handle( client_device ); struct surface *surface = swapchain->surface; @@ -950,7 +963,7 @@ static VkResult win32u_vkAcquireNextImageKHR( VkDevice client_device, VkSwapchai VkResult res;
res = device->p_vkAcquireNextImageKHR( device->host.device, swapchain->obj.host.swapchain, timeout, - semaphore, fence, image_index ); + semaphore ? semaphore->host.semaphore : 0, fence, image_index );
if (!res && NtUserGetClientRect( surface->hwnd, &client_rect, NtUserGetDpiForWindow( surface->hwnd ) ) && !extents_equals( &swapchain->extents, &client_rect )) @@ -978,6 +991,13 @@ static VkResult win32u_vkQueuePresentKHR( VkQueue client_queue, const VkPresentI !(swapchains = malloc( present_info->swapchainCount * sizeof(*swapchains) ))) return VK_ERROR_OUT_OF_HOST_MEMORY;
+ for (uint32_t i = 0; i < present_info->waitSemaphoreCount; i++) + { + VkSemaphore *semaphores = (VkSemaphore *)present_info->pWaitSemaphores; /* cast away const, it has been copied in the thunks */ + struct vulkan_semaphore *semaphore = vulkan_semaphore_from_handle( semaphores[i] ); + semaphores[i] = semaphore->host.semaphore; + } + for (uint32_t i = 0; i < present_info->swapchainCount; i++) { struct swapchain *swapchain = swapchain_from_handle( present_info->pSwapchains[i] ); @@ -1061,6 +1081,20 @@ static VkResult win32u_vkQueueSubmit( VkQueue client_queue, uint32_t count, cons command_buffers[j] = command_buffer->host.command_buffer; }
+ for (uint32_t j = 0; j < submit->waitSemaphoreCount; j++) + { + VkSemaphore *semaphores = (VkSemaphore *)submit->pWaitSemaphores; /* cast away const, it has been copied in the thunks */ + struct vulkan_semaphore *semaphore = vulkan_semaphore_from_handle( semaphores[j] ); + semaphores[j] = semaphore->host.semaphore; + } + + for (uint32_t j = 0; j < submit->signalSemaphoreCount; j++) + { + VkSemaphore *semaphores = (VkSemaphore *)submit->pSignalSemaphores; /* cast away const, it has been copied in the thunks */ + struct vulkan_semaphore *semaphore = vulkan_semaphore_from_handle( semaphores[j] ); + semaphores[j] = semaphore->host.semaphore; + } + for (next = &prev->pNext; *next; prev = *next, next = &(*next)->pNext) { switch ((*next)->sType) @@ -1108,6 +1142,22 @@ static VkResult win32u_vkQueueSubmit2( VkQueue client_queue, uint32_t count, con if (command_buffer_infos->pNext) FIXME( "Unhandled struct chain\n" ); }
+ for (uint32_t j = 0; j < submit->waitSemaphoreInfoCount; j++) + { + VkSemaphoreSubmitInfo *semaphore_infos = (VkSemaphoreSubmitInfo *)submit->pWaitSemaphoreInfos; /* cast away const, it has been copied in the thunks */ + struct vulkan_semaphore *semaphore = vulkan_semaphore_from_handle( semaphore_infos[j].semaphore ); + semaphore_infos[j].semaphore = semaphore->host.semaphore; + if (semaphore_infos->pNext) FIXME( "Unhandled struct chain\n" ); + } + + for (uint32_t j = 0; j < submit->signalSemaphoreInfoCount; j++) + { + VkSemaphoreSubmitInfo *semaphore_infos = (VkSemaphoreSubmitInfo *)submit->pSignalSemaphoreInfos; /* cast away const, it has been copied in the thunks */ + struct vulkan_semaphore *semaphore = vulkan_semaphore_from_handle( semaphore_infos[j].semaphore ); + semaphore_infos[j].semaphore = semaphore->host.semaphore; + if (semaphore_infos->pNext) FIXME( "Unhandled struct chain\n" ); + } + for (next = &prev->pNext; *next; prev = *next, next = &(*next)->pNext) { switch ((*next)->sType) @@ -1134,6 +1184,10 @@ static VkResult win32u_vkCreateSemaphore( VkDevice client_device, const VkSemaph VkSemaphoreCreateInfo *create_info = (VkSemaphoreCreateInfo *)client_create_info; /* cast away const, chain has been copied in the thunks */ struct vulkan_device *device = vulkan_device_from_handle( client_device ); VkBaseOutStructure **next, *prev = (VkBaseOutStructure *)create_info; + struct vulkan_instance *instance = device->physical_device->instance; + struct semaphore *semaphore; + VkSemaphore host_semaphore; + VkResult res;
TRACE( "device %p, create_info %p, allocator %p, ret %p\n", device, create_info, allocator, ret );
@@ -1155,16 +1209,35 @@ static VkResult win32u_vkCreateSemaphore( VkDevice client_device, const VkSemaph } }
- return device->p_vkCreateSemaphore( device->host.device, create_info, NULL /* allocator */, ret ); + if (!(semaphore = calloc( 1, sizeof(*semaphore) ))) return VK_ERROR_OUT_OF_HOST_MEMORY; + + if ((res = device->p_vkCreateSemaphore( device->host.device, create_info, NULL /* allocator */, &host_semaphore ))) + { + free( semaphore ); + return res; + } + + vulkan_object_init( &semaphore->obj.obj, host_semaphore ); + instance->p_insert_object( instance, &semaphore->obj.obj ); + + *ret = semaphore->obj.client.semaphore; + return res; }
static void win32u_vkDestroySemaphore( VkDevice client_device, VkSemaphore client_semaphore, const VkAllocationCallbacks *allocator ) { struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct semaphore *semaphore = semaphore_from_handle( client_semaphore ); + struct vulkan_instance *instance = device->physical_device->instance; + + TRACE( "device %p, semaphore %p, allocator %p\n", device, semaphore, allocator ); + + if (!client_semaphore) return;
- TRACE( "device %p, client_semaphore 0x%s, allocator %p\n", device, wine_dbgstr_longlong( client_semaphore ), allocator ); + device->p_vkDestroySemaphore( device->host.device, semaphore->obj.host.semaphore, NULL /* allocator */ ); + instance->p_remove_object( instance, &semaphore->obj.obj );
- device->p_vkDestroySemaphore( device->host.device, client_semaphore, NULL /* allocator */ ); + free( semaphore ); }
static VkResult win32u_vkGetSemaphoreWin32HandleKHR( VkDevice client_device, const VkSemaphoreGetWin32HandleInfoKHR *handle_info, HANDLE *handle ) diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index f8dac7568d7..44f5d1f5ea8 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -1124,6 +1124,9 @@ class VkHandle(object): return "vulkan_surface_from_handle({0})->host.surface".format(name) if self.name == "VkSwapchainKHR": return "vulkan_swapchain_from_handle({0})->host.swapchain".format(name) + if self.name == "VkSemaphore": + return "vulkan_semaphore_from_handle({0})->host.semaphore".format(name) + if self.is_dispatchable(): LOGGER.error("Unhandled host handle for: {0}".format(self.name)) return None diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index 03a896fac3b..c1d93705184 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -9618,6 +9618,8 @@ static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle) return (uint64_t) (uintptr_t) vulkan_physical_device_from_handle(((VkPhysicalDevice) (uintptr_t) handle))->host.physical_device; case VK_OBJECT_TYPE_QUEUE: return (uint64_t) (uintptr_t) vulkan_queue_from_handle(((VkQueue) (uintptr_t) handle))->host.queue; + case VK_OBJECT_TYPE_SEMAPHORE: + return (uint64_t) vulkan_semaphore_from_handle(handle)->host.semaphore; case VK_OBJECT_TYPE_SURFACE_KHR: return (uint64_t) vulkan_surface_from_handle(handle)->host.surface; case VK_OBJECT_TYPE_SWAPCHAIN_KHR: @@ -38952,7 +38954,7 @@ static void convert_VkSamplerCaptureDescriptorDataInfoEXT_win32_to_host(const Vk FIXME("Unexpected pNext\n"); }
-static void convert_VkSemaphoreGetWin32HandleInfoKHR_win32_to_host(const VkSemaphoreGetWin32HandleInfoKHR32 *in, VkSemaphoreGetWin32HandleInfoKHR *out) +static void convert_VkSemaphoreGetWin32HandleInfoKHR_win32_to_unwrapped_host(const VkSemaphoreGetWin32HandleInfoKHR32 *in, VkSemaphoreGetWin32HandleInfoKHR *out) { if (!in) return;
@@ -39076,7 +39078,7 @@ static void convert_VkImportFenceWin32HandleInfoKHR_win32_to_host(const VkImport FIXME("Unexpected pNext\n"); }
-static void convert_VkImportSemaphoreWin32HandleInfoKHR_win32_to_host(const VkImportSemaphoreWin32HandleInfoKHR32 *in, VkImportSemaphoreWin32HandleInfoKHR *out) +static void convert_VkImportSemaphoreWin32HandleInfoKHR_win32_to_unwrapped_host(const VkImportSemaphoreWin32HandleInfoKHR32 *in, VkImportSemaphoreWin32HandleInfoKHR *out) { if (!in) return;
@@ -39102,13 +39104,25 @@ static void convert_VkInitializePerformanceApiInfoINTEL_win32_to_host(const VkIn FIXME("Unexpected pNext\n"); }
+#ifdef _WIN64 +static void convert_VkLatencySleepInfoNV_win64_to_host(const VkLatencySleepInfoNV *in, VkLatencySleepInfoNV *out) +{ + if (!in) return; + + out->sType = in->sType; + out->pNext = in->pNext; + out->signalSemaphore = vulkan_semaphore_from_handle(in->signalSemaphore)->host.semaphore; + out->value = in->value; +} +#endif /* _WIN64 */ + static void convert_VkLatencySleepInfoNV_win32_to_host(const VkLatencySleepInfoNV32 *in, VkLatencySleepInfoNV *out) { if (!in) return;
out->sType = in->sType; out->pNext = NULL; - out->signalSemaphore = in->signalSemaphore; + out->signalSemaphore = vulkan_semaphore_from_handle(in->signalSemaphore)->host.semaphore; out->value = in->value; if (in->pNext) FIXME("Unexpected pNext\n"); @@ -39156,6 +39170,24 @@ static void convert_VkMemoryMapInfo_win32_to_unwrapped_host(const VkMemoryMapInf FIXME("Unexpected pNext\n"); }
+#ifdef _WIN64 +static const VkSemaphore *convert_VkSemaphore_array_win64_to_host(struct conversion_context *ctx, const VkSemaphore *in, uint32_t count) +{ + VkSemaphore *out; + unsigned int i; + + if (!in || !count) return NULL; + + out = conversion_context_alloc(ctx, count * sizeof(*out)); + for (i = 0; i < count; i++) + { + out[i] = vulkan_semaphore_from_handle(in[i])->host.semaphore; + } + + return out; +} +#endif /* _WIN64 */ + #ifdef _WIN64 static void convert_VkSparseMemoryBind_win64_to_host(const VkSparseMemoryBind *in, VkSparseMemoryBind *out) { @@ -39314,7 +39346,7 @@ static void convert_VkBindSparseInfo_win64_to_host(struct conversion_context *ct out->sType = in->sType; out->pNext = in->pNext; out->waitSemaphoreCount = in->waitSemaphoreCount; - out->pWaitSemaphores = in->pWaitSemaphores; + out->pWaitSemaphores = convert_VkSemaphore_array_win64_to_host(ctx, in->pWaitSemaphores, in->waitSemaphoreCount); out->bufferBindCount = in->bufferBindCount; out->pBufferBinds = convert_VkSparseBufferMemoryBindInfo_array_win64_to_host(ctx, in->pBufferBinds, in->bufferBindCount); out->imageOpaqueBindCount = in->imageOpaqueBindCount; @@ -39322,7 +39354,7 @@ static void convert_VkBindSparseInfo_win64_to_host(struct conversion_context *ct out->imageBindCount = in->imageBindCount; out->pImageBinds = convert_VkSparseImageMemoryBindInfo_array_win64_to_host(ctx, in->pImageBinds, in->imageBindCount); out->signalSemaphoreCount = in->signalSemaphoreCount; - out->pSignalSemaphores = in->pSignalSemaphores; + out->pSignalSemaphores = convert_VkSemaphore_array_win64_to_host(ctx, in->pSignalSemaphores, in->signalSemaphoreCount); } #endif /* _WIN64 */
@@ -39344,6 +39376,22 @@ static const VkBindSparseInfo *convert_VkBindSparseInfo_array_win64_to_host(stru } #endif /* _WIN64 */
+static const VkSemaphore *convert_VkSemaphore_array_win32_to_host(struct conversion_context *ctx, const VkSemaphore *in, uint32_t count) +{ + VkSemaphore *out; + unsigned int i; + + if (!in || !count) return NULL; + + out = conversion_context_alloc(ctx, count * sizeof(*out)); + for (i = 0; i < count; i++) + { + out[i] = vulkan_semaphore_from_handle(in[i])->host.semaphore; + } + + return out; +} + static void convert_VkSparseMemoryBind_win32_to_host(const VkSparseMemoryBind32 *in, VkSparseMemoryBind *out) { if (!in) return; @@ -39484,7 +39532,7 @@ static void convert_VkBindSparseInfo_win32_to_host(struct conversion_context *ct out->sType = in->sType; out->pNext = NULL; out->waitSemaphoreCount = in->waitSemaphoreCount; - out->pWaitSemaphores = UlongToPtr(in->pWaitSemaphores); + out->pWaitSemaphores = convert_VkSemaphore_array_win32_to_host(ctx, (const VkSemaphore *)UlongToPtr(in->pWaitSemaphores), in->waitSemaphoreCount); out->bufferBindCount = in->bufferBindCount; out->pBufferBinds = convert_VkSparseBufferMemoryBindInfo_array_win32_to_host(ctx, (const VkSparseBufferMemoryBindInfo32 *)UlongToPtr(in->pBufferBinds), in->bufferBindCount); out->imageOpaqueBindCount = in->imageOpaqueBindCount; @@ -39492,7 +39540,7 @@ static void convert_VkBindSparseInfo_win32_to_host(struct conversion_context *ct out->imageBindCount = in->imageBindCount; out->pImageBinds = convert_VkSparseImageMemoryBindInfo_array_win32_to_host(ctx, (const VkSparseImageMemoryBindInfo32 *)UlongToPtr(in->pImageBinds), in->imageBindCount); out->signalSemaphoreCount = in->signalSemaphoreCount; - out->pSignalSemaphores = UlongToPtr(in->pSignalSemaphores); + out->pSignalSemaphores = convert_VkSemaphore_array_win32_to_host(ctx, (const VkSemaphore *)UlongToPtr(in->pSignalSemaphores), in->signalSemaphoreCount);
for (in_header = UlongToPtr(in->pNext); in_header; in_header = UlongToPtr(in_header->pNext)) { @@ -39589,6 +39637,24 @@ static void convert_VkOutOfBandQueueTypeInfoNV_win32_to_host(const VkOutOfBandQu FIXME("Unexpected pNext\n"); }
+#ifdef _WIN64 +static const VkSemaphore *convert_VkSemaphore_array_win64_to_unwrapped_host(struct conversion_context *ctx, const VkSemaphore *in, uint32_t count) +{ + VkSemaphore *out; + unsigned int i; + + if (!in || !count) return NULL; + + out = conversion_context_alloc(ctx, count * sizeof(*out)); + for (i = 0; i < count; i++) + { + out[i] = in[i]; + } + + return out; +} +#endif /* _WIN64 */ + #ifdef _WIN64 static const VkSwapchainKHR *convert_VkSwapchainKHR_array_win64_to_unwrapped_host(struct conversion_context *ctx, const VkSwapchainKHR *in, uint32_t count) { @@ -39615,7 +39681,7 @@ static void convert_VkPresentInfoKHR_win64_to_unwrapped_host(struct conversion_c out->sType = in->sType; out->pNext = in->pNext; out->waitSemaphoreCount = in->waitSemaphoreCount; - out->pWaitSemaphores = in->pWaitSemaphores; + out->pWaitSemaphores = convert_VkSemaphore_array_win64_to_unwrapped_host(ctx, in->pWaitSemaphores, in->waitSemaphoreCount); out->swapchainCount = in->swapchainCount; out->pSwapchains = convert_VkSwapchainKHR_array_win64_to_unwrapped_host(ctx, in->pSwapchains, in->swapchainCount); out->pImageIndices = in->pImageIndices; @@ -39623,6 +39689,22 @@ static void convert_VkPresentInfoKHR_win64_to_unwrapped_host(struct conversion_c } #endif /* _WIN64 */
+static const VkSemaphore *convert_VkSemaphore_array_win32_to_unwrapped_host(struct conversion_context *ctx, const VkSemaphore *in, uint32_t count) +{ + VkSemaphore *out; + unsigned int i; + + if (!in || !count) return NULL; + + out = conversion_context_alloc(ctx, count * sizeof(*out)); + for (i = 0; i < count; i++) + { + out[i] = in[i]; + } + + return out; +} + static const VkSwapchainKHR *convert_VkSwapchainKHR_array_win32_to_unwrapped_host(struct conversion_context *ctx, const VkSwapchainKHR *in, uint32_t count) { VkSwapchainKHR *out; @@ -39673,7 +39755,7 @@ static void convert_VkPresentInfoKHR_win32_to_unwrapped_host(struct conversion_c out->sType = in->sType; out->pNext = NULL; out->waitSemaphoreCount = in->waitSemaphoreCount; - out->pWaitSemaphores = UlongToPtr(in->pWaitSemaphores); + out->pWaitSemaphores = convert_VkSemaphore_array_win32_to_unwrapped_host(ctx, (const VkSemaphore *)UlongToPtr(in->pWaitSemaphores), in->waitSemaphoreCount); out->swapchainCount = in->swapchainCount; out->pSwapchains = convert_VkSwapchainKHR_array_win32_to_unwrapped_host(ctx, (const VkSwapchainKHR *)UlongToPtr(in->pSwapchains), in->swapchainCount); out->pImageIndices = UlongToPtr(in->pImageIndices); @@ -39841,12 +39923,12 @@ static void convert_VkSubmitInfo_win64_to_unwrapped_host(struct conversion_conte out->sType = in->sType; out->pNext = NULL; out->waitSemaphoreCount = in->waitSemaphoreCount; - out->pWaitSemaphores = in->pWaitSemaphores; + out->pWaitSemaphores = convert_VkSemaphore_array_win64_to_unwrapped_host(ctx, in->pWaitSemaphores, in->waitSemaphoreCount); out->pWaitDstStageMask = in->pWaitDstStageMask; out->commandBufferCount = in->commandBufferCount; out->pCommandBuffers = convert_VkCommandBuffer_array_win64_to_unwrapped_host(ctx, in->pCommandBuffers, in->commandBufferCount); out->signalSemaphoreCount = in->signalSemaphoreCount; - out->pSignalSemaphores = in->pSignalSemaphores; + out->pSignalSemaphores = convert_VkSemaphore_array_win64_to_unwrapped_host(ctx, in->pSignalSemaphores, in->signalSemaphoreCount);
for (in_header = (void *)in->pNext; in_header; in_header = (void *)in_header->pNext) { @@ -40029,12 +40111,12 @@ static void convert_VkSubmitInfo_win32_to_unwrapped_host(struct conversion_conte out->sType = in->sType; out->pNext = NULL; out->waitSemaphoreCount = in->waitSemaphoreCount; - out->pWaitSemaphores = UlongToPtr(in->pWaitSemaphores); + out->pWaitSemaphores = convert_VkSemaphore_array_win32_to_unwrapped_host(ctx, (const VkSemaphore *)UlongToPtr(in->pWaitSemaphores), in->waitSemaphoreCount); out->pWaitDstStageMask = UlongToPtr(in->pWaitDstStageMask); out->commandBufferCount = in->commandBufferCount; out->pCommandBuffers = convert_VkCommandBuffer_array_win32_to_unwrapped_host(ctx, (const PTR32 *)UlongToPtr(in->pCommandBuffers), in->commandBufferCount); out->signalSemaphoreCount = in->signalSemaphoreCount; - out->pSignalSemaphores = UlongToPtr(in->pSignalSemaphores); + out->pSignalSemaphores = convert_VkSemaphore_array_win32_to_unwrapped_host(ctx, (const VkSemaphore *)UlongToPtr(in->pSignalSemaphores), in->signalSemaphoreCount);
for (in_header = UlongToPtr(in->pNext); in_header; in_header = UlongToPtr(in_header->pNext)) { @@ -40189,7 +40271,7 @@ static const VkSubmitInfo *convert_VkSubmitInfo_array_win32_to_unwrapped_host(st }
#ifdef _WIN64 -static void convert_VkSemaphoreSubmitInfo_win64_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo *in, VkSemaphoreSubmitInfo *out) +static void convert_VkSemaphoreSubmitInfo_win64_to_unwrapped_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo *in, VkSemaphoreSubmitInfo *out) { if (!in) return;
@@ -40202,6 +40284,38 @@ static void convert_VkSemaphoreSubmitInfo_win64_to_host(struct conversion_contex } #endif /* _WIN64 */
+#ifdef _WIN64 +static const VkSemaphoreSubmitInfo *convert_VkSemaphoreSubmitInfo_array_win64_to_unwrapped_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo *in, uint32_t count) +{ + VkSemaphoreSubmitInfo *out; + unsigned int i; + + if (!in || !count) return NULL; + + out = conversion_context_alloc(ctx, count * sizeof(*out)); + for (i = 0; i < count; i++) + { + convert_VkSemaphoreSubmitInfo_win64_to_unwrapped_host(ctx, &in[i], &out[i]); + } + + return out; +} +#endif /* _WIN64 */ + +#ifdef _WIN64 +static void convert_VkSemaphoreSubmitInfo_win64_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo *in, VkSemaphoreSubmitInfo *out) +{ + if (!in) return; + + out->sType = in->sType; + out->pNext = in->pNext; + out->semaphore = vulkan_semaphore_from_handle(in->semaphore)->host.semaphore; + out->value = in->value; + out->stageMask = in->stageMask; + out->deviceIndex = in->deviceIndex; +} +#endif /* _WIN64 */ + #ifdef _WIN64 static const VkSemaphoreSubmitInfo *convert_VkSemaphoreSubmitInfo_array_win64_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo *in, uint32_t count) { @@ -40287,11 +40401,11 @@ static void convert_VkSubmitInfo2_win64_to_unwrapped_host(struct conversion_cont out->pNext = NULL; out->flags = in->flags; out->waitSemaphoreInfoCount = in->waitSemaphoreInfoCount; - out->pWaitSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_host(ctx, in->pWaitSemaphoreInfos, in->waitSemaphoreInfoCount); + out->pWaitSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_unwrapped_host(ctx, in->pWaitSemaphoreInfos, in->waitSemaphoreInfoCount); out->commandBufferInfoCount = in->commandBufferInfoCount; out->pCommandBufferInfos = convert_VkCommandBufferSubmitInfo_array_win64_to_unwrapped_host(ctx, in->pCommandBufferInfos, in->commandBufferInfoCount); out->signalSemaphoreInfoCount = in->signalSemaphoreInfoCount; - out->pSignalSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_host(ctx, in->pSignalSemaphoreInfos, in->signalSemaphoreInfoCount); + out->pSignalSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_unwrapped_host(ctx, in->pSignalSemaphoreInfos, in->signalSemaphoreInfoCount);
for (in_header = (void *)in->pNext; in_header; in_header = (void *)in_header->pNext) { @@ -40393,7 +40507,7 @@ static const VkSubmitInfo2 *convert_VkSubmitInfo2_array_win64_to_unwrapped_host( } #endif /* _WIN64 */
-static void convert_VkSemaphoreSubmitInfo_win32_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo32 *in, VkSemaphoreSubmitInfo *out) +static void convert_VkSemaphoreSubmitInfo_win32_to_unwrapped_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo32 *in, VkSemaphoreSubmitInfo *out) { if (!in) return;
@@ -40407,6 +40521,36 @@ static void convert_VkSemaphoreSubmitInfo_win32_to_host(struct conversion_contex FIXME("Unexpected pNext\n"); }
+static const VkSemaphoreSubmitInfo *convert_VkSemaphoreSubmitInfo_array_win32_to_unwrapped_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo32 *in, uint32_t count) +{ + VkSemaphoreSubmitInfo *out; + unsigned int i; + + if (!in || !count) return NULL; + + out = conversion_context_alloc(ctx, count * sizeof(*out)); + for (i = 0; i < count; i++) + { + convert_VkSemaphoreSubmitInfo_win32_to_unwrapped_host(ctx, &in[i], &out[i]); + } + + return out; +} + +static void convert_VkSemaphoreSubmitInfo_win32_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo32 *in, VkSemaphoreSubmitInfo *out) +{ + if (!in) return; + + out->sType = in->sType; + out->pNext = NULL; + out->semaphore = vulkan_semaphore_from_handle(in->semaphore)->host.semaphore; + out->value = in->value; + out->stageMask = in->stageMask; + out->deviceIndex = in->deviceIndex; + if (in->pNext) + FIXME("Unexpected pNext\n"); +} + static const VkSemaphoreSubmitInfo *convert_VkSemaphoreSubmitInfo_array_win32_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo32 *in, uint32_t count) { VkSemaphoreSubmitInfo *out; @@ -40485,11 +40629,11 @@ static void convert_VkSubmitInfo2_win32_to_unwrapped_host(struct conversion_cont out->pNext = NULL; out->flags = in->flags; out->waitSemaphoreInfoCount = in->waitSemaphoreInfoCount; - out->pWaitSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win32_to_host(ctx, (const VkSemaphoreSubmitInfo32 *)UlongToPtr(in->pWaitSemaphoreInfos), in->waitSemaphoreInfoCount); + out->pWaitSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win32_to_unwrapped_host(ctx, (const VkSemaphoreSubmitInfo32 *)UlongToPtr(in->pWaitSemaphoreInfos), in->waitSemaphoreInfoCount); out->commandBufferInfoCount = in->commandBufferInfoCount; out->pCommandBufferInfos = convert_VkCommandBufferSubmitInfo_array_win32_to_unwrapped_host(ctx, (const VkCommandBufferSubmitInfo32 *)UlongToPtr(in->pCommandBufferInfos), in->commandBufferInfoCount); out->signalSemaphoreInfoCount = in->signalSemaphoreInfoCount; - out->pSignalSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win32_to_host(ctx, (const VkSemaphoreSubmitInfo32 *)UlongToPtr(in->pSignalSemaphoreInfos), in->signalSemaphoreInfoCount); + out->pSignalSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win32_to_unwrapped_host(ctx, (const VkSemaphoreSubmitInfo32 *)UlongToPtr(in->pSignalSemaphoreInfos), in->signalSemaphoreInfoCount);
for (in_header = UlongToPtr(in->pNext); in_header; in_header = UlongToPtr(in_header->pNext)) { @@ -40797,13 +40941,25 @@ static void convert_VkLatencySleepModeInfoNV_win32_to_host(const VkLatencySleepM FIXME("Unexpected pNext\n"); }
+#ifdef _WIN64 +static void convert_VkSemaphoreSignalInfo_win64_to_host(const VkSemaphoreSignalInfo *in, VkSemaphoreSignalInfo *out) +{ + if (!in) return; + + out->sType = in->sType; + out->pNext = in->pNext; + out->semaphore = vulkan_semaphore_from_handle(in->semaphore)->host.semaphore; + out->value = in->value; +} +#endif /* _WIN64 */ + static void convert_VkSemaphoreSignalInfo_win32_to_host(const VkSemaphoreSignalInfo32 *in, VkSemaphoreSignalInfo *out) { if (!in) return;
out->sType = in->sType; out->pNext = NULL; - out->semaphore = in->semaphore; + out->semaphore = vulkan_semaphore_from_handle(in->semaphore)->host.semaphore; out->value = in->value; if (in->pNext) FIXME("Unexpected pNext\n"); @@ -41141,7 +41297,21 @@ static void convert_VkPresentWait2InfoKHR_win32_to_host(const VkPresentWait2Info FIXME("Unexpected pNext\n"); }
-static void convert_VkSemaphoreWaitInfo_win32_to_host(const VkSemaphoreWaitInfo32 *in, VkSemaphoreWaitInfo *out) +#ifdef _WIN64 +static void convert_VkSemaphoreWaitInfo_win64_to_host(struct conversion_context *ctx, const VkSemaphoreWaitInfo *in, VkSemaphoreWaitInfo *out) +{ + if (!in) return; + + out->sType = in->sType; + out->pNext = in->pNext; + out->flags = in->flags; + out->semaphoreCount = in->semaphoreCount; + out->pSemaphores = convert_VkSemaphore_array_win64_to_host(ctx, in->pSemaphores, in->semaphoreCount); + out->pValues = in->pValues; +} +#endif /* _WIN64 */ + +static void convert_VkSemaphoreWaitInfo_win32_to_host(struct conversion_context *ctx, const VkSemaphoreWaitInfo32 *in, VkSemaphoreWaitInfo *out) { if (!in) return;
@@ -41149,7 +41319,7 @@ static void convert_VkSemaphoreWaitInfo_win32_to_host(const VkSemaphoreWaitInfo3 out->pNext = NULL; out->flags = in->flags; out->semaphoreCount = in->semaphoreCount; - out->pSemaphores = UlongToPtr(in->pSemaphores); + out->pSemaphores = convert_VkSemaphore_array_win32_to_host(ctx, (const VkSemaphore *)UlongToPtr(in->pSemaphores), in->semaphoreCount); out->pValues = UlongToPtr(in->pValues); if (in->pNext) FIXME("Unexpected pNext\n"); @@ -57820,7 +57990,7 @@ static NTSTATUS thunk64_vkGetSemaphoreCounterValue(void *args)
TRACE("%p, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->semaphore), params->pValue);
- params->result = vulkan_device_from_handle(params->device)->p_vkGetSemaphoreCounterValue(vulkan_device_from_handle(params->device)->host.device, params->semaphore, params->pValue); + params->result = vulkan_device_from_handle(params->device)->p_vkGetSemaphoreCounterValue(vulkan_device_from_handle(params->device)->host.device, vulkan_semaphore_from_handle(params->semaphore)->host.semaphore, params->pValue); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -57837,7 +58007,7 @@ static NTSTATUS thunk32_vkGetSemaphoreCounterValue(void *args)
TRACE("%#x, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->semaphore), params->pValue);
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetSemaphoreCounterValue(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->semaphore, (uint64_t *)UlongToPtr(params->pValue)); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetSemaphoreCounterValue(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, vulkan_semaphore_from_handle(params->semaphore)->host.semaphore, (uint64_t *)UlongToPtr(params->pValue)); return STATUS_SUCCESS; }
@@ -57848,7 +58018,7 @@ static NTSTATUS thunk64_vkGetSemaphoreCounterValueKHR(void *args)
TRACE("%p, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->semaphore), params->pValue);
- params->result = vulkan_device_from_handle(params->device)->p_vkGetSemaphoreCounterValueKHR(vulkan_device_from_handle(params->device)->host.device, params->semaphore, params->pValue); + params->result = vulkan_device_from_handle(params->device)->p_vkGetSemaphoreCounterValueKHR(vulkan_device_from_handle(params->device)->host.device, vulkan_semaphore_from_handle(params->semaphore)->host.semaphore, params->pValue); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -57865,7 +58035,7 @@ static NTSTATUS thunk32_vkGetSemaphoreCounterValueKHR(void *args)
TRACE("%#x, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->semaphore), params->pValue);
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetSemaphoreCounterValueKHR(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->semaphore, (uint64_t *)UlongToPtr(params->pValue)); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetSemaphoreCounterValueKHR(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, vulkan_semaphore_from_handle(params->semaphore)->host.semaphore, (uint64_t *)UlongToPtr(params->pValue)); return STATUS_SUCCESS; }
@@ -57894,7 +58064,7 @@ static NTSTATUS thunk32_vkGetSemaphoreWin32HandleKHR(void *args)
TRACE("%#x, %#x, %#x\n", params->device, params->pGetWin32HandleInfo, params->pHandle);
- convert_VkSemaphoreGetWin32HandleInfoKHR_win32_to_host((const VkSemaphoreGetWin32HandleInfoKHR32 *)UlongToPtr(params->pGetWin32HandleInfo), &pGetWin32HandleInfo_host); + convert_VkSemaphoreGetWin32HandleInfoKHR_win32_to_unwrapped_host((const VkSemaphoreGetWin32HandleInfoKHR32 *)UlongToPtr(params->pGetWin32HandleInfo), &pGetWin32HandleInfo_host); params->result = vk_funcs->p_vkGetSemaphoreWin32HandleKHR((VkDevice)UlongToPtr(params->device), &pGetWin32HandleInfo_host, (HANDLE *)UlongToPtr(params->pHandle)); return STATUS_SUCCESS; } @@ -58277,7 +58447,7 @@ static NTSTATUS thunk32_vkImportSemaphoreWin32HandleKHR(void *args)
TRACE("%#x, %#x\n", params->device, params->pImportSemaphoreWin32HandleInfo);
- convert_VkImportSemaphoreWin32HandleInfoKHR_win32_to_host((const VkImportSemaphoreWin32HandleInfoKHR32 *)UlongToPtr(params->pImportSemaphoreWin32HandleInfo), &pImportSemaphoreWin32HandleInfo_host); + convert_VkImportSemaphoreWin32HandleInfoKHR_win32_to_unwrapped_host((const VkImportSemaphoreWin32HandleInfoKHR32 *)UlongToPtr(params->pImportSemaphoreWin32HandleInfo), &pImportSemaphoreWin32HandleInfo_host); params->result = vk_funcs->p_vkImportSemaphoreWin32HandleKHR((VkDevice)UlongToPtr(params->device), &pImportSemaphoreWin32HandleInfo_host); return STATUS_SUCCESS; } @@ -58355,10 +58525,12 @@ static NTSTATUS thunk32_vkInvalidateMappedMemoryRanges(void *args) static NTSTATUS thunk64_vkLatencySleepNV(void *args) { struct vkLatencySleepNV_params *params = args; + VkLatencySleepInfoNV pSleepInfo_host;
TRACE("%p, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->swapchain), params->pSleepInfo);
- params->result = vulkan_device_from_handle(params->device)->p_vkLatencySleepNV(vulkan_device_from_handle(params->device)->host.device, vulkan_swapchain_from_handle(params->swapchain)->host.swapchain, params->pSleepInfo); + convert_VkLatencySleepInfoNV_win64_to_host(params->pSleepInfo, &pSleepInfo_host); + params->result = vulkan_device_from_handle(params->device)->p_vkLatencySleepNV(vulkan_device_from_handle(params->device)->host.device, vulkan_swapchain_from_handle(params->swapchain)->host.swapchain, &pSleepInfo_host); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -59525,10 +59697,12 @@ static NTSTATUS thunk32_vkSetPrivateDataEXT(void *args) static NTSTATUS thunk64_vkSignalSemaphore(void *args) { struct vkSignalSemaphore_params *params = args; + VkSemaphoreSignalInfo pSignalInfo_host;
TRACE("%p, %p\n", params->device, params->pSignalInfo);
- params->result = vulkan_device_from_handle(params->device)->p_vkSignalSemaphore(vulkan_device_from_handle(params->device)->host.device, params->pSignalInfo); + convert_VkSemaphoreSignalInfo_win64_to_host(params->pSignalInfo, &pSignalInfo_host); + params->result = vulkan_device_from_handle(params->device)->p_vkSignalSemaphore(vulkan_device_from_handle(params->device)->host.device, &pSignalInfo_host); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -59554,10 +59728,12 @@ static NTSTATUS thunk32_vkSignalSemaphore(void *args) static NTSTATUS thunk64_vkSignalSemaphoreKHR(void *args) { struct vkSignalSemaphoreKHR_params *params = args; + VkSemaphoreSignalInfo pSignalInfo_host;
TRACE("%p, %p\n", params->device, params->pSignalInfo);
- params->result = vulkan_device_from_handle(params->device)->p_vkSignalSemaphoreKHR(vulkan_device_from_handle(params->device)->host.device, params->pSignalInfo); + convert_VkSemaphoreSignalInfo_win64_to_host(params->pSignalInfo, &pSignalInfo_host); + params->result = vulkan_device_from_handle(params->device)->p_vkSignalSemaphoreKHR(vulkan_device_from_handle(params->device)->host.device, &pSignalInfo_host); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -60128,10 +60304,16 @@ static NTSTATUS thunk32_vkWaitForPresentKHR(void *args) static NTSTATUS thunk64_vkWaitSemaphores(void *args) { struct vkWaitSemaphores_params *params = args; + VkSemaphoreWaitInfo pWaitInfo_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%p, %p, 0x%s\n", params->device, params->pWaitInfo, wine_dbgstr_longlong(params->timeout));
- params->result = vulkan_device_from_handle(params->device)->p_vkWaitSemaphores(vulkan_device_from_handle(params->device)->host.device, params->pWaitInfo, params->timeout); + init_conversion_context(ctx); + convert_VkSemaphoreWaitInfo_win64_to_host(ctx, params->pWaitInfo, &pWaitInfo_host); + params->result = vulkan_device_from_handle(params->device)->p_vkWaitSemaphores(vulkan_device_from_handle(params->device)->host.device, &pWaitInfo_host, params->timeout); + free_conversion_context(ctx); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -60146,11 +60328,15 @@ static NTSTATUS thunk32_vkWaitSemaphores(void *args) VkResult result; } *params = args; VkSemaphoreWaitInfo pWaitInfo_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%#x, %#x, 0x%s\n", params->device, params->pWaitInfo, wine_dbgstr_longlong(params->timeout));
- convert_VkSemaphoreWaitInfo_win32_to_host((const VkSemaphoreWaitInfo32 *)UlongToPtr(params->pWaitInfo), &pWaitInfo_host); + init_conversion_context(ctx); + convert_VkSemaphoreWaitInfo_win32_to_host(ctx, (const VkSemaphoreWaitInfo32 *)UlongToPtr(params->pWaitInfo), &pWaitInfo_host); params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkWaitSemaphores(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, &pWaitInfo_host, params->timeout); + free_conversion_context(ctx); return STATUS_SUCCESS; }
@@ -60158,10 +60344,16 @@ static NTSTATUS thunk32_vkWaitSemaphores(void *args) static NTSTATUS thunk64_vkWaitSemaphoresKHR(void *args) { struct vkWaitSemaphoresKHR_params *params = args; + VkSemaphoreWaitInfo pWaitInfo_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%p, %p, 0x%s\n", params->device, params->pWaitInfo, wine_dbgstr_longlong(params->timeout));
- params->result = vulkan_device_from_handle(params->device)->p_vkWaitSemaphoresKHR(vulkan_device_from_handle(params->device)->host.device, params->pWaitInfo, params->timeout); + init_conversion_context(ctx); + convert_VkSemaphoreWaitInfo_win64_to_host(ctx, params->pWaitInfo, &pWaitInfo_host); + params->result = vulkan_device_from_handle(params->device)->p_vkWaitSemaphoresKHR(vulkan_device_from_handle(params->device)->host.device, &pWaitInfo_host, params->timeout); + free_conversion_context(ctx); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -60176,11 +60368,15 @@ static NTSTATUS thunk32_vkWaitSemaphoresKHR(void *args) VkResult result; } *params = args; VkSemaphoreWaitInfo pWaitInfo_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%#x, %#x, 0x%s\n", params->device, params->pWaitInfo, wine_dbgstr_longlong(params->timeout));
- convert_VkSemaphoreWaitInfo_win32_to_host((const VkSemaphoreWaitInfo32 *)UlongToPtr(params->pWaitInfo), &pWaitInfo_host); + init_conversion_context(ctx); + convert_VkSemaphoreWaitInfo_win32_to_host(ctx, (const VkSemaphoreWaitInfo32 *)UlongToPtr(params->pWaitInfo), &pWaitInfo_host); params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkWaitSemaphoresKHR(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, &pWaitInfo_host, params->timeout); + free_conversion_context(ctx); return STATUS_SUCCESS; }
@@ -60677,6 +60873,7 @@ BOOL wine_vk_is_type_wrapped(VkObjectType type) type == VK_OBJECT_TYPE_INSTANCE || type == VK_OBJECT_TYPE_PHYSICAL_DEVICE || type == VK_OBJECT_TYPE_QUEUE || + type == VK_OBJECT_TYPE_SEMAPHORE || type == VK_OBJECT_TYPE_SURFACE_KHR || type == VK_OBJECT_TYPE_SWAPCHAIN_KHR; } diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index 64cb609ed32..5619f28e3e3 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -47,7 +47,7 @@ struct vulkan_client_object #include "wine/rbtree.h"
/* Wine internal vulkan driver version, needs to be bumped upon vulkan_funcs changes. */ -#define WINE_VULKAN_DRIVER_VERSION 44 +#define WINE_VULKAN_DRIVER_VERSION 45
struct vulkan_object { @@ -182,6 +182,16 @@ static inline struct vulkan_swapchain *vulkan_swapchain_from_handle( VkSwapchain return (struct vulkan_swapchain *)(UINT_PTR)handle; }
+struct vulkan_semaphore +{ + VULKAN_OBJECT_HEADER( VkSemaphore, semaphore ); +}; + +static inline struct vulkan_semaphore *vulkan_semaphore_from_handle( VkSemaphore handle ) +{ + return (struct vulkan_semaphore *)(UINT_PTR)handle; +} + struct vulkan_funcs { /* Vulkan global functions. These are the only calls at this point a graphics driver