From 4c0eb627a04186251aea4b63581ca74ccab0a956 Mon Sep 17 00:00:00 2001 From: John Zulauf Date: Wed, 17 Jan 2018 11:06:34 -0700 Subject: layers: Add validation for destroyed layouts Add three tests to flag with descriptor set update operations are being done to descriptor sets with destroyed descriptor set layouts. The tests use overload VUID (generic "must be valid * handles) which need to be replaced with specific ones when they are added to the spec. VALIDATION_ERROR_15c00280 (write dst must be valid) -> write dst created from destroyed layout VALIDATION_ERROR_03207601 (copy dst must be valid) -> copy dst created from destroyed layout VALIDATION_ERROR_0322d201 (copy src must be valid) -> copy src create from destroyed layout Change-Id: I8a3edc67b3e86037cdaa6353176814abfddef1a0 --- layers/descriptor_sets.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'layers/descriptor_sets.cpp') diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 79e3ca44..47ca0541 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -39,7 +39,12 @@ struct BindingNumCmp { // Proactively reserve and resize as possible, as the reallocation was visible in profiling cvdescriptorset::DescriptorSetLayout::DescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo *p_create_info, const VkDescriptorSetLayout layout) - : layout_(layout), flags_(p_create_info->flags), binding_count_(0), descriptor_count_(0), dynamic_descriptor_count_(0) { + : layout_(layout), + layout_destroyed_(false), + flags_(p_create_info->flags), + binding_count_(0), + descriptor_count_(0), + dynamic_descriptor_count_(0) { binding_type_stats_ = {0, 0, 0}; std::set sorted_bindings; const uint32_t input_bindings_count = p_create_info->bindingCount; @@ -624,6 +629,29 @@ void cvdescriptorset::DescriptorSet::PerformWriteUpdate(const VkWriteDescriptorS bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data *report_data, const VkCopyDescriptorSet *update, const DescriptorSet *src_set, UNIQUE_VALIDATION_ERROR_CODE *error_code, std::string *error_msg) { + // Verify dst layout still valid + if (p_layout_->IsDestroyed()) { + // TODO: Update to "cannot copy to dst descriptor set with destroyed descriptor set layout" VUID when present + *error_code = VALIDATION_ERROR_03207601; + string_sprintf(error_msg, + "Cannot call vkUpdateDescriptorSets() to perform copy update on descriptor set dstSet 0x%" PRIxLEAST64 + " created with destroyed VkDescriptorSetLayout 0x%" PRIxLEAST64, + HandleToUint64(set_), HandleToUint64(p_layout_->GetDescriptorSetLayout())); + return false; + } + + // Verify src layout still valid + if (src_set->p_layout_->IsDestroyed()) { + // TODO: Update to "cannot copy from src descriptor set with destroyed descriptor set layout" VUID when present + *error_code = VALIDATION_ERROR_0322d201; + string_sprintf( + error_msg, + "Cannot call vkUpdateDescriptorSets() to perform copy update of dstSet 0x%" PRIxLEAST64 + " from descriptor set srcSet 0x%" PRIxLEAST64 " created with destroyed VkDescriptorSetLayout 0x%" PRIxLEAST64, + HandleToUint64(set_), HandleToUint64(src_set->set_), HandleToUint64(src_set->p_layout_->GetDescriptorSetLayout())); + return false; + } + // Verify idle ds if (in_use.load()) { // TODO : Re-using Free Idle error code, need copy update idle error code @@ -1310,6 +1338,16 @@ void cvdescriptorset::PerformUpdateDescriptorSetsWithTemplateKHR(layer_data *dev // If an error would occur for this update, return false and fill in details in error_msg string bool cvdescriptorset::DescriptorSet::ValidateWriteUpdate(const debug_report_data *report_data, const VkWriteDescriptorSet *update, UNIQUE_VALIDATION_ERROR_CODE *error_code, std::string *error_msg) { + // Verify dst layout still valid + if (p_layout_->IsDestroyed()) { + // TODO: Update to "cannot write descriptor set with destroyed descriptor set layout" VUID when present + *error_code = VALIDATION_ERROR_15c00280; + string_sprintf(error_msg, + "Cannot call vkUpdateDescriptorSets() to perform write update on descriptor set 0x%" PRIxLEAST64 + " created with destroyed VkDescriptorSetLayout 0x%" PRIxLEAST64, + HandleToUint64(set_), HandleToUint64(p_layout_->GetDescriptorSetLayout())); + return false; + } // Verify idle ds if (in_use.load()) { // TODO : Re-using Free Idle error code, need write update idle error code -- cgit v1.2.3