| 71 | } |
| 72 | |
| 73 | VkSemaphore SemaphorePool::request_semaphore() |
| 74 | { |
| 75 | // Check if there is an available semaphore |
| 76 | if (active_semaphore_count < semaphores.size()) |
| 77 | { |
| 78 | return semaphores[active_semaphore_count++]; |
| 79 | } |
| 80 | |
| 81 | VkSemaphore semaphore{VK_NULL_HANDLE}; |
| 82 | |
| 83 | VkSemaphoreCreateInfo create_info{VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; |
| 84 | |
| 85 | VkResult result = vkCreateSemaphore(device.get_handle(), &create_info, nullptr, &semaphore); |
| 86 | |
| 87 | if (result != VK_SUCCESS) |
| 88 | { |
| 89 | throw std::runtime_error("Failed to create semaphore."); |
| 90 | } |
| 91 | |
| 92 | semaphores.push_back(semaphore); |
| 93 | |
| 94 | active_semaphore_count++; |
| 95 | |
| 96 | return semaphore; |
| 97 | } |
| 98 | |
| 99 | void SemaphorePool::reset() |
| 100 | { |
no test coverage detected