winevulkan: Parse extension require sections one by one.

Signed-off-by: Roderick Colenbrander <thunderbird2k@gmail.com>
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Roderick Colenbrander 2018-06-03 15:52:12 -07:00 committed by Alexandre Julliard
parent 69ca515915
commit 3bb4ecaf16

View File

@ -2359,46 +2359,54 @@ class VkRegistry(object):
LOGGER.debug("Loading extension: {0}".format(ext_name)) LOGGER.debug("Loading extension: {0}".format(ext_name))
# Extensions can add enum values to Core / extension enums, so add these. # Extensions can define one or more require sections each requiring
enums = ext.findall("require/enum") # different features (e.g. Vulkan 1.1). Parse each require section
for enum_elem in enums: # separately, so we can skip sections we don't want.
if "bitpos" in enum_elem.keys(): for require in ext.findall("require"):
# We need to add an extra value to an existing enum type. # Extensions can add enum values to Core / extension enums, so add these.
# E.g. VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG to VkFormatFeatureFlagBits. for enum_elem in require.findall("enum"):
type_name = enum_elem.attrib["extends"] if "bitpos" in enum_elem.keys():
enum = self.types[type_name]["data"] # We need to add an extra value to an existing enum type.
enum.add(VkEnumValue(enum_elem.attrib["name"], 1 << int(enum_elem.attrib["bitpos"]), hex=True)) # E.g. VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG to VkFormatFeatureFlagBits.
elif "offset" in enum_elem.keys(): type_name = enum_elem.attrib["extends"]
ext_number = int(ext.attrib["number"]) enum = self.types[type_name]["data"]
offset = int(enum_elem.attrib["offset"]) enum.add(VkEnumValue(enum_elem.attrib["name"], 1 << int(enum_elem.attrib["bitpos"]), hex=True))
value = EXT_BASE + (ext_number - 1) * EXT_BLOCK_SIZE + offset elif "offset" in enum_elem.keys():
# Extensions promoted to Core, have the extension number as part
# of the enum value. Else retrieve from the extension tag.
if enum_elem.attrib.get("extnumber") is not None:
ext_number = int(enum_elem.attrib.get("extnumber"))
else:
ext_number = int(ext.attrib["number"])
offset = int(enum_elem.attrib["offset"])
value = EXT_BASE + (ext_number - 1) * EXT_BLOCK_SIZE + offset
# Deal with negative values. # Deal with negative values.
direction = enum_elem.attrib.get("dir") direction = enum_elem.attrib.get("dir")
if direction is not None: if direction is not None:
value = -value value = -value
type_name = enum_elem.attrib["extends"] type_name = enum_elem.attrib["extends"]
enum = self.types[type_name]["data"] enum = self.types[type_name]["data"]
enum.add(VkEnumValue(enum_elem.attrib["name"], value)) enum.add(VkEnumValue(enum_elem.attrib["name"], value))
elif "value" in enum_elem.keys(): elif "value" in enum_elem.keys():
self.consts.append(VkConstant(enum_elem.attrib.get("name"), enum_elem.attrib.get("value"))) self.consts.append(VkConstant(enum_elem.attrib.get("name"), enum_elem.attrib.get("value")))
continue continue
else: else:
# This seems to be used to pull in constants e.g. VK_MAX_DEVICE_GROUP_KHX # This seems to be used to pull in constants e.g. VK_MAX_DEVICE_GROUP_KHX
continue continue
# Pull in any commands we need. We infer types to pull in from the command
# as well.
for command in require.findall("command"):
cmd_name = command.attrib["name"]
self._mark_command_required(cmd_name)
# Store a list with extensions. # Store a list with extensions.
ext_info = {"name" : ext_name, "type" : ext_type} ext_info = {"name" : ext_name, "type" : ext_type}
extensions.append(ext_info) extensions.append(ext_info)
# Pull in any commands we need. We infer types to pull in from the command
# as well.
for command in commands:
cmd_name = command.attrib["name"]
self._mark_command_required(cmd_name)
# Sort in alphabetical order. # Sort in alphabetical order.
self.extensions = sorted(extensions, key=lambda ext: ext["name"]) self.extensions = sorted(extensions, key=lambda ext: ext["name"])