| Jeremy Hayes | e4224ee | 2019-01-04 14:41:48 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2019 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2019 Valve Corporation |
| 3 | * Copyright (c) 2015-2019 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2019 Google Inc. |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| John Zulauf | c483f44 | 2017-12-15 14:02:06 -0700 | [diff] [blame] | 19 | * John Zulauf <jzulauf@lunarg.com> |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 20 | */ |
| 21 | #ifndef CORE_VALIDATION_DESCRIPTOR_SETS_H_ |
| 22 | #define CORE_VALIDATION_DESCRIPTOR_SETS_H_ |
| 23 | |
| John Zulauf | d47d061 | 2018-02-16 13:00:34 -0700 | [diff] [blame] | 24 | #include "hash_vk_types.h" |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 25 | #include "vk_layer_logging.h" |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 26 | #include "vk_layer_utils.h" |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 27 | #include "vk_safe_struct.h" |
| 28 | #include "vulkan/vk_layer.h" |
| Mark Lobodzinski | 3382637 | 2017-04-13 11:10:11 -0600 | [diff] [blame] | 29 | #include "vk_object_types.h" |
| Tobin Ehlis | cebc4c0 | 2016-08-22 10:10:43 -0600 | [diff] [blame] | 30 | #include <map> |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 31 | #include <memory> |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 32 | #include <set> |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 33 | #include <unordered_map> |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 34 | #include <unordered_set> |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 35 | #include <vector> |
| 36 | |
| Mark Lobodzinski | b56bbb9 | 2019-02-18 11:49:59 -0700 | [diff] [blame] | 37 | class CoreChecks; |
| John Zulauf | c93c425 | 2019-06-25 09:19:49 -0600 | [diff] [blame] | 38 | class ValidationStateTracker; |
| Tobin Ehlis | 58c884f | 2017-02-08 12:15:27 -0700 | [diff] [blame] | 39 | |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 40 | // Descriptor Data structures |
| John Zulauf | c483f44 | 2017-12-15 14:02:06 -0700 | [diff] [blame] | 41 | namespace cvdescriptorset { |
| 42 | |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 43 | // Utility structs/classes/types |
| John Zulauf | c483f44 | 2017-12-15 14:02:06 -0700 | [diff] [blame] | 44 | // Index range for global indices below, end is exclusive, i.e. [start,end) |
| 45 | struct IndexRange { |
| 46 | IndexRange(uint32_t start_in, uint32_t end_in) : start(start_in), end(end_in) {} |
| 47 | IndexRange() = default; |
| 48 | uint32_t start; |
| 49 | uint32_t end; |
| 50 | }; |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 51 | typedef std::map<uint32_t, descriptor_req> BindingReqMap; |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 52 | |
| 53 | /* |
| John Zulauf | 34ebf27 | 2018-02-16 13:08:47 -0700 | [diff] [blame] | 54 | * DescriptorSetLayoutDef/DescriptorSetLayout classes |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 55 | * |
| John Zulauf | 34ebf27 | 2018-02-16 13:08:47 -0700 | [diff] [blame] | 56 | * Overview - These two classes encapsulate the Vulkan VkDescriptorSetLayout data (layout). |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 57 | * A layout consists of some number of bindings, each of which has a binding#, a |
| 58 | * type, descriptor count, stage flags, and pImmutableSamplers. |
| John Zulauf | 34ebf27 | 2018-02-16 13:08:47 -0700 | [diff] [blame] | 59 | |
| 60 | * The DescriptorSetLayoutDef represents a canonicalization of the input data and contains |
| 61 | * neither per handle or per device state. It is possible for different handles on |
| 62 | * different devices to share a common def. This is used and useful for quick compatibiltiy |
| 63 | * validation. The DescriptorSetLayout refers to a DescriptorSetLayoutDef and contains |
| 64 | * all per handle state. |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 65 | * |
| 66 | * Index vs Binding - A layout is created with an array of VkDescriptorSetLayoutBinding |
| 67 | * where each array index will have a corresponding binding# that is defined in that struct. |
| Tobin Ehlis | 9637fb2 | 2016-12-12 15:59:34 -0700 | [diff] [blame] | 68 | * The binding#, then, is decoupled from VkDescriptorSetLayoutBinding index, which allows |
| 69 | * bindings to be defined out-of-order. This DescriptorSetLayout class, however, stores |
| 70 | * the bindings internally in-order. This is useful for operations which may "roll over" |
| 71 | * from a single binding to the next consecutive binding. |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 72 | * |
| Tobin Ehlis | 9637fb2 | 2016-12-12 15:59:34 -0700 | [diff] [blame] | 73 | * Note that although the bindings are stored in-order, there still may be "gaps" in the |
| 74 | * binding#. For example, if the binding creation order is 8, 7, 10, 3, 4, then the |
| 75 | * internal binding array will have five entries stored in binding order 3, 4, 7, 8, 10. |
| 76 | * To process all of the bindings in a layout you can iterate from 0 to GetBindingCount() |
| 77 | * and use the Get*FromIndex() functions for each index. To just process a single binding, |
| 78 | * use the Get*FromBinding() functions. |
| 79 | * |
| 80 | * Global Index - The binding vector index has as many indices as there are bindings. |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 81 | * This class also has the concept of a Global Index. For the global index functions, |
| 82 | * there are as many global indices as there are descriptors in the layout. |
| 83 | * For the global index, consider all of the bindings to be a flat array where |
| Tobin Ehlis | 9637fb2 | 2016-12-12 15:59:34 -0700 | [diff] [blame] | 84 | * descriptor 0 of of the lowest binding# is index 0 and each descriptor in the layout |
| 85 | * increments from there. So if the lowest binding# in this example had descriptorCount of |
| 86 | * 10, then the GlobalStartIndex of the 2nd lowest binding# will be 10 where 0-9 are the |
| 87 | * global indices for the lowest binding#. |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 88 | */ |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 89 | class DescriptorSetLayoutDef { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 90 | public: |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 91 | // Constructors and destructor |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 92 | DescriptorSetLayoutDef(const VkDescriptorSetLayoutCreateInfo *p_create_info); |
| 93 | size_t hash() const; |
| 94 | |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 95 | uint32_t GetTotalDescriptorCount() const { return descriptor_count_; }; |
| 96 | uint32_t GetDynamicDescriptorCount() const { return dynamic_descriptor_count_; }; |
| Józef Kucia | 1bb0097 | 2017-09-10 11:24:08 +0200 | [diff] [blame] | 97 | VkDescriptorSetLayoutCreateFlags GetCreateFlags() const { return flags_; } |
| Tobin Ehlis | f922ef8 | 2016-11-30 10:19:14 -0700 | [diff] [blame] | 98 | // For a given binding, return the number of descriptors in that binding and all successive bindings |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 99 | uint32_t GetBindingCount() const { return binding_count_; }; |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 100 | // Non-empty binding numbers in order |
| 101 | const std::set<uint32_t> &GetSortedBindingSet() const { return non_empty_bindings_; } |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 102 | // Return true if given binding is present in this layout |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 103 | bool HasBinding(const uint32_t binding) const { return binding_to_index_map_.count(binding) > 0; }; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 104 | // Return true if binding 1 beyond given exists and has same type, stageFlags & immutable sampler use |
| 105 | bool IsNextBindingConsistent(const uint32_t) const; |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 106 | uint32_t GetIndexFromBinding(uint32_t binding) const; |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 107 | // Various Get functions that can either be passed a binding#, which will |
| Tobin Ehlis | 9637fb2 | 2016-12-12 15:59:34 -0700 | [diff] [blame] | 108 | // be automatically translated into the appropriate index, or the index# can be passed in directly |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 109 | uint32_t GetMaxBinding() const { return bindings_[bindings_.size() - 1].binding; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 110 | VkDescriptorSetLayoutBinding const *GetDescriptorSetLayoutBindingPtrFromIndex(const uint32_t) const; |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 111 | VkDescriptorSetLayoutBinding const *GetDescriptorSetLayoutBindingPtrFromBinding(uint32_t binding) const { |
| 112 | return GetDescriptorSetLayoutBindingPtrFromIndex(GetIndexFromBinding(binding)); |
| 113 | } |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 114 | const std::vector<safe_VkDescriptorSetLayoutBinding> &GetBindings() const { return bindings_; } |
| John Zulauf | 223b69d | 2018-11-09 16:00:59 -0700 | [diff] [blame] | 115 | const std::vector<VkDescriptorBindingFlagsEXT> &GetBindingFlags() const { return binding_flags_; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 116 | uint32_t GetDescriptorCountFromIndex(const uint32_t) const; |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 117 | uint32_t GetDescriptorCountFromBinding(const uint32_t binding) const { |
| 118 | return GetDescriptorCountFromIndex(GetIndexFromBinding(binding)); |
| 119 | } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 120 | VkDescriptorType GetTypeFromIndex(const uint32_t) const; |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 121 | VkDescriptorType GetTypeFromBinding(const uint32_t binding) const { return GetTypeFromIndex(GetIndexFromBinding(binding)); } |
| 122 | VkShaderStageFlags GetStageFlagsFromIndex(const uint32_t) const; |
| 123 | VkShaderStageFlags GetStageFlagsFromBinding(const uint32_t binding) const { |
| 124 | return GetStageFlagsFromIndex(GetIndexFromBinding(binding)); |
| 125 | } |
| Jeff Bolz | fdf9607 | 2018-04-10 14:32:18 -0500 | [diff] [blame] | 126 | VkDescriptorBindingFlagsEXT GetDescriptorBindingFlagsFromIndex(const uint32_t) const; |
| 127 | VkDescriptorBindingFlagsEXT GetDescriptorBindingFlagsFromBinding(const uint32_t binding) const { |
| 128 | return GetDescriptorBindingFlagsFromIndex(GetIndexFromBinding(binding)); |
| 129 | } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 130 | VkSampler const *GetImmutableSamplerPtrFromBinding(const uint32_t) const; |
| 131 | VkSampler const *GetImmutableSamplerPtrFromIndex(const uint32_t) const; |
| Tobin Ehlis | a3525e0 | 2016-11-17 10:50:52 -0700 | [diff] [blame] | 132 | // For a given binding and array index, return the corresponding index into the dynamic offset array |
| 133 | int32_t GetDynamicOffsetIndexFromBinding(uint32_t binding) const { |
| 134 | auto dyn_off = binding_to_dynamic_array_idx_map_.find(binding); |
| 135 | if (dyn_off == binding_to_dynamic_array_idx_map_.end()) { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 136 | assert(0); // Requesting dyn offset for invalid binding/array idx pair |
| Tobin Ehlis | a3525e0 | 2016-11-17 10:50:52 -0700 | [diff] [blame] | 137 | return -1; |
| 138 | } |
| 139 | return dyn_off->second; |
| 140 | } |
| John Zulauf | c483f44 | 2017-12-15 14:02:06 -0700 | [diff] [blame] | 141 | // For a particular binding, get the global index range |
| 142 | // This call should be guarded by a call to "HasBinding(binding)" to verify that the given binding exists |
| 143 | const IndexRange &GetGlobalIndexRangeFromBinding(const uint32_t) const; |
| John Zulauf | 7705bfc | 2019-06-10 09:52:04 -0600 | [diff] [blame] | 144 | const cvdescriptorset::IndexRange &GetGlobalIndexRangeFromIndex(uint32_t index) const; |
| John Zulauf | c483f44 | 2017-12-15 14:02:06 -0700 | [diff] [blame] | 145 | |
| Mark Lobodzinski | 4aa479d | 2017-03-10 09:14:00 -0700 | [diff] [blame] | 146 | // Helper function to get the next valid binding for a descriptor |
| 147 | uint32_t GetNextValidBinding(const uint32_t) const; |
| Józef Kucia | f0c94d4 | 2017-10-25 22:15:22 +0200 | [diff] [blame] | 148 | bool IsPushDescriptor() const { return GetCreateFlags() & VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR; }; |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 149 | |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 150 | struct BindingTypeStats { |
| 151 | uint32_t dynamic_buffer_count; |
| 152 | uint32_t non_dynamic_buffer_count; |
| 153 | uint32_t image_sampler_count; |
| 154 | }; |
| 155 | const BindingTypeStats &GetBindingTypeStats() const { return binding_type_stats_; } |
| 156 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 157 | private: |
| John Zulauf | 223b69d | 2018-11-09 16:00:59 -0700 | [diff] [blame] | 158 | // Only the first three data members are used for hash and equality checks, the other members are derived from them, and are |
| 159 | // used to speed up the various lookups/queries/validations |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 160 | VkDescriptorSetLayoutCreateFlags flags_; |
| 161 | std::vector<safe_VkDescriptorSetLayoutBinding> bindings_; |
| Jeff Bolz | fdf9607 | 2018-04-10 14:32:18 -0500 | [diff] [blame] | 162 | std::vector<VkDescriptorBindingFlagsEXT> binding_flags_; |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 163 | |
| 164 | // Convenience data structures for rapid lookup of various descriptor set layout properties |
| John Zulauf | b6d7120 | 2017-12-22 16:47:09 -0700 | [diff] [blame] | 165 | std::set<uint32_t> non_empty_bindings_; // Containing non-emtpy bindings in numerical order |
| 166 | std::unordered_map<uint32_t, uint32_t> binding_to_index_map_; |
| 167 | // The following map allows an non-iterative lookup of a binding from a global index... |
| John Zulauf | 7705bfc | 2019-06-10 09:52:04 -0600 | [diff] [blame] | 168 | std::vector<IndexRange> global_index_range_; // range is exclusive of .end |
| Tobin Ehlis | a3525e0 | 2016-11-17 10:50:52 -0700 | [diff] [blame] | 169 | // For a given binding map to associated index in the dynamic offset array |
| 170 | std::unordered_map<uint32_t, uint32_t> binding_to_dynamic_array_idx_map_; |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 171 | |
| Jeff Bolz | fdf9607 | 2018-04-10 14:32:18 -0500 | [diff] [blame] | 172 | uint32_t binding_count_; // # of bindings in this layout |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 173 | uint32_t descriptor_count_; // total # descriptors in this layout |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 174 | uint32_t dynamic_descriptor_count_; |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 175 | BindingTypeStats binding_type_stats_; |
| Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 176 | }; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 177 | |
| Jeremy Hayes | e4224ee | 2019-01-04 14:41:48 -0700 | [diff] [blame] | 178 | static inline bool operator==(const DescriptorSetLayoutDef &lhs, const DescriptorSetLayoutDef &rhs) { |
| John Zulauf | 223b69d | 2018-11-09 16:00:59 -0700 | [diff] [blame] | 179 | bool result = (lhs.GetCreateFlags() == rhs.GetCreateFlags()) && (lhs.GetBindings() == rhs.GetBindings()) && |
| 180 | (lhs.GetBindingFlags() == rhs.GetBindingFlags()); |
| 181 | return result; |
| John Zulauf | d47d061 | 2018-02-16 13:00:34 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| John Zulauf | 34ebf27 | 2018-02-16 13:08:47 -0700 | [diff] [blame] | 184 | // Canonical dictionary of DSL definitions -- independent of device or handle |
| 185 | using DescriptorSetLayoutDict = hash_util::Dictionary<DescriptorSetLayoutDef, hash_util::HasHashMember<DescriptorSetLayoutDef>>; |
| 186 | using DescriptorSetLayoutId = DescriptorSetLayoutDict::Id; |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 187 | |
| 188 | class DescriptorSetLayout { |
| 189 | public: |
| 190 | // Constructors and destructor |
| 191 | DescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo *p_create_info, const VkDescriptorSetLayout layout); |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 192 | bool HasBinding(const uint32_t binding) const { return layout_id_->HasBinding(binding); } |
| 193 | // Return true if this layout is compatible with passed in layout from a pipelineLayout, |
| 194 | // else return false and update error_msg with description of incompatibility |
| John Zulauf | 9ce3b25 | 2019-06-06 15:20:22 -0600 | [diff] [blame] | 195 | // Return true if this layout is compatible with passed in layout |
| 196 | bool IsCompatible(DescriptorSetLayout const *rh_ds_layout) const; |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 197 | // Straightforward Get functions |
| 198 | VkDescriptorSetLayout GetDescriptorSetLayout() const { return layout_; }; |
| 199 | bool IsDestroyed() const { return layout_destroyed_; } |
| 200 | void MarkDestroyed() { layout_destroyed_ = true; } |
| Shannon McPherson | c06c33d | 2018-06-28 17:21:12 -0600 | [diff] [blame] | 201 | const DescriptorSetLayoutDef *GetLayoutDef() const { return layout_id_.get(); } |
| 202 | DescriptorSetLayoutId GetLayoutId() const { return layout_id_; } |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 203 | uint32_t GetTotalDescriptorCount() const { return layout_id_->GetTotalDescriptorCount(); }; |
| 204 | uint32_t GetDynamicDescriptorCount() const { return layout_id_->GetDynamicDescriptorCount(); }; |
| 205 | uint32_t GetBindingCount() const { return layout_id_->GetBindingCount(); }; |
| 206 | VkDescriptorSetLayoutCreateFlags GetCreateFlags() const { return layout_id_->GetCreateFlags(); } |
| 207 | bool IsNextBindingConsistent(const uint32_t) const; |
| 208 | uint32_t GetIndexFromBinding(uint32_t binding) const { return layout_id_->GetIndexFromBinding(binding); } |
| 209 | // Various Get functions that can either be passed a binding#, which will |
| 210 | // be automatically translated into the appropriate index, or the index# can be passed in directly |
| 211 | uint32_t GetMaxBinding() const { return layout_id_->GetMaxBinding(); } |
| 212 | VkDescriptorSetLayoutBinding const *GetDescriptorSetLayoutBindingPtrFromIndex(const uint32_t index) const { |
| 213 | return layout_id_->GetDescriptorSetLayoutBindingPtrFromIndex(index); |
| 214 | } |
| 215 | VkDescriptorSetLayoutBinding const *GetDescriptorSetLayoutBindingPtrFromBinding(uint32_t binding) const { |
| 216 | return layout_id_->GetDescriptorSetLayoutBindingPtrFromBinding(binding); |
| 217 | } |
| 218 | const std::vector<safe_VkDescriptorSetLayoutBinding> &GetBindings() const { return layout_id_->GetBindings(); } |
| Tony-LunarG | a77cade | 2019-03-06 10:49:22 -0700 | [diff] [blame] | 219 | const std::set<uint32_t> &GetSortedBindingSet() const { return layout_id_->GetSortedBindingSet(); } |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 220 | uint32_t GetDescriptorCountFromIndex(const uint32_t index) const { return layout_id_->GetDescriptorCountFromIndex(index); } |
| 221 | uint32_t GetDescriptorCountFromBinding(const uint32_t binding) const { |
| 222 | return layout_id_->GetDescriptorCountFromBinding(binding); |
| 223 | } |
| 224 | VkDescriptorType GetTypeFromIndex(const uint32_t index) const { return layout_id_->GetTypeFromIndex(index); } |
| 225 | VkDescriptorType GetTypeFromBinding(const uint32_t binding) const { return layout_id_->GetTypeFromBinding(binding); } |
| 226 | VkShaderStageFlags GetStageFlagsFromIndex(const uint32_t index) const { return layout_id_->GetStageFlagsFromIndex(index); } |
| 227 | VkShaderStageFlags GetStageFlagsFromBinding(const uint32_t binding) const { |
| 228 | return layout_id_->GetStageFlagsFromBinding(binding); |
| 229 | } |
| Jeff Bolz | fdf9607 | 2018-04-10 14:32:18 -0500 | [diff] [blame] | 230 | VkDescriptorBindingFlagsEXT GetDescriptorBindingFlagsFromIndex(const uint32_t index) const { |
| 231 | return layout_id_->GetDescriptorBindingFlagsFromIndex(index); |
| 232 | } |
| 233 | VkDescriptorBindingFlagsEXT GetDescriptorBindingFlagsFromBinding(const uint32_t binding) const { |
| 234 | return layout_id_->GetDescriptorBindingFlagsFromBinding(binding); |
| 235 | } |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 236 | VkSampler const *GetImmutableSamplerPtrFromBinding(const uint32_t binding) const { |
| 237 | return layout_id_->GetImmutableSamplerPtrFromBinding(binding); |
| 238 | } |
| 239 | VkSampler const *GetImmutableSamplerPtrFromIndex(const uint32_t index) const { |
| 240 | return layout_id_->GetImmutableSamplerPtrFromIndex(index); |
| 241 | } |
| 242 | // For a given binding and array index, return the corresponding index into the dynamic offset array |
| 243 | int32_t GetDynamicOffsetIndexFromBinding(uint32_t binding) const { |
| 244 | return layout_id_->GetDynamicOffsetIndexFromBinding(binding); |
| 245 | } |
| 246 | // For a particular binding, get the global index range |
| 247 | // This call should be guarded by a call to "HasBinding(binding)" to verify that the given binding exists |
| 248 | const IndexRange &GetGlobalIndexRangeFromBinding(const uint32_t binding) const { |
| 249 | return layout_id_->GetGlobalIndexRangeFromBinding(binding); |
| 250 | } |
| John Zulauf | 7705bfc | 2019-06-10 09:52:04 -0600 | [diff] [blame] | 251 | const IndexRange &GetGlobalIndexRangeFromIndex(uint32_t index) const { return layout_id_->GetGlobalIndexRangeFromIndex(index); } |
| 252 | |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 253 | // Helper function to get the next valid binding for a descriptor |
| 254 | uint32_t GetNextValidBinding(const uint32_t binding) const { return layout_id_->GetNextValidBinding(binding); } |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 255 | bool IsPushDescriptor() const { return layout_id_->IsPushDescriptor(); } |
| John Zulauf | 382e191 | 2019-06-10 15:27:44 -0600 | [diff] [blame] | 256 | bool IsVariableDescriptorCountFromIndex(uint32_t index) const { |
| 257 | return !!(GetDescriptorBindingFlagsFromIndex(index) & VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT); |
| 258 | } |
| 259 | bool IsVariableDescriptorCount(uint32_t binding) const { |
| 260 | return IsVariableDescriptorCountFromIndex(GetIndexFromBinding(binding)); |
| 261 | } |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 262 | |
| 263 | using BindingTypeStats = DescriptorSetLayoutDef::BindingTypeStats; |
| 264 | const BindingTypeStats &GetBindingTypeStats() const { return layout_id_->GetBindingTypeStats(); } |
| 265 | |
| John Zulauf | 4a015c9 | 2019-06-04 09:50:05 -0600 | [diff] [blame] | 266 | // Binding Iterator |
| 267 | class ConstBindingIterator { |
| 268 | public: |
| 269 | ConstBindingIterator() = delete; |
| 270 | ConstBindingIterator(const ConstBindingIterator &other) = default; |
| 271 | ConstBindingIterator &operator=(const ConstBindingIterator &rhs) = default; |
| 272 | |
| 273 | ConstBindingIterator(const DescriptorSetLayout *layout) : layout_(layout), index_(0) { assert(layout); } |
| 274 | ConstBindingIterator(const DescriptorSetLayout *layout, uint32_t binding) : ConstBindingIterator(layout) { |
| 275 | index_ = layout->GetIndexFromBinding(binding); |
| 276 | } |
| 277 | |
| 278 | VkDescriptorSetLayoutBinding const *GetDescriptorSetLayoutBindingPtr() const { |
| 279 | return layout_->GetDescriptorSetLayoutBindingPtrFromIndex(index_); |
| 280 | } |
| 281 | uint32_t GetDescriptorCount() const { return layout_->GetDescriptorCountFromIndex(index_); } |
| 282 | VkDescriptorType GetType() const { return layout_->GetTypeFromIndex(index_); } |
| 283 | VkShaderStageFlags GetStageFlags() const { return layout_->GetStageFlagsFromIndex(index_); } |
| 284 | |
| 285 | VkDescriptorBindingFlagsEXT GetDescriptorBindingFlags() const { |
| 286 | return layout_->GetDescriptorBindingFlagsFromIndex(index_); |
| 287 | } |
| 288 | |
| John Zulauf | 382e191 | 2019-06-10 15:27:44 -0600 | [diff] [blame] | 289 | bool IsVariableDescriptorCount() const { return layout_->IsVariableDescriptorCountFromIndex(index_); } |
| 290 | |
| John Zulauf | 4a015c9 | 2019-06-04 09:50:05 -0600 | [diff] [blame] | 291 | VkSampler const *GetImmutableSamplerPtr() const { return layout_->GetImmutableSamplerPtrFromIndex(index_); } |
| John Zulauf | 7705bfc | 2019-06-10 09:52:04 -0600 | [diff] [blame] | 292 | const IndexRange &GetGlobalIndexRange() const { return layout_->GetGlobalIndexRangeFromIndex(index_); } |
| John Zulauf | 4a015c9 | 2019-06-04 09:50:05 -0600 | [diff] [blame] | 293 | bool AtEnd() const { return index_ == layout_->GetBindingCount(); } |
| 294 | |
| John Zulauf | 382e191 | 2019-06-10 15:27:44 -0600 | [diff] [blame] | 295 | // Return index into dynamic offset array for given binding |
| 296 | int32_t GetDynamicOffsetIndex() const { |
| 297 | return layout_->GetDynamicOffsetIndexFromBinding(Binding()); // There is only binding mapped access in layout_ |
| 298 | } |
| 299 | |
| John Zulauf | 4a015c9 | 2019-06-04 09:50:05 -0600 | [diff] [blame] | 300 | bool operator==(const ConstBindingIterator &rhs) { return (index_ = rhs.index_) && (layout_ == rhs.layout_); } |
| 301 | |
| 302 | ConstBindingIterator &operator++() { |
| 303 | if (!AtEnd()) { |
| 304 | index_++; |
| 305 | } |
| 306 | return *this; |
| 307 | } |
| 308 | |
| 309 | bool IsConsistent(const ConstBindingIterator &other) const { |
| 310 | if (AtEnd() || other.AtEnd()) { |
| 311 | return false; |
| 312 | } |
| 313 | const auto *binding_ci = GetDescriptorSetLayoutBindingPtr(); |
| 314 | const auto *other_binding_ci = other.GetDescriptorSetLayoutBindingPtr(); |
| 315 | assert((binding_ci != nullptr) && (other_binding_ci != nullptr)); |
| 316 | |
| 317 | if ((binding_ci->descriptorType != other_binding_ci->descriptorType) || |
| 318 | (binding_ci->stageFlags != other_binding_ci->stageFlags) || |
| 319 | (!hash_util::similar_for_nullity(binding_ci->pImmutableSamplers, other_binding_ci->pImmutableSamplers)) || |
| 320 | (GetDescriptorBindingFlags() != other.GetDescriptorBindingFlags())) { |
| 321 | return false; |
| 322 | } |
| 323 | return true; |
| 324 | } |
| 325 | |
| 326 | const DescriptorSetLayout *Layout() const { return layout_; } |
| 327 | uint32_t Binding() const { return layout_->GetBindings()[index_].binding; } |
| 328 | ConstBindingIterator Next() { |
| 329 | ConstBindingIterator next(*this); |
| 330 | ++next; |
| 331 | return next; |
| 332 | } |
| 333 | |
| 334 | private: |
| 335 | const DescriptorSetLayout *layout_; |
| 336 | uint32_t index_; |
| 337 | }; |
| 338 | ConstBindingIterator end() const { return ConstBindingIterator(this, GetBindingCount()); } |
| 339 | |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 340 | private: |
| 341 | VkDescriptorSetLayout layout_; |
| 342 | bool layout_destroyed_; |
| 343 | DescriptorSetLayoutId layout_id_; |
| 344 | }; |
| 345 | |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 346 | /* |
| 347 | * Descriptor classes |
| 348 | * Descriptor is an abstract base class from which 5 separate descriptor types are derived. |
| 349 | * This allows the WriteUpdate() and CopyUpdate() operations to be specialized per |
| 350 | * descriptor type, but all descriptors in a set can be accessed via the common Descriptor*. |
| 351 | */ |
| 352 | |
| 353 | // Slightly broader than type, each c++ "class" will has a corresponding "DescriptorClass" |
| Jeff Bolz | fbe5158 | 2018-09-13 10:01:35 -0500 | [diff] [blame] | 354 | enum DescriptorClass { PlainSampler, ImageSampler, Image, TexelBuffer, GeneralBuffer, InlineUniform, AccelerationStructure }; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 355 | |
| 356 | class Descriptor { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 357 | public: |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 358 | virtual ~Descriptor(){}; |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 359 | virtual void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) = 0; |
| 360 | virtual void CopyUpdate(const Descriptor *) = 0; |
| Tobin Ehlis | 8020eea | 2016-08-17 11:10:41 -0600 | [diff] [blame] | 361 | // Create binding between resources of this descriptor and given cb_node |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 362 | virtual void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) = 0; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 363 | virtual DescriptorClass GetClass() const { return descriptor_class; }; |
| 364 | // Special fast-path check for SamplerDescriptors that are immutable |
| 365 | virtual bool IsImmutableSampler() const { return false; }; |
| 366 | // Check for dynamic descriptor type |
| 367 | virtual bool IsDynamic() const { return false; }; |
| 368 | // Check for storage descriptor type |
| 369 | virtual bool IsStorage() const { return false; }; |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 370 | bool updated; // Has descriptor been updated? |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 371 | DescriptorClass descriptor_class; |
| 372 | }; |
| John Zulauf | c93c425 | 2019-06-25 09:19:49 -0600 | [diff] [blame] | 373 | |
| John Zulauf | 9ce3b25 | 2019-06-06 15:20:22 -0600 | [diff] [blame] | 374 | // Return true if this layout is compatible with passed in layout from a pipelineLayout, |
| 375 | // else return false and update error_msg with description of incompatibility |
| 376 | bool VerifySetLayoutCompatibility(DescriptorSetLayout const *lh_ds_layout, DescriptorSetLayout const *rh_ds_layout, |
| 377 | std::string *error_msg); |
| John Zulauf | d9435c3 | 2019-06-05 15:55:36 -0600 | [diff] [blame] | 378 | bool ValidateDescriptorSetLayoutCreateInfo(const debug_report_data *report_data, const VkDescriptorSetLayoutCreateInfo *create_info, |
| 379 | const bool push_descriptor_ext, const uint32_t max_push_descriptors, |
| 380 | const bool descriptor_indexing_ext, |
| 381 | const VkPhysicalDeviceDescriptorIndexingFeaturesEXT *descriptor_indexing_features, |
| 382 | const VkPhysicalDeviceInlineUniformBlockFeaturesEXT *inline_uniform_block_features, |
| 383 | const VkPhysicalDeviceInlineUniformBlockPropertiesEXT *inline_uniform_block_props); |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 384 | |
| 385 | class SamplerDescriptor : public Descriptor { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 386 | public: |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 387 | SamplerDescriptor(const VkSampler *); |
| 388 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; |
| 389 | void CopyUpdate(const Descriptor *) override; |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 390 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 391 | virtual bool IsImmutableSampler() const override { return immutable_; }; |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 392 | VkSampler GetSampler() const { return sampler_; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 393 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 394 | private: |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 395 | VkSampler sampler_; |
| 396 | bool immutable_; |
| Tobin Ehlis | 546326f | 2016-04-26 11:06:05 -0600 | [diff] [blame] | 397 | }; |
| 398 | |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 399 | class ImageSamplerDescriptor : public Descriptor { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 400 | public: |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 401 | ImageSamplerDescriptor(const VkSampler *); |
| 402 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; |
| 403 | void CopyUpdate(const Descriptor *) override; |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 404 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override; |
| Tobin Ehlis | c962515 | 2016-05-24 16:47:36 -0600 | [diff] [blame] | 405 | virtual bool IsImmutableSampler() const override { return immutable_; }; |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 406 | VkSampler GetSampler() const { return sampler_; } |
| 407 | VkImageView GetImageView() const { return image_view_; } |
| 408 | VkImageLayout GetImageLayout() const { return image_layout_; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 409 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 410 | private: |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 411 | VkSampler sampler_; |
| 412 | bool immutable_; |
| 413 | VkImageView image_view_; |
| 414 | VkImageLayout image_layout_; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 415 | }; |
| 416 | |
| 417 | class ImageDescriptor : public Descriptor { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 418 | public: |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 419 | ImageDescriptor(const VkDescriptorType); |
| 420 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; |
| 421 | void CopyUpdate(const Descriptor *) override; |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 422 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override; |
| Norbert Nopper | 419a109 | 2016-05-15 19:19:41 +0200 | [diff] [blame] | 423 | virtual bool IsStorage() const override { return storage_; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 424 | VkImageView GetImageView() const { return image_view_; } |
| 425 | VkImageLayout GetImageLayout() const { return image_layout_; } |
| 426 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 427 | private: |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 428 | bool storage_; |
| 429 | VkImageView image_view_; |
| 430 | VkImageLayout image_layout_; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 431 | }; |
| 432 | |
| 433 | class TexelDescriptor : public Descriptor { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 434 | public: |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 435 | TexelDescriptor(const VkDescriptorType); |
| 436 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; |
| 437 | void CopyUpdate(const Descriptor *) override; |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 438 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override; |
| Tobin Ehlis | f490f2e | 2016-05-17 06:43:48 -0600 | [diff] [blame] | 439 | virtual bool IsStorage() const override { return storage_; } |
| 440 | VkBufferView GetBufferView() const { return buffer_view_; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 441 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 442 | private: |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 443 | VkBufferView buffer_view_; |
| 444 | bool storage_; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 445 | }; |
| 446 | |
| 447 | class BufferDescriptor : public Descriptor { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 448 | public: |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 449 | BufferDescriptor(const VkDescriptorType); |
| 450 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override; |
| 451 | void CopyUpdate(const Descriptor *) override; |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 452 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 453 | virtual bool IsDynamic() const override { return dynamic_; } |
| 454 | virtual bool IsStorage() const override { return storage_; } |
| 455 | VkBuffer GetBuffer() const { return buffer_; } |
| 456 | VkDeviceSize GetOffset() const { return offset_; } |
| 457 | VkDeviceSize GetRange() const { return range_; } |
| 458 | |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 459 | private: |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 460 | bool storage_; |
| 461 | bool dynamic_; |
| 462 | VkBuffer buffer_; |
| 463 | VkDeviceSize offset_; |
| 464 | VkDeviceSize range_; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 465 | }; |
| Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 466 | |
| 467 | class InlineUniformDescriptor : public Descriptor { |
| 468 | public: |
| Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 469 | InlineUniformDescriptor(const VkDescriptorType) { |
| 470 | updated = false; |
| 471 | descriptor_class = InlineUniform; |
| 472 | } |
| Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 473 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override { updated = true; } |
| Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 474 | void CopyUpdate(const Descriptor *) override { updated = true; } |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 475 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override {} |
| Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 476 | }; |
| 477 | |
| Jeff Bolz | fbe5158 | 2018-09-13 10:01:35 -0500 | [diff] [blame] | 478 | class AccelerationStructureDescriptor : public Descriptor { |
| 479 | public: |
| Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 480 | AccelerationStructureDescriptor(const VkDescriptorType) { |
| 481 | updated = false; |
| 482 | descriptor_class = AccelerationStructure; |
| 483 | } |
| Jeff Bolz | fbe5158 | 2018-09-13 10:01:35 -0500 | [diff] [blame] | 484 | void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override { updated = true; } |
| Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 485 | void CopyUpdate(const Descriptor *) override { updated = true; } |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 486 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *) override {} |
| Jeff Bolz | fbe5158 | 2018-09-13 10:01:35 -0500 | [diff] [blame] | 487 | }; |
| 488 | |
| Tobin Ehlis | 68d0adf | 2016-06-01 11:33:50 -0600 | [diff] [blame] | 489 | // Structs to contain common elements that need to be shared between Validate* and Perform* calls below |
| 490 | struct AllocateDescriptorSetsData { |
| Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 491 | std::map<uint32_t, uint32_t> required_descriptors_by_type; |
| Tobin Ehlis | a8e46e7 | 2017-06-21 10:16:10 -0600 | [diff] [blame] | 492 | std::vector<std::shared_ptr<DescriptorSetLayout const>> layout_nodes; |
| Tobin Ehlis | 68d0adf | 2016-06-01 11:33:50 -0600 | [diff] [blame] | 493 | AllocateDescriptorSetsData(uint32_t); |
| 494 | }; |
| Tobin Ehlis | ee47146 | 2016-05-26 11:21:59 -0600 | [diff] [blame] | 495 | // Helper functions for descriptor set functions that cross multiple sets |
| 496 | // "Validate" will make sure an update is ok without actually performing it |
| Mark Lobodzinski | 3840ca0 | 2019-03-08 18:36:11 -0700 | [diff] [blame] | 497 | bool ValidateUpdateDescriptorSets(const debug_report_data *, const CoreChecks *, uint32_t, const VkWriteDescriptorSet *, uint32_t, |
| Mark Lobodzinski | b56bbb9 | 2019-02-18 11:49:59 -0700 | [diff] [blame] | 498 | const VkCopyDescriptorSet *, const char *func_name); |
| Tobin Ehlis | ee47146 | 2016-05-26 11:21:59 -0600 | [diff] [blame] | 499 | // "Perform" does the update with the assumption that ValidateUpdateDescriptorSets() has passed for the given update |
| John Zulauf | e3b35f3 | 2019-06-25 14:21:21 -0600 | [diff] [blame] | 500 | void PerformUpdateDescriptorSets(ValidationStateTracker *, uint32_t, const VkWriteDescriptorSet *, uint32_t, |
| 501 | const VkCopyDescriptorSet *); |
| John Zulauf | b845eb2 | 2018-10-12 11:41:06 -0600 | [diff] [blame] | 502 | |
| John Zulauf | 4a015c9 | 2019-06-04 09:50:05 -0600 | [diff] [blame] | 503 | // Core Validation specific validation checks using DescriptorSet and DescriptorSetLayoutAccessors |
| 504 | // TODO: migrate out of descriptor_set.cpp/h |
| 505 | // For a particular binding starting at offset and having update_count descriptors |
| 506 | // updated, verify that for any binding boundaries crossed, the update is consistent |
| 507 | bool VerifyUpdateConsistency(DescriptorSetLayout::ConstBindingIterator current_binding, uint32_t offset, uint32_t update_count, |
| 508 | const char *type, const VkDescriptorSet set, std::string *error_msg); |
| John Zulauf | d9435c3 | 2019-06-05 15:55:36 -0600 | [diff] [blame] | 509 | |
| 510 | // Validate buffer descriptor update info |
| 511 | bool ValidateBufferUsage(BUFFER_STATE const *buffer_node, VkDescriptorType type, std::string *error_code, std::string *error_msg); |
| John Zulauf | 4a015c9 | 2019-06-04 09:50:05 -0600 | [diff] [blame] | 512 | |
| John Zulauf | b845eb2 | 2018-10-12 11:41:06 -0600 | [diff] [blame] | 513 | // Helper class to encapsulate the descriptor update template decoding logic |
| 514 | struct DecodedTemplateUpdate { |
| 515 | std::vector<VkWriteDescriptorSet> desc_writes; |
| 516 | std::vector<VkWriteDescriptorSetInlineUniformBlockEXT> inline_infos; |
| John Zulauf | e3b35f3 | 2019-06-25 14:21:21 -0600 | [diff] [blame] | 517 | DecodedTemplateUpdate(const ValidationStateTracker *device_data, VkDescriptorSet descriptorSet, |
| 518 | const TEMPLATE_STATE *template_state, const void *pData, |
| 519 | VkDescriptorSetLayout push_layout = VK_NULL_HANDLE); |
| John Zulauf | b845eb2 | 2018-10-12 11:41:06 -0600 | [diff] [blame] | 520 | }; |
| Tobin Ehlis | ee47146 | 2016-05-26 11:21:59 -0600 | [diff] [blame] | 521 | |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 522 | /* |
| 523 | * DescriptorSet class |
| 524 | * |
| 525 | * Overview - This class encapsulates the Vulkan VkDescriptorSet data (set). |
| 526 | * A set has an underlying layout which defines the bindings in the set and the |
| 527 | * types and numbers of descriptors in each descriptor slot. Most of the layout |
| 528 | * interfaces are exposed through identically-named functions in the set class. |
| 529 | * Please refer to the DescriptorSetLayout comment above for a description of |
| 530 | * index, binding, and global index. |
| 531 | * |
| 532 | * At construction a vector of Descriptor* is created with types corresponding to the |
| 533 | * layout. The primary operation performed on the descriptors is to update them |
| 534 | * via write or copy updates, and validate that the update contents are correct. |
| 535 | * In order to validate update contents, the DescriptorSet stores a bunch of ptrs |
| 536 | * to data maps where various Vulkan objects can be looked up. The management of |
| 537 | * those maps is performed externally. The set class relies on their contents to |
| 538 | * be correct at the time of update. |
| 539 | */ |
| Tobin Ehlis | 05be5df | 2016-05-05 08:25:02 -0600 | [diff] [blame] | 540 | class DescriptorSet : public BASE_NODE { |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 541 | public: |
| John Zulauf | c93c425 | 2019-06-25 09:19:49 -0600 | [diff] [blame] | 542 | using StateTracker = ValidationStateTracker; |
| Tobin Ehlis | 452b453 | 2017-06-21 09:56:13 -0600 | [diff] [blame] | 543 | DescriptorSet(const VkDescriptorSet, const VkDescriptorPool, const std::shared_ptr<DescriptorSetLayout const> &, |
| John Zulauf | c93c425 | 2019-06-25 09:19:49 -0600 | [diff] [blame] | 544 | uint32_t variable_count, StateTracker *); |
| Tobin Ehlis | 9906d9d | 2016-05-17 14:23:46 -0600 | [diff] [blame] | 545 | ~DescriptorSet(); |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 546 | // A number of common Get* functions that return data based on layout from which this set was created |
| Tobin Ehlis | 7cd8c79 | 2017-06-20 08:30:39 -0600 | [diff] [blame] | 547 | uint32_t GetTotalDescriptorCount() const { return p_layout_->GetTotalDescriptorCount(); }; |
| 548 | uint32_t GetDynamicDescriptorCount() const { return p_layout_->GetDynamicDescriptorCount(); }; |
| 549 | uint32_t GetBindingCount() const { return p_layout_->GetBindingCount(); }; |
| 550 | VkDescriptorType GetTypeFromIndex(const uint32_t index) const { return p_layout_->GetTypeFromIndex(index); }; |
| Tobin Ehlis | 7cd8c79 | 2017-06-20 08:30:39 -0600 | [diff] [blame] | 551 | VkDescriptorType GetTypeFromBinding(const uint32_t binding) const { return p_layout_->GetTypeFromBinding(binding); }; |
| 552 | uint32_t GetDescriptorCountFromIndex(const uint32_t index) const { return p_layout_->GetDescriptorCountFromIndex(index); }; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 553 | uint32_t GetDescriptorCountFromBinding(const uint32_t binding) const { |
| Tobin Ehlis | 7cd8c79 | 2017-06-20 08:30:39 -0600 | [diff] [blame] | 554 | return p_layout_->GetDescriptorCountFromBinding(binding); |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 555 | }; |
| Tobin Ehlis | a3525e0 | 2016-11-17 10:50:52 -0700 | [diff] [blame] | 556 | // Return index into dynamic offset array for given binding |
| 557 | int32_t GetDynamicOffsetIndexFromBinding(uint32_t binding) const { |
| Tobin Ehlis | 7cd8c79 | 2017-06-20 08:30:39 -0600 | [diff] [blame] | 558 | return p_layout_->GetDynamicOffsetIndexFromBinding(binding); |
| Tobin Ehlis | a3525e0 | 2016-11-17 10:50:52 -0700 | [diff] [blame] | 559 | } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 560 | // Return true if given binding is present in this set |
| Tobin Ehlis | 7cd8c79 | 2017-06-20 08:30:39 -0600 | [diff] [blame] | 561 | bool HasBinding(const uint32_t binding) const { return p_layout_->HasBinding(binding); }; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 562 | // For given set of bindings, add any buffers and images that will be updated to their respective unordered_sets & return number |
| 563 | // of objects inserted |
| Tobin Ehlis | cebc4c0 | 2016-08-22 10:10:43 -0600 | [diff] [blame] | 564 | uint32_t GetStorageUpdates(const std::map<uint32_t, descriptor_req> &, std::unordered_set<VkBuffer> *, |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 565 | std::unordered_set<VkImageView> *) const; |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 566 | |
| John Zulauf | 4e7bcb5 | 2018-11-02 10:46:30 -0600 | [diff] [blame] | 567 | std::string StringifySetAndLayout() const; |
| John Zulauf | d9435c3 | 2019-06-05 15:55:36 -0600 | [diff] [blame] | 568 | |
| John Zulauf | 1d27e0a | 2018-11-05 10:12:48 -0700 | [diff] [blame] | 569 | // Perform a push update whose contents were just validated using ValidatePushDescriptorsUpdate |
| 570 | void PerformPushDescriptorsUpdate(uint32_t write_count, const VkWriteDescriptorSet *p_wds); |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 571 | // Perform a WriteUpdate whose contents were just validated using ValidateWriteUpdate |
| 572 | void PerformWriteUpdate(const VkWriteDescriptorSet *); |
| Tobin Ehlis | 300888c | 2016-05-18 13:43:26 -0600 | [diff] [blame] | 573 | // Perform a CopyUpdate whose contents were just validated using ValidateCopyUpdate |
| 574 | void PerformCopyUpdate(const VkCopyDescriptorSet *, const DescriptorSet *); |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 575 | |
| John Zulauf | 1f8174b | 2018-02-16 12:58:37 -0700 | [diff] [blame] | 576 | const std::shared_ptr<DescriptorSetLayout const> GetLayout() const { return p_layout_; }; |
| John Zulauf | d9435c3 | 2019-06-05 15:55:36 -0600 | [diff] [blame] | 577 | VkDescriptorSetLayout GetDescriptorSetLayout() const { return p_layout_->GetDescriptorSetLayout(); } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 578 | VkDescriptorSet GetSet() const { return set_; }; |
| 579 | // Return unordered_set of all command buffers that this set is bound to |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 580 | std::unordered_set<CMD_BUFFER_STATE *> GetBoundCmdBuffers() const { return cb_bindings; } |
| John Zulauf | 6f3d2bd | 2018-10-29 17:08:42 -0600 | [diff] [blame] | 581 | // Bind given cmd_buffer to this descriptor set and |
| 582 | // update CB image layout map with image/imagesampler descriptor image layouts |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 583 | void UpdateDrawState(CoreChecks *, CMD_BUFFER_STATE *, const std::map<uint32_t, descriptor_req> &); |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 584 | |
| 585 | // Track work that has been bound or validated to avoid duplicate work, important when large descriptor arrays |
| 586 | // are present |
| 587 | typedef std::unordered_set<uint32_t> TrackedBindings; |
| 588 | static void FilterAndTrackOneBindingReq(const BindingReqMap::value_type &binding_req_pair, const BindingReqMap &in_req, |
| 589 | BindingReqMap *out_req, TrackedBindings *set); |
| 590 | static void FilterAndTrackOneBindingReq(const BindingReqMap::value_type &binding_req_pair, const BindingReqMap &in_req, |
| 591 | BindingReqMap *out_req, TrackedBindings *set, uint32_t limit); |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 592 | void FilterAndTrackBindingReqs(CMD_BUFFER_STATE *, const BindingReqMap &in_req, BindingReqMap *out_req); |
| 593 | void FilterAndTrackBindingReqs(CMD_BUFFER_STATE *, PIPELINE_STATE *, const BindingReqMap &in_req, BindingReqMap *out_req); |
| 594 | void ClearCachedDynamicDescriptorValidation(CMD_BUFFER_STATE *cb_state) { |
| 595 | cached_validation_[cb_state].dynamic_buffers.clear(); |
| 596 | } |
| 597 | void ClearCachedValidation(CMD_BUFFER_STATE *cb_state) { cached_validation_.erase(cb_state); } |
| Tobin Ehlis | 2556f5b | 2016-06-24 17:22:16 -0600 | [diff] [blame] | 598 | // If given cmd_buffer is in the cb_bindings set, remove it |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 599 | void RemoveBoundCommandBuffer(CMD_BUFFER_STATE *cb_node) { |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 600 | cb_bindings.erase(cb_node); |
| 601 | ClearCachedValidation(cb_node); |
| 602 | } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 603 | VkSampler const *GetImmutableSamplerPtrFromBinding(const uint32_t index) const { |
| Tobin Ehlis | 7cd8c79 | 2017-06-20 08:30:39 -0600 | [diff] [blame] | 604 | return p_layout_->GetImmutableSamplerPtrFromBinding(index); |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 605 | }; |
| 606 | // For a particular binding, get the global index |
| Tony-LunarG | a77cade | 2019-03-06 10:49:22 -0700 | [diff] [blame] | 607 | const IndexRange GetGlobalIndexRangeFromBinding(const uint32_t binding, bool actual_length = false) const { |
| 608 | if (actual_length && binding == p_layout_->GetMaxBinding() && IsVariableDescriptorCount(binding)) { |
| 609 | IndexRange range = p_layout_->GetGlobalIndexRangeFromBinding(binding); |
| 610 | auto diff = GetDescriptorCountFromBinding(binding) - GetVariableDescriptorCount(); |
| 611 | range.end -= diff; |
| 612 | return range; |
| 613 | } |
| John Zulauf | c483f44 | 2017-12-15 14:02:06 -0700 | [diff] [blame] | 614 | return p_layout_->GetGlobalIndexRangeFromBinding(binding); |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 615 | }; |
| 616 | // Return true if any part of set has ever been updated |
| 617 | bool IsUpdated() const { return some_update_; }; |
| Józef Kucia | f0c94d4 | 2017-10-25 22:15:22 +0200 | [diff] [blame] | 618 | bool IsPushDescriptor() const { return p_layout_->IsPushDescriptor(); }; |
| John Zulauf | 382e191 | 2019-06-10 15:27:44 -0600 | [diff] [blame] | 619 | bool IsVariableDescriptorCount(uint32_t binding) const { return p_layout_->IsVariableDescriptorCount(binding); } |
| Tony-LunarG | 81efe39 | 2019-03-07 15:43:27 -0700 | [diff] [blame] | 620 | bool IsUpdateAfterBind(uint32_t binding) const { |
| 621 | return !!(p_layout_->GetDescriptorBindingFlagsFromBinding(binding) & VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT_EXT); |
| 622 | } |
| Jeff Bolz | fdf9607 | 2018-04-10 14:32:18 -0500 | [diff] [blame] | 623 | uint32_t GetVariableDescriptorCount() const { return variable_count_; } |
| 624 | DESCRIPTOR_POOL_STATE *GetPoolState() const { return pool_state_; } |
| Tony-LunarG | a77cade | 2019-03-06 10:49:22 -0700 | [diff] [blame] | 625 | const Descriptor *GetDescriptorFromGlobalIndex(const uint32_t index) const { return descriptors_[index].get(); } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 626 | |
| John Zulauf | 613fd98 | 2019-06-04 15:14:41 -0600 | [diff] [blame] | 627 | private: |
| Tobin Ehlis | 9906d9d | 2016-05-17 14:23:46 -0600 | [diff] [blame] | 628 | // Private helper to set all bound cmd buffers to INVALID state |
| 629 | void InvalidateBoundCmdBuffers(); |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 630 | bool some_update_; // has any part of the set ever been updated? |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 631 | VkDescriptorSet set_; |
| Tobin Ehlis | 7ca20be | 2016-10-12 15:09:16 -0600 | [diff] [blame] | 632 | DESCRIPTOR_POOL_STATE *pool_state_; |
| Tobin Ehlis | 452b453 | 2017-06-21 09:56:13 -0600 | [diff] [blame] | 633 | const std::shared_ptr<DescriptorSetLayout const> p_layout_; |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 634 | std::vector<std::unique_ptr<Descriptor>> descriptors_; |
| John Zulauf | c93c425 | 2019-06-25 09:19:49 -0600 | [diff] [blame] | 635 | StateTracker *state_data_; |
| Jeff Bolz | fdf9607 | 2018-04-10 14:32:18 -0500 | [diff] [blame] | 636 | uint32_t variable_count_; |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 637 | |
| 638 | // Cached binding and validation support: |
| 639 | // |
| 640 | // For the lifespan of a given command buffer recording, do lazy evaluation, caching, and dirtying of |
| 641 | // expensive validation operation (typically per-draw) |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 642 | typedef std::unordered_map<CMD_BUFFER_STATE *, TrackedBindings> TrackedBindingMap; |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 643 | // Track the validation caching of bindings vs. the command buffer and draw state |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 644 | typedef std::unordered_map<uint32_t, CMD_BUFFER_STATE::ImageLayoutUpdateCount> VersionedBindings; |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 645 | struct CachedValidation { |
| 646 | TrackedBindings command_binding_and_usage; // Persistent for the life of the recording |
| 647 | TrackedBindings non_dynamic_buffers; // Persistent for the life of the recording |
| 648 | TrackedBindings dynamic_buffers; // Dirtied (flushed) each BindDescriptorSet |
| 649 | std::unordered_map<PIPELINE_STATE *, VersionedBindings> image_samplers; // Tested vs. changes to CB's ImageLayout |
| 650 | }; |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 651 | typedef std::unordered_map<CMD_BUFFER_STATE *, CachedValidation> CachedValidationMap; |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 652 | // Image and ImageView bindings are validated per pipeline and not invalidate by repeated binding |
| 653 | CachedValidationMap cached_validation_; |
| 654 | }; |
| 655 | // For the "bindless" style resource usage with many descriptors, need to optimize binding and validation |
| 656 | class PrefilterBindRequestMap { |
| 657 | public: |
| 658 | static const uint32_t kManyDescriptors_ = 64; // TODO base this number on measured data |
| 659 | std::unique_ptr<BindingReqMap> filtered_map_; |
| 660 | const BindingReqMap &orig_map_; |
| 661 | |
| Mark Lobodzinski | 33a34b8 | 2019-04-25 11:38:36 -0600 | [diff] [blame] | 662 | PrefilterBindRequestMap(DescriptorSet &ds, const BindingReqMap &in_map, CMD_BUFFER_STATE *cb_state); |
| 663 | PrefilterBindRequestMap(DescriptorSet &ds, const BindingReqMap &in_map, CMD_BUFFER_STATE *cb_state, PIPELINE_STATE *); |
| John Zulauf | 48a6a70 | 2017-12-22 17:14:54 -0700 | [diff] [blame] | 664 | const BindingReqMap &Map() const { return (filtered_map_) ? *filtered_map_ : orig_map_; } |
| Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 665 | }; |
| Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 666 | } // namespace cvdescriptorset |
| Mark Lobodzinski | 64318ba | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 667 | #endif // CORE_VALIDATION_DESCRIPTOR_SETS_H_ |