diff options
| author | Charles Giessen <charles@lunarg.com> | 2020-06-22 11:50:24 -0600 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2020-06-22 13:18:13 -0600 |
| commit | 0a46a92e57976c51c82c597c21b0d283040348bf (patch) | |
| tree | fde5d284da14ce818e011507cc94cc04b82b2d0f /scripts | |
| parent | 977b7ccbacc1071e62c1c82b242a28a2b1806ec9 (diff) | |
| download | usermoji-0a46a92e57976c51c82c597c21b0d283040348bf.tar.xz | |
vulkaninfo: fix ordering issues in generated code
Previously the codegen would reorder structs as it pleased
This commit fixed several instances of bad ordering or lack thereof.
Change-Id: Ieda89c64f7400b807407c2fd26660fea10e2bb59
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/vulkaninfo_generator.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py index adc01865..e1e80a60 100644 --- a/scripts/vulkaninfo_generator.py +++ b/scripts/vulkaninfo_generator.py @@ -221,33 +221,40 @@ class VulkanInfoGenerator(OutputGenerator): for f in flags_to_gen: types_to_gen.add(f) - types_to_gen = types_to_gen.union( + types_to_gen.update( GatherTypesToGen(self.all_structures, structures_to_gen)) for key in EXTENSION_CATEGORIES.keys(): - types_to_gen = types_to_gen.union( + types_to_gen.update( GatherTypesToGen(self.all_structures, self.extension_sets[key])) + types_to_gen = sorted(types_to_gen) names_of_structures_to_gen = set() for s in self.all_structures: if s.name in types_to_gen: names_of_structures_to_gen.add(s.name) + names_of_structures_to_gen = sorted(names_of_structures_to_gen) structs_to_comp = set() for s in struct_comparisons_to_gen: structs_to_comp.add(s) - structs_to_comp = structs_to_comp.union( + structs_to_comp.update( GatherTypesToGen(self.all_structures, struct_comparisons_to_gen)) for key, value in self.extension_sets.items(): self.extension_sets[key] = sorted(value) - alias_versions = {} + alias_versions = OrderedDict() for version in self.vulkan_versions: for aliased_type, aliases in self.aliases.items(): for alias in aliases: if alias in version.names: alias_versions[alias] = version.minorVersion + self.enums = sorted(self.enums, key=operator.attrgetter('name')) + self.flags = sorted(self.flags, key=operator.attrgetter('name')) + self.bitmasks = sorted(self.bitmasks, key=operator.attrgetter('name')) + self.all_structures = sorted(self.all_structures, key=operator.attrgetter('name')) + # print the types gathered out = '' out += license_header + "\n" @@ -283,6 +290,8 @@ class VulkanInfoGenerator(OutputGenerator): self.extension_sets[key], self.all_structures, value.get('type'), self.extTypes, self.aliases, self.vulkan_versions) for s in (x for x in self.all_structures if x.name in structs_to_comp): + out += PrintStructComparisonForwardDecl(s) + for s in (x for x in self.all_structures if x.name in structs_to_comp): out += PrintStructComparison(s) for s in (x for x in self.all_structures if x.name in struct_short_versions_to_gen): out += PrintStructShort(s) @@ -355,6 +364,7 @@ def GatherTypesToGen(structure_list, structures): for m in s.members: if m.typeID not in predefined_types and m.name not in ['sType', 'pNext']: types.add(m.typeID) + types = sorted(types) return types @@ -630,7 +640,9 @@ def PrintChainIterator(listName, structures, all_structures, checkExtLoc, extTyp out += " while (place) {\n" out += " struct VkStructureHeader *structure = (struct VkStructureHeader *)place;\n" out += " p.SetSubHeader();\n" - for s in all_structures: + sorted_structures = sorted( + all_structures, key=operator.attrgetter('name')) + for s in sorted_structures: if s.sTypeName is None: continue @@ -690,6 +702,12 @@ def PrintChainIterator(listName, structures, all_structures, checkExtLoc, extTyp out += "}\n" return out +def PrintStructComparisonForwardDecl(structure): + out = '' + out += "bool operator==(const " + structure.name + \ + " & a, const " + structure.name + " b);\n" + return out + def PrintStructComparison(structure): out = '' @@ -899,8 +917,8 @@ class VulkanExtension: self.extNameStr = None self.vktypes = [] self.vkfuncs = [] - self.constants = {} - self.enumValues = {} + self.constants = OrderedDict() + self.enumValues = OrderedDict() self.version = 0 self.node = rootNode @@ -957,3 +975,4 @@ class VulkanVersion: self.names.add(func.get('name')) for enum in req.findall('enum'): self.names.add(enum.get('name')) + self.names = sorted(self.names) |
