| 108 | } |
| 109 | |
| 110 | void ResourceCache::update_descriptor_sets(const std::vector<core::ImageView> &old_views, const std::vector<core::ImageView> &new_views) |
| 111 | { |
| 112 | // Find descriptor sets referring to the old image view |
| 113 | std::vector<VkWriteDescriptorSet> set_updates; |
| 114 | std::set<size_t> matches; |
| 115 | |
| 116 | for (size_t i = 0; i < old_views.size(); ++i) |
| 117 | { |
| 118 | auto &old_view = old_views[i]; |
| 119 | auto &new_view = new_views[i]; |
| 120 | |
| 121 | for (auto &kd_pair : state.descriptor_sets) |
| 122 | { |
| 123 | auto &key = kd_pair.first; |
| 124 | auto &descriptor_set = kd_pair.second; |
| 125 | |
| 126 | auto &image_infos = descriptor_set.get_image_infos(); |
| 127 | |
| 128 | for (auto &ba_pair : image_infos) |
| 129 | { |
| 130 | auto &binding = ba_pair.first; |
| 131 | auto &array = ba_pair.second; |
| 132 | |
| 133 | for (auto &ai_pair : array) |
| 134 | { |
| 135 | auto &array_element = ai_pair.first; |
| 136 | auto &image_info = ai_pair.second; |
| 137 | |
| 138 | if (image_info.imageView == old_view.get_handle()) |
| 139 | { |
| 140 | // Save key to remove old descriptor set |
| 141 | matches.insert(key); |
| 142 | |
| 143 | // Update image info with new view |
| 144 | image_info.imageView = new_view.get_handle(); |
| 145 | |
| 146 | // Save struct for writing the update later |
| 147 | { |
| 148 | VkWriteDescriptorSet write_descriptor_set{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; |
| 149 | |
| 150 | if (auto binding_info = descriptor_set.get_layout().get_layout_binding(binding)) |
| 151 | { |
| 152 | write_descriptor_set.dstBinding = binding; |
| 153 | write_descriptor_set.descriptorType = binding_info->descriptorType; |
| 154 | write_descriptor_set.pImageInfo = &image_info; |
| 155 | write_descriptor_set.dstSet = descriptor_set.get_handle(); |
| 156 | write_descriptor_set.dstArrayElement = array_element; |
| 157 | write_descriptor_set.descriptorCount = 1; |
| 158 | |
| 159 | set_updates.push_back(write_descriptor_set); |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | LOGE("Shader layout set does not use image binding at #{}", binding); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
nothing calls this directly
no test coverage detected