Commit 511a8bfa authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Use struct conversion functions for array conversion implementations.

parent a242422e
...@@ -1203,18 +1203,18 @@ class VkVariable(object): ...@@ -1203,18 +1203,18 @@ class VkVariable(object):
conversions.extend(m.get_conversions(unwrap, is_const)) conversions.extend(m.get_conversions(unwrap, is_const))
if self.is_static_array() or self.is_dynamic_array():
for conv in [False, True]: for conv in [False, True]:
if self.needs_conversion(conv, unwrap, Direction.INPUT, parent_const): if self.needs_conversion(conv, unwrap, Direction.INPUT, parent_const):
conversions.append(ArrayConversionFunction(self, Direction.INPUT, conv, unwrap)) conversions.append(StructConversionFunction(self.struct, Direction.INPUT, conv, unwrap))
if self.needs_conversion(conv, unwrap, Direction.OUTPUT, parent_const): if self.needs_conversion(conv, unwrap, Direction.OUTPUT, parent_const):
conversions.append(ArrayConversionFunction(self, Direction.OUTPUT, conv, unwrap)) conversions.append(StructConversionFunction(self.struct, Direction.OUTPUT, conv, unwrap))
elif self.is_struct():
if self.is_static_array() or self.is_dynamic_array():
for conv in [False, True]: for conv in [False, True]:
if self.needs_conversion(conv, unwrap, Direction.INPUT, parent_const): if self.needs_conversion(conv, unwrap, Direction.INPUT, parent_const):
conversions.append(StructConversionFunction(self.struct, Direction.INPUT, conv, unwrap)) conversions.append(ArrayConversionFunction(self, Direction.INPUT, conv, unwrap))
if self.needs_conversion(conv, unwrap, Direction.OUTPUT, parent_const): if self.needs_conversion(conv, unwrap, Direction.OUTPUT, parent_const):
conversions.append(StructConversionFunction(self.struct, Direction.OUTPUT, conv, unwrap)) conversions.append(ArrayConversionFunction(self, Direction.OUTPUT, conv, unwrap))
return conversions return conversions
...@@ -2034,14 +2034,15 @@ class StructConversionFunction(object): ...@@ -2034,14 +2034,15 @@ class StructConversionFunction(object):
body += "#if !defined(USE_STRUCT_CONVERSION)\n" body += "#if !defined(USE_STRUCT_CONVERSION)\n"
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
if self.conv: if self.conv:
body += "static inline void {0}(".format(self.name) body += "static inline void {0}(".format(self.name)
if self.direction == Direction.OUTPUT: if self.direction == Direction.OUTPUT:
params = ["const {0}_host *in".format(self.type), "{0} *out".format(self.type)] params = ["const {0} *in".format(host_type), "{0} *out".format(self.type)]
else: else:
params = ["const {0} *in".format(self.type), "{0}_host *out".format(self.type)] params = ["const {0} *in".format(self.type), "{0} *out".format(host_type)]
# Generate parameter list # Generate parameter list
if needs_alloc: if needs_alloc:
...@@ -2171,11 +2172,20 @@ class ArrayConversionFunction(object): ...@@ -2171,11 +2172,20 @@ class ArrayConversionFunction(object):
body += " {\n" body += " {\n"
if self.array.is_struct(): if self.array.is_struct():
for m in self.array.struct: struct = self.array.struct
# TODO: support copying of pNext extension structures! win_part = "win32" if self.conv else "win64"
# Luckily though no extension struct at this point needs conversion. host_part = "host" if self.unwrap else "unwrapped_host"
body += " " + m.copy("in[i].", "out[i].", self.direction, self.conv, self.unwrap) 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)
ctx_part = ""
if self.direction == Direction.INPUT and struct.needs_alloc(self.conv, self.unwrap):
ctx_part = "ctx, "
body += " convert_{0}_{1}({2}&in[i], &out[i]);\n".format(
struct.name, conv_suffix, ctx_part)
elif self.array.is_handle() and self.direction == Direction.INPUT: elif self.array.is_handle() and self.direction == Direction.INPUT:
body += " out[i] = " + self.array.handle.driver_handle("in[i]") + ";\n" body += " out[i] = " + self.array.handle.driver_handle("in[i]") + ";\n"
else: else:
......
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