From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/make_vulkan | 41 ++++++++++++++++++++++++--------- dlls/winevulkan/vulkan_thunks.c | 16 ++++++------- 2 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index f951481bf63..7d0f109785e 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -325,6 +325,7 @@ class Direction(Enum): class Unwrap(Enum): NONE = 0 HOST = 1 + DRIVER = 2
def api_is_vulkan(obj): @@ -337,12 +338,16 @@ def convert_suffix(direction, win_type, unwrap, is_wrapped): return "host_to_{0}".format(win_type) if unwrap == Unwrap.NONE: return "unwrapped_host_to_{0}".format(win_type) + if unwrap == Unwrap.DRIVER: + return "driver_to_{0}".format(win_type) return "host_to_{0}".format(win_type) else: if not is_wrapped: return "{0}_to_host".format(win_type) if unwrap == Unwrap.NONE: return "{0}_to_unwrapped_host".format(win_type) + if unwrap == Unwrap.DRIVER: + return "{0}_to_driver".format(win_type) return "{0}_to_host".format(win_type)
@@ -626,10 +631,12 @@ class VkFunction(object): # and is used by the code generation. self.required = True if func_info else False
- if self.name not in MANUAL_UNIX_THUNKS: - self.unwrap = Unwrap.HOST - else: + if self.name in MANUAL_UNIX_THUNKS: self.unwrap = Unwrap.NONE + elif self.name in USER_DRIVER_FUNCS: + self.unwrap = Unwrap.DRIVER + else: + self.unwrap = Unwrap.HOST
@staticmethod def from_alias(command, alias): @@ -1190,10 +1197,19 @@ class VkHandle(object):
return self.host_handle(name)
- def is_wrapped(self, unwrap): + def unwrap_handle(self, name, unwrap): + if unwrap == Unwrap.DRIVER: + return self.driver_handle(name) + if unwrap == Unwrap.HOST: + return self.host_handle(name) + assert unwrap != Unwrap.NONE + return None + + def is_wrapped(self, unwrap=Unwrap.HOST): + if unwrap == Unwrap.DRIVER: + return self.driver_handle("test") is not None if unwrap == Unwrap.HOST: return self.host_handle("test") is not None - assert unwrap == Unwrap.NONE return False
@@ -1552,15 +1568,16 @@ class VkMember(VkVariable): LOGGER.err("OUTPUT parameter {0}.{1} cannot be unwrapped".format(self.type, self.name)) elif self.optional: return "{0}{1} = {2} ? {3} : 0;\n".format(output, self.name, self.value(input, conv), - handle.driver_handle(self.value(input, conv))) + handle.unwrap_handle(self.value(input, conv), unwrap)) else: return "{0}{1} = {2};\n".format(output, self.name, - handle.driver_handle(self.value(input, conv))) + handle.unwrap_handle(self.value(input, conv), unwrap)) elif self.is_generic_handle(): if direction == Direction.OUTPUT: LOGGER.err("OUTPUT parameter {0}.{1} cannot be unwrapped".format(self.type, self.name)) - else: - return "{0}{1} = wine_vk_unwrap_handle({2}{3}, {2}{1});\n".format(output, self.name, input, self.object_type) + if unwrap == Unwrap.DRIVER and self.is_wrapped(Unwrap.DRIVER): + LOGGER.err("DRIVER unwrapping of {0}.{1} not implemented".format(self.type, self.name)) + return "{0}{1} = wine_vk_unwrap_handle({2}{3}, {2}{1});\n".format(output, self.name, input, self.object_type) else: selector_part = ", {0}{1}".format(input, self.selector) if self.selector else "" if direction == Direction.OUTPUT: @@ -1954,13 +1971,15 @@ class VkParam(VkVariable): if unwrap != Unwrap.NONE: unwrap_handle = None if self.object_type != None and self.type == "uint64_t": + if unwrap == Unwrap.DRIVER and self.is_wrapped(Unwrap.DRIVER): + LOGGER.err("DRIVER unwrapping of {0}.{1} not implemented".format(self.type, self.name)) unwrap_handle = "wine_vk_unwrap_handle({0}{1}, {0}{2})".format( params_prefix, self.object_type, self.name)
elif self.is_handle(): # We need to pass the host handle to the host Vulkan calls and # the wine driver's handle to calls which are wrapped by the driver. - unwrap_handle = self.handle.driver_handle(p) + unwrap_handle = self.handle.unwrap_handle(p, unwrap) if unwrap_handle: if self.optional: unwrap_handle = "{0}{1} ? {2} : 0".format(params_prefix, self.name, unwrap_handle) @@ -2620,7 +2639,7 @@ class ArrayConversionFunction(object): if self.unwrap == Unwrap.NONE or not handle.is_wrapped(Unwrap.HOST): body += " out[i] = {0};\n".format(input) elif self.direction == Direction.INPUT: - body += " out[i] = " + handle.driver_handle(input) + ";\n" + body += " out[i] = {0};\n".format(handle.unwrap_handle(input, self.unwrap)) else: LOGGER.warning("Unhandled handle output conversion") elif self.array.pointer_array: diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index a766883115d..113b529c560 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -17914,7 +17914,7 @@ static inline const VkShaderCreateInfoEXT *convert_VkShaderCreateInfoEXT_array_w }
#ifdef _WIN64 -static inline void convert_VkSwapchainCreateInfoKHR_win64_to_host(const VkSwapchainCreateInfoKHR *in, VkSwapchainCreateInfoKHR *out) +static inline void convert_VkSwapchainCreateInfoKHR_win64_to_driver(const VkSwapchainCreateInfoKHR *in, VkSwapchainCreateInfoKHR *out) { if (!in) return;
@@ -17939,7 +17939,7 @@ static inline void convert_VkSwapchainCreateInfoKHR_win64_to_host(const VkSwapch } #endif /* _WIN64 */
-static inline void convert_VkSwapchainCreateInfoKHR_win32_to_host(struct conversion_context *ctx, const VkSwapchainCreateInfoKHR32 *in, VkSwapchainCreateInfoKHR *out) +static inline void convert_VkSwapchainCreateInfoKHR_win32_to_driver(struct conversion_context *ctx, const VkSwapchainCreateInfoKHR32 *in, VkSwapchainCreateInfoKHR *out) { const VkBaseInStructure32 *in_header; VkBaseOutStructure *out_header = (void *)out; @@ -26448,7 +26448,7 @@ static inline void convert_VkSurfaceCapabilities2KHR_host_to_win32(const VkSurfa }
#ifdef _WIN64 -static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_host(const VkPhysicalDeviceSurfaceInfo2KHR *in, VkPhysicalDeviceSurfaceInfo2KHR *out) +static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_driver(const VkPhysicalDeviceSurfaceInfo2KHR *in, VkPhysicalDeviceSurfaceInfo2KHR *out) { if (!in) return;
@@ -26458,7 +26458,7 @@ static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_host(const V } #endif /* _WIN64 */
-static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win32_to_host(struct conversion_context *ctx, const VkPhysicalDeviceSurfaceInfo2KHR32 *in, VkPhysicalDeviceSurfaceInfo2KHR *out) +static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win32_to_driver(struct conversion_context *ctx, const VkPhysicalDeviceSurfaceInfo2KHR32 *in, VkPhysicalDeviceSurfaceInfo2KHR *out) { const VkBaseInStructure32 *in_header; VkBaseOutStructure *out_header = (void *)out; @@ -36113,7 +36113,7 @@ static NTSTATUS thunk64_vkCreateSwapchainKHR(void *args)
TRACE("%p, %p, %p, %p\n", params->device, params->pCreateInfo, params->pAllocator, params->pSwapchain);
- convert_VkSwapchainCreateInfoKHR_win64_to_host(params->pCreateInfo, &pCreateInfo_host); + convert_VkSwapchainCreateInfoKHR_win64_to_driver(params->pCreateInfo, &pCreateInfo_host); params->result = wine_device_from_handle(params->device)->funcs.p_vkCreateSwapchainKHR(wine_device_from_handle(params->device)->host_device, &pCreateInfo_host, NULL, params->pSwapchain); return STATUS_SUCCESS; } @@ -36136,7 +36136,7 @@ static NTSTATUS thunk32_vkCreateSwapchainKHR(void *args) TRACE("%#x, %#x, %#x, %#x\n", params->device, params->pCreateInfo, params->pAllocator, params->pSwapchain);
init_conversion_context(ctx); - convert_VkSwapchainCreateInfoKHR_win32_to_host(ctx, (const VkSwapchainCreateInfoKHR32 *)UlongToPtr(params->pCreateInfo), &pCreateInfo_host); + convert_VkSwapchainCreateInfoKHR_win32_to_driver(ctx, (const VkSwapchainCreateInfoKHR32 *)UlongToPtr(params->pCreateInfo), &pCreateInfo_host); params->result = wine_device_from_handle((VkDevice)UlongToPtr(params->device))->funcs.p_vkCreateSwapchainKHR(wine_device_from_handle((VkDevice)UlongToPtr(params->device))->host_device, &pCreateInfo_host, NULL, (VkSwapchainKHR *)UlongToPtr(params->pSwapchain)); free_conversion_context(ctx); return STATUS_SUCCESS; @@ -41232,7 +41232,7 @@ static NTSTATUS thunk64_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args)
TRACE("%p, %p, %p, %p\n", params->physicalDevice, params->pSurfaceInfo, params->pSurfaceFormatCount, params->pSurfaceFormats);
- convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_host(params->pSurfaceInfo, &pSurfaceInfo_host); + convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_driver(params->pSurfaceInfo, &pSurfaceInfo_host); params->result = wine_phys_dev_from_handle(params->physicalDevice)->instance->funcs.p_vkGetPhysicalDeviceSurfaceFormats2KHR(wine_phys_dev_from_handle(params->physicalDevice)->host_physical_device, &pSurfaceInfo_host, params->pSurfaceFormatCount, params->pSurfaceFormats); return STATUS_SUCCESS; } @@ -41256,7 +41256,7 @@ static NTSTATUS thunk32_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args) TRACE("%#x, %#x, %#x, %#x\n", params->physicalDevice, params->pSurfaceInfo, params->pSurfaceFormatCount, params->pSurfaceFormats);
init_conversion_context(ctx); - convert_VkPhysicalDeviceSurfaceInfo2KHR_win32_to_host(ctx, (const VkPhysicalDeviceSurfaceInfo2KHR32 *)UlongToPtr(params->pSurfaceInfo), &pSurfaceInfo_host); + convert_VkPhysicalDeviceSurfaceInfo2KHR_win32_to_driver(ctx, (const VkPhysicalDeviceSurfaceInfo2KHR32 *)UlongToPtr(params->pSurfaceInfo), &pSurfaceInfo_host); pSurfaceFormats_host = convert_VkSurfaceFormat2KHR_array_win32_to_host(ctx, (VkSurfaceFormat2KHR32 *)UlongToPtr(params->pSurfaceFormats), *(uint32_t *)UlongToPtr(params->pSurfaceFormatCount)); params->result = wine_phys_dev_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->instance->funcs.p_vkGetPhysicalDeviceSurfaceFormats2KHR(wine_phys_dev_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->host_physical_device, &pSurfaceInfo_host, (uint32_t *)UlongToPtr(params->pSurfaceFormatCount), pSurfaceFormats_host); convert_VkSurfaceFormat2KHR_array_host_to_win32(pSurfaceFormats_host, (VkSurfaceFormat2KHR32 *)UlongToPtr(params->pSurfaceFormats), *(uint32_t *)UlongToPtr(params->pSurfaceFormatCount));