Skip to content
Snippets Groups Projects
Commit c9fc7049 authored by Mark Lobodzinski's avatar Mark Lobodzinski
Browse files

layers: Add pNext cycle/redundancy checks to PV

Change-Id: I06d311821ef0c10683ad8bdaf076231143cde22f
parent a0c58a64
No related branches found
No related tags found
No related merge requests found
...@@ -491,12 +491,17 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap ...@@ -491,12 +491,17 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap
const char *allowed_struct_names, const void *next, size_t allowed_type_count, const char *allowed_struct_names, const void *next, size_t allowed_type_count,
const VkStructureType *allowed_types, uint32_t header_version) { const VkStructureType *allowed_types, uint32_t header_version) {
bool skip_call = false; bool skip_call = false;
std::unordered_set<const void *> cycle_check;
std::unordered_set<VkStructureType, std::hash<int>> unique_stype_check;
const char disclaimer[] = const char disclaimer[] =
"This warning is based on the Valid Usage documentation for version %d of the Vulkan header. It " "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 " "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 " "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"; "is not guaranteed to work correctly with validation enabled";
// TODO: The valid pNext structure types are not recursive. Each structure has its own list of valid sTypes for pNext.
// Codegen a map of vectors containing the allowable pNext types for each struct and use that here -- also simplifies parms.
if (next != NULL) { if (next != NULL) {
if (allowed_type_count == 0) { if (allowed_type_count == 0) {
std::string message = "%s: value of %s must be NULL. "; std::string message = "%s: value of %s must be NULL. ";
...@@ -509,10 +514,31 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap ...@@ -509,10 +514,31 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap
const VkStructureType *end = allowed_types + allowed_type_count; const VkStructureType *end = allowed_types + allowed_type_count;
const GenericHeader *current = reinterpret_cast<const GenericHeader *>(next); const GenericHeader *current = reinterpret_cast<const GenericHeader *>(next);
cycle_check.insert(next);
while (current != NULL) { while (current != NULL) {
if (std::find(start, end, current->sType) == end) { if (cycle_check.find(current->pNext) != cycle_check.end()) {
std::string type_name = string_VkStructureType(current->sType); std::string message = "%s: %s chain contains a cycle -- pNext pointer " PRIx64 " is repeated.";
skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
__LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name,
parameter_name.get_name().c_str(), reinterpret_cast<uint64_t>(next));
break;
} else {
cycle_check.insert(current->pNext);
}
std::string type_name = string_VkStructureType(current->sType);
if (unique_stype_check.find(current->sType) != unique_stype_check.end()) {
std::string message = "%s: %s chain contains duplicate structure types: %s appears multiple times.";
skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
__LINE__, INVALID_STRUCT_PNEXT, LayerName, message.c_str(), api_name,
parameter_name.get_name().c_str(), type_name.c_str());
} else {
unique_stype_check.insert(current->sType);
}
if (std::find(start, end, current->sType) == end) {
if (type_name == UnsupportedStructureTypeString) { if (type_name == UnsupportedStructureTypeString) {
std::string message = std::string message =
"%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed " "%s: %s chain includes a structure with unexpected VkStructureType (%d); Allowed "
...@@ -532,7 +558,6 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap ...@@ -532,7 +558,6 @@ static bool validate_struct_pnext(debug_report_data *report_data, const char *ap
header_version, parameter_name.get_name().c_str()); header_version, parameter_name.get_name().c_str());
} }
} }
current = reinterpret_cast<const GenericHeader *>(current->pNext); current = reinterpret_cast<const GenericHeader *>(current->pNext);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment