diff options
| author | Tobin Ehlis <tobine@google.com> | 2017-03-14 11:22:50 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2017-03-15 06:57:27 -0600 |
| commit | bd6cca98c4f7c6b0022daade891388774aa2cf81 (patch) | |
| tree | e836d1935e255959a1359acbff52930ff37a7f85 | |
| parent | 95447595e162090cbd2cfbf48021f459c293e3ed (diff) | |
| download | usermoji-bd6cca98c4f7c6b0022daade891388774aa2cf81.tar.xz | |
layers:Connect VK_EXT_validation_flags
Add support for VK_EXT_validation_flags in core_validation.
The only enum currently supported is VK_VALIDATION_CHECK_ALL_EXT which
disables all existing flags in validation. Note that most checks are
still not guarded by flags so that option will only disable the checks
that are guarded by flags.
In testing this I found a bug with AllocateDescriptorSets() where
common state was not updated with the flag enabled so this includes a
fix for that issue as well.
| -rw-r--r-- | layers/core_validation.cpp | 31 | ||||
| -rw-r--r-- | layers/core_validation_types.h | 4 | ||||
| -rw-r--r-- | layers/descriptor_sets.cpp | 32 | ||||
| -rw-r--r-- | layers/descriptor_sets.h | 7 |
4 files changed, 58 insertions, 16 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index f64a4b74..164bc28f 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3809,6 +3809,20 @@ static void checkInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateI } } +// For the given ValidationCheck enum, set all relevant instance disabled flags to true +void SetDisabledFlags(instance_layer_data *instance_data, VkValidationFlagsEXT *val_flags_struct) { + for (uint32_t i = 0; i < val_flags_struct->disabledValidationCheckCount; ++i) { + switch (val_flags_struct->pDisabledValidationChecks[i]) { + case VK_VALIDATION_CHECK_ALL_EXT: + // Set all disabled flags to true + instance_data->disabled.SetAll(true); + break; + default: + break; + } + } +} + VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); @@ -3833,6 +3847,17 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreat init_core_validation(instance_data, pAllocator); ValidateLayerOrdering(*pCreateInfo); + // Parse any pNext chains + if (pCreateInfo->pNext) { + GENERIC_HEADER *struct_header = (GENERIC_HEADER *)pCreateInfo->pNext; + while (struct_header) { + // Check for VkValidationFlagsExt + if (VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT == struct_header->sType) { + SetDisabledFlags(instance_data, (VkValidationFlagsEXT *)struct_header); + } + struct_header = (GENERIC_HEADER *)struct_header->pNext; + } + } return result; } @@ -6158,7 +6183,7 @@ const VkImageFormatProperties *GetImageFormatProperties(core_validation::layer_d return image_format_properties; } -const debug_report_data *GetReportData(core_validation::layer_data *device_data) { return device_data->report_data; } +const debug_report_data *GetReportData(const core_validation::layer_data *device_data) { return device_data->report_data; } const VkPhysicalDeviceProperties *GetPhysicalDeviceProperties(core_validation::layer_data *device_data) { return &device_data->phys_dev_props; @@ -6682,9 +6707,11 @@ VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptor // as well as DescriptorSetLayout ptrs used for later update. static bool PreCallValidateAllocateDescriptorSets(layer_data *dev_data, const VkDescriptorSetAllocateInfo *pAllocateInfo, cvdescriptorset::AllocateDescriptorSetsData *common_data) { + // Always update common data + cvdescriptorset::UpdateAllocateDescriptorSetsData(dev_data, pAllocateInfo, common_data); if (dev_data->instance_data->disabled.allocate_descriptor_sets) return false; // All state checks for AllocateDescriptorSets is done in single function - return cvdescriptorset::ValidateAllocateDescriptorSets(dev_data->report_data, pAllocateInfo, dev_data, common_data); + return cvdescriptorset::ValidateAllocateDescriptorSets(dev_data, pAllocateInfo, common_data); } // Allocation state was good and call down chain was made so update state based on allocating descriptor sets static void PostCallRecordAllocateDescriptorSets(layer_data *dev_data, const VkDescriptorSetAllocateInfo *pAllocateInfo, diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index 84a64386..73b5c802 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -729,6 +729,8 @@ struct CHECK_DISABLED { bool get_query_pool_results; bool destroy_buffer; bool shader_validation; // Skip validation for shaders + + void SetAll(bool value) { std::fill(&command_buffer_state, &shader_validation + 1, value); } }; struct MT_FB_ATTACHMENT_INFO { @@ -804,7 +806,7 @@ const VkFormatProperties *GetFormatProperties(core_validation::layer_data *devic const VkImageFormatProperties *GetImageFormatProperties(core_validation::layer_data *device_data, VkFormat format, VkImageType image_type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags); -const debug_report_data *GetReportData(layer_data *); +const debug_report_data *GetReportData(const layer_data *); const VkPhysicalDeviceProperties *GetPhysicalDeviceProperties(layer_data *); const CHECK_DISABLED *GetDisables(layer_data *); std::unordered_map<VkImage, std::unique_ptr<IMAGE_STATE>> *GetImageMap(core_validation::layer_data *); diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index ada51a02..92d0ce08 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -1608,11 +1608,29 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri // All checks passed so update contents are good return true; } +// Update the common AllocateDescriptorSetsData +void cvdescriptorset::UpdateAllocateDescriptorSetsData(const layer_data *dev_data, const VkDescriptorSetAllocateInfo *p_alloc_info, + AllocateDescriptorSetsData *ds_data) { + for (uint32_t i = 0; i < p_alloc_info->descriptorSetCount; i++) { + auto layout = GetDescriptorSetLayout(dev_data, p_alloc_info->pSetLayouts[i]); + if (layout) { + ds_data->layout_nodes[i] = layout; + // Count total descriptors required per type + for (uint32_t j = 0; j < layout->GetBindingCount(); ++j) { + const auto &binding_layout = layout->GetDescriptorSetLayoutBindingPtrFromIndex(j); + uint32_t typeIndex = static_cast<uint32_t>(binding_layout->descriptorType); + ds_data->required_descriptors_by_type[typeIndex] += binding_layout->descriptorCount; + } + } + // Any unknown layouts will be flagged as errors during ValidateAllocateDescriptorSets() call + } +}; // Verify that the state at allocate time is correct, but don't actually allocate the sets yet -bool cvdescriptorset::ValidateAllocateDescriptorSets(const debug_report_data *report_data, - const VkDescriptorSetAllocateInfo *p_alloc_info, const layer_data *dev_data, - AllocateDescriptorSetsData *ds_data) { +bool cvdescriptorset::ValidateAllocateDescriptorSets(const core_validation::layer_data *dev_data, + const VkDescriptorSetAllocateInfo *p_alloc_info, + const AllocateDescriptorSetsData *ds_data) { bool skip_call = false; + auto report_data = core_validation::GetReportData(dev_data); for (uint32_t i = 0; i < p_alloc_info->descriptorSetCount; i++) { auto layout = GetDescriptorSetLayout(dev_data, p_alloc_info->pSetLayouts[i]); @@ -1622,14 +1640,6 @@ bool cvdescriptorset::ValidateAllocateDescriptorSets(const debug_report_data *re reinterpret_cast<const uint64_t &>(p_alloc_info->pSetLayouts[i]), __LINE__, DRAWSTATE_INVALID_LAYOUT, "DS", "Unable to find set layout node for layout 0x%" PRIxLEAST64 " specified in vkAllocateDescriptorSets() call", reinterpret_cast<const uint64_t &>(p_alloc_info->pSetLayouts[i])); - } else { - ds_data->layout_nodes[i] = layout; - // Count total descriptors required per type - for (uint32_t j = 0; j < layout->GetBindingCount(); ++j) { - const auto &binding_layout = layout->GetDescriptorSetLayoutBindingPtrFromIndex(j); - uint32_t typeIndex = static_cast<uint32_t>(binding_layout->descriptorType); - ds_data->required_descriptors_by_type[typeIndex] += binding_layout->descriptorCount; - } } } auto pool_state = GetDescriptorPoolState(dev_data, p_alloc_info->descriptorPool); diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h index c842aed2..293b481b 100644 --- a/layers/descriptor_sets.h +++ b/layers/descriptor_sets.h @@ -290,9 +290,12 @@ void PerformUpdateDescriptorSets(const core_validation::layer_data *, uint32_t, // Similar to PerformUpdateDescriptorSets, this function will do the same for updating via templates void PerformUpdateDescriptorSetsWithTemplateKHR(layer_data *, VkDescriptorSet, std::unique_ptr<TEMPLATE_STATE> const &, const void *); +// Update the common AllocateDescriptorSetsData struct which can then be shared between Validate* and Perform* funcs below +void UpdateAllocateDescriptorSetsData(const layer_data *dev_data, const VkDescriptorSetAllocateInfo *, + AllocateDescriptorSetsData *); // Validate that Allocation state is ok -bool ValidateAllocateDescriptorSets(const debug_report_data *, const VkDescriptorSetAllocateInfo *, - const core_validation::layer_data *, AllocateDescriptorSetsData *); +bool ValidateAllocateDescriptorSets(const core_validation::layer_data *, const VkDescriptorSetAllocateInfo *, + const AllocateDescriptorSetsData *); // Update state based on allocating new descriptorsets void PerformAllocateDescriptorSets(const VkDescriptorSetAllocateInfo *, const VkDescriptorSet *, const AllocateDescriptorSetsData *, std::unordered_map<VkDescriptorPool, DESCRIPTOR_POOL_STATE *> *, |
