aboutsummaryrefslogtreecommitdiff
path: root/layers/descriptor_sets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'layers/descriptor_sets.cpp')
-rw-r--r--layers/descriptor_sets.cpp27
1 files changed, 6 insertions, 21 deletions
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<DescriptorSetLayoutDef> : public hash_util::HasHashMember<DescriptorSetLayoutDef> {};
-} // 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<DescriptorSetLayoutDef, DescriptorSetLayoutId, std::hash<DescriptorSetLayoutDef>,
- std::equal_to<DescriptorSetLayoutDef>>
- descriptor_set_layout_dict;
-
-DescriptorSetLayoutId get_definition_id(const VkDescriptorSetLayoutCreateInfo *p_create_info) {
- DescriptorSetLayoutId from_input = std::make_shared<DescriptorSetLayoutDef>(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 <It, bool> pair returned by insert, and extracts the value from the
- // <key, value> 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,