From 7b59978c199c64bd8428cdae570f989002a7a2a4 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Fri, 7 Apr 2017 12:20:30 -0600 Subject: layers:Add image layout validation for descriptors This change adds validation to make sure that an image layout at the time the image is used in a descriptor matches the layout that was given when the descriptor was updated. Because image view covers a range of mip levels, loop over each level and verify layouts one at a time. Also Updated a number of validate functions to use cont ptr params for data that they aren't changing. --- layers/descriptor_sets.cpp | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'layers/descriptor_sets.cpp') diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 84663c4b..de349457 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -24,6 +24,7 @@ #include "descriptor_sets.h" #include "vk_enum_string_helper.h" #include "vk_safe_struct.h" +#include "buffer_validation.h" #include #include @@ -395,7 +396,8 @@ bool cvdescriptorset::DescriptorSet::IsCompatible(const DescriptorSetLayout *lay // that any update buffers are valid, and that any dynamic offsets are within the bounds of their buffers. // Return true if state is acceptable, or false and write an error message into error string bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::map &bindings, - const std::vector &dynamic_offsets, std::string *error) const { + const std::vector &dynamic_offsets, const GLOBAL_CB_NODE *cb_node, + const char *caller, std::string *error) const { for (auto binding_pair : bindings) { auto binding = binding_pair.first; if (!p_layout_->HasBinding(binding)) { @@ -472,9 +474,15 @@ bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::map(descriptors_[i].get())->GetImageView() - : static_cast(descriptors_[i].get())->GetImageView(); + VkImageView image_view; + VkImageLayout image_layout; + if (descriptor_class == ImageSampler) { + image_view = static_cast(descriptors_[i].get())->GetImageView(); + image_layout = static_cast(descriptors_[i].get())->GetImageLayout(); + } else { + image_view = static_cast(descriptors_[i].get())->GetImageView(); + image_layout = static_cast(descriptors_[i].get())->GetImageLayout(); + } auto reqs = binding_pair.second; auto image_view_state = GetImageViewState(device_data_, image_view); @@ -493,7 +501,30 @@ bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::mapcreateInfo.samples != VK_SAMPLE_COUNT_1_BIT) { std::stringstream error_str; error_str << "Descriptor in binding #" << binding << " at global descriptor index " << i @@ -502,7 +533,6 @@ bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::mapcreateInfo.samples == VK_SAMPLE_COUNT_1_BIT) { std::stringstream error_str; error_str << "Descriptor in binding #" << binding << " at global descriptor index " << i -- cgit v1.2.3