Skip to content

Commit 1c76007

Browse files
committed
layers: Legitimize wait count atomic
1 parent bfdde0c commit 1c76007

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

layers/state_tracker/queue_state.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ class Queue : public StateObject, public SubStateManager<QueueSubState> {
206206
DeviceState& device_state_;
207207
const VkQueueFamilyProperties queue_family_properties_;
208208

209-
// TODO: made this atomic to workaround thread sanitizer.
210-
// Likely not a proper solution, need to investigate how this count should be used
211-
std::atomic_uint32_t timeline_wait_count_ = 0;
212-
213209
void ThreadFunc();
214210
QueueSubmission *NextSubmission();
215211

@@ -223,6 +219,13 @@ class Queue : public StateObject, public SubStateManager<QueueSubState> {
223219
mutable std::mutex lock_;
224220
// condition to wake up the queue's thread
225221
std::condition_variable cond_;
222+
223+
// This is an early-exit hint for FindTimelineWaitWithoutResolvingSignal.
224+
// Concurrent updates are safe: the counter can temporarily be larger than the
225+
// actual wait count, but not smaller, which is required for correctness.
226+
// FindTimelineWaitWithoutResolvingSignal cannot miss unresolved timeline waits,
227+
// but it can iterate a bit longer.
228+
std::atomic_uint32_t timeline_wait_count_ = 0;
226229
};
227230

228231
class QueueSubState {

0 commit comments

Comments
 (0)