layers: Pass common data between pre/post AllocDescriptorSets
With the break between PreValidate* and PostRecord* calls in the layers
we can suffer having to do some repeat work in the Post step. In order
to prevent this, this CL slightly modifies the interface to pass common
data between the pre/post calls in a custom AllocateDescriptorSetsData
struct.
I initially attempted to fill this data in a separate function that
would preceed the PreValidate* call, but such a function would need to
include some validation as it includes map checks which may fail.
The simplest solution, then, seems to be passing a ptr to the common
data to the PreValidate* function who then fills the data. If the
validation and call down the chain succeed, the PostRecord* function
then takes a ptr to the common data to prevent having to redo the
work that was done at validation time.
diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h
index af062dd..bb5907c 100644
--- a/layers/descriptor_sets.h
+++ b/layers/descriptor_sets.h
@@ -245,6 +245,12 @@
VkDeviceSize offset_;
VkDeviceSize range_;
};
+// Structs to contain common elements that need to be shared between Validate* and Perform* calls below
+struct AllocateDescriptorSetsData {
+ uint32_t required_descriptors_by_type[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
+ std::vector<cvdescriptorset::DescriptorSetLayout const *> layout_nodes;
+ AllocateDescriptorSetsData(uint32_t);
+};
// Helper functions for descriptor set functions that cross multiple sets
// "Validate" will make sure an update is ok without actually performing it
bool ValidateUpdateDescriptorSets(const debug_report_data *,
@@ -256,17 +262,21 @@
// Validate that Allocation state is ok
bool ValidateAllocateDescriptorSets(const debug_report_data *, const VkDescriptorSetAllocateInfo *,
const std::unordered_map<VkDescriptorSetLayout, cvdescriptorset::DescriptorSetLayout *> &,
- const std::unordered_map<VkDescriptorPool, DESCRIPTOR_POOL_NODE *> &);
+ const std::unordered_map<VkDescriptorPool, DESCRIPTOR_POOL_NODE *> &,
+ AllocateDescriptorSetsData *);
// Update state based on allocating new descriptorsets
-void PerformAllocateDescriptorSets(
- const VkDescriptorSetAllocateInfo *, const VkDescriptorSet *, std::unordered_map<VkDescriptorPool, DESCRIPTOR_POOL_NODE *> *,
- std::unordered_map<VkDescriptorSet, cvdescriptorset::DescriptorSet *> *,
- const std::unordered_map<VkDescriptorSetLayout, cvdescriptorset::DescriptorSetLayout *> &,
- const std::unordered_map<VkBuffer, BUFFER_NODE> &, const std::unordered_map<VkDeviceMemory, DEVICE_MEM_INFO> &,
- const std::unordered_map<VkBufferView, VkBufferViewCreateInfo> &,
- const std::unordered_map<VkSampler, std::unique_ptr<SAMPLER_NODE>> &,
- const std::unordered_map<VkImageView, VkImageViewCreateInfo> &, const std::unordered_map<VkImage, IMAGE_NODE> &,
- const std::unordered_map<VkImage, VkSwapchainKHR> &, const std::unordered_map<VkSwapchainKHR, SWAPCHAIN_NODE *> &);
+void PerformAllocateDescriptorSets(const VkDescriptorSetAllocateInfo *, const VkDescriptorSet *, const AllocateDescriptorSetsData *,
+ std::unordered_map<VkDescriptorPool, DESCRIPTOR_POOL_NODE *> *,
+ std::unordered_map<VkDescriptorSet, cvdescriptorset::DescriptorSet *> *,
+ const std::unordered_map<VkDescriptorSetLayout, cvdescriptorset::DescriptorSetLayout *> &,
+ const std::unordered_map<VkBuffer, BUFFER_NODE> &,
+ const std::unordered_map<VkDeviceMemory, DEVICE_MEM_INFO> &,
+ const std::unordered_map<VkBufferView, VkBufferViewCreateInfo> &,
+ const std::unordered_map<VkSampler, std::unique_ptr<SAMPLER_NODE>> &,
+ const std::unordered_map<VkImageView, VkImageViewCreateInfo> &,
+ const std::unordered_map<VkImage, IMAGE_NODE> &,
+ const std::unordered_map<VkImage, VkSwapchainKHR> &,
+ const std::unordered_map<VkSwapchainKHR, SWAPCHAIN_NODE *> &);
/*
* DescriptorSet class