diff options
| author | Dustin Graves <dustin@lunarg.com> | 2016-07-19 13:43:53 -0600 |
|---|---|---|
| committer | Dustin Graves <dustin@lunarg.com> | 2016-07-20 11:46:49 -0600 |
| commit | d512872df8a2698630c32f1ddc8a84d488263b2f (patch) | |
| tree | 4479a13e8e68d43a0f1b32fa444e7f081215db4d | |
| parent | 1d48d6c79e0f025d563e5878b14ec8304e366230 (diff) | |
| download | usermoji-d512872df8a2698630c32f1ddc8a84d488263b2f.tar.xz | |
layers: Change pNext validation error to warning
Change the severity level of the parameter_validation layer's pNext
parameter validation messages from error to warning. Also add an
explanation that the warning is derived from the Valid Usage
language from version X of the Vulkan spec/header, which may be out
of date:
This warning is based on the Valid Usage documentation for version %d
of the Vulkan header. It is possible that you are using a struct
from a private extension or an extension that was added to a later
version of the Vulkan header, in which case your use of pNext is
perfectly valid but is not guaranteed to work correctly with
validation enabled
Issues-Addressed: LunarXchange 560
Change-Id: I97f55cba7538506d246e45ef603a86db9ad1adcb
| -rwxr-xr-x | generator.py | 2 | ||||
| -rw-r--r-- | layers/parameter_validation.cpp | 12 | ||||
| -rw-r--r-- | layers/parameter_validation_utils.h | 67 |
3 files changed, 46 insertions, 35 deletions
diff --git a/generator.py b/generator.py index 26fe99ea..65c6a40d 100755 --- a/generator.py +++ b/generator.py @@ -3431,7 +3431,7 @@ class ParamCheckerOutputGenerator(OutputGenerator): extStructCount = 'ARRAY_SIZE(allowedStructs)' extStructVar = 'allowedStructs' extStructNames = '"' + ', '.join(structs) + '"' - checkExpr.append('skipCall |= validate_struct_pnext(report_data, "{}", "{}", {}, {}{}, {}, {});\n'.format( + checkExpr.append('skipCall |= validate_struct_pnext(report_data, "{}", "{}", {}, {}{}, {}, {}, GeneratedHeaderVersion);\n'.format( funcPrintName, valuePrintName, extStructNames, prefix, value.name, extStructCount, extStructVar)) return checkExpr # diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index 80be9ce2..4d2f9f94 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -2802,7 +2802,7 @@ CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t } else { skip_call |= validate_struct_pnext(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", - NULL, pCreateInfos[i].pTessellationState->pNext, 0, NULL); + NULL, pCreateInfos[i].pTessellationState->pNext, 0, NULL, GeneratedHeaderVersion); skip_call |= validate_reserved_flags(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", @@ -2832,7 +2832,7 @@ CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t } else { skip_call |= validate_struct_pnext(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pViewportState->pNext", NULL, - pCreateInfos[i].pViewportState->pNext, 0, NULL); + pCreateInfos[i].pViewportState->pNext, 0, NULL, GeneratedHeaderVersion); skip_call |= validate_reserved_flags(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pViewportState->flags", @@ -2919,7 +2919,7 @@ CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t } else { skip_call |= validate_struct_pnext(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pMultisampleState->pNext", - NULL, pCreateInfos[i].pMultisampleState->pNext, 0, NULL); + NULL, pCreateInfos[i].pMultisampleState->pNext, 0, NULL, GeneratedHeaderVersion); skip_call |= validate_reserved_flags(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pMultisampleState->flags", @@ -2955,7 +2955,7 @@ CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t if (pCreateInfos[i].pDepthStencilState != nullptr) { skip_call |= validate_struct_pnext(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pDepthStencilState->pNext", - NULL, pCreateInfos[i].pDepthStencilState->pNext, 0, NULL); + NULL, pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedHeaderVersion); skip_call |= validate_reserved_flags(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pDepthStencilState->flags", @@ -3027,7 +3027,7 @@ CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t if (pCreateInfos[i].pColorBlendState != nullptr) { skip_call |= validate_struct_pnext(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pColorBlendState->pNext", NULL, - pCreateInfos[i].pColorBlendState->pNext, 0, NULL); + pCreateInfos[i].pColorBlendState->pNext, 0, NULL, GeneratedHeaderVersion); skip_call |= validate_reserved_flags(report_data, "vkCreateGraphicsPipelines", "pCreateInfos[i].pColorBlendState->flags", @@ -3788,7 +3788,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer commandBuffer, if (pBeginInfo->pInheritanceInfo != NULL) { skip_call |= validate_struct_pnext(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->pNext", NULL, - pBeginInfo->pInheritanceInfo->pNext, 0, NULL); + pBeginInfo->pInheritanceInfo->pNext, 0, NULL, GeneratedHeaderVersion); skip_call |= validate_bool32(report_data, "vkBeginCommandBuffer", "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pBeginInfo->pInheritanceInfo->occlusionQueryEnable); diff --git a/layers/parameter_validation_utils.h b/layers/parameter_validation_utils.h index c49ce473..2d42f85c 100644 --- a/layers/parameter_validation_utils.h +++ b/layers/parameter_validation_utils.h @@ -442,44 +442,55 @@ static bool validate_string_array(debug_report_data *report_data, const char *ap * verify that pNext is null. * * @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 allowedStructNames Names of allowed structs. + * @param api_name Name of API call being validated. + * @param parameter_name Name of parameter being validated. + * @param allowed_struct_names Names of allowed structs. * @param next Pointer to validate. - * @param allowedTypeCount total number of allowed structure types. - * @param allowedTypes array of strcuture types allowed for pNext. + * @param allowed_type_count Total number of allowed structure types. + * @param allowed_types Array of strcuture types allowed for pNext. + * @param header_version Version of header defining the pNext validation rules. * @return Boolean value indicating that the call should be skipped. */ -static bool validate_struct_pnext(debug_report_data *report_data, const char *apiName, const char *parameterName, - const char *allowedStructNames, const void *next, size_t allowedTypeCount, - const VkStructureType *allowedTypes) { - bool skipCall = false; +static bool validate_struct_pnext(debug_report_data *report_data, const char *api_name, const char *parameter_name, + const char *allowed_struct_names, const void *next, size_t allowed_type_count, + const VkStructureType *allowed_types, uint32_t header_version) { + bool skip_call = false; + const char disclaimer[] = "This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It " + "is possible that you are using a struct from a private extension or an extension that was added " + "to a later version of the Vulkan header, in which case your use of %s is perfectly valid but " + "is not guaranteed to work correctly with validation enabled"; if (next != NULL) { - if (allowedTypeCount == 0) { - skipCall |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - INVALID_STRUCT_PNEXT, LayerName, "%s: value of %s must be NULL", apiName, parameterName); + if (allowed_type_count == 0) { + std::string message = "%s: value of %s must be NULL. "; + message += disclaimer; + skip_call |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, + INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, parameter_name, header_version, parameter_name); } else { - const VkStructureType *start = allowedTypes; - const VkStructureType *end = allowedTypes + allowedTypeCount; + const VkStructureType *start = allowed_types; + const VkStructureType *end = allowed_types + allowed_type_count; const GenericHeader *current = reinterpret_cast<const GenericHeader *>(next); while (current != NULL) { if (std::find(start, end, current->sType) == end) { - std::string typeName = string_VkStructureType(current->sType); - - if (typeName == UnsupportedStructureTypeString) { - skipCall |= log_msg( - report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - INVALID_STRUCT_PNEXT, LayerName, - "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed structures are [%s]", - apiName, parameterName, current->sType, allowedStructNames); + std::string type_name = string_VkStructureType(current->sType); + + if (type_name == UnsupportedStructureTypeString) { + std::string message = "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed " + "structures are [%s]. "; + message += disclaimer; + skip_call |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, + 0, __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, + parameter_name, current->sType, allowed_struct_names, header_version, parameter_name); } else { - skipCall |= log_msg( - report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, - INVALID_STRUCT_PNEXT, LayerName, - "%s: %s chain includes a structure with unexpected VkStructureType %s; Allowed structures are [%s]", - apiName, parameterName, typeName.c_str(), allowedStructNames); + std::string message = + "%s: %s chain includes a structure with unexpected VkStructureType %s; Allowed structures are [%s]. "; + message += disclaimer; + skip_call |= + log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, + __LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name, parameter_name, + type_name.c_str(), allowed_struct_names, header_version, parameter_name); } } @@ -488,7 +499,7 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap } } - return skipCall; + return skip_call; } /** |
