| 328 | } |
| 329 | |
| 330 | void vvl::Queue::ThreadFunc() { |
| 331 | VVL_TracySetThreadName(__FUNCTION__); |
| 332 | |
| 333 | QueueSubmission* submission = nullptr; |
| 334 | |
| 335 | // Roll this queue forward, one submission at a time. |
| 336 | while (true) { |
| 337 | submission = NextSubmission(); |
| 338 | if (submission == nullptr) { |
| 339 | break; |
| 340 | } |
| 341 | Retire(*submission); |
| 342 | // wake up anyone waiting for this submission to be retired |
| 343 | { |
| 344 | std::shared_ptr<Fence> fence; |
| 345 | std::promise<void> completed; |
| 346 | { |
| 347 | auto guard = Lock(); |
| 348 | fence = std::move(submission->fence); |
| 349 | completed = std::move(submission->completed); |
| 350 | submissions_.pop_front(); |
| 351 | } |
| 352 | |
| 353 | // Retire the fence after removing the submission from the queue (submissions_.pop_front). |
| 354 | // This ensures the completed QueueSubmission is not visible after vkWaitForFences |
| 355 | if (fence) { |
| 356 | fence->Retire(); |
| 357 | } |
| 358 | |
| 359 | // Unblock waiting QueueWaitIdle/DeviceWaitIdle |
| 360 | completed.set_value(); |
| 361 | } |
| 362 | } |
| 363 | } |