aboutsummaryrefslogtreecommitdiff
path: root/layers/descriptor_sets.cpp
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-05-24 13:07:12 -0600
committerTobin Ehlis <tobine@google.com>2016-05-31 08:49:43 -0600
commitb4e1c579bd811fa59ffbd5e6bad6cd4c25722d91 (patch)
tree211ae36fbc7083884fdd592aa989319afe6f8161 /layers/descriptor_sets.cpp
parentae2eb29829c370138f08131b2246f67a0cc0ddd1 (diff)
downloadusermoji-b4e1c579bd811fa59ffbd5e6bad6cd4c25722d91.tar.xz
layers: Improve descriptor copy update validation
Add buffer usage bit validation for descriptor copy updates. Pass down known descriptor type to copy validate function to avoid having to look it up again. Fix various incorrect "write" references in the copy update error messages.
Diffstat (limited to 'layers/descriptor_sets.cpp')
-rw-r--r--layers/descriptor_sets.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp
index e6c8ab65..db712175 100644
--- a/layers/descriptor_sets.cpp
+++ b/layers/descriptor_sets.cpp
@@ -545,7 +545,7 @@ bool cvdescriptorset::DescriptorSet::ValidateCopyUpdate(const debug_report_data
}
}
// Update parameters all look good and descriptor updated so verify update contents
- if (!VerifyCopyUpdateContents(update, src_set, src_start_idx, error))
+ if (!VerifyCopyUpdateContents(update, src_set, src_type, src_start_idx, error))
return false;
// All checks passed so update is good
@@ -1125,7 +1125,7 @@ bool cvdescriptorset::DescriptorSet::VerifyWriteUpdateContents(const VkWriteDesc
}
// Verify that the contents of the update are ok, but don't perform actual update
bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescriptorSet *update, const DescriptorSet *src_set,
- const uint32_t index, std::string *error) const {
+ VkDescriptorType type, uint32_t index, std::string *error) const {
switch (src_set->descriptors_[index]->descriptor_class) {
case PlainSampler: {
for (uint32_t di = 0; di < update->descriptorCount; ++di) {
@@ -1161,10 +1161,10 @@ 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, src_set->GetTypeFromGlobalIndex(index), image_view_map_, image_map_,
- image_to_swapchain_map_, swapchain_map_, error)) {
+ if (!ValidateImageUpdate(image_view, image_layout, type, image_view_map_, image_map_, 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_str << "Attempted copy update to combined image sampler descriptor failed due to: " << error->c_str();
*error = error_str.str();
return false;
}
@@ -1175,10 +1175,10 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri
auto img_desc = static_cast<const ImageDescriptor *>(src_set->descriptors_[index + di].get());
auto image_view = img_desc->GetImageView();
auto image_layout = img_desc->GetImageLayout();
- if (!ValidateImageUpdate(image_view, image_layout, src_set->GetTypeFromGlobalIndex(index), image_view_map_, image_map_,
- image_to_swapchain_map_, swapchain_map_, error)) {
+ if (!ValidateImageUpdate(image_view, image_layout, type, image_view_map_, image_map_, 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_str << "Attempted copy update to image descriptor failed due to: " << error->c_str();
*error = error_str.str();
return false;
}
@@ -1188,9 +1188,17 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri
case TexelBuffer: {
for (uint32_t di = 0; di < update->descriptorCount; ++di) {
auto buffer_view = static_cast<TexelDescriptor *>(src_set->descriptors_[index + di].get())->GetBufferView();
- if (!buffer_view_map_->count(buffer_view)) {
+ auto bv_it = buffer_view_map_->find(buffer_view);
+ if (bv_it == buffer_view_map_->end()) {
std::stringstream error_str;
- error_str << "Attempted write update to texel buffer descriptor with invalid buffer view: " << buffer_view;
+ error_str << "Attempted copy update to texel buffer descriptor with invalid buffer view: " << buffer_view;
+ *error = error_str.str();
+ return false;
+ }
+ auto buffer = bv_it->second.buffer;
+ if (!ValidateBufferUpdate(buffer, type, error)) {
+ std::stringstream error_str;
+ error_str << "Attempted copy update to texel buffer descriptor failed due to: " << error->c_str();
*error = error_str.str();
return false;
}
@@ -1200,9 +1208,9 @@ bool cvdescriptorset::DescriptorSet::VerifyCopyUpdateContents(const VkCopyDescri
case GeneralBuffer: {
for (uint32_t di = 0; di < update->descriptorCount; ++di) {
auto buffer = static_cast<BufferDescriptor *>(src_set->descriptors_[index + di].get())->GetBuffer();
- if (!buffer_map_->count(buffer)) {
+ if (!ValidateBufferUpdate(buffer, type, error)) {
std::stringstream error_str;
- error_str << "Attempted write update to buffer descriptor with invalid buffer: " << buffer;
+ error_str << "Attempted copy update to buffer descriptor failed due to: " << error->c_str();
*error = error_str.str();
return false;
}