From 24f5504fa89bbacf282229ef4384a67a05797d4b Mon Sep 17 00:00:00 2001 From: Dustin Graves Date: Wed, 23 Mar 2016 19:44:00 -0600 Subject: layers: Codegen VkBool32/enum parameter validation Now generating the VkBool32 and enum checks: - Warns if a VkBool32 parameter is neither VK_TRUE nor VK_FALSE - Warns if an enum token value falls outside of the enum's begin/end range and the token was not added by an extension. Only checkes enum's that have a begin/end range. Detection of tokens added by extensions is based on the base_value defined in appendic C.10 of the Vulkan specification. Change-Id: Id49ace52fea8a35972f96d54247b98aba182c09e --- generator.py | 243 +++++++++--- layers/parameter_validation.cpp | 760 ++---------------------------------- layers/parameter_validation_utils.h | 166 ++++++-- 3 files changed, 370 insertions(+), 799 deletions(-) diff --git a/generator.py b/generator.py index 023dd106..5a9ed709 100644 --- a/generator.py +++ b/generator.py @@ -2835,6 +2835,12 @@ class ParamCheckerOutputGenerator(OutputGenerator): diagFile = sys.stdout): OutputGenerator.__init__(self, errFile, warnFile, diagFile) self.INDENT_SPACES = 4 + # Struct member categories, to be used to avoid validating output values retrieved by queries such as vkGetPhysicalDeviceProperties + # For example, VkPhysicalDeviceProperties will be ignored for vkGetPhysicalDeviceProperties where it is an ouput, but will be processed + # for vkCreateDevice where is it a member of the VkDeviceCreateInfo input parameter. + self.STRUCT_MEMBERS_INPUT_ONLY_NONE = 1 # The struct contains no 'input-only' members and will always be processed + self.STRUCT_MEMBERS_INPUT_ONLY_MIXED = 2 # The struct contains some 'input-only' members; these members will only be processed when the struct is an input parameter + self.STRUCT_MEMBERS_INPUT_ONLY_EXCLUSIVE = 3 # The struct contains only 'input-only' members; the entire struct will only be processed when it is an input parameter # Commands to ignore self.blacklist = [ 'vkGetInstanceProcAddr', @@ -2852,10 +2858,13 @@ class ParamCheckerOutputGenerator(OutputGenerator): self.structTypes = dict() # Map of Vulkan struct typename to required VkStructureType self.commands = [] # List of CommandData records for all Vulkan commands self.structMembers = [] # List of StructMemberData records for all Vulkan structs - self.validatedStructs = set() # Set of structs containing members that require validation + self.validatedStructs = dict() # Map of structs containing members that require validation to a value indicating + # that the struct contains members that are only validated when it is an input parameter + self.enumRanges = dict() # Map of enum name to BEGIN/END range values # Named tuples to store struct and command data self.StructType = namedtuple('StructType', ['name', 'value']) - self.CommandParam = namedtuple('CommandParam', ['type', 'name', 'ispointer', 'isstaticarray', 'isoptional', 'iscount', 'len', 'extstructs', 'cdecl']) + self.CommandParam = namedtuple('CommandParam', ['type', 'name', 'ispointer', 'isstaticarray', 'isbool', 'israngedenum', + 'isconst', 'isoptional', 'iscount', 'len', 'extstructs', 'cdecl']) self.CommandData = namedtuple('CommandData', ['name', 'params', 'cdecl']) self.StructMemberData = namedtuple('StructMemberData', ['name', 'members']) # @@ -2918,7 +2927,8 @@ class ParamCheckerOutputGenerator(OutputGenerator): self.structTypes = dict() self.commands = [] self.structMembers = [] - self.validatedStructs = set() + self.validatedStructs = dict() + self.enumRanges = dict() def endFeature(self): # C-specific # Actually write the interface to the output file. @@ -2988,6 +2998,7 @@ class ParamCheckerOutputGenerator(OutputGenerator): type = info[0] name = info[1] stypeValue = '' + cdecl = self.makeCParamDecl(member, 0) # Process VkStructureType if type == 'VkStructureType': # Extract the required struct type value from the comments @@ -3020,11 +3031,14 @@ class ParamCheckerOutputGenerator(OutputGenerator): membersInfo.append(self.CommandParam(type=type, name=name, ispointer=self.paramIsPointer(member), isstaticarray=isstaticarray, + isbool=True if type == 'VkBool32' else False, + israngedenum=True if type in self.enumRanges else False, + isconst=True if 'const' in cdecl else False, isoptional=isoptional, iscount=iscount, len=self.getLen(member), extstructs=member.attrib.get('validextensionstructs') if name == 'pNext' else None, - cdecl=self.makeCParamDecl(member, 0))) + cdecl=cdecl)) self.structMembers.append(self.StructMemberData(name=typeName, members=membersInfo)) # # Capture group (e.g. C "enum" type) info to be used for @@ -3032,11 +3046,25 @@ class ParamCheckerOutputGenerator(OutputGenerator): # These are concatenated together with other types. def genGroup(self, groupinfo, groupName): OutputGenerator.genGroup(self, groupinfo, groupName) + groupElem = groupinfo.elem + # + # Store the sType values if groupName == 'VkStructureType': - groupElem = groupinfo.elem for elem in groupElem.findall('enum'): - name = elem.get('name') - self.stypes.append(name) + self.stypes.append(elem.get('name')) + else: + # Determine if begin/end ranges are needed (we don't do this for VkStructureType, which has a more finely grained check) + expandName = re.sub(r'([0-9a-z_])([A-Z0-9][^A-Z0-9]?)',r'\1_\2',groupName).upper() + expandPrefix = expandName + expandSuffix = '' + expandSuffixMatch = re.search(r'[A-Z][A-Z]+$',groupName) + if expandSuffixMatch: + expandSuffix = '_' + expandSuffixMatch.group() + # Strip off the suffix from the prefix + expandPrefix = expandName.rsplit(expandSuffix, 1)[0] + isEnum = ('FLAG_BITS' not in expandPrefix) + if isEnum: + self.enumRanges[groupName] = (expandPrefix + '_BEGIN_RANGE' + expandSuffix, expandPrefix + '_END_RANGE' + expandSuffix) # # Capture command parameter info to be used for param # check code generation. @@ -3054,6 +3082,7 @@ class ParamCheckerOutputGenerator(OutputGenerator): paramsInfo = [] for param in params: paramInfo = self.getTypeNameTuple(param) + cdecl = self.makeCParamDecl(param, 0) # Check for parameter name in lens set iscount = False if paramInfo[1] in lens: @@ -3061,11 +3090,14 @@ class ParamCheckerOutputGenerator(OutputGenerator): paramsInfo.append(self.CommandParam(type=paramInfo[0], name=paramInfo[1], ispointer=self.paramIsPointer(param), isstaticarray=self.paramIsStaticArray(param), + isbool=True if paramInfo[0] == 'VkBool32' else False, + israngedenum=True if paramInfo[0] in self.enumRanges else False, + isconst=True if 'const' in cdecl else False, isoptional=self.paramIsOptional(param), iscount=iscount, len=self.getLen(param), extstructs=None, - cdecl=self.makeCParamDecl(param, 0))) + cdecl=cdecl)) self.commands.append(self.CommandData(name=name, params=paramsInfo, cdecl=self.makeCDecls(cmdinfo.elem)[0])) # # Check if the parameter passed in is a pointer @@ -3168,7 +3200,8 @@ class ParamCheckerOutputGenerator(OutputGenerator): if name: if '->' in name: # The count is obtained by dereferencing a member of a struct parameter - lenParam = self.CommandParam(name=name, iscount=True, ispointer=False, isoptional=False, type=None, len=None, isstaticarray=None, extstructs=None, cdecl=None) + lenParam = self.CommandParam(name=name, iscount=True, ispointer=False, isbool=False, israngedenum=False, isconst=False, + isstaticarray=None, isoptional=False, type=None, len=None, extstructs=None, cdecl=None) elif 'latexmath' in name: lenName, decoratedName = self.parseLateXMath(name) lenParam = self.getParamByName(params, lenName) @@ -3221,26 +3254,32 @@ class ParamCheckerOutputGenerator(OutputGenerator): return indent + expr # # Generate the parameter checking code - def genFuncBody(self, indent, name, values, valuePrefix, variablePrefix, structName): + def genFuncBody(self, indent, name, values, valuePrefix, variablePrefix, structName, needConditionCheck): funcBody = '' unused = [] + # Code to conditionally check parameters only when they are inputs. Primarily avoids + # checking uninitialized members of output structs used to retrieve bools and enums. + # Conditional checks are grouped together to be appended to funcBody within a single + # if check for input parameter direction. + conditionalExprs = [] for value in values: checkExpr = '' # Code to check the current parameter + lenParam = None + # + # Generate the full name of the value, which will be printed in + # the error message, by adding the variable prefix to the + # value name + valueDisplayName = '(std::string({}) + std::string("{}")).c_str()'.format(variablePrefix, value.name) if variablePrefix else '"{}"'.format(value.name) # # Check for NULL pointers, ignore the inout count parameters that # will be validated with their associated array if (value.ispointer or value.isstaticarray) and not value.iscount: - # - # Generate the full name of the value, which will be printed in - # the error message, by adding the variable prefix to the - # value name - valueDisplayName = '(std::string({}) + std::string("{}")).c_str()'.format(variablePrefix, value.name) if variablePrefix else '"{}"'.format(value.name) # # Parameters for function argument generation req = 'VK_TRUE' # Paramerter can be NULL cpReq = 'VK_TRUE' # Count pointer can be NULL cvReq = 'VK_TRUE' # Count value can be 0 - lenParam = None + lenDisplayName = None # Name of length parameter to print with validation messages; parameter name with prefix applied # # Generate required/optional parameter strings for the pointer and count values if value.isoptional: @@ -3248,7 +3287,7 @@ class ParamCheckerOutputGenerator(OutputGenerator): if value.len: # The parameter is an array with an explicit count parameter lenParam = self.getLenParam(values, value.len) - if not lenParam: print(value.len) + lenDisplayName = '(std::string({}) + std::string("{}")).c_str()'.format(variablePrefix, lenParam.name) if variablePrefix else '"{}"'.format(lenParam.name) if lenParam.ispointer: # Count parameters that are pointers are inout if type(lenParam.isoptional) is list: @@ -3270,9 +3309,9 @@ class ParamCheckerOutputGenerator(OutputGenerator): # This is an array if lenParam.ispointer: # When the length parameter is a pointer, there is an extra Boolean parameter in the function call to indicate if it is required - checkExpr = 'skipCall |= validate_struct_type_array(report_data, {}, "{ln}", {dn}, "{sv}", {pf}{ln}, {pf}{vn}, {sv}, {}, {}, {});\n'.format(name, cpReq, cvReq, req, ln=lenParam.name, dn=valueDisplayName, vn=value.name, sv=stype.value, pf=valuePrefix) + checkExpr = 'skipCall |= validate_struct_type_array(report_data, {}, {ldn}, {dn}, "{sv}", {pf}{ln}, {pf}{vn}, {sv}, {}, {}, {});\n'.format(name, cpReq, cvReq, req, ln=lenParam.name, ldn=lenDisplayName, dn=valueDisplayName, vn=value.name, sv=stype.value, pf=valuePrefix) else: - checkExpr = 'skipCall |= validate_struct_type_array(report_data, {}, "{ln}", {dn}, "{sv}", {pf}{ln}, {pf}{vn}, {sv}, {}, {});\n'.format(name, cvReq, req, ln=lenParam.name, dn=valueDisplayName, vn=value.name, sv=stype.value, pf=valuePrefix) + checkExpr = 'skipCall |= validate_struct_type_array(report_data, {}, {ldn}, {dn}, "{sv}", {pf}{ln}, {pf}{vn}, {sv}, {}, {});\n'.format(name, cvReq, req, ln=lenParam.name, ldn=lenDisplayName, dn=valueDisplayName, vn=value.name, sv=stype.value, pf=valuePrefix) else: checkExpr = 'skipCall |= validate_struct_type(report_data, {}, {}, "{sv}", {}{vn}, {sv}, {});\n'.format(name, valueDisplayName, valuePrefix, req, vn=value.name, sv=stype.value) elif value.name == 'pNext': @@ -3293,17 +3332,15 @@ class ParamCheckerOutputGenerator(OutputGenerator): if lenParam: # This is an array if lenParam.ispointer: - # If count and array parameters are optional, there - # will be no validation + # If count and array parameters are optional, there will be no validation if req == 'VK_TRUE' or cpReq == 'VK_TRUE' or cvReq == 'VK_TRUE': # When the length parameter is a pointer, there is an extra Boolean parameter in the function call to indicate if it is required - checkExpr = 'skipCall |= validate_array(report_data, {}, "{ln}", {dn}, {pf}{ln}, {pf}{vn}, {}, {}, {});\n'.format(name, cpReq, cvReq, req, ln=lenParam.name, dn=valueDisplayName, vn=value.name, pf=valuePrefix) + checkExpr = 'skipCall |= validate_array(report_data, {}, {ldn}, {dn}, {pf}{ln}, {pf}{vn}, {}, {}, {});\n'.format(name, cpReq, cvReq, req, ln=lenParam.name, ldn=lenDisplayName, dn=valueDisplayName, vn=value.name, pf=valuePrefix) else: - # If count and array parameters are optional, there - # will be no validation + # If count and array parameters are optional, there will be no validation if req == 'VK_TRUE' or cvReq == 'VK_TRUE': funcName = 'validate_array' if value.type != 'char' else 'validate_string_array' - checkExpr = 'skipCall |= {}(report_data, {}, "{ln}", {dn}, {pf}{ln}, {pf}{vn}, {}, {});\n'.format(funcName, name, cvReq, req, ln=lenParam.name, dn=valueDisplayName, vn=value.name, pf=valuePrefix) + checkExpr = 'skipCall |= {}(report_data, {}, {ldn}, {dn}, {pf}{ln}, {pf}{vn}, {}, {});\n'.format(funcName, name, cvReq, req, ln=lenParam.name, ldn=lenDisplayName, dn=valueDisplayName, vn=value.name, pf=valuePrefix) elif not value.isoptional: # Function pointers need a reinterpret_cast to void* if value.type[:4] == 'PFN_': @@ -3314,16 +3351,98 @@ class ParamCheckerOutputGenerator(OutputGenerator): # If this is a pointer to a struct, see if it contains members # that need to be checked if value.type in self.validatedStructs: - if checkExpr: - checkExpr += '\n' + indent # # The name prefix used when reporting an error with a struct member (eg. the 'pCreateInfor->' in 'pCreateInfo->sType') prefix = '(std::string({}) + std::string("{}->")).c_str()'.format(variablePrefix, value.name) if variablePrefix else '"{}->"'.format(value.name) - checkExpr += 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}{});\n'.format(value.type, name, prefix, valuePrefix, value.name) + # + membersInputOnly = self.validatedStructs[value.type] + # + # If the current struct has mixed 'input-only' and 'non-input-only' members, it needs an isInput flag + if membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_MIXED: + # If this function is called from another struct validation function (valuePrefix is not empty), then we forward the 'isInput' prameter + isInput = 'isInput' + if not valuePrefix: + # We are validating function parameters and need to determine if the current value is an input parameter + isInput = 'true' if value.isconst else 'false' + if checkExpr: + checkExpr += '\n' + indent + checkExpr += 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}, {}{});\n'.format(value.type, name, prefix, isInput, valuePrefix, value.name) + else: + # Validation function does not have an isInput field + expr = 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}{});\n'.format(value.type, name, prefix, valuePrefix, value.name) + # + # If the struct only has input-only members and is a member of another struct, it is conditionally processed based on 'isInput' + if valuePrefix and membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_EXCLUSIVE: + if needConditionCheck: + conditionalExprs.append(expr) + else: + if checkExpr: + checkExpr += '\n' + indent + checkExpr += expr + # + # If the struct is a function parameter (valuePrefix is empty) and only contains input-only parameters, it can be ignored if it is not an input + elif (membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_NONE) or (not valuePrefix and membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_EXCLUSIVE and value.isconst): + if checkExpr: + checkExpr += '\n' + indent + checkExpr += expr + elif value.isbool and value.isconst: + expr = 'skipCall |= validate_bool32_array(report_data, {}, {}, {pf}{}, {pf}{});\n'.format(name, valueDisplayName, lenParam.name, value.name, pf=valuePrefix) + if checkExpr: + checkExpr += '\n' + indent + checkExpr += expr + elif value.israngedenum and value.isconst: + enumRange = self.enumRanges[value.type] + expr = 'skipCall |= validate_ranged_enum_array(report_data, {}, {}, "{}", {}, {}, {pf}{}, {pf}{});\n'.format(name, valueDisplayName, value.type, enumRange[0], enumRange[1], lenParam.name, value.name, pf=valuePrefix) + if checkExpr: + checkExpr += '\n' + indent + checkExpr += expr elif value.type in self.validatedStructs: - # The name prefix used when reporting an error with a struct member (eg. the 'pCreateInfor->' in 'pCreateInfo->sType') + # The name of the value with prefix applied prefix = '(std::string({}) + std::string("{}.")).c_str()'.format(variablePrefix, value.name) if variablePrefix else '"{}."'.format(value.name) - checkExpr += 'skipCall |= parameter_validation_{}(report_data, {}, {}, &({}{}));\n'.format(value.type, name, prefix, valuePrefix, value.name) + # + membersInputOnly = self.validatedStructs[value.type] + # + # If the current struct has mixed 'input-only' and 'non-input-only' members, it needs an isInput flag + if membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_MIXED: + # If this function is called from another struct validation function (valuePrefix is not empty), then we forward the 'isInput' prameter + isInput = 'isInput' + if not valuePrefix: + # We are validating function parameters and need to determine if the current value is an input parameter + isInput = 'true' if value.isconst else 'false' + if checkExpr: + checkExpr += '\n' + indent + checkExpr += 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}, &({}{}));\n'.format(value.type, name, prefix, isInput, valuePrefix, value.name) + else: + # Validation function does not have an isInput field + expr = 'skipCall |= parameter_validation_{}(report_data, {}, {}, &({}{}));\n'.format(value.type, name, prefix, valuePrefix, value.name) + # + # If the struct only has input-only members and is a member of another struct, it is conditionally processed based on 'isInput' + if valuePrefix and membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_EXCLUSIVE: + if needConditionCheck: + conditionalExprs.append(expr) + else: + if checkExpr: + checkExpr += '\n' + indent + checkExpr += expr + # + # If the struct is a function parameter (valuePrefix is empty) and only contains input-only parameters, it can be ignored if it is not an input + elif (membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_NONE) or (not valuePrefix and membersInputOnly == self.STRUCT_MEMBERS_INPUT_ONLY_EXCLUSIVE and value.isconst): + if checkExpr: + checkExpr += '\n' + indent + checkExpr += expr + elif value.isbool: + expr = 'skipCall |= validate_bool32(report_data, {}, {}, {}{});\n'.format(name, valueDisplayName, valuePrefix, value.name) + if needConditionCheck: + conditionalExprs.append(expr) + else: + checkExpr = expr + elif value.israngedenum: + enumRange = self.enumRanges[value.type] + expr = 'skipCall |= validate_ranged_enum(report_data, {}, {}, "{}", {}, {}, {}{});\n'.format(name, valueDisplayName, value.type, enumRange[0], enumRange[1], valuePrefix, value.name) + if needConditionCheck: + conditionalExprs.append(expr) + else: + checkExpr = expr # # Append the parameter check to the function body for the current command if checkExpr: @@ -3334,24 +3453,40 @@ class ParamCheckerOutputGenerator(OutputGenerator): else: funcBody += indent + checkExpr elif not value.iscount: - # The parameter is not checked (counts will be checked with - # their associated array) + # If no expression was generated for this value, it is unreferenced by the validation function, unless + # it is an array count, which is indirectly referenced for array valiadation. unused.append(value.name) + # Add the 'input' only checks + if conditionalExprs: + funcBody += '\n' + funcBody += indent + 'if (isInput) {' + indent = self.incIndent(indent) + for conditionalExpr in conditionalExprs: + funcBody += '\n' + funcBody += indent + conditionalExpr + indent = self.decIndent(indent) + funcBody += indent + '}\n' return funcBody, unused # # Post-process the collected struct member data to create a list of structs # with members that need to be validated def prepareStructMemberData(self): for struct in self.structMembers: + inputOnly = False + validated = False for member in struct.members: if not member.iscount: lenParam = self.getLenParam(struct.members, member.len) - # The sType needs to be validated - # An required array/count needs to be validated + # The sType value needs to be validated + # The pNext value needs to be validated + # A required array/count needs to be validated # A required pointer needs to be validated - validated = False + # A bool needs to be validated, and the struct is an input parameter + # An enum needs to be validated, and the struct is an input parameter if member.type in self.structTypes: validated = True + elif member.name == 'pNext': + validated = True elif member.ispointer and lenParam: # This is an array # Make sure len is not optional if lenParam.ispointer: @@ -3362,27 +3497,45 @@ class ParamCheckerOutputGenerator(OutputGenerator): validated = True elif member.ispointer and not member.isoptional: validated = True - # - if validated: - self.validatedStructs.add(struct.name) - # Second pass to check for struct members that are structs - # requiring validation + elif member.isbool or member.israngedenum: + inputOnly = True + # + if validated or inputOnly: + if not validated: + self.validatedStructs[struct.name] = self.STRUCT_MEMBERS_INPUT_ONLY_EXCLUSIVE + elif not inputOnly: + self.validatedStructs[struct.name] = self.STRUCT_MEMBERS_INPUT_ONLY_NONE + else: + self.validatedStructs[struct.name] = self.STRUCT_MEMBERS_INPUT_ONLY_MIXED + # Second pass to check for struct members that are structs requiring validation + # May not be necessary, as structs seem to always be defined before first use in the XML registry for member in struct.members: if member.type in self.validatedStructs: - self.validatedStructs.add(struct.name) + memberInputOnly = self.validatedStructs[member.type] + if not struct.name in self.validatedStructs: + self.validatedStructs[struct.name] = memberInputOnly + elif self.validatedStructs[struct.name] != memberInputOnly: + self.validatedStructs[struct.name] = self.STRUCT_MEMBERS_INPUT_ONLY_MIXED # # Generate the struct member check code from the captured data def processStructMemberData(self): indent = self.incIndent(None) for struct in self.structMembers: - # The string returned by genFuncBody will be nested in an if check - # for a NULL pointer, so needs its indent incremented - funcBody, unused = self.genFuncBody(self.incIndent(indent), 'pFuncName', struct.members, 'pStruct->', 'pVariableName', struct.name) + needConditionCheck = False + if struct.name in self.validatedStructs and self.validatedStructs[struct.name] == self.STRUCT_MEMBERS_INPUT_ONLY_MIXED: + needConditionCheck = True + # + # The string returned by genFuncBody will be nested in an if check for a NULL pointer, so needs its indent incremented + funcBody, unused = self.genFuncBody(self.incIndent(indent), 'pFuncName', struct.members, 'pStruct->', 'pVariableName', struct.name, needConditionCheck) if funcBody: cmdDef = 'static VkBool32 parameter_validation_{}(\n'.format(struct.name) cmdDef += ' debug_report_data*'.ljust(self.genOpts.alignFuncParam) + ' report_data,\n' cmdDef += ' const char*'.ljust(self.genOpts.alignFuncParam) + ' pFuncName,\n' cmdDef += ' const char*'.ljust(self.genOpts.alignFuncParam) + ' pVariableName,\n' + # If there is a funcBody, this struct must have an entry in the validatedStructs dictionary + if self.validatedStructs[struct.name] == self.STRUCT_MEMBERS_INPUT_ONLY_MIXED: + # If the struct has mixed input only and non-input only members, it needs a flag to indicate if it is an input or output + cmdDef += ' bool'.ljust(self.genOpts.alignFuncParam) + ' isInput,\n' cmdDef += ' const {}*'.format(struct.name).ljust(self.genOpts.alignFuncParam) + ' pStruct)\n' cmdDef += '{\n' cmdDef += indent + 'VkBool32 skipCall = VK_FALSE;\n' @@ -3399,7 +3552,7 @@ class ParamCheckerOutputGenerator(OutputGenerator): def processCmdData(self): indent = self.incIndent(None) for command in self.commands: - cmdBody, unused = self.genFuncBody(indent, '"{}"'.format(command.name), command.params, '', None, None) + cmdBody, unused = self.genFuncBody(indent, '"{}"'.format(command.name), command.params, '', None, None, False) if cmdBody: cmdDef = self.getCmdDef(command) + '\n' cmdDef += '{\n' diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index fb0783a1..714a5eb4 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -1477,18 +1477,6 @@ vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFea } } -bool PostGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties *pFormatProperties) { - - if (format < VK_FORMAT_BEGIN_RANGE || format > VK_FORMAT_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceFormatProperties parameter, VkFormat format, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties) { VkBool32 skipCall = VK_FALSE; @@ -1500,33 +1488,12 @@ vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat fo if (skipCall == VK_FALSE) { get_dispatch_table(pc_instance_table_map, physicalDevice) ->GetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties); - - PostGetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties); } } bool PostGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties, VkResult result) { - - if (format < VK_FORMAT_BEGIN_RANGE || format > VK_FORMAT_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceImageFormatProperties parameter, VkFormat format, is an unrecognized enumerator"); - return false; - } - - if (type < VK_IMAGE_TYPE_BEGIN_RANGE || type > VK_IMAGE_TYPE_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceImageFormatProperties parameter, VkImageType type, is an unrecognized enumerator"); - return false; - } - - if (tiling < VK_IMAGE_TILING_BEGIN_RANGE || tiling > VK_IMAGE_TILING_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceImageFormatProperties parameter, VkImageTiling tiling, is an unrecognized enumerator"); - return false; - } - if (result < VK_SUCCESS) { std::string reason = "vkGetPhysicalDeviceImageFormatProperties parameter, VkResult result, is " + EnumeratorString(result); log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", @@ -1561,21 +1528,6 @@ vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkForm return result; } -bool PostGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) { - - if (pProperties != nullptr) { - if (pProperties->deviceType < VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE || - pProperties->deviceType > VK_PHYSICAL_DEVICE_TYPE_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceProperties parameter, VkPhysicalDeviceType pProperties->deviceType, is an unrecognized " - "enumerator"); - return false; - } - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) { VkBool32 skipCall = VK_FALSE; @@ -1586,8 +1538,6 @@ vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceP if (skipCall == VK_FALSE) { get_dispatch_table(pc_instance_table_map, physicalDevice)->GetPhysicalDeviceProperties(physicalDevice, pProperties); - - PostGetPhysicalDeviceProperties(physicalDevice, pProperties); } } @@ -1702,14 +1652,14 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice p if (pCreateInfo != NULL) { if ((pCreateInfo->enabledLayerCount > 0) && (pCreateInfo->ppEnabledLayerNames != NULL)) { - for (auto i = 0; i < pCreateInfo->enabledLayerCount; i++) { + for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { skipCall |= validate_string(my_instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", pCreateInfo->ppEnabledLayerNames[i]); } } if ((pCreateInfo->enabledExtensionCount > 0) && (pCreateInfo->ppEnabledExtensionNames != NULL)) { - for (auto i = 0; i < pCreateInfo->enabledExtensionCount; i++) { + for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { skipCall |= validate_string(my_instance_data->report_data, "vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", pCreateInfo->ppEnabledExtensionNames[i]); } @@ -2130,25 +2080,6 @@ vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t *pSp bool PostGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pNumProperties, VkSparseImageFormatProperties *pProperties) { - - if (format < VK_FORMAT_BEGIN_RANGE || format > VK_FORMAT_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceSparseImageFormatProperties parameter, VkFormat format, is an unrecognized enumerator"); - return false; - } - - if (type < VK_IMAGE_TYPE_BEGIN_RANGE || type > VK_IMAGE_TYPE_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceSparseImageFormatProperties parameter, VkImageType type, is an unrecognized enumerator"); - return false; - } - - if (tiling < VK_IMAGE_TILING_BEGIN_RANGE || tiling > VK_IMAGE_TILING_END_RANGE) { - log_msg(mdd(physicalDevice), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkGetPhysicalDeviceSparseImageFormatProperties parameter, VkImageTiling tiling, is an unrecognized enumerator"); - return false; - } - if (pProperties != nullptr) { if ((pProperties->aspectMask & (VK_IMAGE_ASPECT_COLOR_BIT | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT | VK_IMAGE_ASPECT_METADATA_BIT)) == 0) { @@ -2476,18 +2407,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkE return result; } -bool PreCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->queryType < VK_QUERY_TYPE_BEGIN_RANGE || pCreateInfo->queryType > VK_QUERY_TYPE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateQueryPool parameter, VkQueryType pCreateInfo->queryType, is an unrecognized enumerator"); - return false; - } - } - - return true; -} - bool PostCreateQueryPool(VkDevice device, VkQueryPool *pQueryPool, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkCreateQueryPool parameter, VkResult result, is " + EnumeratorString(result); @@ -2509,8 +2428,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device skipCall |= parameter_validation_vkCreateQueryPool(my_data->report_data, pCreateInfo, pAllocator, pQueryPool); if (skipCall == VK_FALSE) { - PreCreateQueryPool(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); PostCreateQueryPool(device, pQueryPool, result); @@ -2567,11 +2484,7 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice de bool PreCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo) { if (pCreateInfo != nullptr) { - if (pCreateInfo->sharingMode < VK_SHARING_MODE_BEGIN_RANGE || pCreateInfo->sharingMode > VK_SHARING_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateBuffer parameter, VkSharingMode pCreateInfo->sharingMode, is an unrecognized enumerator"); - return false; - } else if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { + if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { validate_queue_family_indices(device, "vkCreateBuffer", pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices); } @@ -2624,18 +2537,6 @@ vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *p } } -bool PreCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->format < VK_FORMAT_BEGIN_RANGE || pCreateInfo->format > VK_FORMAT_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateBufferView parameter, VkFormat pCreateInfo->format, is an unrecognized enumerator"); - return false; - } - } - - return true; -} - bool PostCreateBufferView(VkDevice device, VkBufferView *pView, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkCreateBufferView parameter, VkResult result, is " + EnumeratorString(result); @@ -2657,8 +2558,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice devic skipCall |= parameter_validation_vkCreateBufferView(my_data->report_data, pCreateInfo, pAllocator, pView); if (skipCall == VK_FALSE) { - PreCreateBufferView(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateBufferView(device, pCreateInfo, pAllocator, pView); PostCreateBufferView(device, pView, result); @@ -2682,26 +2581,7 @@ vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocation bool PreCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo) { if (pCreateInfo != nullptr) { - if (pCreateInfo->imageType < VK_IMAGE_TYPE_BEGIN_RANGE || pCreateInfo->imageType > VK_IMAGE_TYPE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImage parameter, VkImageType pCreateInfo->imageType, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->format < VK_FORMAT_BEGIN_RANGE || pCreateInfo->format > VK_FORMAT_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImage parameter, VkFormat pCreateInfo->format, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->tiling < VK_IMAGE_TILING_BEGIN_RANGE || pCreateInfo->tiling > VK_IMAGE_TILING_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImage parameter, VkImageTiling pCreateInfo->tiling, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->sharingMode < VK_SHARING_MODE_BEGIN_RANGE || pCreateInfo->sharingMode > VK_SHARING_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImage parameter, VkSharingMode pCreateInfo->sharingMode, is an unrecognized enumerator"); - return false; - } else if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { + if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { validate_queue_family_indices(device, "vkCreateImage", pCreateInfo->queueFamilyIndexCount, pCreateInfo->pQueueFamilyIndices); } @@ -2781,47 +2661,6 @@ vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubreso } } -bool PreCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->viewType < VK_IMAGE_VIEW_TYPE_BEGIN_RANGE || pCreateInfo->viewType > VK_IMAGE_VIEW_TYPE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImageView parameter, VkImageViewType pCreateInfo->viewType, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->format < VK_FORMAT_BEGIN_RANGE || pCreateInfo->format > VK_FORMAT_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImageView parameter, VkFormat pCreateInfo->format, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->components.r < VK_COMPONENT_SWIZZLE_BEGIN_RANGE || - pCreateInfo->components.r > VK_COMPONENT_SWIZZLE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImageView parameter, VkComponentSwizzle pCreateInfo->components.r, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->components.g < VK_COMPONENT_SWIZZLE_BEGIN_RANGE || - pCreateInfo->components.g > VK_COMPONENT_SWIZZLE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImageView parameter, VkComponentSwizzle pCreateInfo->components.g, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->components.b < VK_COMPONENT_SWIZZLE_BEGIN_RANGE || - pCreateInfo->components.b > VK_COMPONENT_SWIZZLE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImageView parameter, VkComponentSwizzle pCreateInfo->components.b, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->components.a < VK_COMPONENT_SWIZZLE_BEGIN_RANGE || - pCreateInfo->components.a > VK_COMPONENT_SWIZZLE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateImageView parameter, VkComponentSwizzle pCreateInfo->components.a, is an unrecognized enumerator"); - return false; - } - } - - return true; -} - bool PostCreateImageView(VkDevice device, VkImageView *pView, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkCreateImageView parameter, VkResult result, is " + EnumeratorString(result); @@ -2843,8 +2682,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device skipCall |= parameter_validation_vkCreateImageView(my_data->report_data, pCreateInfo, pAllocator, pView); if (skipCall == VK_FALSE) { - PreCreateImageView(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateImageView(device, pCreateInfo, pAllocator, pView); PostCreateImageView(device, pView, result); @@ -3041,122 +2878,13 @@ bool PreCreateGraphicsPipelines(VkDevice device, const VkGraphicsPipelineCreateI } } - if (pCreateInfos->pVertexInputState != nullptr) { - if (pCreateInfos->pVertexInputState->pVertexBindingDescriptions != nullptr) { - if (pCreateInfos->pVertexInputState->pVertexBindingDescriptions->inputRate < VK_VERTEX_INPUT_RATE_BEGIN_RANGE || - pCreateInfos->pVertexInputState->pVertexBindingDescriptions->inputRate > VK_VERTEX_INPUT_RATE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkVertexInputRate " - "pCreateInfos->pVertexInputState->pVertexBindingDescriptions->inputRate, is an unrecognized " - "enumerator"); - return false; - } - } - if (pCreateInfos->pVertexInputState->pVertexAttributeDescriptions != nullptr) { - if (pCreateInfos->pVertexInputState->pVertexAttributeDescriptions->format < VK_FORMAT_BEGIN_RANGE || - pCreateInfos->pVertexInputState->pVertexAttributeDescriptions->format > VK_FORMAT_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkFormat " - "pCreateInfos->pVertexInputState->pVertexAttributeDescriptions->format, is an unrecognized enumerator"); - return false; - } - } - } - if (pCreateInfos->pInputAssemblyState != nullptr) { - if (pCreateInfos->pInputAssemblyState->topology < VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE || - pCreateInfos->pInputAssemblyState->topology > VK_PRIMITIVE_TOPOLOGY_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkPrimitiveTopology pCreateInfos->pInputAssemblyState->topology, is " - "an unrecognized enumerator"); - return false; - } - } if (pCreateInfos->pRasterizationState != nullptr) { - if (pCreateInfos->pRasterizationState->polygonMode < VK_POLYGON_MODE_BEGIN_RANGE || - pCreateInfos->pRasterizationState->polygonMode > VK_POLYGON_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkPolygonMode pCreateInfos->pRasterizationState->polygonMode, is an " - "unrecognized enumerator"); - return false; - } if (pCreateInfos->pRasterizationState->cullMode & ~VK_CULL_MODE_FRONT_AND_BACK) { log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", "vkCreateGraphicsPipelines parameter, VkCullMode pCreateInfos->pRasterizationState->cullMode, is an " "unrecognized enumerator"); return false; } - if (pCreateInfos->pRasterizationState->frontFace < VK_FRONT_FACE_BEGIN_RANGE || - pCreateInfos->pRasterizationState->frontFace > VK_FRONT_FACE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkFrontFace pCreateInfos->pRasterizationState->frontFace, is an " - "unrecognized enumerator"); - return false; - } - } - if (pCreateInfos->pDepthStencilState != nullptr) { - if (pCreateInfos->pDepthStencilState->depthCompareOp < VK_COMPARE_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->depthCompareOp > VK_COMPARE_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkCompareOp pCreateInfos->pDepthStencilState->depthCompareOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->front.failOp < VK_STENCIL_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->front.failOp > VK_STENCIL_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkStencilOp pCreateInfos->pDepthStencilState->front.failOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->front.passOp < VK_STENCIL_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->front.passOp > VK_STENCIL_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkStencilOp pCreateInfos->pDepthStencilState->front.passOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->front.depthFailOp < VK_STENCIL_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->front.depthFailOp > VK_STENCIL_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkStencilOp pCreateInfos->pDepthStencilState->front.depthFailOp, is " - "an unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->front.compareOp < VK_COMPARE_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->front.compareOp > VK_COMPARE_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkCompareOp pCreateInfos->pDepthStencilState->front.compareOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->back.failOp < VK_STENCIL_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->back.failOp > VK_STENCIL_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkStencilOp pCreateInfos->pDepthStencilState->back.failOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->back.passOp < VK_STENCIL_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->back.passOp > VK_STENCIL_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkStencilOp pCreateInfos->pDepthStencilState->back.passOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->back.depthFailOp < VK_STENCIL_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->back.depthFailOp > VK_STENCIL_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkStencilOp pCreateInfos->pDepthStencilState->back.depthFailOp, is " - "an unrecognized enumerator"); - return false; - } - if (pCreateInfos->pDepthStencilState->back.compareOp < VK_COMPARE_OP_BEGIN_RANGE || - pCreateInfos->pDepthStencilState->back.compareOp > VK_COMPARE_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateGraphicsPipelines parameter, VkCompareOp pCreateInfos->pDepthStencilState->back.compareOp, is an " - "unrecognized enumerator"); - return false; - } } if (pCreateInfos->pColorBlendState != nullptr) { if (pCreateInfos->pColorBlendState->logicOpEnable == VK_TRUE && @@ -3219,7 +2947,7 @@ bool PreCreateGraphicsPipelines(VkDevice device, const VkGraphicsPipelineCreateI } int i = 0; - for (auto j = 0; j < pCreateInfos[i].stageCount; j++) { + for (size_t j = 0; j < pCreateInfos[i].stageCount; j++) { validate_string(data->report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pStages[j].pName", pCreateInfos[i].pStages[j].pName); } @@ -3369,74 +3097,6 @@ vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const } } -bool PreCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->magFilter < VK_FILTER_BEGIN_RANGE || pCreateInfo->magFilter > VK_FILTER_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkFilter pCreateInfo->magFilter, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->minFilter < VK_FILTER_BEGIN_RANGE || pCreateInfo->minFilter > VK_FILTER_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkFilter pCreateInfo->minFilter, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->mipmapMode < VK_SAMPLER_MIPMAP_MODE_BEGIN_RANGE || - pCreateInfo->mipmapMode > VK_SAMPLER_MIPMAP_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkSamplerMipmapMode pCreateInfo->mipmapMode, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->addressModeU < VK_SAMPLER_ADDRESS_MODE_BEGIN_RANGE || - pCreateInfo->addressModeU > VK_SAMPLER_ADDRESS_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkTexAddress pCreateInfo->addressModeU, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->addressModeV < VK_SAMPLER_ADDRESS_MODE_BEGIN_RANGE || - pCreateInfo->addressModeV > VK_SAMPLER_ADDRESS_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkTexAddress pCreateInfo->addressModeV, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->addressModeW < VK_SAMPLER_ADDRESS_MODE_BEGIN_RANGE || - pCreateInfo->addressModeW > VK_SAMPLER_ADDRESS_MODE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkTexAddress pCreateInfo->addressModeW, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->anisotropyEnable > VK_TRUE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkBool32 pCreateInfo->anisotropyEnable, is an unrecognized boolean"); - return false; - } - if (pCreateInfo->compareEnable > VK_TRUE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkBool32 pCreateInfo->compareEnable, is an unrecognized boolean"); - return false; - } - if (pCreateInfo->compareEnable) { - if (pCreateInfo->compareOp < VK_COMPARE_OP_BEGIN_RANGE || pCreateInfo->compareOp > VK_COMPARE_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkCompareOp pCreateInfo->compareOp, is an unrecognized enumerator"); - return false; - } - } - if (pCreateInfo->borderColor < VK_BORDER_COLOR_BEGIN_RANGE || pCreateInfo->borderColor > VK_BORDER_COLOR_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkBorderColor pCreateInfo->borderColor, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->unnormalizedCoordinates > VK_TRUE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateSampler parameter, VkBool32 pCreateInfo->unnormalizedCoordinates, is an unrecognized boolean"); - return false; - } - } - - return true; -} - bool PostCreateSampler(VkDevice device, VkSampler *pSampler, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkCreateSampler parameter, VkResult result, is " + EnumeratorString(result); @@ -3458,8 +3118,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, skipCall |= parameter_validation_vkCreateSampler(my_data->report_data, pCreateInfo, pAllocator, pSampler); if (skipCall == VK_FALSE) { - PreCreateSampler(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateSampler(device, pCreateInfo, pAllocator, pSampler); PostCreateSampler(device, pSampler, result); @@ -3481,22 +3139,6 @@ vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks } } -bool PreCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->pBindings != nullptr) { - if (pCreateInfo->pBindings->descriptorType < VK_DESCRIPTOR_TYPE_BEGIN_RANGE || - pCreateInfo->pBindings->descriptorType > VK_DESCRIPTOR_TYPE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateDescriptorSetLayout parameter, VkDescriptorType pCreateInfo->pBindings->descriptorType, is an " - "unrecognized enumerator"); - return false; - } - } - } - - return true; -} - bool PostCreateDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout *pSetLayout, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkCreateDescriptorSetLayout parameter, VkResult result, is " + EnumeratorString(result); @@ -3519,8 +3161,6 @@ vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateIn skipCall |= parameter_validation_vkCreateDescriptorSetLayout(my_data->report_data, pCreateInfo, pAllocator, pSetLayout); if (skipCall == VK_FALSE) { - PreCreateDescriptorSetLayout(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); @@ -3543,22 +3183,6 @@ vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSe } } -bool PreCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->pPoolSizes != nullptr) { - if (pCreateInfo->pPoolSizes->type < VK_DESCRIPTOR_TYPE_BEGIN_RANGE || - pCreateInfo->pPoolSizes->type > VK_DESCRIPTOR_TYPE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateDescriptorPool parameter, VkDescriptorType pCreateInfo->pTypeCount->type, is an unrecognized " - "enumerator"); - return false; - } - } - } - - return true; -} - bool PostCreateDescriptorPool(VkDevice device, uint32_t maxSets, VkDescriptorPool *pDescriptorPool, VkResult result) { /* TODOVV: How do we validate maxSets? Probably belongs in the limits layer? */ @@ -3584,8 +3208,6 @@ vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreat skipCall |= parameter_validation_vkCreateDescriptorPool(my_data->report_data, pCreateInfo, pAllocator, pDescriptorPool); if (skipCall == VK_FALSE) { - PreCreateDescriptorPool(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool); @@ -3692,33 +3314,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice dev return result; } -bool PreUpdateDescriptorSets(VkDevice device, const VkWriteDescriptorSet *pDescriptorWrites, - const VkCopyDescriptorSet *pDescriptorCopies) { - if (pDescriptorWrites != nullptr) { - if (pDescriptorWrites->descriptorType < VK_DESCRIPTOR_TYPE_BEGIN_RANGE || - pDescriptorWrites->descriptorType > VK_DESCRIPTOR_TYPE_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkUpdateDescriptorSets parameter, VkDescriptorType pDescriptorWrites->descriptorType, is an unrecognized " - "enumerator"); - return false; - } - /* TODO: Validate other parts of pImageInfo, pBufferInfo, pTexelBufferView? */ - /* TODO: This test should probably only be done if descriptorType is correct type of descriptor */ - if (pDescriptorWrites->pImageInfo != nullptr) { - if (((pDescriptorWrites->pImageInfo->imageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pDescriptorWrites->pImageInfo->imageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pDescriptorWrites->pImageInfo->imageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkUpdateDescriptorSets parameter, VkImageLayout pDescriptorWrites->pDescriptors->imageLayout, is an " - "unrecognized enumerator"); - return false; - } - } - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) { @@ -3730,8 +3325,6 @@ vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkW descriptorCopyCount, pDescriptorCopies); if (skipCall == VK_FALSE) { - PreUpdateDescriptorSets(device, pDescriptorWrites, pDescriptorCopies); - get_dispatch_table(pc_device_table_map, device) ->UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies); } @@ -3780,113 +3373,6 @@ vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocat } } -bool PreCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->pAttachments != nullptr) { - if (pCreateInfo->pAttachments->format < VK_FORMAT_BEGIN_RANGE || - pCreateInfo->pAttachments->format > VK_FORMAT_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkFormat pCreateInfo->pAttachments->format, is an unrecognized enumerator"); - return false; - } - if (pCreateInfo->pAttachments->loadOp < VK_ATTACHMENT_LOAD_OP_BEGIN_RANGE || - pCreateInfo->pAttachments->loadOp > VK_ATTACHMENT_LOAD_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->pAttachments->loadOp, is an unrecognized " - "enumerator"); - return false; - } - if (pCreateInfo->pAttachments->storeOp < VK_ATTACHMENT_STORE_OP_BEGIN_RANGE || - pCreateInfo->pAttachments->storeOp > VK_ATTACHMENT_STORE_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->pAttachments->storeOp, is an unrecognized " - "enumerator"); - return false; - } - if (pCreateInfo->pAttachments->stencilLoadOp < VK_ATTACHMENT_LOAD_OP_BEGIN_RANGE || - pCreateInfo->pAttachments->stencilLoadOp > VK_ATTACHMENT_LOAD_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkAttachmentLoadOp pCreateInfo->pAttachments->stencilLoadOp, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfo->pAttachments->stencilStoreOp < VK_ATTACHMENT_STORE_OP_BEGIN_RANGE || - pCreateInfo->pAttachments->stencilStoreOp > VK_ATTACHMENT_STORE_OP_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkAttachmentStoreOp pCreateInfo->pAttachments->stencilStoreOp, is an " - "unrecognized enumerator"); - return false; - } - if (((pCreateInfo->pAttachments->initialLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pCreateInfo->pAttachments->initialLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pCreateInfo->pAttachments->initialLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pAttachments->initialLayout, is an unrecognized " - "enumerator"); - return false; - } - if (((pCreateInfo->pAttachments->initialLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pCreateInfo->pAttachments->initialLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pCreateInfo->pAttachments->initialLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pAttachments->finalLayout, is an unrecognized " - "enumerator"); - return false; - } - } - if (pCreateInfo->pSubpasses != nullptr) { - if (pCreateInfo->pSubpasses->pipelineBindPoint < VK_PIPELINE_BIND_POINT_BEGIN_RANGE || - pCreateInfo->pSubpasses->pipelineBindPoint > VK_PIPELINE_BIND_POINT_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkPipelineBindPoint pCreateInfo->pSubpasses->pipelineBindPoint, is an " - "unrecognized enumerator"); - return false; - } - if (pCreateInfo->pSubpasses->pInputAttachments != nullptr) { - if (((pCreateInfo->pSubpasses->pInputAttachments->layout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pCreateInfo->pSubpasses->pInputAttachments->layout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pCreateInfo->pSubpasses->pInputAttachments->layout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pSubpasses->pInputAttachments->layout, is an " - "unrecognized enumerator"); - return false; - } - } - if (pCreateInfo->pSubpasses->pColorAttachments != nullptr) { - if (((pCreateInfo->pSubpasses->pColorAttachments->layout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pCreateInfo->pSubpasses->pColorAttachments->layout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pCreateInfo->pSubpasses->pColorAttachments->layout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pSubpasses->pColorAttachments->layout, is an " - "unrecognized enumerator"); - return false; - } - } - if (pCreateInfo->pSubpasses->pResolveAttachments != nullptr) { - if (((pCreateInfo->pSubpasses->pResolveAttachments->layout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pCreateInfo->pSubpasses->pResolveAttachments->layout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pCreateInfo->pSubpasses->pResolveAttachments->layout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pSubpasses->pResolveAttachments->layout, is " - "an unrecognized enumerator"); - return false; - } - } - if (pCreateInfo->pSubpasses->pDepthStencilAttachment && - ((pCreateInfo->pSubpasses->pDepthStencilAttachment->layout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || - (pCreateInfo->pSubpasses->pDepthStencilAttachment->layout > VK_IMAGE_LAYOUT_END_RANGE)) && - (pCreateInfo->pSubpasses->pDepthStencilAttachment->layout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCreateRenderPass parameter, VkImageLayout pCreateInfo->pSubpasses->pDepthStencilAttachment->layout, is " - "an unrecognized enumerator"); - return false; - } - } - } - - return true; -} - bool PostCreateRenderPass(VkDevice device, VkRenderPass *pRenderPass, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkCreateRenderPass parameter, VkResult result, is " + EnumeratorString(result); @@ -3909,8 +3395,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice devic skipCall |= parameter_validation_vkCreateRenderPass(my_data->report_data, pCreateInfo, pAllocator, pRenderPass); if (skipCall == VK_FALSE) { - PreCreateRenderPass(device, pCreateInfo); - result = get_dispatch_table(pc_device_table_map, device)->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); PostCreateRenderPass(device, pRenderPass, result); @@ -4011,18 +3495,6 @@ vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolRese return result; } -bool PreCreateCommandBuffer(VkDevice device, const VkCommandBufferAllocateInfo *pCreateInfo) { - if (pCreateInfo != nullptr) { - if (pCreateInfo->level < VK_COMMAND_BUFFER_LEVEL_BEGIN_RANGE || pCreateInfo->level > VK_COMMAND_BUFFER_LEVEL_END_RANGE) { - log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkAllocateCommandBuffers parameter, VkCommandBufferLevel pCreateInfo->level, is an unrecognized enumerator"); - return false; - } - } - - return true; -} - bool PostCreateCommandBuffer(VkDevice device, VkCommandBuffer *pCommandBuffer, VkResult result) { if (result < VK_SUCCESS) { std::string reason = "vkAllocateCommandBuffers parameter, VkResult result, is " + EnumeratorString(result); @@ -4044,8 +3516,6 @@ vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAl skipCall |= parameter_validation_vkAllocateCommandBuffers(my_data->report_data, pAllocateInfo, pCommandBuffers); if (skipCall == VK_FALSE) { - PreCreateCommandBuffer(device, pAllocateInfo); - result = get_dispatch_table(pc_device_table_map, device)->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); PostCreateCommandBuffer(device, pCommandBuffers, result); @@ -4140,22 +3610,17 @@ vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags fl return result; } -bool PostCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) { - - if (pipelineBindPoint < VK_PIPELINE_BIND_POINT_BEGIN_RANGE || pipelineBindPoint > VK_PIPELINE_BIND_POINT_END_RANGE) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBindPipeline parameter, VkPipelineBindPoint pipelineBindPoint, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) { - get_dispatch_table(pc_device_table_map, commandBuffer)->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); + VkBool32 skipCall = VK_FALSE; + layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); + assert(my_data != NULL); - PostCmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); + skipCall |= parameter_validation_vkCmdBindPipeline(my_data->report_data, pipelineBindPoint, pipeline); + + if (skipCall == VK_FALSE) { + get_dispatch_table(pc_device_table_map, commandBuffer)->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); + } } VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL @@ -4227,18 +3692,6 @@ vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceM get_dispatch_table(pc_device_table_map, commandBuffer)->CmdSetStencilReference(commandBuffer, faceMask, reference); } -bool PostCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, - uint32_t firstSet, uint32_t setCount, uint32_t dynamicOffsetCount) { - - if (pipelineBindPoint < VK_PIPELINE_BIND_POINT_BEGIN_RANGE || pipelineBindPoint > VK_PIPELINE_BIND_POINT_END_RANGE) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBindDescriptorSets parameter, VkPipelineBindPoint pipelineBindPoint, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, @@ -4254,27 +3707,20 @@ vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipel get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); - - PostCmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, dynamicOffsetCount); } } -bool PostCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) { - - if (indexType < VK_INDEX_TYPE_BEGIN_RANGE || indexType > VK_INDEX_TYPE_END_RANGE) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBindIndexBuffer parameter, VkIndexType indexType, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) { - get_dispatch_table(pc_device_table_map, commandBuffer)->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); + VkBool32 skipCall = VK_FALSE; + layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); + assert(my_data != NULL); + + skipCall |= parameter_validation_vkCmdBindIndexBuffer(my_data->report_data, buffer, offset, indexType); - PostCmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); + if (skipCall == VK_FALSE) { + get_dispatch_table(pc_device_table_map, commandBuffer)->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); + } } VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, @@ -4380,25 +3826,6 @@ bool PreCmdCopyImage(VkCommandBuffer commandBuffer, const VkImageCopy *pRegions) return true; } -bool PostCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount) { - if (((srcImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (srcImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (srcImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdCopyImage parameter, VkImageLayout srcImageLayout, is an unrecognized enumerator"); - return false; - } - - if (((dstImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (dstImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (dstImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdCopyImage parameter, VkImageLayout dstImageLayout, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) { @@ -4414,8 +3841,6 @@ vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout sr get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); - - PostCmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount); } } @@ -4438,32 +3863,6 @@ bool PreCmdBlitImage(VkCommandBuffer commandBuffer, const VkImageBlit *pRegions) return true; } -bool PostCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, VkFilter filter) { - - if (((srcImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (srcImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (srcImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBlitImage parameter, VkImageLayout srcImageLayout, is an unrecognized enumerator"); - return false; - } - - if (((dstImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (dstImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (dstImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBlitImage parameter, VkImageLayout dstImageLayout, is an unrecognized enumerator"); - return false; - } - - if (filter < VK_FILTER_BEGIN_RANGE || filter > VK_FILTER_END_RANGE) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBlitImage parameter, VkFilter filter, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) { @@ -4479,8 +3878,6 @@ vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout sr get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter); - - PostCmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, filter); } } @@ -4498,19 +3895,6 @@ bool PreCmdCopyBufferToImage(VkCommandBuffer commandBuffer, const VkBufferImageC return true; } -bool PostCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, - uint32_t regionCount) { - - if (((dstImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (dstImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (dstImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdCopyBufferToImage parameter, VkImageLayout dstImageLayout, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions) { @@ -4526,8 +3910,6 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffe get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); - - PostCmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount); } } @@ -4545,19 +3927,6 @@ bool PreCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, const VkBufferImageC return true; } -bool PostCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, - uint32_t regionCount) { - - if (((srcImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (srcImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (srcImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdCopyImageToBuffer parameter, VkImageLayout srcImageLayout, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) { @@ -4573,8 +3942,6 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffe get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions); - - PostCmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount); } } @@ -4597,18 +3964,6 @@ vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize get_dispatch_table(pc_device_table_map, commandBuffer)->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); } -bool PostCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, uint32_t rangeCount) { - - if (((imageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (imageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (imageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdClearColorImage parameter, VkImageLayout imageLayout, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue *pColor, uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { @@ -4621,24 +3976,9 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer if (skipCall == VK_FALSE) { get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); - - PostCmdClearColorImage(commandBuffer, image, imageLayout, rangeCount); } } -bool PostCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, - const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount) { - - if (((imageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (imageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (imageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdClearDepthStencilImage parameter, VkImageLayout imageLayout, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, @@ -4653,8 +3993,6 @@ vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImag if (skipCall == VK_FALSE) { get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges); - - PostCmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount); } } @@ -4694,26 +4032,6 @@ bool PreCmdResolveImage(VkCommandBuffer commandBuffer, const VkImageResolve *pRe return true; } -bool PostCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount) { - - if (((srcImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (srcImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (srcImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdResolveImage parameter, VkImageLayout srcImageLayout, is an unrecognized enumerator"); - return false; - } - - if (((dstImageLayout < VK_IMAGE_LAYOUT_BEGIN_RANGE) || (dstImageLayout > VK_IMAGE_LAYOUT_END_RANGE)) && - (dstImageLayout != VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdResolveImage parameter, VkImageLayout dstImageLayout, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions) { @@ -4729,8 +4047,6 @@ vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout get_dispatch_table(pc_device_table_map, commandBuffer) ->CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); - - PostCmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount); } } @@ -4835,17 +4151,6 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer co } } -bool PostCmdBeginRenderPass(VkCommandBuffer commandBuffer, VkSubpassContents contents) { - - if (contents < VK_SUBPASS_CONTENTS_BEGIN_RANGE || contents > VK_SUBPASS_CONTENTS_END_RANGE) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdBeginRenderPass parameter, VkSubpassContents contents, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents) { VkBool32 skipCall = VK_FALSE; @@ -4856,26 +4161,19 @@ vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo if (skipCall == VK_FALSE) { get_dispatch_table(pc_device_table_map, commandBuffer)->CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents); - - PostCmdBeginRenderPass(commandBuffer, contents); } } -bool PostCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) { - - if (contents < VK_SUBPASS_CONTENTS_BEGIN_RANGE || contents > VK_SUBPASS_CONTENTS_END_RANGE) { - log_msg(mdd(commandBuffer), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "vkCmdNextSubpass parameter, VkSubpassContents contents, is an unrecognized enumerator"); - return false; - } - - return true; -} - VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) { - get_dispatch_table(pc_device_table_map, commandBuffer)->CmdNextSubpass(commandBuffer, contents); + VkBool32 skipCall = VK_FALSE; + layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); + assert(my_data != NULL); - PostCmdNextSubpass(commandBuffer, contents); + skipCall |= parameter_validation_vkCmdNextSubpass(my_data->report_data, contents); + + if (skipCall == VK_FALSE) { + get_dispatch_table(pc_device_table_map, commandBuffer)->CmdNextSubpass(commandBuffer, contents); + } } VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer) { diff --git a/layers/parameter_validation_utils.h b/layers/parameter_validation_utils.h index 7cb80c06..ef899549 100644 --- a/layers/parameter_validation_utils.h +++ b/layers/parameter_validation_utils.h @@ -33,6 +33,7 @@ #define PARAMETER_VALIDATION_UTILS_H #include +#include #include #include "vulkan/vulkan.h" @@ -46,9 +47,29 @@ struct GenericHeader { }; } -// String returned by string_VkStructureType for an unrecognized type +// Layer name string to be logged with validation messages. +const char ParameterValidationName[] = "ParameterValidation"; + +// String returned by string_VkStructureType for an unrecognized type. const std::string UnsupportedStructureTypeString = "Unhandled VkStructureType"; +// The base value used when computing the offset for an enumeration token value that is added by an extension. +// When validating enumeration tokens, any value >= to this value is considered to be provided by an extension. +// See Appendix C.10 "Assigning Extension Token Values" from the Vulkan specification +const uint32_t ExtEnumBaseValue = 1000000000; + +template bool is_extension_added_token(T value) { + return (std::abs(static_cast(value)) >= ExtEnumBaseValue); +} + +// VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE token is a special case that was converted from a core token to an +// extension added token. Its original value was intentionally preserved after the conversion, so it does not use +// the base value that other extension added tokens use, and it does not fall within the enum's begin/end range. +template <> bool is_extension_added_token(VkSamplerAddressMode value) { + bool result = (std::abs(static_cast(value)) >= ExtEnumBaseValue); + return (result || (value == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE)); +} + /** * Validate a required pointer. * @@ -65,8 +86,8 @@ static VkBool32 validate_required_pointer(debug_report_data *report_data, const VkBool32 skipCall = VK_FALSE; if (value == NULL) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "%s: required parameter %s specified as NULL", apiName, parameterName); + skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, parameterName); } return skipCall; @@ -101,7 +122,7 @@ VkBool32 validate_array(debug_report_data *report_data, const char *apiName, con if (count == NULL) { if (countPtrRequired == VK_TRUE) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: required parameter %s specified as NULL", apiName, countName); + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, countName); } } else { skipCall |= validate_array(report_data, apiName, countName, arrayName, (*count), array, countValueRequired, arrayRequired); @@ -134,15 +155,15 @@ VkBool32 validate_array(debug_report_data *report_data, const char *apiName, con // Count parameters not tagged as optional cannot be 0 if ((count == 0) && (countRequired == VK_TRUE)) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "%s: value of %s must be greater than 0", apiName, countName); + skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: value of %s must be greater than 0", apiName, countName); } // Array parameters not tagged as optional cannot be NULL, // unless the count is 0 if ((array == NULL) && (arrayRequired == VK_TRUE) && (count != 0)) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "%s: required parameter %s specified as NULL", apiName, arrayName); + skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, arrayName); } return skipCall; @@ -168,11 +189,11 @@ VkBool32 validate_struct_type(debug_report_data *report_data, const char *apiNam if (value == NULL) { if (required == VK_TRUE) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: required parameter %s specified as NULL", apiName, parameterName); + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, parameterName); } } else if (value->sType != sType) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", - "%s: parameter %s->sType must be %s", apiName, parameterName, sTypeName); + skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: parameter %s->sType must be %s", apiName, parameterName, sTypeName); } return skipCall; @@ -209,7 +230,7 @@ VkBool32 validate_struct_type_array(debug_report_data *report_data, const char * if (count == NULL) { if (countPtrRequired == VK_TRUE) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: required parameter %s specified as NULL", apiName, countName); + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, countName); } } else { skipCall |= validate_struct_type_array(report_data, apiName, countName, arrayName, sTypeName, (*count), array, sType, @@ -248,21 +269,22 @@ VkBool32 validate_struct_type_array(debug_report_data *report_data, const char * // Count parameters not tagged as optional cannot be 0 if ((count == 0) && (countRequired == VK_TRUE)) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: parameter %s must be greater than 0", apiName, countName); + ParameterValidationName, "%s: parameter %s must be greater than 0", apiName, countName); } // Array parameters not tagged as optional cannot be NULL, // unless the count is 0 if ((array == NULL) && (arrayRequired == VK_TRUE) && (count != 0)) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: required parameter %s specified as NULL", apiName, arrayName); + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, arrayName); } } else { // Verify that all structs in the array have the correct type for (uint32_t i = 0; i < count; ++i) { if (array[i].sType != sType) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: parameter %s[%d].sType must be %s", apiName, arrayName, i, sTypeName); + skipCall |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: parameter %s[%d].sType must be %s", apiName, arrayName, i, sTypeName); } } } @@ -297,21 +319,22 @@ static VkBool32 validate_string_array(debug_report_data *report_data, const char // Count parameters not tagged as optional cannot be 0 if ((count == 0) && (countRequired == VK_TRUE)) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: parameter %s must be greater than 0", apiName, countName); + ParameterValidationName, "%s: parameter %s must be greater than 0", apiName, countName); } // Array parameters not tagged as optional cannot be NULL, // unless the count is 0 if ((array == NULL) && (arrayRequired == VK_TRUE) && (count != 0)) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: required parameter %s specified as NULL", apiName, arrayName); + ParameterValidationName, "%s: required parameter %s specified as NULL", apiName, arrayName); } } else { // Verify that strings in the array not NULL for (uint32_t i = 0; i < count; ++i) { if (array[i] == NULL) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: required parameter %s[%d] specified as NULL", apiName, arrayName, i); + skipCall |= + log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: required parameter %s[%d] specified as NULL", apiName, arrayName, i); } } } @@ -343,7 +366,7 @@ static VkBool32 validate_struct_pnext(debug_report_data *report_data, const char if (next != NULL) { if (allowedTypeCount == 0) { skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, - "PARAMCHECK", "%s: value of %s must be NULL", apiName, parameterName); + ParameterValidationName, "%s: value of %s must be NULL", apiName, parameterName); } else { const VkStructureType *start = allowedTypes; const VkStructureType *end = allowedTypes + allowedTypeCount; @@ -355,12 +378,14 @@ static VkBool32 validate_struct_pnext(debug_report_data *report_data, const char if (typeName == UnsupportedStructureTypeString) { skipCall |= log_msg( - report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", + report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed structures are [%s]", apiName, parameterName, current->sType, allowedStructNames); } else { skipCall |= log_msg( - report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, "PARAMCHECK", + report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: %s chain includes a structure with unexpected VkStructureType %s; Allowed structures are [%s]", apiName, parameterName, typeName.c_str(), allowedStructNames); } @@ -374,4 +399,99 @@ static VkBool32 validate_struct_pnext(debug_report_data *report_data, const char return skipCall; } +/** +* Validate a VkBool32 value. +* +* Generate a warning if a VkBool32 value is neither VK_TRUE nor VK_FALSE. +* +* @param report_data debug_report_data object for routing validation messages. +* @param apiName Name of API call being validated. +* @param parameterName Name of parameter being validated. +* @param value Boolean value to validate. +* @return Boolean value indicating that the call should be skipped. +*/ +static VkBool32 validate_bool32(debug_report_data *report_data, const char *apiName, const char *parameterName, VkBool32 value) { + VkBool32 skipCall = VK_FALSE; + + if ((value != VK_TRUE) && (value != VK_FALSE)) { + skipCall |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: value of %s (%d) is neither VK_TRUE nor VK_FALSE", apiName, parameterName, value); + } + + return skipCall; +} + +/** +* Validate a Vulkan enumeration value. +* +* Generate a warning if an enumeration token value does not fall within the core enumeration +* begin and end token values, and was not added to the enumeration by an extension. Extension +* provided enumerations use the equation specified in Appendix C.10 of the Vulkan specification, +* with 1,000,000,000 as the base token value. +* +* @note This function does not expect to process enumerations defining bitmask flag bits. +* +* @param report_data debug_report_data object for routing validation messages. +* @param apiName Name of API call being validated. +* @param parameterName Name of parameter being validated. +* @param enumName Name of the enumeration being validated. +* @param begin The begin range value for the enumeration. +* @param end The end range value for the enumeration. +* @param value Boolean value to validate. +* @return Boolean value indicating that the call should be skipped. +*/ +template +VkBool32 validate_ranged_enum(debug_report_data *report_data, const char *apiName, const char *parameterName, const char *enumName, + T begin, T end, T value) { + VkBool32 skipCall = VK_FALSE; + + if (((value < begin) || (value > end)) && !is_extension_added_token(value)) { + skipCall |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: value of %s (%d) does not fall within the begin..end range of the core %s " + "enumeration tokens and is not an extension added token", + apiName, parameterName, value, enumName); + } + + return skipCall; +} + +/** +* Validate an array of Vulkan enumeration value. +* +* Process all enumeration token values in the specified array and generate a warning if a value +* does not fall within the core enumeration begin and end token values, and was not added to +* the enumeration by an extension. Extension provided enumerations use the equation specified +* in Appendix C.10 of the Vulkan specification, with 1,000,000,000 as the base token value. +* +* @note This function does not expect to process enumerations defining bitmask flag bits. +* +* @param report_data debug_report_data object for routing validation messages. +* @param apiName Name of API call being validated. +* @param parameterName Name of parameter being validated. +* @param enumName Name of the enumeration being validated. +* @param begin The begin range value for the enumeration. +* @param end The end range value for the enumeration. +* @param value Boolean value to validate. +* @return Boolean value indicating that the call should be skipped. +*/ +template +static VkBool32 validate_ranged_enum_array(debug_report_data *report_data, const char *apiName, const char *parameterName, + const char *enumName, T begin, T end, uint32_t count, const T *pValues) { + VkBool32 skipCall = VK_FALSE; + + for (uint32_t i = 0; i < count; ++i) { + if (((pValues[i] < begin) || (pValues[i] > end)) && !is_extension_added_token(pValues[i])) { + skipCall |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, 1, + ParameterValidationName, "%s: value of %s[%d] (%d) does not fall within the begin..end range of the core %s " + "enumeration tokens and is not an extension added token", + apiName, parameterName, i, pValues[i], enumName); + } + } + + return skipCall; +} + #endif // PARAMETER_VALIDATION_UTILS_H -- cgit v1.2.3