From 920ff191e83225ae7d8cecc6ed8f6c7f38487450 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Thu, 2 Jun 2016 11:49:22 -0600 Subject: layers: Add getImageNode() helper Add getImageNode() helper to core_validation and use it. Also update DescriptorSet class to use the helper and kill its image_map member. --- layers/descriptor_sets.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'layers/descriptor_sets.cpp') diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index e3f6e9d4..9039a122 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -265,11 +265,10 @@ cvdescriptorset::AllocateDescriptorSetsData::AllocateDescriptorSetsData(uint32_t cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const DescriptorSetLayout *layout, const core_validation::layer_data *dev_data, - const std::unordered_map *image_map, const std::unordered_map *image_to_swapchain_map, const std::unordered_map *swapchain_map) - : some_update_(false), set_(set), p_layout_(layout), device_data_(dev_data), image_map_(image_map), - image_to_swapchain_map_(image_to_swapchain_map), swapchain_map_(swapchain_map) { + : some_update_(false), set_(set), p_layout_(layout), device_data_(dev_data), image_to_swapchain_map_(image_to_swapchain_map), + swapchain_map_(swapchain_map) { // Foreach binding, create default descriptors of given type for (uint32_t i = 0; i < p_layout_->GetBindingCount(); ++i) { auto type = p_layout_->GetTypeFromIndex(i); @@ -584,7 +583,6 @@ bool cvdescriptorset::ValidateSampler(const VkSampler sampler, const core_valida bool cvdescriptorset::ValidateImageUpdate(VkImageView image_view, VkImageLayout image_layout, VkDescriptorType type, const core_validation::layer_data *dev_data, - const std::unordered_map *image_map, const std::unordered_map *image_to_swapchain_map, const std::unordered_map *swapchain_map, std::string *error) { @@ -601,10 +599,10 @@ bool cvdescriptorset::ValidateImageUpdate(VkImageView image_view, VkImageLayout VkImage image = iv_data->image; VkFormat format = VK_FORMAT_MAX_ENUM; VkImageUsageFlags usage = 0; - auto img_pair = image_map->find(image); - if (img_pair != image_map->end()) { - format = img_pair->second.createInfo.format; - usage = img_pair->second.createInfo.usage; + auto image_node = getImageNode(dev_data, image); + if (image_node) { + format = image_node->createInfo.format; + usage = image_node->createInfo.usage; } else { // Also need to check the swapchains. auto swapchain_pair = image_to_swapchain_map->find(image); @@ -1034,8 +1032,8 @@ bool cvdescriptorset::DescriptorSet::VerifyWriteUpdateContents(const VkWriteDesc // Validate image auto image_view = update->pImageInfo[di].imageView; auto image_layout = update->pImageInfo[di].imageLayout; - if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, image_map_, - image_to_swapchain_map_, swapchain_map_, error)) { + if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, image_to_swapchain_map_, + swapchain_map_, error)) { std::stringstream error_str; error_str << "Attempted write update to combined image sampler descriptor failed due to: " << error->c_str(); *error = error_str.str(); @@ -1066,8 +1064,8 @@ bool cvdescriptorset::DescriptorSet::VerifyWriteUpdateContents(const VkWriteDesc for (uint32_t di = 0; di < update->descriptorCount; ++di) { auto image_view = update->pImageInfo[di].imageView; auto image_layout = update->pImageInfo[di].imageLayout; - if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, image_map_, - image_to_swapchain_map_, swapchain_map_, error)) { + if (!ValidateImageUpdate(image_view, image_layout, update->descriptorType, device_data_, image_to_swapchain_map_, + swapchain_map_, error)) { std::stringstream error_str; error_str << "Attempted write update to image descriptor failed due to: " << error->c_str(); *error = error_str.str(); @@ -1157,8 +1155,8 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri // Validate image auto image_view = img_samp_desc->GetImageView(); auto image_layout = img_samp_desc->GetImageLayout(); - if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, image_map_, image_to_swapchain_map_, - swapchain_map_, error)) { + if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, image_to_swapchain_map_, swapchain_map_, + error)) { std::stringstream error_str; error_str << "Attempted copy update to combined image sampler descriptor failed due to: " << error->c_str(); *error = error_str.str(); @@ -1171,8 +1169,8 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri auto img_desc = static_cast(src_set->descriptors_[index + di].get()); auto image_view = img_desc->GetImageView(); auto image_layout = img_desc->GetImageLayout(); - if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, image_map_, image_to_swapchain_map_, - swapchain_map_, error)) { + if (!ValidateImageUpdate(image_view, image_layout, type, device_data_, image_to_swapchain_map_, swapchain_map_, + error)) { std::stringstream error_str; error_str << "Attempted copy update to image descriptor failed due to: " << error->c_str(); *error = error_str.str(); @@ -1283,7 +1281,6 @@ void cvdescriptorset::PerformAllocateDescriptorSets( const AllocateDescriptorSetsData *ds_data, std::unordered_map *pool_map, std::unordered_map *set_map, const core_validation::layer_data *dev_data, const std::unordered_map &layout_map, - const std::unordered_map &image_map, const std::unordered_map &image_to_swapchain_map, const std::unordered_map &swapchain_map) { auto pool_state = (*pool_map)[p_alloc_info->descriptorPool]; @@ -1296,7 +1293,7 @@ void cvdescriptorset::PerformAllocateDescriptorSets( * global map and the pool's set. */ for (uint32_t i = 0; i < p_alloc_info->descriptorSetCount; i++) { - auto new_ds = new cvdescriptorset::DescriptorSet(descriptor_sets[i], ds_data->layout_nodes[i], dev_data, &image_map, + auto new_ds = new cvdescriptorset::DescriptorSet(descriptor_sets[i], ds_data->layout_nodes[i], dev_data, &image_to_swapchain_map, &swapchain_map); pool_state->sets.insert(new_ds); -- cgit v1.2.3