| 209 | } |
| 210 | |
| 211 | void Swapchain::AcquireImage(uint32_t image_index, const std::shared_ptr<vvl::Semaphore>& semaphore_state, |
| 212 | const std::shared_ptr<vvl::Fence>& fence_state) { |
| 213 | acquired_images++; |
| 214 | images[image_index].acquired = true; |
| 215 | images[image_index].acquire_semaphore = semaphore_state; |
| 216 | images[image_index].acquire_fence = fence_state; |
| 217 | |
| 218 | if (semaphore_state) { |
| 219 | if (semaphore_state->Scope() == vvl::Semaphore::kInternal) { |
| 220 | images[image_index].acquire_semaphore_status = AcquireSyncStatus::Signaled; |
| 221 | } else { |
| 222 | // For external semaphores (where waits can't be tracked), assume an optimistic scenario |
| 223 | // in which the semaphore has been waited on. |
| 224 | images[image_index].acquire_semaphore_status = AcquireSyncStatus::WasWaitedOn; |
| 225 | } |
| 226 | semaphore_state->SetAcquiredImage(shared_from_this(), image_index); |
| 227 | } |
| 228 | if (fence_state) { |
| 229 | if (fence_state->Scope() == vvl::Fence::kInternal) { |
| 230 | images[image_index].acquire_fence_status = AcquireSyncStatus::Signaled; |
| 231 | } else { |
| 232 | // For external fences (where waits can't be tracked), assume an optimistic scenario |
| 233 | // in which the fence has been waited on. |
| 234 | images[image_index].acquire_fence_status = AcquireSyncStatus::WasWaitedOn; |
| 235 | } |
| 236 | fence_state->SetAcquiredImage(shared_from_this(), image_index); |
| 237 | if (images[image_index].present_submission_ref.has_value()) { |
| 238 | fence_state->SetPresentSubmissionRef(*images[image_index].present_submission_ref); |
| 239 | images[image_index].present_submission_ref.reset(); |
| 240 | } |
| 241 | } |
| 242 | images[image_index].ResetPresentWaitSemaphores(); |
| 243 | |
| 244 | acquire_history_ring_buffer[acquire_request_count % acquire_history_ring_buffer_size] = image_index; |
| 245 | acquire_request_count++; |
| 246 | } |
| 247 | |
| 248 | void Swapchain::Destroy() { |
| 249 | for (auto& swapchain_image : images) { |
no test coverage detected