Debian Codegraph @

src/gpu/graphite/dawn/DawnAsyncWait.cpp

raw
1 /*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/gpu/graphite/dawn/DawnAsyncWait.h"
9
10 #include "src/gpu/graphite/Caps.h"
11 #include "src/gpu/graphite/dawn/DawnSharedContext.h"
12
13 namespace skgpu::graphite {
14
15 DawnAsyncWait::DawnAsyncWait(const DawnSharedContext* sharedContext)
16 : fSharedContext(sharedContext)
17 , fSignaled(false) {}
18
19 bool DawnAsyncWait::yieldAndCheck() const {
20 if (fSharedContext->hasTick()) {
21 if (fSignaled.load(std::memory_order_acquire)) {
22 return true;
23 }
24
25 fSharedContext->tick();
26 }
27 return fSignaled.load(std::memory_order_acquire);
28 }
29
30 bool DawnAsyncWait::mayBusyWait() const { return fSharedContext->caps()->allowCpuSync(); }
31
32 void DawnAsyncWait::busyWait() const {
33 SkASSERT(fSharedContext->hasTick());
34 while (!this->yieldAndCheck()) {}
35 }
36
37 } // namespace skgpu::graphite