Commit 0b503549 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Use local structs declarations for 32-bit conversion functions.

parent c479ffcd
...@@ -864,7 +864,7 @@ class VkFunction(object): ...@@ -864,7 +864,7 @@ class VkFunction(object):
thunk += " struct\n" thunk += " struct\n"
thunk += " {\n" thunk += " {\n"
for p in self.params: for p in self.params:
thunk += " {0};\n".format(p.definition(is_member=True)) thunk += " {0};\n".format(p.definition(is_thunk=True, is_member=True))
if self.extra_param: if self.extra_param:
thunk += " void *{0};\n".format(self.extra_param) thunk += " void *{0};\n".format(self.extra_param)
if self.type != "void": if self.type != "void":
...@@ -1386,7 +1386,7 @@ class VkMember(VkVariable): ...@@ -1386,7 +1386,7 @@ class VkMember(VkVariable):
else: else:
return "{0}{1} = {2}{1};\n".format(output, self.name, input) return "{0}{1} = {2}{1};\n".format(output, self.name, input)
def definition(self, align=False, conv=False): def definition(self, align=False, conv=False, postfix=""):
""" Generate prototype for given function. """ Generate prototype for given function.
Args: Args:
...@@ -1401,15 +1401,19 @@ class VkMember(VkVariable): ...@@ -1401,15 +1401,19 @@ class VkMember(VkVariable):
if self.is_struct_forward_declaration(): if self.is_struct_forward_declaration():
text += "struct " text += "struct "
if conv and self.is_struct():
text += "{0}_host".format(self.type)
else:
text += self.type text += self.type
if conv and self.needs_host_type():
text += "32"
elif postfix and self.needs_host_type():
text += postfix
if self.is_pointer(): if self.is_pointer():
text += " {0}{1}".format(self.pointer, self.name) text += " {0}{1}".format(self.pointer, self.name)
else: else:
if align and self.needs_alignment(): if align and self.needs_alignment():
if conv:
text += " DECLSPEC_ALIGN(8) " + self.name
else:
text += " WINE_VK_ALIGN(8) " + self.name text += " WINE_VK_ALIGN(8) " + self.name
else: else:
text += " " + self.name text += " " + self.name
...@@ -1612,7 +1616,7 @@ class VkParam(VkVariable): ...@@ -1612,7 +1616,7 @@ class VkParam(VkVariable):
proto += self.type proto += self.type
name = self.name name = self.name
if is_thunk and self.needs_host_type(): if is_thunk and self.needs_host_type():
proto += "_host" proto += "32" if is_member else "_host"
if is_member and self.needs_alignment(): if is_member and self.needs_alignment():
proto += " DECLSPEC_ALIGN(8)" proto += " DECLSPEC_ALIGN(8)"
...@@ -1876,6 +1880,8 @@ class VkStruct(Sequence): ...@@ -1876,6 +1880,8 @@ class VkStruct(Sequence):
if postfix: if postfix:
suffix = postfix suffix = postfix
elif conv:
suffix = "32"
else: else:
suffix = "" suffix = ""
...@@ -1889,16 +1895,11 @@ class VkStruct(Sequence): ...@@ -1889,16 +1895,11 @@ class VkStruct(Sequence):
for m in self: for m in self:
if align and m.needs_alignment(): if align and m.needs_alignment():
text += " {0};\n".format(m.definition(align=align)) text += " {0};\n".format(m.definition(align=align, conv=conv, postfix=postfix))
elif conv and m.needs_host_type():
text += " {0};\n".format(m.definition(conv=conv))
else: else:
text += " {0};\n".format(m.definition()) text += " {0};\n".format(m.definition(conv=conv, postfix=postfix))
if postfix is not None: text += "}} {0}{1};\n".format(self.name, suffix)
text += "}} {0}{1};\n".format(self.name, postfix)
else:
text += "}} {0};\n".format(self.name)
for aliasee in self.aliased_by: for aliasee in self.aliased_by:
text += "typedef {0}{2} {1}{2};\n".format(self.name, aliasee.name, suffix) text += "typedef {0}{2} {1}{2};\n".format(self.name, aliasee.name, suffix)
...@@ -2120,6 +2121,8 @@ class StructConversionFunction(object): ...@@ -2120,6 +2121,8 @@ class StructConversionFunction(object):
needs_alloc = self.direction != Direction.OUTPUT and self.operand.needs_alloc(self.conv, self.unwrap) needs_alloc = self.direction != Direction.OUTPUT and self.operand.needs_alloc(self.conv, self.unwrap)
host_type = self.type + "_host" if self.operand.needs_host_type() else self.type host_type = self.type + "_host" if self.operand.needs_host_type() else self.type
win_type = self.type win_type = self.type
if self.conv and self.operand.needs_host_type():
win_type += "32"
if self.direction == Direction.OUTPUT and self.const: if self.direction == Direction.OUTPUT and self.const:
win_type = "const " + win_type win_type = "const " + win_type
...@@ -2188,12 +2191,13 @@ class StructConversionFunction(object): ...@@ -2188,12 +2191,13 @@ class StructConversionFunction(object):
stype = next(x for x in ext.members if x.name == "sType").values stype = next(x for x in ext.members if x.name == "sType").values
host_type = ext.name + "_host" if self.conv and ext.needs_host_type() else ext.name host_type = ext.name + "_host" if self.conv and ext.needs_host_type() else ext.name
win_type = ext.name + "32" if self.conv and ext.needs_host_type() else ext.name
if self.direction == Direction.INPUT: if self.direction == Direction.INPUT:
in_type = "const " + ext.name in_type = "const " + win_type
out_type = host_type out_type = host_type
else: else:
in_type = "const " + host_type in_type = "const " + host_type
out_type = ext.name out_type = win_type
body += " case {0}:\n".format(stype) body += " case {0}:\n".format(stype)
body += " {\n" body += " {\n"
...@@ -2289,9 +2293,11 @@ class ArrayConversionFunction(object): ...@@ -2289,9 +2293,11 @@ class ArrayConversionFunction(object):
else: else:
host_type = self.type host_type = self.type
win_type = self.type win_type = self.type
pointer_part = self.array.pointer if self.array.pointer else "*" if self.conv and self.array.needs_host_type():
win_type += "32"
if self.direction == Direction.OUTPUT and self.array.is_const(): if self.direction == Direction.OUTPUT and self.array.is_const():
win_type = "const " + win_type win_type = "const " + win_type
pointer_part = self.array.pointer if self.array.pointer else "*"
if self.direction == Direction.OUTPUT: if self.direction == Direction.OUTPUT:
params = ["const {0} {1}in".format(host_type, pointer_part), params = ["const {0} {1}in".format(host_type, pointer_part),
...@@ -2440,6 +2446,12 @@ class VkGenerator(object): ...@@ -2440,6 +2446,12 @@ class VkGenerator(object):
f.write("WINE_DEFAULT_DEBUG_CHANNEL(vulkan);\n\n") f.write("WINE_DEFAULT_DEBUG_CHANNEL(vulkan);\n\n")
f.write("#if defined(USE_STRUCT_CONVERSION)\n\n")
for struct in self.host_structs:
f.write(struct.definition(conv=True, align=True))
f.write("\n")
f.write("#endif /* USE_STRUCT_CONVERSION */\n\n")
f.write("static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle)\n") f.write("static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle)\n")
f.write("{\n") f.write("{\n")
f.write(" switch(type)\n") f.write(" switch(type)\n")
...@@ -2587,7 +2599,7 @@ class VkGenerator(object): ...@@ -2587,7 +2599,7 @@ class VkGenerator(object):
if struct.is_alias(): if struct.is_alias():
continue continue
f.write("#if defined(USE_STRUCT_CONVERSION)\n") f.write("#if defined(USE_STRUCT_CONVERSION)\n")
f.write(struct.definition(align=False, conv=True, postfix="_host")) f.write(struct.definition(align=False, postfix="_host"))
f.write("#else\n") f.write("#else\n")
f.write("typedef {0} {0}_host;\n".format(struct.name)) f.write("typedef {0} {0}_host;\n".format(struct.name))
for aliasee in struct.aliased_by: for aliasee in struct.aliased_by:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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