@@ -111,10 +111,6 @@ bool SubmitTimeTracker::ProcessBatch(std::vector<std::shared_ptr<CommandBuffer>>
111111
112112bool SubmitTimeTracker::ProcessSignal (VkSemaphore timeline, uint64_t signal_value) {
113113 bool skip = false ;
114- auto semaphore = validator_.Get <Semaphore>(timeline);
115- if (!semaphore || semaphore->type != VK_SEMAPHORE_TYPE_TIMELINE) {
116- return skip;
117- }
118114 const bool new_timeline_signal = UpdateTimelineValue (timeline, signal_value);
119115 if (new_timeline_signal) {
120116 skip |= PropagateTimelineSignals ();
@@ -126,14 +122,12 @@ std::vector<VkSemaphoreSubmitInfo> SubmitTimeTracker::GetUnresolvedTimelineWaits
126122 vvl::span<const VkSemaphoreSubmitInfo> wait_semaphores) {
127123 std::vector<VkSemaphoreSubmitInfo> unresolved;
128124 for (const auto & wait : wait_semaphores) {
129- auto semaphore = validator_.Get <Semaphore>(wait.semaphore );
130- if (!semaphore || semaphore->type != VK_SEMAPHORE_TYPE_TIMELINE || semaphore->Scope () != Semaphore::kInternal ) {
131- // Only timeline semaphores can introduce pending waits.
132- // For external semaphores we cannot reliably track signals
125+ const std::optional<uint64_t > current_value = GetTimelineValue (wait.semaphore );
126+ if (!current_value.has_value ()) {
127+ // Invalid or external semaphores should not block this batch
133128 continue ;
134129 }
135- const uint64_t current_value = GetTimelineValue (wait.semaphore );
136- if (wait.value > current_value) {
130+ if (wait.value > *current_value) {
137131 unresolved.emplace_back (wait);
138132 }
139133 }
@@ -143,10 +137,6 @@ std::vector<VkSemaphoreSubmitInfo> SubmitTimeTracker::GetUnresolvedTimelineWaits
143137bool SubmitTimeTracker::RegisterTimelineSignals (vvl::span<const VkSemaphoreSubmitInfo> signal_semaphores) {
144138 bool new_timeline_signals = false ;
145139 for (const VkSemaphoreSubmitInfo& signal : signal_semaphores) {
146- auto semaphore = validator_.Get <Semaphore>(signal.semaphore );
147- if (!semaphore || semaphore->type != VK_SEMAPHORE_TYPE_TIMELINE) {
148- continue ;
149- }
150140 new_timeline_signals |= UpdateTimelineValue (signal.semaphore , signal.value );
151141 }
152142 return new_timeline_signals;
@@ -180,20 +170,34 @@ bool SubmitTimeTracker::PropagateTimelineSignals() {
180170
181171bool SubmitTimeTracker::CanBeResolved (const UnresolvedBatch& batch) const {
182172 for (const VkSemaphoreSubmitInfo& wait : batch.unresolved_timeline_waits ) {
183- const uint64_t current_value = GetTimelineValue (wait.semaphore );
173+ const std::optional<uint64_t > current_value = GetTimelineValue (wait.semaphore );
174+ if (!current_value.has_value ()) {
175+ // Invalid or external semaphores should not block this batch
176+ continue ;
177+ }
184178 if (wait.value > current_value) {
185179 return false ;
186180 }
187181 }
188182 return true ;
189183}
190184
191- uint64_t SubmitTimeTracker::GetTimelineValue (VkSemaphore timeline) const {
185+ std::optional<uint64_t > SubmitTimeTracker::GetTimelineValue (VkSemaphore timeline) const {
186+ auto semaphore_state = validator_.Get <Semaphore>(timeline);
187+ if (!semaphore_state || semaphore_state->type != VK_SEMAPHORE_TYPE_TIMELINE ||
188+ semaphore_state->Scope () != Semaphore::kInternal ) {
189+ // Used by the caller to detect invalid/non-timeline/external semaphores
190+ return {};
191+ }
192192 const uint64_t current_value = vvl::FindExisting (timeline_signals_, timeline);
193193 return current_value;
194194}
195195
196196bool SubmitTimeTracker::UpdateTimelineValue (VkSemaphore timeline, uint64_t signal_value) {
197+ auto semaphore_state = validator_.Get <Semaphore>(timeline);
198+ if (!semaphore_state || semaphore_state->type != VK_SEMAPHORE_TYPE_TIMELINE) {
199+ return false ;
200+ }
197201 uint64_t & current_value = vvl::FindExisting (timeline_signals_, timeline);
198202 if (signal_value <= current_value) {
199203 return false ; // non-increasing signal, the error should be reported elsewhere
0 commit comments