For shared resources.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 106 ++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 58 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 32f48f6bc9c..d060c7fd006 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -530,22 +530,16 @@ static void wine_vk_device_init_queues(struct wine_device *object, const VkDevic object->queue_count += info->queueCount; }
-static const char *find_extension(const char *const *extensions, uint32_t count, const char *ext) -{ - while (count--) - { - if (!strcmp(extensions[count], ext)) - return extensions[count]; - } - return NULL; -} - -static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physical_device, +static VkResult wine_vk_device_convert_create_info(struct vulkan_physical_device *physical_device, struct conversion_context *ctx, const VkDeviceCreateInfo *src, VkDeviceCreateInfo *dst) { - struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle(client_physical_device); - const char *extra_extensions[3], * const*extensions = src->ppEnabledExtensionNames; - unsigned int i, extra_count = 0, extensions_count = src->enabledExtensionCount; + bool has_swapchain_maintenance1 = false; + bool has_external_memory_host = false; + bool has_map_memory_placed = false; + bool has_external_memory = false; + bool has_map_memory2 = false; + const char **extensions; + uint32_t count;
*dst = *src;
@@ -553,16 +547,23 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi dst->enabledLayerCount = 0; dst->ppEnabledLayerNames = NULL;
- TRACE("Enabled %u extensions.\n", extensions_count); - for (i = 0; i < extensions_count; i++) + count = src->enabledExtensionCount; + extensions = conversion_context_alloc(ctx, (count + 16) * sizeof(*extensions)); + memcpy(extensions, dst->ppEnabledExtensionNames, count * sizeof(*extensions)); + dst->ppEnabledExtensionNames = extensions; + + for (const char **extension = extensions, **end = extension + count; extension < end; extension++) { - const char *extension_name = extensions[i]; - TRACE("Extension %u: %s.\n", i, debugstr_a(extension_name)); - if (!wine_vk_device_extension_supported(extension_name)) + if (!wine_vk_device_extension_supported(*extension)) { - WARN("Extension %s is not supported.\n", debugstr_a(extension_name)); + WARN("Extension %s is not supported.\n", debugstr_a(*extension)); return VK_ERROR_EXTENSION_NOT_PRESENT; } + if (!strcmp(*extension, "VK_EXT_map_memory_placed")) has_map_memory_placed = true; + if (!strcmp(*extension, "VK_KHR_map_memory2")) has_map_memory2 = true; + if (!strcmp(*extension, "VK_KHR_external_memory")) has_external_memory = true; + if (!strcmp(*extension, "VK_EXT_external_memory_host")) has_external_memory_host = true; + if (!strcmp(*extension, "VK_EXT_swapchain_maintenance1")) has_swapchain_maintenance1 = true; }
if (physical_device->map_placed_align) @@ -576,37 +577,24 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi map_placed_features->memoryUnmapReserve = VK_TRUE; dst->pNext = map_placed_features;
- if (!find_extension(extensions, extensions_count, "VK_EXT_map_memory_placed")) - extra_extensions[extra_count++] = "VK_EXT_map_memory_placed"; - if (!find_extension(extensions, extensions_count, "VK_KHR_map_memory2")) - extra_extensions[extra_count++] = "VK_KHR_map_memory2"; + if (!has_map_memory_placed) extensions[count++] = "VK_EXT_map_memory_placed"; + if (!has_map_memory2) extensions[count++] = "VK_KHR_map_memory2"; } else if (physical_device->external_memory_align) { - if (!find_extension(extensions, extensions_count, "VK_KHR_external_memory")) - extra_extensions[extra_count++] = "VK_KHR_external_memory"; - if (!find_extension(extensions, extensions_count, "VK_EXT_external_memory_host")) - extra_extensions[extra_count++] = "VK_EXT_external_memory_host"; + if (!has_external_memory) extensions[count++] = "VK_KHR_external_memory"; + if (!has_external_memory_host) extensions[count++] = "VK_EXT_external_memory_host"; }
/* win32u uses VkSwapchainPresentScalingCreateInfoEXT if available. */ - if (physical_device->has_swapchain_maintenance1) - { - if (!find_extension(extensions, extensions_count, "VK_EXT_swapchain_maintenance1")) - extra_extensions[extra_count++] = "VK_EXT_swapchain_maintenance1"; - } + if (physical_device->has_swapchain_maintenance1 && !has_swapchain_maintenance1) + extensions[count++] = "VK_EXT_swapchain_maintenance1";
- if (extra_count) - { - const char **new_extensions; - - dst->enabledExtensionCount += extra_count; - new_extensions = conversion_context_alloc(ctx, dst->enabledExtensionCount * sizeof(*new_extensions)); - memcpy(new_extensions, extensions, extensions_count * sizeof(*new_extensions)); - memcpy(new_extensions + extensions_count, extra_extensions, extra_count * sizeof(*new_extensions)); - dst->ppEnabledExtensionNames = new_extensions; - } + TRACE("Enabling %u device extensions\n", count); + for (const char **extension = extensions, **end = extension + count; extension < end; extension++) + TRACE(" - %s\n", debugstr_a(*extension));
+ dst->enabledExtensionCount = count; return VK_SUCCESS; }
@@ -646,9 +634,10 @@ static VkResult wine_vk_instance_convert_create_info(struct conversion_context * { VkDebugUtilsMessengerCreateInfoEXT *debug_utils_messenger; VkDebugReportCallbackCreateInfoEXT *debug_report_callback; - const char **new_extensions; VkBaseInStructure *header; + const char **extensions; unsigned int i; + uint32_t count;
*dst = *src;
@@ -701,36 +690,37 @@ static VkResult wine_vk_instance_convert_create_info(struct conversion_context * } }
- new_extensions = conversion_context_alloc(ctx, (src->enabledExtensionCount + 2) * - sizeof(*src->ppEnabledExtensionNames)); - memcpy(new_extensions, src->ppEnabledExtensionNames, - dst->enabledExtensionCount * sizeof(*dst->ppEnabledExtensionNames)); - dst->ppEnabledExtensionNames = new_extensions; + count = src->enabledExtensionCount; + extensions = conversion_context_alloc(ctx, (count + 2) * sizeof(*extensions)); + memcpy(extensions, src->ppEnabledExtensionNames, count * sizeof(*dst->ppEnabledExtensionNames)); + dst->ppEnabledExtensionNames = extensions; dst->enabledExtensionCount = src->enabledExtensionCount;
- for (i = 0; i < dst->enabledExtensionCount; i++) + for (const char **extension = extensions, **end = extension + count; extension < end; extension++) { - const char *extension_name = dst->ppEnabledExtensionNames[i]; - if (!strcmp(extension_name, "VK_EXT_debug_utils") || !strcmp(extension_name, "VK_EXT_debug_report")) + if (!strcmp(*extension, "VK_EXT_debug_utils") || !strcmp(*extension, "VK_EXT_debug_report")) { rb_init(&instance->objects, vulkan_object_compare); pthread_rwlock_init(&instance->objects_lock, NULL); } - if (!strcmp(extension_name, "VK_KHR_win32_surface")) + if (!strcmp(*extension, "VK_KHR_win32_surface")) { - new_extensions[i] = vk_funcs->p_get_host_surface_extension(); + *extension = vk_funcs->p_get_host_surface_extension(); instance->enable_win32_surface = VK_TRUE; } }
if (use_external_memory()) { - new_extensions[dst->enabledExtensionCount++] = "VK_KHR_get_physical_device_properties2"; - new_extensions[dst->enabledExtensionCount++] = "VK_KHR_external_memory_capabilities"; + extensions[count++] = "VK_KHR_get_physical_device_properties2"; + extensions[count++] = "VK_KHR_external_memory_capabilities"; }
- TRACE("Enabled %u instance extensions.\n", dst->enabledExtensionCount); + TRACE("Enabling %u instance extensions\n", count); + for (const char **extension = extensions, **end = extension + count; extension < end; extension++) + TRACE(" - %s\n", debugstr_a(*extension));
+ dst->enabledExtensionCount = count; return VK_SUCCESS; }
@@ -894,7 +884,7 @@ VkResult wine_vkCreateDevice(VkPhysicalDevice client_physical_device, const VkDe return VK_ERROR_OUT_OF_HOST_MEMORY;
init_conversion_context(&ctx); - res = wine_vk_device_convert_create_info(client_physical_device, &ctx, create_info, &create_info_host); + res = wine_vk_device_convert_create_info(physical_device, &ctx, create_info, &create_info_host); if (res == VK_SUCCESS) res = instance->p_vkCreateDevice(physical_device->host.physical_device, &create_info_host, NULL /* allocator */, &host_device);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 2 +- dlls/winevulkan/vulkan.c | 12 +++++++++++- include/wine/vulkan_driver.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index a3546bf2291..dff20c7f7ef 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -876,7 +876,7 @@ static VkResult win32u_vkCreateSwapchainKHR( VkDevice client_device, const VkSwa */ if (NtUserGetClientRect( surface->hwnd, &client_rect, NtUserGetWinMonitorDpi( surface->hwnd, MDT_RAW_DPI ) ) && !extents_equals( &create_info_host.imageExtent, &client_rect ) && - physical_device->has_swapchain_maintenance1) + physical_device->has_surface_maintenance1 && physical_device->has_swapchain_maintenance1) { scaling.scalingBehavior = VK_PRESENT_SCALING_STRETCH_BIT_EXT; create_info_host.pNext = &scaling; diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index d060c7fd006..19d2ba7ef42 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -379,6 +379,8 @@ static VkResult vulkan_physical_device_init(struct vulkan_physical_device *physi have_external_memory_host = TRUE; else if (!strcmp(host_properties[i].extensionName, "VK_EXT_map_memory_placed")) have_memory_placed = TRUE; + else if (!strcmp(host_properties[i].extensionName, "VK_EXT_surface_maintenance1")) + physical_device->has_surface_maintenance1 = true; else if (!strcmp(host_properties[i].extensionName, "VK_EXT_swapchain_maintenance1")) physical_device->has_swapchain_maintenance1 = true; else if (!strcmp(host_properties[i].extensionName, "VK_KHR_map_memory2")) @@ -535,9 +537,11 @@ static VkResult wine_vk_device_convert_create_info(struct vulkan_physical_device { bool has_swapchain_maintenance1 = false; bool has_external_memory_host = false; + bool has_surface_maintenance1 = false; bool has_map_memory_placed = false; bool has_external_memory = false; bool has_map_memory2 = false; + bool has_swapchain = false; const char **extensions; uint32_t count;
@@ -564,6 +568,8 @@ static VkResult wine_vk_device_convert_create_info(struct vulkan_physical_device if (!strcmp(*extension, "VK_KHR_external_memory")) has_external_memory = true; if (!strcmp(*extension, "VK_EXT_external_memory_host")) has_external_memory_host = true; if (!strcmp(*extension, "VK_EXT_swapchain_maintenance1")) has_swapchain_maintenance1 = true; + if (!strcmp(*extension, "VK_EXT_surface_maintenance1")) has_surface_maintenance1 = true; + if (!strcmp(*extension, "VK_KHR_swapchain")) has_swapchain = true; }
if (physical_device->map_placed_align) @@ -587,8 +593,12 @@ static VkResult wine_vk_device_convert_create_info(struct vulkan_physical_device }
/* win32u uses VkSwapchainPresentScalingCreateInfoEXT if available. */ - if (physical_device->has_swapchain_maintenance1 && !has_swapchain_maintenance1) + if (physical_device->has_surface_maintenance1 && physical_device->has_swapchain_maintenance1 && + has_swapchain && !has_swapchain_maintenance1) + { + if (!has_surface_maintenance1) extensions[count++] = "VK_EXT_surface_maintenance1"; extensions[count++] = "VK_EXT_swapchain_maintenance1"; + }
TRACE("Enabling %u device extensions\n", count); for (const char **extension = extensions, **end = extension + count; extension < end; extension++) diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index 9b42e895f01..64cb609ed32 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -94,6 +94,7 @@ struct vulkan_physical_device { VULKAN_OBJECT_HEADER( VkPhysicalDevice, physical_device ); struct vulkan_instance *instance; + bool has_surface_maintenance1; bool has_swapchain_maintenance1;
VkExtensionProperties *extensions;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index dff20c7f7ef..21e91de36ce 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -963,14 +963,14 @@ static VkResult win32u_vkAcquireNextImageKHR( VkDevice client_device, VkSwapchai return res; }
-static VkResult win32u_vkQueuePresentKHR( VkQueue client_queue, const VkPresentInfoKHR *present_info ) +static VkResult win32u_vkQueuePresentKHR( VkQueue client_queue, const VkPresentInfoKHR *client_present_info ) { + VkPresentInfoKHR *present_info = (VkPresentInfoKHR *)client_present_info; /* cast away const, it has been copied in the thunks */ struct vulkan_queue *queue = vulkan_queue_from_handle( client_queue ); VkSwapchainKHR swapchains_buffer[16], *swapchains = swapchains_buffer; - VkPresentInfoKHR present_info_host = *present_info; struct vulkan_device *device = queue->device; + const VkSwapchainKHR *client_swapchains; VkResult res; - UINT i;
TRACE( "queue %p, present_info %p\n", queue, present_info );
@@ -978,19 +978,20 @@ static VkResult win32u_vkQueuePresentKHR( VkQueue client_queue, const VkPresentI !(swapchains = malloc( present_info->swapchainCount * sizeof(*swapchains) ))) return VK_ERROR_OUT_OF_HOST_MEMORY;
- for (i = 0; i < present_info->swapchainCount; i++) + for (uint32_t i = 0; i < present_info->swapchainCount; i++) { struct swapchain *swapchain = swapchain_from_handle( present_info->pSwapchains[i] ); swapchains[i] = swapchain->obj.host.swapchain; }
- present_info_host.pSwapchains = swapchains; + client_swapchains = present_info->pSwapchains; + present_info->pSwapchains = swapchains;
- res = device->p_vkQueuePresentKHR( queue->host.queue, &present_info_host ); + res = device->p_vkQueuePresentKHR( queue->host.queue, present_info );
- for (i = 0; i < present_info->swapchainCount; i++) + for (uint32_t i = 0; i < present_info->swapchainCount; i++) { - struct swapchain *swapchain = swapchain_from_handle( present_info->pSwapchains[i] ); + struct swapchain *swapchain = swapchain_from_handle( client_swapchains[i] ); VkResult swapchain_res = present_info->pResults ? present_info->pResults[i] : res; struct surface *surface = swapchain->surface; RECT client_rect;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/make_vulkan | 3 +++ dlls/winevulkan/vulkan_thunks.c | 42 +++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 998f68fd8eb..f8dac7568d7 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -312,6 +312,7 @@ STRUCT_CHAIN_CONVERSIONS = { "VkPhysicalDeviceImageFormatInfo2": {}, "VkCommandBufferSubmitInfo": {}, "VkSemaphoreCreateInfo": {}, + "VkSemaphoreSubmitInfo": {}, "VkFenceCreateInfo": {}, "VkSubmitInfo": {}, "VkSubmitInfo2": {}, @@ -2265,6 +2266,8 @@ class StructConversionFunction(object):
if self.direction == Direction.OUTPUT and not any([any([self.member_needs_copy(ext, m) for m in ext]) for ext in self.operand.struct_extensions]): needs_extensions = False + if len(self.operand.struct_extensions) == 0: + needs_extensions = False
body += "{\n" if needs_extensions: diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index b6d5c15e989..03a896fac3b 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -40188,6 +40188,38 @@ static const VkSubmitInfo *convert_VkSubmitInfo_array_win32_to_unwrapped_host(st return out; }
+#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 = in->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) +{ + 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_host(ctx, &in[i], &out[i]); + } + + return out; +} +#endif /* _WIN64 */ + #ifdef _WIN64 static void convert_VkCommandBufferSubmitInfo_win64_to_unwrapped_host(struct conversion_context *ctx, const VkCommandBufferSubmitInfo *in, VkCommandBufferSubmitInfo *out) { @@ -40212,7 +40244,7 @@ static void convert_VkCommandBufferSubmitInfo_win64_to_unwrapped_host(struct con out_ext->sType = VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_SUBMIT_INFO_ARM; out_ext->pNext = NULL; out_ext->stripeSemaphoreInfoCount = in_ext->stripeSemaphoreInfoCount; - out_ext->pStripeSemaphoreInfos = in_ext->pStripeSemaphoreInfos; + out_ext->pStripeSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_host(ctx, in_ext->pStripeSemaphoreInfos, in_ext->stripeSemaphoreInfoCount); out_header->pNext = (void *)out_ext; out_header = (void *)out_ext; break; @@ -40255,11 +40287,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 = in->pWaitSemaphoreInfos; + out->pWaitSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_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 = in->pSignalSemaphoreInfos; + out->pSignalSemaphoreInfos = convert_VkSemaphoreSubmitInfo_array_win64_to_host(ctx, in->pSignalSemaphoreInfos, in->signalSemaphoreInfoCount);
for (in_header = (void *)in->pNext; in_header; in_header = (void *)in_header->pNext) { @@ -40361,7 +40393,7 @@ static const VkSubmitInfo2 *convert_VkSubmitInfo2_array_win64_to_unwrapped_host( } #endif /* _WIN64 */
-static void convert_VkSemaphoreSubmitInfo_win32_to_host(const VkSemaphoreSubmitInfo32 *in, VkSemaphoreSubmitInfo *out) +static void convert_VkSemaphoreSubmitInfo_win32_to_host(struct conversion_context *ctx, const VkSemaphoreSubmitInfo32 *in, VkSemaphoreSubmitInfo *out) { if (!in) return;
@@ -40385,7 +40417,7 @@ static const VkSemaphoreSubmitInfo *convert_VkSemaphoreSubmitInfo_array_win32_to out = conversion_context_alloc(ctx, count * sizeof(*out)); for (i = 0; i < count; i++) { - convert_VkSemaphoreSubmitInfo_win32_to_host(&in[i], &out[i]); + convert_VkSemaphoreSubmitInfo_win32_to_host(ctx, &in[i], &out[i]); }
return out;
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
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 64 ++++++++-- dlls/winevulkan/make_vulkan | 2 + dlls/winevulkan/vulkan_thunks.c | 206 +++++++++++++++++++++++++++++--- include/wine/vulkan_driver.h | 12 +- 4 files changed, 257 insertions(+), 27 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index e091016bbcb..f54a3a4bddc 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -97,12 +97,23 @@ struct semaphore struct vulkan_semaphore obj; };
-static inline struct semaphore *semaphore_from_handle( VkSemaphore handle ) +static struct semaphore *semaphore_from_handle( VkSemaphore handle ) { struct vulkan_semaphore *obj = vulkan_semaphore_from_handle( handle ); return CONTAINING_RECORD( obj, struct semaphore, obj ); }
+struct fence +{ + struct vulkan_fence obj; +}; + +static struct fence *fence_from_handle( VkFence handle ) +{ + struct vulkan_fence *obj = vulkan_fence_from_handle( handle ); + return CONTAINING_RECORD( obj, struct fence, obj ); +} + static VkResult allocate_external_host_memory( struct vulkan_device *device, VkMemoryAllocateInfo *alloc_info, uint32_t mem_flags, VkImportMemoryHostPointerInfoEXT *import_info ) { @@ -930,6 +941,7 @@ static VkResult win32u_vkAcquireNextImage2KHR( VkDevice client_device, const VkA uint32_t *image_index ) { struct vulkan_semaphore *semaphore = acquire_info->semaphore ? vulkan_semaphore_from_handle( acquire_info->semaphore ) : NULL; + struct vulkan_fence *fence = acquire_info->fence ? vulkan_fence_from_handle( acquire_info->fence ) : 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; @@ -939,6 +951,7 @@ static VkResult win32u_vkAcquireNextImage2KHR( VkDevice client_device, const VkA
acquire_info_host.swapchain = swapchain->obj.host.swapchain; acquire_info_host.semaphore = semaphore ? semaphore->host.semaphore : 0; + acquire_info_host.fence = fence ? fence->host.fence : 0; res = device->p_vkAcquireNextImage2KHR( device->host.device, &acquire_info_host, image_index );
if (!res && NtUserGetClientRect( surface->hwnd, &client_rect, NtUserGetDpiForWindow( surface->hwnd ) ) && @@ -953,9 +966,10 @@ static VkResult win32u_vkAcquireNextImage2KHR( VkDevice client_device, const VkA }
static VkResult win32u_vkAcquireNextImageKHR( VkDevice client_device, VkSwapchainKHR client_swapchain, uint64_t timeout, - VkSemaphore client_semaphore, VkFence fence, uint32_t *image_index ) + VkSemaphore client_semaphore, VkFence client_fence, uint32_t *image_index ) { struct vulkan_semaphore *semaphore = client_semaphore ? vulkan_semaphore_from_handle( client_semaphore ) : NULL; + struct vulkan_fence *fence = client_fence ? vulkan_fence_from_handle( client_fence ) : NULL; struct swapchain *swapchain = swapchain_from_handle( client_swapchain ); struct vulkan_device *device = vulkan_device_from_handle( client_device ); struct surface *surface = swapchain->surface; @@ -963,7 +977,8 @@ static VkResult win32u_vkAcquireNextImageKHR( VkDevice client_device, VkSwapchai VkResult res;
res = device->p_vkAcquireNextImageKHR( device->host.device, swapchain->obj.host.swapchain, timeout, - semaphore ? semaphore->host.semaphore : 0, fence, image_index ); + semaphore ? semaphore->host.semaphore : 0, fence ? fence->host.fence : 0, + image_index );
if (!res && NtUserGetClientRect( surface->hwnd, &client_rect, NtUserGetDpiForWindow( surface->hwnd ) ) && !extents_equals( &swapchain->extents, &client_rect )) @@ -1062,12 +1077,13 @@ static VkResult win32u_vkQueuePresentKHR( VkQueue client_queue, const VkPresentI return res; }
-static VkResult win32u_vkQueueSubmit( VkQueue client_queue, uint32_t count, const VkSubmitInfo *submits, VkFence fence ) +static VkResult win32u_vkQueueSubmit( VkQueue client_queue, uint32_t count, const VkSubmitInfo *submits, VkFence client_fence ) { + struct vulkan_fence *fence = client_fence ? vulkan_fence_from_handle( client_fence ) : NULL; struct vulkan_queue *queue = vulkan_queue_from_handle( client_queue ); struct vulkan_device *device = queue->device;
- TRACE( "queue %p, count %u, submits %p, fence 0x%s\n", queue, count, submits, wine_dbgstr_longlong( fence ) ); + TRACE( "queue %p, count %u, submits %p, fence %p\n", queue, count, submits, fence );
for (uint32_t i = 0; i < count; i++) { @@ -1119,15 +1135,16 @@ static VkResult win32u_vkQueueSubmit( VkQueue client_queue, uint32_t count, cons } }
- return device->p_vkQueueSubmit( queue->host.queue, count, submits, fence ); + return device->p_vkQueueSubmit( queue->host.queue, count, submits, fence ? fence->host.fence : 0 ); }
-static VkResult win32u_vkQueueSubmit2( VkQueue client_queue, uint32_t count, const VkSubmitInfo2 *submits, VkFence fence ) +static VkResult win32u_vkQueueSubmit2( VkQueue client_queue, uint32_t count, const VkSubmitInfo2 *submits, VkFence client_fence ) { + struct vulkan_fence *fence = client_fence ? vulkan_fence_from_handle( client_fence ) : NULL; struct vulkan_queue *queue = vulkan_queue_from_handle( client_queue ); struct vulkan_device *device = queue->device;
- TRACE( "queue %p, count %u, submits %p, fence 0x%s\n", queue, count, submits, wine_dbgstr_longlong( fence ) ); + TRACE( "queue %p, count %u, submits %p, fence %p\n", queue, count, submits, fence );
for (uint32_t i = 0; i < count; i++) { @@ -1175,7 +1192,7 @@ static VkResult win32u_vkQueueSubmit2( VkQueue client_queue, uint32_t count, con } }
- return device->p_vkQueueSubmit2( queue->host.queue, count, submits, fence ); + return device->p_vkQueueSubmit2( queue->host.queue, count, submits, fence ? fence->host.fence : 0 ); }
static VkResult win32u_vkCreateSemaphore( VkDevice client_device, const VkSemaphoreCreateInfo *client_create_info, @@ -1274,6 +1291,10 @@ static VkResult win32u_vkCreateFence( VkDevice client_device, const VkFenceCreat VkFenceCreateInfo *create_info = (VkFenceCreateInfo *)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 fence *fence; + VkFence host_fence; + VkResult res;
TRACE( "device %p, create_info %p, allocator %p, ret %p\n", device, create_info, allocator, ret );
@@ -1293,16 +1314,35 @@ static VkResult win32u_vkCreateFence( VkDevice client_device, const VkFenceCreat } }
- return device->p_vkCreateFence( device->host.device, create_info, NULL /* allocator */, ret ); + if (!(fence = calloc( 1, sizeof(*fence) ))) return VK_ERROR_OUT_OF_HOST_MEMORY; + + if ((res = device->p_vkCreateFence( device->host.device, create_info, NULL /* allocator */, &host_fence ))) + { + free( fence ); + return res; + } + + vulkan_object_init( &fence->obj.obj, host_fence ); + instance->p_insert_object( instance, &fence->obj.obj ); + + *ret = fence->obj.client.fence; + return res; }
static void win32u_vkDestroyFence( VkDevice client_device, VkFence client_fence, const VkAllocationCallbacks *allocator ) { struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct fence *fence = fence_from_handle( client_fence ); + struct vulkan_instance *instance = device->physical_device->instance; + + TRACE( "device %p, fence %p, allocator %p\n", device, fence, allocator ); + + if (!client_fence) return;
- TRACE( "device %p, client_fence %s, allocator %p\n", device, wine_dbgstr_longlong( client_fence ), allocator ); + device->p_vkDestroyFence( device->host.device, fence->obj.host.fence, NULL /* allocator */ ); + instance->p_remove_object( instance, &fence->obj.obj );
- return device->p_vkDestroyFence( device->host.device, client_fence, allocator ); + free( fence ); }
static VkResult win32u_vkGetFenceWin32HandleKHR( VkDevice client_device, const VkFenceGetWin32HandleInfoKHR *handle_info, HANDLE *handle ) diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 44f5d1f5ea8..d94ba9eadf4 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -1126,6 +1126,8 @@ class VkHandle(object): 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.name == "VkFence": + return "vulkan_fence_from_handle({0})->host.fence".format(name)
if self.is_dispatchable(): LOGGER.error("Unhandled host handle for: {0}".format(self.name)) diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index c1d93705184..7fa3491fedb 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -9612,6 +9612,8 @@ static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle) return (uint64_t) (uintptr_t) vulkan_device_from_handle(((VkDevice) (uintptr_t) handle))->host.device; case VK_OBJECT_TYPE_DEVICE_MEMORY: return (uint64_t) vulkan_device_memory_from_handle(handle)->host.device_memory; + case VK_OBJECT_TYPE_FENCE: + return (uint64_t) vulkan_fence_from_handle(handle)->host.fence; case VK_OBJECT_TYPE_INSTANCE: return (uint64_t) (uintptr_t) vulkan_instance_from_handle(((VkInstance) (uintptr_t) handle))->host.instance; case VK_OBJECT_TYPE_PHYSICAL_DEVICE: @@ -28441,7 +28443,7 @@ static void convert_VkVideoEncodeSessionParametersFeedbackInfoKHR_host_to_win32( } }
-static void convert_VkFenceGetWin32HandleInfoKHR_win32_to_host(const VkFenceGetWin32HandleInfoKHR32 *in, VkFenceGetWin32HandleInfoKHR *out) +static void convert_VkFenceGetWin32HandleInfoKHR_win32_to_unwrapped_host(const VkFenceGetWin32HandleInfoKHR32 *in, VkFenceGetWin32HandleInfoKHR *out) { if (!in) return;
@@ -39063,7 +39065,7 @@ static void convert_VkVideoSessionMemoryRequirementsKHR_array_host_to_win32(cons } }
-static void convert_VkImportFenceWin32HandleInfoKHR_win32_to_host(const VkImportFenceWin32HandleInfoKHR32 *in, VkImportFenceWin32HandleInfoKHR *out) +static void convert_VkImportFenceWin32HandleInfoKHR_win32_to_unwrapped_host(const VkImportFenceWin32HandleInfoKHR32 *in, VkImportFenceWin32HandleInfoKHR *out) { if (!in) return;
@@ -39673,19 +39675,154 @@ static const VkSwapchainKHR *convert_VkSwapchainKHR_array_win64_to_unwrapped_hos } #endif /* _WIN64 */
+#ifdef _WIN64 +static const VkFence *convert_VkFence_array_win64_to_host(struct conversion_context *ctx, const VkFence *in, uint32_t count) +{ + VkFence *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_fence_from_handle(in[i])->host.fence; + } + + return out; +} +#endif /* _WIN64 */ + #ifdef _WIN64 static void convert_VkPresentInfoKHR_win64_to_unwrapped_host(struct conversion_context *ctx, const VkPresentInfoKHR *in, VkPresentInfoKHR *out) { + const VkBaseInStructure *in_header; + VkBaseOutStructure *out_header = (void *)out; + if (!in) return;
out->sType = in->sType; - out->pNext = in->pNext; + out->pNext = NULL; out->waitSemaphoreCount = in->waitSemaphoreCount; 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; out->pResults = in->pResults; + + for (in_header = (void *)in->pNext; in_header; in_header = (void *)in_header->pNext) + { + switch (in_header->sType) + { + case VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR: + { + VkDeviceGroupPresentInfoKHR *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkDeviceGroupPresentInfoKHR *in_ext = (const VkDeviceGroupPresentInfoKHR *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR; + out_ext->pNext = NULL; + out_ext->swapchainCount = in_ext->swapchainCount; + out_ext->pDeviceMasks = in_ext->pDeviceMasks; + out_ext->mode = in_ext->mode; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_FRAME_BOUNDARY_EXT: + { + VkFrameBoundaryEXT *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkFrameBoundaryEXT *in_ext = (const VkFrameBoundaryEXT *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_FRAME_BOUNDARY_EXT; + out_ext->pNext = NULL; + out_ext->flags = in_ext->flags; + out_ext->frameID = in_ext->frameID; + out_ext->imageCount = in_ext->imageCount; + out_ext->pImages = in_ext->pImages; + out_ext->bufferCount = in_ext->bufferCount; + out_ext->pBuffers = in_ext->pBuffers; + out_ext->tagName = in_ext->tagName; + out_ext->tagSize = in_ext->tagSize; + out_ext->pTag = in_ext->pTag; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_FRAME_BOUNDARY_TENSORS_ARM: + { + VkFrameBoundaryTensorsARM *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkFrameBoundaryTensorsARM *in_ext = (const VkFrameBoundaryTensorsARM *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_FRAME_BOUNDARY_TENSORS_ARM; + out_ext->pNext = NULL; + out_ext->tensorCount = in_ext->tensorCount; + out_ext->pTensors = in_ext->pTensors; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_PRESENT_ID_2_KHR: + { + VkPresentId2KHR *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkPresentId2KHR *in_ext = (const VkPresentId2KHR *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_PRESENT_ID_2_KHR; + out_ext->pNext = NULL; + out_ext->swapchainCount = in_ext->swapchainCount; + out_ext->pPresentIds = in_ext->pPresentIds; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_PRESENT_ID_KHR: + { + VkPresentIdKHR *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkPresentIdKHR *in_ext = (const VkPresentIdKHR *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_PRESENT_ID_KHR; + out_ext->pNext = NULL; + out_ext->swapchainCount = in_ext->swapchainCount; + out_ext->pPresentIds = in_ext->pPresentIds; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR: + { + VkPresentRegionsKHR *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkPresentRegionsKHR *in_ext = (const VkPresentRegionsKHR *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR; + out_ext->pNext = NULL; + out_ext->swapchainCount = in_ext->swapchainCount; + out_ext->pRegions = in_ext->pRegions; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_FENCE_INFO_KHR: + { + VkSwapchainPresentFenceInfoKHR *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkSwapchainPresentFenceInfoKHR *in_ext = (const VkSwapchainPresentFenceInfoKHR *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_FENCE_INFO_KHR; + out_ext->pNext = NULL; + out_ext->swapchainCount = in_ext->swapchainCount; + out_ext->pFences = convert_VkFence_array_win64_to_host(ctx, in_ext->pFences, in_ext->swapchainCount); + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + case VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_KHR: + { + VkSwapchainPresentModeInfoKHR *out_ext = conversion_context_alloc(ctx, sizeof(*out_ext)); + const VkSwapchainPresentModeInfoKHR *in_ext = (const VkSwapchainPresentModeInfoKHR *)in_header; + out_ext->sType = VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_KHR; + out_ext->pNext = NULL; + out_ext->swapchainCount = in_ext->swapchainCount; + out_ext->pPresentModes = in_ext->pPresentModes; + out_header->pNext = (void *)out_ext; + out_header = (void *)out_ext; + break; + } + default: + FIXME("Unhandled sType %u.\n", in_header->sType); + break; + } + } } #endif /* _WIN64 */
@@ -39745,6 +39882,22 @@ static const VkPresentRegionKHR *convert_VkPresentRegionKHR_array_win32_to_host( return out; }
+static const VkFence *convert_VkFence_array_win32_to_host(struct conversion_context *ctx, const VkFence *in, uint32_t count) +{ + VkFence *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_fence_from_handle(in[i])->host.fence; + } + + return out; +} + static void convert_VkPresentInfoKHR_win32_to_unwrapped_host(struct conversion_context *ctx, const VkPresentInfoKHR32 *in, VkPresentInfoKHR *out) { const VkBaseInStructure32 *in_header; @@ -39852,7 +40005,7 @@ static void convert_VkPresentInfoKHR_win32_to_unwrapped_host(struct conversion_c out_ext->sType = VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_FENCE_INFO_KHR; out_ext->pNext = NULL; out_ext->swapchainCount = in_ext->swapchainCount; - out_ext->pFences = UlongToPtr(in_ext->pFences); + out_ext->pFences = convert_VkFence_array_win32_to_host(ctx, (const VkFence *)UlongToPtr(in_ext->pFences), in_ext->swapchainCount); out_header->pNext = (void *)out_ext; out_header = (void *)out_ext; break; @@ -54558,7 +54711,7 @@ static NTSTATUS thunk64_vkGetFenceStatus(void *args)
TRACE("%p, 0x%s\n", params->device, wine_dbgstr_longlong(params->fence));
- params->result = vulkan_device_from_handle(params->device)->p_vkGetFenceStatus(vulkan_device_from_handle(params->device)->host.device, params->fence); + params->result = vulkan_device_from_handle(params->device)->p_vkGetFenceStatus(vulkan_device_from_handle(params->device)->host.device, vulkan_fence_from_handle(params->fence)->host.fence); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -54574,7 +54727,7 @@ static NTSTATUS thunk32_vkGetFenceStatus(void *args)
TRACE("%#x, 0x%s\n", params->device, wine_dbgstr_longlong(params->fence));
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetFenceStatus(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->fence); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetFenceStatus(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, vulkan_fence_from_handle(params->fence)->host.fence); return STATUS_SUCCESS; }
@@ -54603,7 +54756,7 @@ static NTSTATUS thunk32_vkGetFenceWin32HandleKHR(void *args)
TRACE("%#x, %#x, %#x\n", params->device, params->pGetWin32HandleInfo, params->pHandle);
- convert_VkFenceGetWin32HandleInfoKHR_win32_to_host((const VkFenceGetWin32HandleInfoKHR32 *)UlongToPtr(params->pGetWin32HandleInfo), &pGetWin32HandleInfo_host); + convert_VkFenceGetWin32HandleInfoKHR_win32_to_unwrapped_host((const VkFenceGetWin32HandleInfoKHR32 *)UlongToPtr(params->pGetWin32HandleInfo), &pGetWin32HandleInfo_host); params->result = vk_funcs->p_vkGetFenceWin32HandleKHR((VkDevice)UlongToPtr(params->device), &pGetWin32HandleInfo_host, (HANDLE *)UlongToPtr(params->pHandle)); return STATUS_SUCCESS; } @@ -58418,7 +58571,7 @@ static NTSTATUS thunk32_vkImportFenceWin32HandleKHR(void *args)
TRACE("%#x, %#x\n", params->device, params->pImportFenceWin32HandleInfo);
- convert_VkImportFenceWin32HandleInfoKHR_win32_to_host((const VkImportFenceWin32HandleInfoKHR32 *)UlongToPtr(params->pImportFenceWin32HandleInfo), &pImportFenceWin32HandleInfo_host); + convert_VkImportFenceWin32HandleInfoKHR_win32_to_unwrapped_host((const VkImportFenceWin32HandleInfoKHR32 *)UlongToPtr(params->pImportFenceWin32HandleInfo), &pImportFenceWin32HandleInfo_host); params->result = vk_funcs->p_vkImportFenceWin32HandleKHR((VkDevice)UlongToPtr(params->device), &pImportFenceWin32HandleInfo_host); return STATUS_SUCCESS; } @@ -58753,7 +58906,7 @@ static NTSTATUS thunk64_vkQueueBindSparse(void *args)
init_conversion_context(ctx); pBindInfo_host = convert_VkBindSparseInfo_array_win64_to_host(ctx, params->pBindInfo, params->bindInfoCount); - params->result = vulkan_queue_from_handle(params->queue)->device->p_vkQueueBindSparse(vulkan_queue_from_handle(params->queue)->host.queue, params->bindInfoCount, pBindInfo_host, params->fence); + params->result = vulkan_queue_from_handle(params->queue)->device->p_vkQueueBindSparse(vulkan_queue_from_handle(params->queue)->host.queue, params->bindInfoCount, pBindInfo_host, params->fence ? vulkan_fence_from_handle(params->fence)->host.fence : 0); free_conversion_context(ctx); return STATUS_SUCCESS; } @@ -58777,7 +58930,7 @@ static NTSTATUS thunk32_vkQueueBindSparse(void *args)
init_conversion_context(ctx); pBindInfo_host = convert_VkBindSparseInfo_array_win32_to_host(ctx, (const VkBindSparseInfo32 *)UlongToPtr(params->pBindInfo), params->bindInfoCount); - params->result = vulkan_queue_from_handle((VkQueue)UlongToPtr(params->queue))->device->p_vkQueueBindSparse(vulkan_queue_from_handle((VkQueue)UlongToPtr(params->queue))->host.queue, params->bindInfoCount, pBindInfo_host, params->fence); + params->result = vulkan_queue_from_handle((VkQueue)UlongToPtr(params->queue))->device->p_vkQueueBindSparse(vulkan_queue_from_handle((VkQueue)UlongToPtr(params->queue))->host.queue, params->bindInfoCount, pBindInfo_host, params->fence ? vulkan_fence_from_handle(params->fence)->host.fence : 0); free_conversion_context(ctx); return STATUS_SUCCESS; } @@ -59336,10 +59489,16 @@ static NTSTATUS thunk32_vkResetEvent(void *args) static NTSTATUS thunk64_vkResetFences(void *args) { struct vkResetFences_params *params = args; + const VkFence *pFences_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%p, %u, %p\n", params->device, params->fenceCount, params->pFences);
- params->result = vulkan_device_from_handle(params->device)->p_vkResetFences(vulkan_device_from_handle(params->device)->host.device, params->fenceCount, params->pFences); + init_conversion_context(ctx); + pFences_host = convert_VkFence_array_win64_to_host(ctx, params->pFences, params->fenceCount); + params->result = vulkan_device_from_handle(params->device)->p_vkResetFences(vulkan_device_from_handle(params->device)->host.device, params->fenceCount, pFences_host); + free_conversion_context(ctx); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -59353,10 +59512,16 @@ static NTSTATUS thunk32_vkResetFences(void *args) PTR32 pFences; VkResult result; } *params = args; + const VkFence *pFences_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%#x, %u, %#x\n", params->device, params->fenceCount, params->pFences);
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkResetFences(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->fenceCount, (const VkFence *)UlongToPtr(params->pFences)); + init_conversion_context(ctx); + pFences_host = convert_VkFence_array_win32_to_host(ctx, (const VkFence *)UlongToPtr(params->pFences), params->fenceCount); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkResetFences(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->fenceCount, pFences_host); + free_conversion_context(ctx); return STATUS_SUCCESS; }
@@ -60215,10 +60380,16 @@ static NTSTATUS thunk32_vkUpdateVideoSessionParametersKHR(void *args) static NTSTATUS thunk64_vkWaitForFences(void *args) { struct vkWaitForFences_params *params = args; + const VkFence *pFences_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%p, %u, %p, %u, 0x%s\n", params->device, params->fenceCount, params->pFences, params->waitAll, wine_dbgstr_longlong(params->timeout));
- params->result = vulkan_device_from_handle(params->device)->p_vkWaitForFences(vulkan_device_from_handle(params->device)->host.device, params->fenceCount, params->pFences, params->waitAll, params->timeout); + init_conversion_context(ctx); + pFences_host = convert_VkFence_array_win64_to_host(ctx, params->pFences, params->fenceCount); + params->result = vulkan_device_from_handle(params->device)->p_vkWaitForFences(vulkan_device_from_handle(params->device)->host.device, params->fenceCount, pFences_host, params->waitAll, params->timeout); + free_conversion_context(ctx); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -60234,10 +60405,16 @@ static NTSTATUS thunk32_vkWaitForFences(void *args) uint64_t DECLSPEC_ALIGN(8) timeout; VkResult result; } *params = args; + const VkFence *pFences_host; + struct conversion_context local_ctx; + struct conversion_context *ctx = &local_ctx;
TRACE("%#x, %u, %#x, %u, 0x%s\n", params->device, params->fenceCount, params->pFences, params->waitAll, wine_dbgstr_longlong(params->timeout));
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkWaitForFences(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->fenceCount, (const VkFence *)UlongToPtr(params->pFences), params->waitAll, params->timeout); + init_conversion_context(ctx); + pFences_host = convert_VkFence_array_win32_to_host(ctx, (const VkFence *)UlongToPtr(params->pFences), params->fenceCount); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkWaitForFences(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->fenceCount, pFences_host, params->waitAll, params->timeout); + free_conversion_context(ctx); return STATUS_SUCCESS; }
@@ -60870,6 +61047,7 @@ BOOL wine_vk_is_type_wrapped(VkObjectType type) type == VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR || type == VK_OBJECT_TYPE_DEVICE || type == VK_OBJECT_TYPE_DEVICE_MEMORY || + type == VK_OBJECT_TYPE_FENCE || type == VK_OBJECT_TYPE_INSTANCE || type == VK_OBJECT_TYPE_PHYSICAL_DEVICE || type == VK_OBJECT_TYPE_QUEUE || diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index 5619f28e3e3..6a31bc75b5b 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 45 +#define WINE_VULKAN_DRIVER_VERSION 46
struct vulkan_object { @@ -192,6 +192,16 @@ static inline struct vulkan_semaphore *vulkan_semaphore_from_handle( VkSemaphore return (struct vulkan_semaphore *)(UINT_PTR)handle; }
+struct vulkan_fence +{ + VULKAN_OBJECT_HEADER( VkFence, fence ); +}; + +static inline struct vulkan_fence *vulkan_fence_from_handle( VkFence handle ) +{ + return (struct vulkan_fence *)(UINT_PTR)handle; +} + struct vulkan_funcs { /* Vulkan global functions. These are the only calls at this point a graphics driver