aboutsummaryrefslogtreecommitdiff
path: root/scripts/parameter_validation_generator.py
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2017-06-01 15:10:13 -0600
committerMark Lobodzinski <mark@lunarg.com>2017-06-06 14:36:42 -0600
commitb5b46b4c65f29e371c702bdeb5c6a8fbf8c74d66 (patch)
tree8369ab8fb054eb89681ec8b81dbe90800950ef24 /scripts/parameter_validation_generator.py
parent605facc8ce1457479ba3c690b0d5869d5dff364c (diff)
downloadusermoji-b5b46b4c65f29e371c702bdeb5c6a8fbf8c74d66.tar.xz
layers: Unify extension enable tracking
Switch parameter validation code-generated extension dependency checks to use the existing data in vk_extension_helper.h. Change-Id: I6e3c83f68430c1d3de915e05a84944782b4a55a2
Diffstat (limited to 'scripts/parameter_validation_generator.py')
-rw-r--r--scripts/parameter_validation_generator.py69
1 files changed, 39 insertions, 30 deletions
diff --git a/scripts/parameter_validation_generator.py b/scripts/parameter_validation_generator.py
index 0e276bfe..7d3b873d 100644
--- a/scripts/parameter_validation_generator.py
+++ b/scripts/parameter_validation_generator.py
@@ -144,7 +144,7 @@ class ParamCheckerOutputGenerator(OutputGenerator):
# Header version
self.headerVersion = None
# Internal state - accumulators for different inner block text
- self.sections = dict([(section, []) for section in self.ALL_SECTIONS])
+ self.validation = [] # Text comprising the main per-api parameter validation routines
self.structNames = [] # List of Vulkan struct typenames
self.stypes = [] # Values from the VkStructureType enumeration
self.structTypes = dict() # Map of Vulkan struct typename to required VkStructureType
@@ -157,12 +157,15 @@ class ParamCheckerOutputGenerator(OutputGenerator):
self.flagBits = dict() # Map of flag bits typename to list of values
self.newFlags = set() # Map of flags typenames /defined in the current feature/
self.required_extensions = [] # List of required extensions for the current extension
+ self.extension_type = '' # Type of active feature (extension), device or instance
+ self.extension_names = dict() # Dictionary of extension names to extension name defines
+
# Named tuples to store struct and command data
self.StructType = namedtuple('StructType', ['name', 'value'])
self.CommandParam = namedtuple('CommandParam', ['type', 'name', 'ispointer', 'isstaticarray', 'isbool', 'israngedenum',
'isconst', 'isoptional', 'iscount', 'noautovalidity', 'len', 'extstructs',
'condition', 'cdecl'])
- self.CommandData = namedtuple('CommandData', ['name', 'params', 'cdecl'])
+ self.CommandData = namedtuple('CommandData', ['name', 'params', 'cdecl', 'extension_type'])
self.StructMemberData = namedtuple('StructMemberData', ['name', 'members'])
#
def incIndent(self, indent):
@@ -211,7 +214,9 @@ class ParamCheckerOutputGenerator(OutputGenerator):
def endFile(self):
# C-specific
self.newline()
-
+ commands_text = '\n'.join(self.validation)
+ write(commands_text, file=self.outFile)
+ self.newline()
# Output declarations and record intercepted procedures
write('// Declarations', file=self.outFile)
write('\n'.join(self.declarations), file=self.outFile)
@@ -236,7 +241,6 @@ class ParamCheckerOutputGenerator(OutputGenerator):
# end function prototypes separately for this feature. They're only
# printed in endFeature().
self.headerVersion = None
- self.sections = dict([(section, []) for section in self.ALL_SECTIONS])
self.structNames = []
self.stypes = []
self.structTypes = dict()
@@ -246,20 +250,29 @@ class ParamCheckerOutputGenerator(OutputGenerator):
# Save list of required extensions for this extension
self.required_extensions = []
if self.featureName != "VK_VERSION_1_0":
+ # Save Name Define to get correct enable name later
+ nameElem = interface[0][1]
+ name = nameElem.get('name')
+ self.extension_names[self.featureName] = name
+ # This extension is the first dependency for this command
self.required_extensions.append(self.featureName)
+ # Add any defined extension dependencies to the dependency list for this command
required_extensions = interface.get('requires')
if required_extensions is not None:
self.required_extensions.extend(required_extensions.split(','))
+ # And note if this is an Instance or Device extension
+ self.extension_type = interface.get('type')
def endFeature(self):
# C-specific
# Actually write the interface to the output file.
if (self.emit):
- self.newline()
# If type declarations are needed by other features based on
# this one, it may be necessary to suppress the ExtraProtect,
# or move it below the 'for section...' loop.
+ ifdef = ''
if (self.featureExtraProtect != None):
- write('#ifdef', self.featureExtraProtect, file=self.outFile)
+ ifdef = '#ifdef %s\n' % self.featureExtraProtect
+ self.validation.append(ifdef)
# Generate the struct member checking code from the captured data
self.processStructMemberData()
# Generate the command parameter checking code from the captured data
@@ -278,25 +291,13 @@ class ParamCheckerOutputGenerator(OutputGenerator):
decl += '|' + bit
decl += ';'
write(decl, file=self.outFile)
- self.newline()
- # Write the parameter validation code to the file
- if (self.sections['command']):
- if (self.genOpts.protectProto):
- write(self.genOpts.protectProto,
- self.genOpts.protectProtoStr, file=self.outFile)
- write('\n'.join(self.sections['command']), end=u'', file=self.outFile)
+ endif = '\n'
if (self.featureExtraProtect != None):
- write('#endif /*', self.featureExtraProtect, '*/', file=self.outFile)
- else:
- self.newline()
+ endif = '#endif // %s\n' % self.featureExtraProtect
+ self.validation.append(endif)
# Finish processing in superclass
OutputGenerator.endFeature(self)
#
- # Append a definition to the specified section
- def appendSection(self, section, text):
- # self.sections[section].append('SECTION: ' + section + '\n')
- self.sections[section].append(text)
- #
# Type generation
def genType(self, typeinfo, name):
OutputGenerator.genType(self, typeinfo, name)
@@ -473,7 +474,7 @@ class ParamCheckerOutputGenerator(OutputGenerator):
extstructs=None,
condition=None,
cdecl=cdecl))
- self.commands.append(self.CommandData(name=name, params=paramsInfo, cdecl=self.makeCDecls(cmdinfo.elem)[0]))
+ self.commands.append(self.CommandData(name=name, params=paramsInfo, cdecl=self.makeCDecls(cmdinfo.elem)[0], extension_type=self.extension_type))
#
# Check if the parameter passed in is a pointer
def paramIsPointer(self, param):
@@ -1024,14 +1025,22 @@ class ParamCheckerOutputGenerator(OutputGenerator):
# Skip first parameter if it is a dispatch handle (everything except vkCreateInstance)
startIndex = 0 if command.name == 'vkCreateInstance' else 1
lines, unused = self.genFuncBody(command.name, command.params[startIndex:], '', '', None)
- if self.required_extensions:
- def_line = 'std::vector<std::string> required_extensions = {'
+ # Cannot validate extension dependencies for device extension APIs a physical device as their dispatchable object
+ if self.required_extensions and self.extension_type == 'device' and command.params[0].type != 'VkPhysicalDevice':
+ # The actual extension names are not all available yet, so we'll tag these now and replace them just before
+ # writing the validation routines out to a file
+ ext_test = ''
for ext in self.required_extensions:
- def_line += '"%s", ' % ext
- def_line = def_line[:-2] + '};'
- ext_call = 'skipCall |= ValidateRequiredExtensions(layer_data, "%s", required_extensions);\n' % command.name
- lines.insert(0, ext_call)
- lines.insert(0, def_line)
+ ext_name_define = ''
+ ext_enable_name = ''
+ for extension in self.registry.extensions:
+ if extension.attrib['name'] == ext:
+ ext_name_define = extension[0][1].get('name')
+ ext_enable_name = ext_name_define.lower()
+ ext_enable_name = re.sub('_extension_name', '', ext_enable_name)
+ break
+ ext_test = 'if (!layer_data->extensions.%s) skipCall |= OutputExtensionError(layer_data, "%s", %s);\n' % (ext_enable_name, command.name, ext_name_define)
+ lines.insert(0, ext_test)
if lines:
cmdDef = self.getCmdDef(command) + '\n'
cmdDef += '{\n'
@@ -1055,4 +1064,4 @@ class ParamCheckerOutputGenerator(OutputGenerator):
cmdDef += '\n'
cmdDef += indent + 'return skipCall;\n'
cmdDef += '}\n'
- self.appendSection('command', cmdDef)
+ self.validation.append(cmdDef)