| 87 | } |
| 88 | |
| 89 | void vvl::DescriptorPool::Free(uint32_t count, const VkDescriptorSet* descriptor_sets) { |
| 90 | auto guard = WriteLock(); |
| 91 | // Update available descriptor sets in pool |
| 92 | available_sets_ += count; |
| 93 | // we want to track frees because we're interested in suggesting re-use |
| 94 | freed_count += count; |
| 95 | |
| 96 | // For each freed descriptor add its resources back into the pool as available and remove from pool and device data |
| 97 | for (uint32_t i = 0; i < count; ++i) { |
| 98 | if (descriptor_sets[i] != VK_NULL_HANDLE) { |
| 99 | auto iter = sets_.find(descriptor_sets[i]); |
| 100 | ASSERT_AND_CONTINUE(iter != sets_.end()); |
| 101 | auto* set_state = iter->second; |
| 102 | const auto& layout = set_state->Layout(); |
| 103 | uint32_t type_index = 0, descriptor_count = 0; |
| 104 | for (uint32_t j = 0; j < layout.GetBindingCount(); ++j) { |
| 105 | type_index = static_cast<uint32_t>(layout.GetTypeFromIndex(j)); |
| 106 | descriptor_count = layout.GetDescriptorCountFromIndex(j); |
| 107 | available_counts_[type_index] += descriptor_count; |
| 108 | } |
| 109 | dev_data_.Destroy<vvl::DescriptorSet>(iter->first); |
| 110 | sets_.erase(iter); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | void vvl::DescriptorPool::Reset() { |
| 116 | auto guard = WriteLock(); |
no test coverage detected