| 671 | } |
| 672 | |
| 673 | std::vector<BatchContextPtr> QueueBatchContext::ResolveSubmitWaits(vvl::span<const VkSemaphoreSubmitInfo> wait_infos, |
| 674 | std::vector<VkSemaphoreSubmitInfo>& unresolved_waits, |
| 675 | SignalsUpdate& signals_update) { |
| 676 | std::vector<BatchContextPtr> resolved_batches; |
| 677 | for (const auto& wait_info : wait_infos) { |
| 678 | auto semaphore_state = sync_state_.Get<vvl::Semaphore>(wait_info.semaphore); |
| 679 | if (!semaphore_state) { |
| 680 | continue; // [core validation check] |
| 681 | } |
| 682 | // Binary semaphore wait: |
| 683 | // * There must be a single resovling signal. If no signal is found, it is a validation error. |
| 684 | // * The resolving signal must not depend on another not yet submitted timeline signal. That's |
| 685 | // not allowed by the specification. When this happens OnBinaryWait also reports that signal |
| 686 | // not found. |
| 687 | // Timeline semaphore wait: |
| 688 | // * No resolving signal is allowed. It is a wait-before-signal scenario. |
| 689 | // * A single resolving signal. The specification defines that exactly *one* signal resolves the wait. |
| 690 | // If there are multiple signals that meet the waiting criteria then implementation may choose |
| 691 | // any of them (which one is unspecified). This also means that a single timeline wait cannot |
| 692 | // synchronize accesses from multiple queues even if each queue has matching signal. |
| 693 | std::optional<SignalInfo> resolving_signal; |
| 694 | |
| 695 | if (semaphore_state->type == VK_SEMAPHORE_TYPE_BINARY) { |
| 696 | resolving_signal = signals_update.OnBinaryWait(wait_info.semaphore); |
| 697 | if (!resolving_signal) { |
| 698 | // [core validation check]: binary signal not found or depends on not yet submitted timeline signal |
| 699 | continue; |
| 700 | } |
| 701 | } else { |
| 702 | // Special case when semaphore initial value satisfies the wait. |
| 703 | // There is no batch that signals initial value, nothing to resolve here. |
| 704 | if (wait_info.value <= semaphore_state->initial_value) { |
| 705 | continue; |
| 706 | } |
| 707 | resolving_signal = signals_update.OnTimelineWait(wait_info.semaphore, wait_info.value); |
| 708 | |
| 709 | // Register wait-before-signal |
| 710 | if (!resolving_signal) { |
| 711 | if (semaphore_state->Scope() == vvl::Semaphore::Scope::kInternal) { |
| 712 | unresolved_waits.emplace_back(wait_info); |
| 713 | continue; |
| 714 | } else { |
| 715 | // Do not register wait-before-signal for external semaphore. |
| 716 | // We might not be able to track the signal. Just assume that wait is satified. |
| 717 | continue; |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | if (resolving_signal->batch) { |
| 722 | ResolveSubmitSemaphoreWait(resolving_signal.value(), wait_info.stageMask); |
| 723 | ImportTags(*resolving_signal->batch); |
| 724 | resolved_batches.emplace_back(std::move(resolving_signal->batch)); |
| 725 | } |
| 726 | } |
| 727 | return resolved_batches; |
| 728 | } |
| 729 | |
| 730 | bool QueueBatchContext::ValidateSubmit(const std::vector<CommandBufferConstPtr>& command_buffers, uint64_t submit_index, |
no test coverage detected