blob: 9239c059190c1c5736f5186b40113fff8a8ecbee [file] [log] [blame]
Tobin Ehlis5ade0692016-10-05 17:18:15 -06001#!/usr/bin/python3 -i
2
3import sys
4import xml.etree.ElementTree as etree
5import urllib2
Tobin Ehlis5ade0692016-10-05 17:18:15 -06006
7#############################
8# spec.py script
9#
10# Overview - this script is intended to generate validation error codes and message strings from the xhtml version of
11# the specification. In addition to generating the header file, it provides a number of corrollary services to aid in
12# generating/updating the header.
13#
14# Ideal flow - Not there currently, but the ideal flow for this script would be that you run the script, it pulls the
15# latest spec, compares it to the current set of generated error codes, and makes any updates as needed
16#
17# Current flow - the current flow acheives all of the ideal flow goals, but with more steps than are desired
18# 1. Get the spec - right now spec has to be manually generated or pulled from the web
19# 2. Generate header from spec - This is done in a single command line
20# 3. Generate database file from spec - Can be done along with step #2 above, the database file contains a list of
21# all error enums and message strings, along with some other info on if those errors are implemented/tested
22# 4. Update header using a given database file as the root and a new spec file as goal - This makes sure that existing
23# errors keep the same enum identifier while also making sure that new errors get a unique_id that continues on
24# from the end of the previous highest unique_id.
25#
26# TODO:
27# 1. Improve string matching to add more automation for figuring out which messages are changed vs. completely new
28#
29#
30#############################
31
32
33spec_filename = "vkspec.html" # can override w/ '-spec <filename>' option
34out_filename = "vk_validation_error_messages.h" # can override w/ '-out <filename>' option
35db_filename = "vk_validation_error_database.txt" # can override w/ '-gendb <filename>' option
36gen_db = False # set to True when '-gendb <filename>' option provided
37spec_compare = False # set to True with '-compare <db_filename>' option
38# This is the root spec link that is used in error messages to point users to spec sections
Tobin Ehlisbd0a9c62016-10-14 18:06:16 -060039#old_spec_url = "https://www.khronos.org/registry/vulkan/specs/1.0/xhtml/vkspec.html"
40spec_url = "https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html"
Tobin Ehlis5ade0692016-10-05 17:18:15 -060041# After the custom validation error message, this is the prefix for the standard message that includes the
42# spec valid usage language as well as the link to nearest section of spec to that language
43error_msg_prefix = "For more information refer to Vulkan Spec Section "
44ns = {'ns': 'http://www.w3.org/1999/xhtml'}
Mark Lobodzinski629d47b2016-10-18 13:34:58 -060045validation_error_enum_name = "VALIDATION_ERROR_"
Tobin Ehlis5ade0692016-10-05 17:18:15 -060046# Dict of new enum values that should be forced to remap to old handles, explicitly set by -remap option
47remap_dict = {}
48
49def printHelp():
50 print "Usage: python spec.py [-spec <specfile.html>] [-out <headerfile.h>] [-gendb <databasefile.txt>] [-compare <databasefile.txt>] [-update] [-remap <new_id-old_id,count>] [-help]"
51 print "\n Default script behavior is to parse the specfile and generate a header of unique error enums and corresponding error messages based on the specfile.\n"
52 print " Default specfile is from online at %s" % (spec_url)
53 print " Default headerfile is %s" % (out_filename)
54 print " Default databasefile is %s" % (db_filename)
55 print "\nIf '-gendb' option is specified then a database file is generated to default file or <databasefile.txt> if supplied. The database file stores"
56 print " the list of enums and their error messages."
57 print "\nIf '-compare' option is specified then the given database file will be read in as the baseline for generating the new specfile"
58 print "\nIf '-update' option is specified this triggers the master flow to automate updating header and database files using default db file as baseline"
59 print " and online spec file as the latest. The default header and database files will be updated in-place for review and commit to the git repo."
60 print "\nIf '-remap' option is specified it supplies forced remapping from new enum ids to old enum ids. This should only be specified along with -update"
61 print " option. Starting at newid and remapping to oldid, count ids will be remapped. Default count is '1' and use ':' to specify multiple remappings."
62
63class Specification:
64 def __init__(self):
65 self.tree = None
66 self.val_error_dict = {} # string for enum is key that references text for output message
67 self.error_db_dict = {} # dict of previous error values read in from database file
68 self.delimiter = '~^~' # delimiter for db file
69 self.copyright = """/* THIS FILE IS GENERATED. DO NOT EDIT. */
70
71/*
72 * Vulkan
73 *
74 * Copyright (c) 2016 Google Inc.
Mark Lobodzinski629d47b2016-10-18 13:34:58 -060075 * Copyright (c) 2016 LunarG, Inc.
Tobin Ehlis5ade0692016-10-05 17:18:15 -060076 *
77 * Licensed under the Apache License, Version 2.0 (the "License");
78 * you may not use this file except in compliance with the License.
79 * You may obtain a copy of the License at
80 *
81 * http://www.apache.org/licenses/LICENSE-2.0
82 *
83 * Unless required by applicable law or agreed to in writing, software
84 * distributed under the License is distributed on an "AS IS" BASIS,
85 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
86 * See the License for the specific language governing permissions and
87 * limitations under the License.
88 *
89 * Author: Tobin Ehlis <tobine@google.com>
90 */"""
91 def _checkInternetSpec(self):
92 """Verify that we can access the spec online"""
93 try:
94 online = urllib2.urlopen(spec_url,timeout=1)
95 return True
96 except urllib2.URLError as err:
97 return False
98 return False
99 def loadFile(self, online=True, spec_file=spec_filename):
100 """Load an API registry XML file into a Registry object and parse it"""
101 # Check if spec URL is available
102 if (online and self._checkInternetSpec()):
103 print "Using spec from online at %s" % (spec_url)
104 self.tree = etree.parse(urllib2.urlopen(spec_url))
105 else:
106 print "Using local spec %s" % (spec_file)
107 self.tree = etree.parse(spec_file)
108 #self.tree.write("tree_output.xhtml")
109 #self.tree = etree.parse("tree_output.xhtml")
110 self.parseTree()
111 def updateDict(self, updated_dict):
112 """Assign internal dict to use updated_dict"""
113 self.val_error_dict = updated_dict
114 def parseTree(self):
115 """Parse the registry Element, once created"""
116 print "Parsing spec file..."
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600117 unique_enum_id = 0
118 self.root = self.tree.getroot()
119 #print "ROOT: %s" % self.root
120 prev_heading = '' # Last seen section heading or sub-heading
121 prev_link = '' # Last seen link id within the spec
122 for tag in self.root.iter(): # iterate down tree
123 # Grab most recent section heading and link
124 if tag.tag in ['{http://www.w3.org/1999/xhtml}h2', '{http://www.w3.org/1999/xhtml}h3']:
125 if tag.get('class') != 'title':
126 continue
127 #print "Found heading %s" % (tag.tag)
128 prev_heading = "".join(tag.itertext())
129 # Insert a space between heading number & title
130 sh_list = prev_heading.rsplit('.', 1)
131 prev_heading = '. '.join(sh_list)
132 prev_link = tag[0].get('id')
133 #print "Set prev_heading %s to have link of %s" % (prev_heading.encode("ascii", "ignore"), prev_link.encode("ascii", "ignore"))
134 elif tag.tag == '{http://www.w3.org/1999/xhtml}a': # grab any intermediate links
135 if tag.get('id') != None:
136 prev_link = tag.get('id')
Tobin Ehlis16b159c2016-10-25 06:33:27 -0600137 #print "Updated prev link to %s" % (prev_link)
Tobin Ehlis69ebddf2016-10-18 15:55:07 -0600138 elif tag.tag == '{http://www.w3.org/1999/xhtml}div' and tag.get('class') == 'sidebar':
139 # parse down sidebar to check for valid usage cases
140 valid_usage = False
141 for elem in tag.iter():
142 if elem.tag == '{http://www.w3.org/1999/xhtml}strong' and None != elem.text and 'Valid Usage' in elem.text:
143 valid_usage = True
144 elif valid_usage and elem.tag == '{http://www.w3.org/1999/xhtml}li': # grab actual valid usage requirements
145 error_msg_str = "%s '%s' which states '%s' (%s#%s)" % (error_msg_prefix, prev_heading, "".join(elem.itertext()).replace('\n', ''), spec_url, prev_link)
146 # Some txt has multiple spaces so split on whitespace and join w/ single space
147 error_msg_str = " ".join(error_msg_str.split())
148 enum_str = "%s%05d" % (validation_error_enum_name, unique_enum_id)
149 # TODO : '\' chars in spec error messages are most likely bad spec txt that needs to be updated
150 self.val_error_dict[enum_str] = error_msg_str.encode("ascii", "ignore").replace("\\", "/")
151 unique_enum_id = unique_enum_id + 1
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600152 #print "Validation Error Dict has a total of %d unique errors and contents are:\n%s" % (unique_enum_id, self.val_error_dict)
153 def genHeader(self, header_file):
154 """Generate a header file based on the contents of a parsed spec"""
155 print "Generating header %s..." % (header_file)
156 file_contents = []
157 file_contents.append(self.copyright)
158 file_contents.append('\n#pragma once')
Tobin Ehlisbf98b692016-10-06 12:58:06 -0600159 file_contents.append('#include <unordered_map>')
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600160 file_contents.append('\n// enum values for unique validation error codes')
161 file_contents.append('// Corresponding validation error message for each enum is given in the mapping table below')
162 file_contents.append('// When a given error occurs, these enum values should be passed to the as the messageCode')
163 file_contents.append('// parameter to the PFN_vkDebugReportCallbackEXT function')
164 enum_decl = ['enum UNIQUE_VALIDATION_ERROR_CODE {']
Tobin Ehlisbf98b692016-10-06 12:58:06 -0600165 error_string_map = ['static std::unordered_map<int, char const *const> validation_error_map{']
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600166 for enum in sorted(self.val_error_dict):
167 #print "Header enum is %s" % (enum)
168 enum_decl.append(' %s = %d,' % (enum, int(enum.split('_')[-1])))
169 error_string_map.append(' {%s, "%s"},' % (enum, self.val_error_dict[enum]))
Mark Lobodzinski629d47b2016-10-18 13:34:58 -0600170 enum_decl.append(' %sMAX_ENUM = %d,' % (validation_error_enum_name, int(enum.split('_')[-1]) + 1))
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600171 enum_decl.append('};')
172 error_string_map.append('};')
173 file_contents.extend(enum_decl)
174 file_contents.append('\n// Mapping from unique validation error enum to the corresponding error message')
175 file_contents.append('// The error message should be appended to the end of a custom error message that is passed')
176 file_contents.append('// as the pMessage parameter to the PFN_vkDebugReportCallbackEXT function')
177 file_contents.extend(error_string_map)
178 #print "File contents: %s" % (file_contents)
179 with open(header_file, "w") as outfile:
180 outfile.write("\n".join(file_contents))
181 def analyze(self):
182 """Print out some stats on the valid usage dict"""
183 # Create dict for # of occurences of identical strings
184 str_count_dict = {}
185 unique_id_count = 0
186 for enum in self.val_error_dict:
187 err_str = self.val_error_dict[enum]
188 if err_str in str_count_dict:
Tobin Ehlis69ebddf2016-10-18 15:55:07 -0600189 print "Found repeat error string"
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600190 str_count_dict[err_str] = str_count_dict[err_str] + 1
191 else:
192 str_count_dict[err_str] = 1
193 unique_id_count = unique_id_count + 1
194 print "Processed %d unique_ids" % (unique_id_count)
195 repeat_string = 0
196 for es in str_count_dict:
197 if str_count_dict[es] > 1:
198 repeat_string = repeat_string + 1
Tobin Ehlis69ebddf2016-10-18 15:55:07 -0600199 print "String '%s' repeated %d times" % (es, repeat_string)
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600200 print "Found %d repeat strings" % (repeat_string)
201 def genDB(self, db_file):
202 """Generate a database of check_enum, check_coded?, testname, error_string"""
203 db_lines = []
204 # Write header for database file
205 db_lines.append("# This is a database file with validation error check information")
206 db_lines.append("# Comments are denoted with '#' char")
207 db_lines.append("# The format of the lines is:")
208 db_lines.append("# <error_enum>%s<check_implemented>%s<testname>%s<errormsg>" % (self.delimiter, self.delimiter, self.delimiter))
Mark Lobodzinski629d47b2016-10-18 13:34:58 -0600209 db_lines.append("# error_enum: Unique error enum for this check of format %s<uniqueid>" % validation_error_enum_name)
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600210 db_lines.append("# check_implemented: 'Y' if check has been implemented in layers, 'U' for unknown, or 'N' for not implemented")
211 db_lines.append("# testname: Name of validation test for this check, 'Unknown' for unknown, or 'None' if not implmented")
212 db_lines.append("# errormsg: The unique error message for this check that includes spec language and link")
213 for enum in sorted(self.val_error_dict):
214 # Default to unknown if check or test are implemented, then update below if appropriate
215 implemented = 'U'
216 testname = 'Unknown'
217 # If we have an existing db entry for this enum, use its implemented/testname values
218 if enum in self.error_db_dict:
219 implemented = self.error_db_dict[enum]['check_implemented']
220 testname = self.error_db_dict[enum]['testname']
221 #print "delimiter: %s, id: %s, str: %s" % (self.delimiter, enum, self.val_error_dict[enum])
222 # No existing entry so default to N for implemented and None for testname
223 db_lines.append("%s%s%s%s%s%s%s" % (enum, self.delimiter, implemented, self.delimiter, testname, self.delimiter, self.val_error_dict[enum]))
224 print "Generating database file %s" % (db_file)
225 with open(db_file, "w") as outfile:
226 outfile.write("\n".join(db_lines))
227 def readDB(self, db_file):
228 """Read a db file into a dict, format of each line is <enum><implemented Y|N?><testname><errormsg>"""
229 db_dict = {} # This is a simple db of just enum->errormsg, the same as is created from spec
230 max_id = 0
231 with open(db_file, "r") as infile:
232 for line in infile:
233 if line.startswith('#'):
234 continue
235 line = line.strip()
236 db_line = line.split(self.delimiter)
Tobin Ehlis802b16e2016-10-11 09:37:19 -0600237 if len(db_line) != 4:
238 print "ERROR: Bad database line doesn't have 4 elements: %s" % (line)
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600239 error_enum = db_line[0]
240 implemented = db_line[1]
241 testname = db_line[2]
242 error_str = db_line[3]
243 db_dict[error_enum] = error_str
244 # Also read complete database contents into our class var for later use
245 self.error_db_dict[error_enum] = {}
246 self.error_db_dict[error_enum]['check_implemented'] = implemented
247 self.error_db_dict[error_enum]['testname'] = testname
248 self.error_db_dict[error_enum]['error_string'] = error_str
249 unique_id = int(db_line[0].split('_')[-1])
250 if unique_id > max_id:
251 max_id = unique_id
252 return (db_dict, max_id)
253 # Compare unique ids from original database to data generated from updated spec
254 # 1. If a new id and error code exactly match original, great
255 # 2. If new id is not in original, but exact error code is, need to use original error code
256 # 3. If new id and new error are not in original, make sure new id picks up from end of original list
257 # 4. If new id in original, but error strings don't match then:
258 # 4a. If error string has exact match in original, update new to use original
259 # 4b. If error string not in original, may be updated error message, manually address
260 def compareDB(self, orig_db_dict, max_id):
261 """Compare orig database dict to new dict, report out findings, and return potential new dict for parsed spec"""
262 # First create reverse dicts of err_strings to IDs
263 next_id = max_id + 1
264 orig_err_to_id_dict = {}
265 # Create an updated dict in-place that will be assigned to self.val_error_dict when done
266 updated_val_error_dict = {}
267 for enum in orig_db_dict:
268 orig_err_to_id_dict[orig_db_dict[enum]] = enum
269 new_err_to_id_dict = {}
270 for enum in self.val_error_dict:
271 new_err_to_id_dict[self.val_error_dict[enum]] = enum
272 ids_parsed = 0
273 # Now parse through new dict and figure out what to do with non-matching things
274 for enum in sorted(self.val_error_dict):
275 ids_parsed = ids_parsed + 1
276 enum_list = enum.split('_') # grab sections of enum for use below
Tobin Ehlisbd0a9c62016-10-14 18:06:16 -0600277 # Any user-forced remap takes precendence
278 if enum_list[-1] in remap_dict:
279 enum_list[-1] = remap_dict[enum_list[-1]]
280 new_enum = "_".join(enum_list)
281 print "NOTE: Using user-supplied remap to force %s to be %s" % (enum, new_enum)
282 updated_val_error_dict[new_enum] = self.val_error_dict[enum]
283 elif enum in orig_db_dict:
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600284 if self.val_error_dict[enum] == orig_db_dict[enum]:
Tobin Ehlisbd0a9c62016-10-14 18:06:16 -0600285 print "Exact match for enum %s" % (enum)
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600286 # Nothing to see here
287 if enum in updated_val_error_dict:
288 print "ERROR: About to overwrite entry for %s" % (enum)
289 updated_val_error_dict[enum] = self.val_error_dict[enum]
290 elif self.val_error_dict[enum] in orig_err_to_id_dict:
291 # Same value w/ different error id, need to anchor to original id
Tobin Ehlisbd0a9c62016-10-14 18:06:16 -0600292 print "Need to switch new id %s to original id %s" % (enum, orig_err_to_id_dict[self.val_error_dict[enum]])
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600293 # Update id at end of new enum to be same id from original enum
294 enum_list[-1] = orig_err_to_id_dict[self.val_error_dict[enum]].split('_')[-1]
295 new_enum = "_".join(enum_list)
296 if new_enum in updated_val_error_dict:
297 print "ERROR: About to overwrite entry for %s" % (new_enum)
298 updated_val_error_dict[new_enum] = self.val_error_dict[enum]
299 else:
300 # No error match:
301 # First check if only link has changed, in which case keep ID but update message
302 orig_msg_list = orig_db_dict[enum].split('(', 1)
303 new_msg_list = self.val_error_dict[enum].split('(', 1)
304 if orig_msg_list[0] == new_msg_list[0]: # Msg is same bug link has changed, keep enum & update msg
305 print "NOTE: Found that only spec link changed for %s so keeping same id w/ new link" % (enum)
306 updated_val_error_dict[enum] = self.val_error_dict[enum]
Tobin Ehlisbd0a9c62016-10-14 18:06:16 -0600307 # This seems to be a new error so need to pick it up from end of original unique ids & flag for review
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600308 else:
309 enum_list[-1] = "%05d" % (next_id)
310 new_enum = "_".join(enum_list)
311 next_id = next_id + 1
312 print "MANUALLY VERIFY: Updated new enum %s to be unique %s. Make sure new error msg is actually unique and not just changed" % (enum, new_enum)
313 print " New error string: %s" % (self.val_error_dict[enum])
314 if new_enum in updated_val_error_dict:
315 print "ERROR: About to overwrite entry for %s" % (new_enum)
316 updated_val_error_dict[new_enum] = self.val_error_dict[enum]
317 else: # new enum is not in orig db
318 if self.val_error_dict[enum] in orig_err_to_id_dict:
Tobin Ehlisbd0a9c62016-10-14 18:06:16 -0600319 print "New enum %s not in orig dict, but exact error message matches original unique id %s" % (enum, orig_err_to_id_dict[self.val_error_dict[enum]])
Tobin Ehlis5ade0692016-10-05 17:18:15 -0600320 # Update new unique_id to use original
321 enum_list[-1] = orig_err_to_id_dict[self.val_error_dict[enum]].split('_')[-1]
322 new_enum = "_".join(enum_list)
323 if new_enum in updated_val_error_dict:
324 print "ERROR: About to overwrite entry for %s" % (new_enum)
325 updated_val_error_dict[new_enum] = self.val_error_dict[enum]
326 else:
327 enum_list[-1] = "%05d" % (next_id)
328 new_enum = "_".join(enum_list)
329 next_id = next_id + 1
330 print "Completely new id and error code, update new id from %s to unique %s" % (enum, new_enum)
331 if new_enum in updated_val_error_dict:
332 print "ERROR: About to overwrite entry for %s" % (new_enum)
333 updated_val_error_dict[new_enum] = self.val_error_dict[enum]
334 # Assign parsed dict to be the udpated dict based on db compare
335 print "In compareDB parsed %d entries" % (ids_parsed)
336 return updated_val_error_dict
337 def validateUpdateDict(self, update_dict):
338 """Compare original dict vs. update dict and make sure that all of the checks are still there"""
339 # Currently just make sure that the same # of checks as the original checks are there
340 #orig_ids = {}
341 orig_id_count = len(self.val_error_dict)
342 #update_ids = {}
343 update_id_count = len(update_dict)
344 if orig_id_count != update_id_count:
345 print "Original dict had %d unique_ids, but updated dict has %d!" % (orig_id_count, update_id_count)
346 return False
347 print "Original dict and updated dict both have %d unique_ids. Great!" % (orig_id_count)
348 return True
349 # TODO : include some more analysis
350
351# User passes in arg of form <new_id1>-<old_id1>[,count1]:<new_id2>-<old_id2>[,count2]:...
352# new_id# = the new enum id that was assigned to an error
353# old_id# = the previous enum id that was assigned to the same error
354# [,count#] = The number of ids to remap starting at new_id#=old_id# and ending at new_id[#+count#-1]=old_id[#+count#-1]
355# If not supplied, then ,1 is assumed, which will only update a single id
356def updateRemapDict(remap_string):
357 """Set up global remap_dict based on user input"""
358 remap_list = remap_string.split(":")
359 for rmap in remap_list:
360 count = 1 # Default count if none supplied
361 id_count_list = rmap.split(',')
362 if len(id_count_list) > 1:
363 count = int(id_count_list[1])
364 new_old_id_list = id_count_list[0].split('-')
365 for offset in range(count):
366 remap_dict["%05d" % (int(new_old_id_list[0]) + offset)] = "%05d" % (int(new_old_id_list[1]) + offset)
367 for new_id in sorted(remap_dict):
368 print "Set to remap new id %s to old id %s" % (new_id, remap_dict[new_id])
369
370if __name__ == "__main__":
371 i = 1
372 use_online = True # Attempt to grab spec from online by default
373 update_option = False
374 while (i < len(sys.argv)):
375 arg = sys.argv[i]
376 i = i + 1
377 if (arg == '-spec'):
378 spec_filename = sys.argv[i]
379 # If user specifies local specfile, skip online
380 use_online = False
381 i = i + 1
382 elif (arg == '-out'):
383 out_filename = sys.argv[i]
384 i = i + 1
385 elif (arg == '-gendb'):
386 gen_db = True
387 # Set filename if supplied, else use default
388 if i < len(sys.argv) and not sys.argv[i].startswith('-'):
389 db_filename = sys.argv[i]
390 i = i + 1
391 elif (arg == '-compare'):
392 db_filename = sys.argv[i]
393 spec_compare = True
394 i = i + 1
395 elif (arg == '-update'):
396 update_option = True
397 spec_compare = True
398 gen_db = True
399 elif (arg == '-remap'):
400 updateRemapDict(sys.argv[i])
401 i = i + 1
402 elif (arg in ['-help', '-h']):
403 printHelp()
404 sys.exit()
405 if len(remap_dict) > 1 and not update_option:
406 print "ERROR: '-remap' option can only be used along with '-update' option. Exiting."
407 sys.exit()
408 spec = Specification()
409 spec.loadFile(use_online, spec_filename)
410 #spec.parseTree()
411 #spec.genHeader(out_filename)
412 spec.analyze()
413 if (spec_compare):
414 # Read in old spec info from db file
415 (orig_db_dict, max_id) = spec.readDB(db_filename)
416 # New spec data should already be read into self.val_error_dict
417 updated_dict = spec.compareDB(orig_db_dict, max_id)
418 update_valid = spec.validateUpdateDict(updated_dict)
419 if update_valid:
420 spec.updateDict(updated_dict)
421 else:
422 sys.exit()
423 if (gen_db):
424 spec.genDB(db_filename)
425 print "Writing out file (-out) to '%s'" % (out_filename)
426 spec.genHeader(out_filename)
427
428##### Example dataset
429# <div class="sidebar">
430# <div class="titlepage">
431# <div>
432# <div>
433# <p class="title">
434# <strong>Valid Usage</strong> # When we get to this guy, we know we're under interesting sidebar
435# </p>
436# </div>
437# </div>
438# </div>
439# <div class="itemizedlist">
440# <ul class="itemizedlist" style="list-style-type: disc; ">
441# <li class="listitem">
442# <em class="parameter">
443# <code>device</code>
444# </em>
445# <span class="normative">must</span> be a valid
446# <code class="code">VkDevice</code> handle
447# </li>
448# <li class="listitem">
449# <em class="parameter">
450# <code>commandPool</code>
451# </em>
452# <span class="normative">must</span> be a valid
453# <code class="code">VkCommandPool</code> handle
454# </li>
455# <li class="listitem">
456# <em class="parameter">
457# <code>flags</code>
458# </em>
459# <span class="normative">must</span> be a valid combination of
460# <code class="code">
461# <a class="link" href="#VkCommandPoolResetFlagBits">VkCommandPoolResetFlagBits</a>
462# </code> values
463# </li>
464# <li class="listitem">
465# <em class="parameter">
466# <code>commandPool</code>
467# </em>
468# <span class="normative">must</span> have been created, allocated, or retrieved from
469# <em class="parameter">
470# <code>device</code>
471# </em>
472# </li>
473# <li class="listitem">All
474# <code class="code">VkCommandBuffer</code>
475# objects allocated from
476# <em class="parameter">
477# <code>commandPool</code>
478# </em>
479# <span class="normative">must</span> not currently be pending execution
480# </li>
481# </ul>
482# </div>
483# </div>
484##### Second example dataset
485# <div class="sidebar">
486# <div class="titlepage">
487# <div>
488# <div>
489# <p class="title">
490# <strong>Valid Usage</strong>
491# </p>
492# </div>
493# </div>
494# </div>
495# <div class="itemizedlist">
496# <ul class="itemizedlist" style="list-style-type: disc; ">
497# <li class="listitem">The <em class="parameter"><code>queueFamilyIndex</code></em> member of any given element of <em class="parameter"><code>pQueueCreateInfos</code></em> <span class="normative">must</span> be unique within <em class="parameter"><code>pQueueCreateInfos</code></em>
498# </li>
499# </ul>
500# </div>
501# </div>
502# <div class="sidebar">
503# <div class="titlepage">
504# <div>
505# <div>
506# <p class="title">
507# <strong>Valid Usage (Implicit)</strong>
508# </p>
509# </div>
510# </div>
511# </div>
512# <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
513#<em class="parameter"><code>sType</code></em> <span class="normative">must</span> be <code class="code">VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO</code>
514#</li><li class="listitem">
515#<em class="parameter"><code>pNext</code></em> <span class="normative">must</span> be <code class="literal">NULL</code>
516#</li><li class="listitem">
517#<em class="parameter"><code>flags</code></em> <span class="normative">must</span> be <code class="literal">0</code>
518#</li><li class="listitem">
519#<em class="parameter"><code>pQueueCreateInfos</code></em> <span class="normative">must</span> be a pointer to an array of <em class="parameter"><code>queueCreateInfoCount</code></em> valid <code class="code">VkDeviceQueueCreateInfo</code> structures
520#</li>