From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/make_vulkan | 80 ++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 41 deletions(-)
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 68cdc2baef1..7e1cc3f1dd9 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -324,6 +324,18 @@ class Direction(Enum): def api_is_vulkan(obj): return "vulkan" in obj.get("api", "vulkan").split(",")
+ +def convert_suffix(direction, win_type, unwrap): + if direction == Direction.OUTPUT: + if not unwrap: + return "unwrapped_host_to_{0}".format(win_type) + return "host_to_{0}".format(win_type) + else: + if not unwrap: + return "{0}_to_unwrapped_host".format(win_type) + return "{0}_to_host".format(win_type) + + class VkBaseType(object): def __init__(self, name, _type, alias=None, requires=None): """ Vulkan base type class. @@ -1493,27 +1505,25 @@ class VkMember(VkVariable): - `conv` indicates whether the statement is in a struct alignment conversion path. """
win_type = "win32" if conv else "win64" + suffix = convert_suffix(direction, win_type, unwrap or not self.is_wrapped()) + if self.needs_conversion(conv, unwrap, direction, False): if self.is_dynamic_array(): # Array length is either a variable name (string) or an int. count = self.get_dyn_array_len(input, conv) - host_part = "host" if unwrap else "unwrapped_host" pointer_part = "pointer_" if self.pointer_array else "" if direction == Direction.OUTPUT: - return "convert_{2}_{7}array_{6}_to_{5}({3}{1}, {0}, {4});\n".format( - self.value(output, conv), self.name, self.type, input, count, win_type, - host_part, pointer_part) + return "convert_{2}_{6}array_{5}({3}{1}, {0}, {4});\n".format(self.value(output, conv), + self.name, self.type, input, count, suffix, pointer_part) else: - return "{0}{1} = convert_{2}_{7}array_{5}_to_{6}(ctx, {3}, {4});\n".format( - output, self.name, self.type, self.value(input, conv), count, win_type, - host_part, pointer_part) + return "{0}{1} = convert_{2}_{6}array_{5}(ctx, {3}, {4});\n".format(output, + self.name, self.type, self.value(input, conv), count, suffix, pointer_part) elif self.is_static_array(): count = self.array_len if direction == Direction.OUTPUT: # Needed by VkMemoryHeap.memoryHeaps - host_part = "host" if unwrap else "unwrapped_host" - return "convert_{0}_array_{6}_to_{5}({2}{1}, {3}{1}, {4});\n".format( - self.type, self.name, input, output, count, win_type, host_part) + return "convert_{0}_array_{5}({2}{1}, {3}{1}, {4});\n".format(self.type, + self.name, input, output, count, suffix) else: # Nothing needed this yet. LOGGER.warn("TODO: implement copying of static array for {0}.{1}".format(self.type, self.name)) @@ -1522,8 +1532,8 @@ class VkMember(VkVariable): if direction == Direction.OUTPUT: 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))) + return "{0}{1} = {2} ? {3} : 0;\n".format(output, self.name, self.value(input, conv), + handle.driver_handle(self.value(input, conv))) else: return "{0}{1} = {2};\n".format(output, self.name, handle.driver_handle(self.value(input, conv))) elif self.is_generic_handle(): @@ -1537,8 +1547,8 @@ class VkMember(VkVariable): return "convert_{0}_host_to_{4}(&{2}{1}, &{3}{1}{5});\n".format(self.type, self.name, input, output, win_type, selector_part) else: ctx_param = "ctx, " if self.needs_alloc(conv, unwrap) else "" - host_part = "host" if unwrap else "unwrapped_host" - return "convert_{0}_{4}_to_{6}({5}&{2}{1}, &{3}{1}{7});\n".format(self.type, self.name, input, output, win_type, ctx_param, host_part, selector_part) + return "convert_{0}_{4}({5}&{2}{1}, &{3}{1}{6});\n".format(self.type, + self.name, input, output, suffix, ctx_param, selector_part) elif self.is_static_array(): bytes_count = "{0} * sizeof({1})".format(self.array_len, self.type) return "memcpy({0}{1}, {2}{1}, {3});\n".format(output, self.name, input, bytes_count) @@ -1747,32 +1757,32 @@ class VkParam(VkVariable):
def copy(self, direction, conv, unwrap, prefix=""): win_type = "win32" if conv else "win64" - wrap_part = "" if unwrap or not self.is_wrapped() else "unwrapped_" + suffix = convert_suffix(direction, win_type, unwrap or not self.is_wrapped()) + if direction == Direction.INPUT: ctx_param = "ctx, " if self.needs_alloc(conv, unwrap) else "" if self.is_dynamic_array(): - return " {0}_host = convert_{2}_array_{4}_to_{6}host({5}{1}, {3});\n".format( - self.name, self.value(prefix, conv), self.type, self.get_dyn_array_len(prefix, conv), - win_type, ctx_param, wrap_part) + return " {0}_host = convert_{2}_array_{4}({5}{1}, {3});\n".format(self.name, self.value(prefix, conv), + self.type, self.get_dyn_array_len(prefix, conv), suffix, ctx_param) 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}_host);\n".format( - self.type, self.value(prefix, conv), self.name, win_type, ctx_param, wrap_part) + ret += " convert_{0}_{3}({4}{1}, {2}_host);\n".format(self.type, self.value(prefix, conv), + self.name, suffix, ctx_param) ret += " }\n" return ret elif self.is_struct(): - return " convert_{0}_{3}_to_{5}host({4}{1}, &{2}_host);\n".format( - self.type, self.value(prefix, conv), self.name, win_type, ctx_param, wrap_part) + return " convert_{0}_{3}({4}{1}, &{2}_host);\n".format(self.type, self.value(prefix, conv), + self.name, suffix, ctx_param) elif self.is_pointer_size() and self.type != "size_t": return " {0}_host = UlongToPtr(*{1});\n".format(self.name, self.value(prefix, conv)) else: return " {0}_host = *{1};\n".format(self.name, self.value(prefix, conv)) else: if self.is_dynamic_array(): - return " convert_{0}_array_{1}host_to_{2}({3}_host, {4}, {5});\n".format( - self.type, wrap_part, win_type, self.name, self.value(prefix, conv), + return " convert_{0}_array_{1}({2}_host, {3}, {4});\n".format( + self.type, suffix, self.name, self.value(prefix, conv), self.get_dyn_array_len(prefix, conv)) elif self.is_struct(): ref_part = "" if self.optional else "&" @@ -2273,11 +2283,7 @@ class StructConversionFunction(object):
name = "convert_{0}_".format(self.type) win_type = "win32" if self.conv else "win64" - host_part = "host" if self.unwrap else "unwrapped_host" - if self.direction == Direction.INPUT: - name += "{0}_to_{1}".format(win_type, host_part) - else: # Direction.OUTPUT - name += "{0}_to_{1}".format(host_part, win_type) + name += convert_suffix(self.direction, win_type, self.unwrap) self.name = name
def __eq__(self, other): @@ -2480,11 +2486,7 @@ class ArrayConversionFunction(object): name += "pointer_" name += "array_" win_type = "win32" if self.conv else "win64" - host_part = "host" if self.unwrap else "unwrapped_host" - if self.direction == Direction.INPUT: - name += "{0}_to_{1}".format(win_type, host_part) - else: # Direction.OUTPUT - name += "{0}_to_{1}".format(host_part, win_type) + name += convert_suffix(self.direction, win_type, self.unwrap) self.name = name
def __eq__(self, other): @@ -2555,11 +2557,7 @@ class ArrayConversionFunction(object): if self.array.is_struct(): struct = self.array.struct win_part = "win32" if self.conv else "win64" - host_part = "host" if self.unwrap else "unwrapped_host" - if self.direction == Direction.INPUT: - conv_suffix = "{0}_to_{1}".format(win_part, host_part) - else: - conv_suffix = "{0}_to_{1}".format(host_part, win_part) + suffix = convert_suffix(self.direction, win_part, self.unwrap)
ctx_part = "" if self.direction == Direction.INPUT and struct.needs_alloc(self.conv, self.unwrap): @@ -2567,7 +2565,7 @@ class ArrayConversionFunction(object):
if not self.array.pointer_array: body += " convert_{0}_{1}({2}&in[i], &out[i]);\n".format( - struct.name, conv_suffix, ctx_part) + struct.name, suffix, ctx_part) else: if struct.needs_conversion(self.conv, self.unwrap, self.direction, False): body += " if (in[i])\n" @@ -2578,7 +2576,7 @@ class ArrayConversionFunction(object): else: in_param = "in[i]" body += " convert_{0}_{1}({2}{3}, out[i]);\n".format( - struct.name, conv_suffix, ctx_part, in_param) + struct.name, suffix, ctx_part, in_param) body += " }\n" body += " else\n" body += " out[i] = NULL;\n"