Commit 95d83f01 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Support pointer dynamic array lengths.

parent 8047c230
......@@ -1097,6 +1097,10 @@ class VkVariable(object):
if type_info:
self.set_type_info(type_info)
def __eq__(self, other):
""" Compare member based on name against a string. """
return self.name == other
def set_type_info(self, type_info):
""" Helper function to set type information from the type registry.
This is needed, because not all type data is available at time of
......@@ -1106,6 +1110,31 @@ class VkVariable(object):
self.handle = type_info["data"] if type_info["category"] == "handle" else None
self.struct = type_info["data"] if type_info["category"] == "struct" else None
def get_dyn_array_len(self, prefix):
if isinstance(self.dyn_array_len, int):
return self.dyn_array_len
len_str = self.dyn_array_len
parent = self.parent
len = prefix
# check if lenght is a member of another struct (for example pAllocateInfo->commandBufferCount)
i = len_str.find("->")
if i != -1:
var = parent[parent.index(len_str[0:i])]
len_str = len_str[i+2:]
len += var.name + "->"
parent = var.struct.members
len += len_str
if not len_str in parent:
return len
var = parent[parent.index(len_str)]
if var.is_pointer():
len = "*" + len
return len
def is_const(self):
return self.const
......@@ -1223,15 +1252,6 @@ class VkMember(VkVariable):
self.values = values
self.bit_width = bit_width
def __eq__(self, other):
""" Compare member based on name against a string.
This method is for convenience by VkStruct, which holds a number of members and needs quick checking
if certain members exist.
"""
return self.name == other
def __repr__(self):
return "{0} {1} {2} {3} {4} {5} {6}".format(self.const, self.struct_fwd_decl, self.type, self.pointer,
self.name, self.array_len, self.dyn_array_len)
......@@ -1313,7 +1333,7 @@ class VkMember(VkVariable):
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.dyn_array_len if isinstance(self.dyn_array_len, int) else "{0}{1}".format(input, self.dyn_array_len)
count = self.get_dyn_array_len(input)
host_part = "host" if unwrap else "unwrapped_host"
if direction == Direction.OUTPUT:
return "convert_{2}_array_{6}_to_{5}({3}{1}, {0}{1}, {4});\n".format(output, self.name, self.type, input, count, win_type, host_part)
......@@ -1557,7 +1577,8 @@ class VkParam(VkVariable):
ctx_param = "&ctx, " if self.needs_alloc(conv, unwrap) else ""
wrap_part = "" if unwrap or not self.needs_unwrapping() else "unwrapped_"
if self.is_dynamic_array():
return " {1}_host = convert_{2}_array_{4}_to_{6}host({5}{0}{1}, {0}{3});\n".format(prefix, self.name, self.type, self.dyn_array_len, win_type, ctx_param, wrap_part)
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)
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:
......
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