aboutsummaryrefslogtreecommitdiff
path: root/layers/descriptor_sets.cpp
diff options
context:
space:
mode:
authorJohn Zulauf <jzulauf@lunarg.com>2018-02-16 13:08:47 -0700
committerjzulauf-lunarg <32470354+jzulauf-lunarg@users.noreply.github.com>2018-03-07 13:11:29 -0700
commit3ba223ece185fa054a7b1d2b2faa1e4035c55cef (patch)
tree3e5cc2d8a706c40f6bb7f6c5fc09ebf30909686f /layers/descriptor_sets.cpp
parent2dbdf3828836c15f514143a24aa0aea42bbb789f (diff)
downloadusermoji-3ba223ece185fa054a7b1d2b2faa1e4035c55cef.tar.xz
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
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,