diff --git a/tools/spec.py b/tools/spec.py index 99e04f8..e53cd6d 100644 --- a/tools/spec.py +++ b/tools/spec.py @@ -903,19 +903,20 @@ if __name__ == '__main__': args = parser.parse_args() - src = open(args.src, 'r') - - tree = ET.parse(src) + # Get a copy of the specification XML + with open(args.src, 'r') as src: + tree = ET.parse(src) root = tree.getroot() + # Find a parser for each of the nodes in the XML reg = registry() - - types = {} - for node in root: target = "parse_%s" % node.tag globals()[target](reg, node) + # Override some requested system types so that they fit more naturally in + # our environment. eg, use appropriate C++ types, or cruft library + # wrappers. reg.types['windows.h'].name = 'cruft/util/win32/windows.hpp' reg.types['void*'] = placeholder('void*') reg.types['nullptr'] = placeholder('nullptr') @@ -924,13 +925,18 @@ if __name__ == '__main__': reg.types['VK_DEFINE_HANDLE'] = aliastype("VK_DEFINE_HANDLE", "void*") reg.types['VK_NULL_HANDLE'] = aliasvalue("VK_NULL_HANDLE", "nullptr"); + # Request serialisation of all features features = [feature(n) for n in root.findall('./feature')] features = dict((f.name,f) for f in features) #reg.extensions['VK_KHR_surface'].apply(reg, platform='xcb') + + # Request a minimal set of extensions that will almost certainly be + # required for all applications. extensions = ["VK_KHR_swapchain", "VK_EXT_debug_report", "VK_KHR_external_memory"] q = reg.serialise(args.platform) + # Finally write out the header, icd, and dispatch code. write_header(args.dst, q) write_icd(args.icd, q) write_dispatch(args.dispatch, q)