| 131 | } |
| 132 | |
| 133 | void vvl::Semaphore::EnqueueWait(const SubmissionReference& wait_submit, uint64_t& payload) { |
| 134 | auto guard = WriteLock(); |
| 135 | if (type == VK_SEMAPHORE_TYPE_BINARY) { |
| 136 | // Update the swapchain image acquire state if the semaphore was used by the acquire operation |
| 137 | if (acquired_image_swapchain_ && !acquired_image_swapchain_->Destroyed()) { |
| 138 | assert(acquired_image_index_ != vvl::kNoIndex32); |
| 139 | acquired_image_swapchain_->images[acquired_image_index_].acquire_semaphore_status = AcquireSyncStatus::WasWaitedOn; |
| 140 | acquired_image_swapchain_.reset(); |
| 141 | acquired_image_index_ = vvl::kNoIndex32; |
| 142 | } |
| 143 | // Get payload value |
| 144 | if (timeline_.empty()) { |
| 145 | if (scope_ != vvl::Semaphore::kInternal) { |
| 146 | // for external semaphore mark wait as completed, no guarantee of signal visibility |
| 147 | completed_ = SemOp(kWait, wait_submit.queue, 0); |
| 148 | current_payload_ = 0; |
| 149 | return; |
| 150 | } else { |
| 151 | // generate binary payload value from the last completed signals |
| 152 | assert(completed_.op_type == kSignal); |
| 153 | payload = completed_.payload; |
| 154 | } |
| 155 | } else { |
| 156 | // generate binary payload value from the most recent pending binary signal |
| 157 | assert(timeline_.rbegin()->second.HasSignaler()); |
| 158 | payload = timeline_.rbegin()->first; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (payload <= completed_.payload) { |
| 163 | // Signal is already retired and its timepoint removed. Mark wait as completed. |
| 164 | // NOTE: wait's submission can still be pending, but timepoint lifetime logic |
| 165 | // is determined by the signal. completed_ is updated when signal is retired. |
| 166 | // The matching waits should be resolved against completed_ in this case. |
| 167 | assert(!vvl::Contains(timeline_, payload)); |
| 168 | completed_.op_type = kWait; |
| 169 | completed_.queue = wait_submit.queue; |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | timeline_[payload].wait_submits.emplace_back(wait_submit); |
| 174 | } |
| 175 | |
| 176 | void vvl::Semaphore::EnqueueAcquire(vvl::Func acquire_command) { |
| 177 | assert(type == VK_SEMAPHORE_TYPE_BINARY); |
no test coverage detected