diff options
| author | Tobin Ehlis <tobine@google.com> | 2016-05-17 08:31:46 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-05-19 06:51:41 -0600 |
| commit | 7ec3f530a68ce4ecedac6c17ba015f79b3b4a15e (patch) | |
| tree | 58d3c056325ce322bde296b50dca58ebc8d7ac7f /layers/descriptor_sets.cpp | |
| parent | b65d0cb5e70256ff3ca1504d5d2e441163658334 (diff) | |
| download | usermoji-7ec3f530a68ce4ecedac6c17ba015f79b3b4a15e.tar.xz | |
layers: Refactor DescriptorSet Update code
This migrates code for DescriptorSet in_use and flagging bound
command buffers as invalid from core_validation.cpp into DescriptorSet
class.
Diffstat (limited to 'layers/descriptor_sets.cpp')
| -rw-r--r-- | layers/descriptor_sets.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 89c44c68..437dcdc3 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -260,6 +260,7 @@ bool cvdescriptorset::DescriptorSetLayout::VerifyUpdateConsistency(uint32_t curr } cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const DescriptorSetLayout *layout, + const debug_report_data *debug_report_data, const std::unordered_map<VkBuffer, BUFFER_NODE> *buffer_map, const std::unordered_map<VkDeviceMemory, DEVICE_MEM_INFO> *memory_map, const std::unordered_map<VkBufferView, VkBufferViewCreateInfo> *buffer_view_map, @@ -268,9 +269,9 @@ cvdescriptorset::DescriptorSet::DescriptorSet(const VkDescriptorSet set, const D const std::unordered_map<VkImage, IMAGE_NODE> *image_map, const std::unordered_map<VkImage, VkSwapchainKHR> *image_to_swapchain_map, const std::unordered_map<VkSwapchainKHR, SWAPCHAIN_NODE *> *swapchain_map) - : some_update_(false), set_(set), p_layout_(layout), buffer_map_(buffer_map), memory_map_(memory_map), - buffer_view_map_(buffer_view_map), sampler_map_(sampler_map), image_view_map_(image_view_map), image_map_(image_map), - image_to_swapchain_map_(image_to_swapchain_map), swapchain_map_(swapchain_map) { + : some_update_(false), set_(set), p_layout_(layout), report_data_(debug_report_data), buffer_map_(buffer_map), + memory_map_(memory_map), buffer_view_map_(buffer_view_map), sampler_map_(sampler_map), image_view_map_(image_view_map), + image_map_(image_map), 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); @@ -456,6 +457,14 @@ uint32_t cvdescriptorset::DescriptorSet::GetAllStorageUpdates(std::unordered_set bool cvdescriptorset::DescriptorSet::WriteUpdate(debug_report_data *report_data, const VkWriteDescriptorSet *update, std::string *error_msg) { auto num_updates = 0; + // Verify idle ds + if (in_use.load()) { + std::stringstream error_str; + error_str << "Cannot call vkUpdateDescriptorSets() to perform write update on descriptor set " << set_ + << " that is in use by a command buffer."; + *error_msg = error_str.str(); + return false; + } // Verify dst binding exists if (!p_layout_->HasBinding(update->dstBinding)) { std::stringstream error_str; @@ -505,12 +514,24 @@ bool cvdescriptorset::DescriptorSet::WriteUpdate(debug_report_data *report_data, if (num_updates != 0) { some_update_ = true; } + // Invalidate any bound command buffers + for (auto cb_node : bound_cmd_buffers_) { + cb_node->state = CB_INVALID; + } return true; } // Copy update bool cvdescriptorset::DescriptorSet::CopyUpdate(debug_report_data *report_data, const VkCopyDescriptorSet *update, const DescriptorSet *src_set, std::string *error) { auto num_updates = 0; + // Verify idle ds + if (in_use.load()) { + std::stringstream error_str; + error_str << "Cannot call vkUpdateDescriptorSets() to perform copy update on descriptor set " << set_ + << " that is in use by a command buffer."; + *error = error_str.str(); + return false; + } if (!p_layout_->HasBinding(update->dstBinding)) { std::stringstream error_str; error_str << "DescriptorSet " << set_ << " does not have copy update dest binding of " << update->dstBinding << "."; @@ -574,6 +595,10 @@ bool cvdescriptorset::DescriptorSet::CopyUpdate(debug_report_data *report_data, if (num_updates != 0) { some_update_ = true; } + // Invalidate any bound command buffers + for (auto cb_node : bound_cmd_buffers_) { + cb_node->state = CB_INVALID; + } return true; } cvdescriptorset::SamplerDescriptor::SamplerDescriptor( @@ -974,4 +999,4 @@ bool cvdescriptorset::TexelDescriptor::CopyUpdate(const Descriptor *src, std::st updated = true; buffer_view_ = buffer_view; return true; -}
\ No newline at end of file +} |
