From 19a23b783842a205bbcf3725b882560464784ef1 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 9 Nov 2022 14:33:46 +0100 Subject: [PATCH] winevulkan: Support conversion of optional parameters. --- dlls/winevulkan/make_vulkan | 16 ++++++++++++++-- dlls/winevulkan/vulkan_thunks.c | 12 ++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 0611388e477..2ed2a5144ed 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -759,6 +759,9 @@ class VkFunction(object): host_type = p.type + "_host" if conv and p.needs_host_type() else p.type if p.is_dynamic_array(): body += " {0} *{1}_host;\n".format(host_type, p.name) + elif p.optional: + body += " {0} *{1}_host = NULL;\n".format(host_type, p.name) + needs_alloc = True else: body += " {0} {1}_host;\n".format(host_type, p.name) if p.needs_alloc(conv, unwrap): @@ -1558,6 +1561,13 @@ class VkParam(VkVariable): if self.is_dynamic_array(): return " {1}_host = convert_{2}_array_{4}_to_{6}host({5}{0}{1}, {3});\n".format( prefix, self.name, self.type, self.get_dyn_array_len(prefix), win_type, ctx_param, wrap_part) + elif self.optional: + ret = " if ({0}{1})\n".format(prefix, self.name) + ret += " {\n" + ret += " {0}_host = conversion_context_alloc(&ctx, sizeof(*{0}_host));\n".format(self.name) + ret += " convert_{0}_{3}_to_{5}host({4}{1}{2}, {2}_host);\n".format(self.type, prefix, self.name, win_type, ctx_param, wrap_part) + ret += " }\n" + return ret else: return " convert_{0}_{3}_to_{5}host({4}{1}{2}, &{2}_host);\n".format(self.type, prefix, self.name, win_type, ctx_param, wrap_part) else: @@ -1565,7 +1575,9 @@ class VkParam(VkVariable): return " convert_{0}_array_{1}host_to_{2}({3}_host, {4}{3}, {5});\n".format( self.type, wrap_part, win_type, self.name, prefix, self.get_dyn_array_len(prefix)) else: - return " convert_{0}_host_to_{3}(&{2}_host, {1}{2});\n".format(self.type, prefix, self.name, win_type) + ref_part = "" if self.optional else "&" + return " convert_{0}_host_to_{3}({4}{2}_host, {1}{2});\n".format( + self.type, prefix, self.name, win_type, ref_part) def definition(self, postfix=None, is_member=False, is_thunk=False): """ Return prototype for the parameter. E.g. 'const char *foo' """ @@ -1700,7 +1712,7 @@ class VkParam(VkVariable): return "NULL" if self.needs_variable(conv, unwrap): - if self.is_dynamic_array(): + if self.is_dynamic_array() or self.optional: return "{0}_host".format(self.name) else: return "&{0}_host".format(self.name) diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index fce2a0efa3d..c7f15d3e294 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -20582,17 +20582,21 @@ static NTSTATUS thunk32_vkGetDeviceFaultInfoEXT(void *args) { struct vkGetDeviceFaultInfoEXT_params *params = args; VkDeviceFaultCountsEXT_host pFaultCounts_host; - VkDeviceFaultInfoEXT_host pFaultInfo_host; + VkDeviceFaultInfoEXT_host *pFaultInfo_host = NULL; struct conversion_context ctx; TRACE("%p, %p, %p\n", params->device, params->pFaultCounts, params->pFaultInfo); init_conversion_context(&ctx); convert_VkDeviceFaultCountsEXT_win32_to_host(params->pFaultCounts, &pFaultCounts_host); - convert_VkDeviceFaultInfoEXT_win32_to_host(&ctx, params->pFaultInfo, &pFaultInfo_host); - params->result = wine_device_from_handle(params->device)->funcs.p_vkGetDeviceFaultInfoEXT(wine_device_from_handle(params->device)->device, &pFaultCounts_host, &pFaultInfo_host); + if (params->pFaultInfo) + { + pFaultInfo_host = conversion_context_alloc(&ctx, sizeof(*pFaultInfo_host)); + convert_VkDeviceFaultInfoEXT_win32_to_host(&ctx, params->pFaultInfo, pFaultInfo_host); + } + params->result = wine_device_from_handle(params->device)->funcs.p_vkGetDeviceFaultInfoEXT(wine_device_from_handle(params->device)->device, &pFaultCounts_host, pFaultInfo_host); convert_VkDeviceFaultCountsEXT_host_to_win32(&pFaultCounts_host, params->pFaultCounts); - convert_VkDeviceFaultInfoEXT_host_to_win32(&pFaultInfo_host, params->pFaultInfo); + convert_VkDeviceFaultInfoEXT_host_to_win32(pFaultInfo_host, params->pFaultInfo); free_conversion_context(&ctx); return STATUS_SUCCESS; }