| 132 | } |
| 133 | |
| 134 | void HPPResourceCache::update_descriptor_sets(const std::vector<vkb::core::HPPImageView> &old_views, const std::vector<vkb::core::HPPImageView> &new_views) |
| 135 | { |
| 136 | // Find descriptor sets referring to the old image view |
| 137 | std::vector<vk::WriteDescriptorSet> set_updates; |
| 138 | std::set<size_t> matches; |
| 139 | |
| 140 | for (size_t i = 0; i < old_views.size(); ++i) |
| 141 | { |
| 142 | auto &old_view = old_views[i]; |
| 143 | auto &new_view = new_views[i]; |
| 144 | |
| 145 | for (auto &kd_pair : state.descriptor_sets) |
| 146 | { |
| 147 | auto &key = kd_pair.first; |
| 148 | auto &descriptor_set = kd_pair.second; |
| 149 | |
| 150 | auto &image_infos = descriptor_set.get_image_infos(); |
| 151 | |
| 152 | for (auto &ba_pair : image_infos) |
| 153 | { |
| 154 | auto &binding = ba_pair.first; |
| 155 | auto &array = ba_pair.second; |
| 156 | |
| 157 | for (auto &ai_pair : array) |
| 158 | { |
| 159 | auto &array_element = ai_pair.first; |
| 160 | auto &image_info = ai_pair.second; |
| 161 | |
| 162 | if (image_info.imageView == old_view.get_handle()) |
| 163 | { |
| 164 | // Save key to remove old descriptor set |
| 165 | matches.insert(key); |
| 166 | |
| 167 | // Update image info with new view |
| 168 | image_info.imageView = new_view.get_handle(); |
| 169 | |
| 170 | // Save struct for writing the update later |
| 171 | if (auto binding_info = descriptor_set.get_layout().get_layout_binding(binding)) |
| 172 | { |
| 173 | vk::WriteDescriptorSet write_descriptor_set{.dstSet = descriptor_set.get_handle(), |
| 174 | .dstBinding = binding, |
| 175 | .dstArrayElement = array_element, |
| 176 | .descriptorCount = 1, |
| 177 | .descriptorType = binding_info->descriptorType, |
| 178 | .pImageInfo = &image_info}; |
| 179 | set_updates.push_back(write_descriptor_set); |
| 180 | } |
| 181 | else |
| 182 | { |
| 183 | LOGE("Shader layout set does not use image binding at #{}", binding); |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if (!set_updates.empty()) |
nothing calls this directly
no test coverage detected