From 3ba223ece185fa054a7b1d2b2faa1e4035c55cef Mon Sep 17 00:00:00 2001 From: John Zulauf Date: Fri, 16 Feb 2018 13:08:47 -0700 Subject: layers: Add canonical/unique ID to pipeline layout Add unique ID's to pipeline layout needed for pipeline layout compatibilty revamp in subsequent commit. Refactor unique ID support into common Dictionary implementation. Change-Id: I0d864c8ef3b3406d6444aed4d73078d25d5eb26f --- layers/descriptor_sets.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'layers/descriptor_sets.cpp') diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index 9f4d3a42..928e4095 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -40,28 +40,13 @@ struct BindingNumCmp { using DescriptorSetLayoutDef = cvdescriptorset::DescriptorSetLayoutDef; using DescriptorSetLayoutId = cvdescriptorset::DescriptorSetLayoutId; -namespace std { -template <> -struct hash : public hash_util::HasHashMember {}; -} // namespace std +// Canonical dictionary of DescriptorSetLayoutDef (without any handle/device specific information) +cvdescriptorset::DescriptorSetLayoutDict descriptor_set_layout_dict; -// Note: std::equal_to is looking for operator == to be defined in the innermost namespace enclosing DescriptorSetLayoutDef -// (i.e. cvdescriptorset) or in the class, base, or containing classes, and does *not* look in :: for it. -static std::unordered_map, - std::equal_to> - descriptor_set_layout_dict; - -DescriptorSetLayoutId get_definition_id(const VkDescriptorSetLayoutCreateInfo *p_create_info) { - DescriptorSetLayoutId from_input = std::make_shared(p_create_info); - - // Insert takes care of the "unique" id part by rejecting the insert if a key matching the DSL def exists, but returning us - // the entry with the extant shared_pointer(id->def) instead. - auto insert_pair = descriptor_set_layout_dict.insert({*from_input, from_input}); - - // This *awful* syntax takes the Iterator from the pair returned by insert, and extracts the value from the - // pair of the Iterator - return insert_pair.first->second; +DescriptorSetLayoutId get_canonical_id(const VkDescriptorSetLayoutCreateInfo *p_create_info) { + return descriptor_set_layout_dict.look_up(DescriptorSetLayoutDef(p_create_info)); } + // Construct DescriptorSetLayout instance from given create info // Proactively reserve and resize as possible, as the reallocation was visible in profiling cvdescriptorset::DescriptorSetLayoutDef::DescriptorSetLayoutDef(const VkDescriptorSetLayoutCreateInfo *p_create_info) @@ -338,7 +323,7 @@ bool cvdescriptorset::DescriptorSetLayoutDef::VerifyUpdateConsistency(uint32_t c // handle invariant portion cvdescriptorset::DescriptorSetLayout::DescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo *p_create_info, const VkDescriptorSetLayout layout) - : layout_(layout), layout_destroyed_(false), layout_id_(get_definition_id(p_create_info)) {} + : layout_(layout), layout_destroyed_(false), layout_id_(get_canonical_id(p_create_info)) {} // Validate descriptor set layout create info bool cvdescriptorset::DescriptorSetLayout::ValidateCreateInfo(const debug_report_data *report_data, -- cgit v1.2.3