Commit 85026ab2 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winevulkan: Unwrap to driver or host depending on the function.

parent f6febfda
...@@ -325,6 +325,7 @@ class Direction(Enum): ...@@ -325,6 +325,7 @@ class Direction(Enum):
class Unwrap(Enum): class Unwrap(Enum):
NONE = 0 NONE = 0
HOST = 1 HOST = 1
DRIVER = 2
def api_is_vulkan(obj): def api_is_vulkan(obj):
...@@ -337,12 +338,16 @@ def convert_suffix(direction, win_type, unwrap, is_wrapped): ...@@ -337,12 +338,16 @@ def convert_suffix(direction, win_type, unwrap, is_wrapped):
return "host_to_{0}".format(win_type) return "host_to_{0}".format(win_type)
if unwrap == Unwrap.NONE: if unwrap == Unwrap.NONE:
return "unwrapped_host_to_{0}".format(win_type) 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) return "host_to_{0}".format(win_type)
else: else:
if not is_wrapped: if not is_wrapped:
return "{0}_to_host".format(win_type) return "{0}_to_host".format(win_type)
if unwrap == Unwrap.NONE: if unwrap == Unwrap.NONE:
return "{0}_to_unwrapped_host".format(win_type) 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) return "{0}_to_host".format(win_type)
...@@ -628,6 +633,8 @@ class VkFunction(object): ...@@ -628,6 +633,8 @@ class VkFunction(object):
if self.name in MANUAL_UNIX_THUNKS: if self.name in MANUAL_UNIX_THUNKS:
self.unwrap = Unwrap.NONE self.unwrap = Unwrap.NONE
elif self.name in USER_DRIVER_FUNCS:
self.unwrap = Unwrap.DRIVER
else: else:
self.unwrap = Unwrap.HOST self.unwrap = Unwrap.HOST
...@@ -1190,6 +1197,14 @@ class VkHandle(object): ...@@ -1190,6 +1197,14 @@ class VkHandle(object):
return self.host_handle(name) return self.host_handle(name)
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): def is_wrapped(self):
return self.host_handle("test") is not None return self.host_handle("test") is not None
...@@ -1549,15 +1564,16 @@ class VkMember(VkVariable): ...@@ -1549,15 +1564,16 @@ class VkMember(VkVariable):
LOGGER.err("OUTPUT parameter {0}.{1} cannot be unwrapped".format(self.type, self.name)) LOGGER.err("OUTPUT parameter {0}.{1} cannot be unwrapped".format(self.type, self.name))
elif self.optional: elif self.optional:
return "{0}{1} = {2} ? {3} : 0;\n".format(output, self.name, self.value(input, conv), 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: else:
return "{0}{1} = {2};\n".format(output, self.name, 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(): elif self.is_generic_handle():
if direction == Direction.OUTPUT: if direction == Direction.OUTPUT:
LOGGER.err("OUTPUT parameter {0}.{1} cannot be unwrapped".format(self.type, self.name)) LOGGER.err("OUTPUT parameter {0}.{1} cannot be unwrapped".format(self.type, self.name))
else: if unwrap == Unwrap.DRIVER and self.is_wrapped(Unwrap.DRIVER):
return "{0}{1} = wine_vk_unwrap_handle({2}{3}, {2}{1});\n".format(output, self.name, input, self.object_type) 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: else:
selector_part = ", {0}{1}".format(input, self.selector) if self.selector else "" selector_part = ", {0}{1}".format(input, self.selector) if self.selector else ""
if direction == Direction.OUTPUT: if direction == Direction.OUTPUT:
...@@ -1951,13 +1967,15 @@ class VkParam(VkVariable): ...@@ -1951,13 +1967,15 @@ class VkParam(VkVariable):
if unwrap != Unwrap.NONE: if unwrap != Unwrap.NONE:
unwrap_handle = None unwrap_handle = None
if self.object_type != None and self.type == "uint64_t": 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( unwrap_handle = "wine_vk_unwrap_handle({0}{1}, {0}{2})".format(
params_prefix, self.object_type, self.name) params_prefix, self.object_type, self.name)
elif self.is_handle(): elif self.is_handle():
# We need to pass the host handle to the host Vulkan calls and # 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. # 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 unwrap_handle:
if self.optional: if self.optional:
unwrap_handle = "{0}{1} ? {2} : 0".format(params_prefix, self.name, unwrap_handle) unwrap_handle = "{0}{1} ? {2} : 0".format(params_prefix, self.name, unwrap_handle)
...@@ -2612,7 +2630,7 @@ class ArrayConversionFunction(object): ...@@ -2612,7 +2630,7 @@ class ArrayConversionFunction(object):
if self.unwrap == Unwrap.NONE or not handle.is_wrapped(): if self.unwrap == Unwrap.NONE or not handle.is_wrapped():
body += " out[i] = {0};\n".format(input) body += " out[i] = {0};\n".format(input)
elif self.direction == Direction.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: else:
LOGGER.warning("Unhandled handle output conversion") LOGGER.warning("Unhandled handle output conversion")
elif self.array.pointer_array: elif self.array.pointer_array:
......
...@@ -17914,7 +17914,7 @@ static inline const VkShaderCreateInfoEXT *convert_VkShaderCreateInfoEXT_array_w ...@@ -17914,7 +17914,7 @@ static inline const VkShaderCreateInfoEXT *convert_VkShaderCreateInfoEXT_array_w
} }
#ifdef _WIN64 #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; if (!in) return;
...@@ -17939,7 +17939,7 @@ static inline void convert_VkSwapchainCreateInfoKHR_win64_to_host(const VkSwapch ...@@ -17939,7 +17939,7 @@ static inline void convert_VkSwapchainCreateInfoKHR_win64_to_host(const VkSwapch
} }
#endif /* _WIN64 */ #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; const VkBaseInStructure32 *in_header;
VkBaseOutStructure *out_header = (void *)out; VkBaseOutStructure *out_header = (void *)out;
...@@ -26448,7 +26448,7 @@ static inline void convert_VkSurfaceCapabilities2KHR_host_to_win32(const VkSurfa ...@@ -26448,7 +26448,7 @@ static inline void convert_VkSurfaceCapabilities2KHR_host_to_win32(const VkSurfa
} }
#ifdef _WIN64 #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; if (!in) return;
...@@ -26458,7 +26458,7 @@ static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_host(const V ...@@ -26458,7 +26458,7 @@ static inline void convert_VkPhysicalDeviceSurfaceInfo2KHR_win64_to_host(const V
} }
#endif /* _WIN64 */ #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; const VkBaseInStructure32 *in_header;
VkBaseOutStructure *out_header = (void *)out; VkBaseOutStructure *out_header = (void *)out;
...@@ -36113,7 +36113,7 @@ static NTSTATUS thunk64_vkCreateSwapchainKHR(void *args) ...@@ -36113,7 +36113,7 @@ static NTSTATUS thunk64_vkCreateSwapchainKHR(void *args)
TRACE("%p, %p, %p, %p\n", params->device, params->pCreateInfo, params->pAllocator, params->pSwapchain); 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); 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; return STATUS_SUCCESS;
} }
...@@ -36136,7 +36136,7 @@ static NTSTATUS thunk32_vkCreateSwapchainKHR(void *args) ...@@ -36136,7 +36136,7 @@ static NTSTATUS thunk32_vkCreateSwapchainKHR(void *args)
TRACE("%#x, %#x, %#x, %#x\n", params->device, params->pCreateInfo, params->pAllocator, params->pSwapchain); TRACE("%#x, %#x, %#x, %#x\n", params->device, params->pCreateInfo, params->pAllocator, params->pSwapchain);
init_conversion_context(ctx); 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)); 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); free_conversion_context(ctx);
return STATUS_SUCCESS; return STATUS_SUCCESS;
...@@ -41232,7 +41232,7 @@ static NTSTATUS thunk64_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args) ...@@ -41232,7 +41232,7 @@ static NTSTATUS thunk64_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args)
TRACE("%p, %p, %p, %p\n", params->physicalDevice, params->pSurfaceInfo, params->pSurfaceFormatCount, params->pSurfaceFormats); 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); 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; return STATUS_SUCCESS;
} }
...@@ -41256,7 +41256,7 @@ static NTSTATUS thunk32_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args) ...@@ -41256,7 +41256,7 @@ static NTSTATUS thunk32_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args)
TRACE("%#x, %#x, %#x, %#x\n", params->physicalDevice, params->pSurfaceInfo, params->pSurfaceFormatCount, params->pSurfaceFormats); TRACE("%#x, %#x, %#x, %#x\n", params->physicalDevice, params->pSurfaceInfo, params->pSurfaceFormatCount, params->pSurfaceFormats);
init_conversion_context(ctx); 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)); 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); 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)); convert_VkSurfaceFormat2KHR_array_host_to_win32(pSurfaceFormats_host, (VkSurfaceFormat2KHR32 *)UlongToPtr(params->pSurfaceFormats), *(uint32_t *)UlongToPtr(params->pSurfaceFormatCount));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment