/src/skia/tools/graphite/GraphiteTestContext.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2021 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 "tools/graphite/GraphiteTestContext.h" |
9 | | |
10 | | #include "include/gpu/graphite/Context.h" |
11 | | #include "include/gpu/graphite/GraphiteTypes.h" |
12 | | #include "include/gpu/graphite/Recording.h" |
13 | | #include "src/core/SkTraceEvent.h" |
14 | | #include "src/gpu/graphite/Caps.h" |
15 | | #include "src/gpu/graphite/ContextPriv.h" |
16 | | #include "tools/gpu/FlushFinishTracker.h" |
17 | | |
18 | | namespace skiatest::graphite { |
19 | | |
20 | 0 | GraphiteTestContext::GraphiteTestContext() {} |
21 | | |
22 | 0 | GraphiteTestContext::~GraphiteTestContext() {} |
23 | | |
24 | | void GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context* context, |
25 | 0 | skgpu::graphite::Recording* recording) { |
26 | 0 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
27 | 0 | SkASSERT(context); |
28 | 0 | SkASSERT(recording); |
29 | |
|
30 | 0 | if (fFinishTrackers[fCurrentFlushIdx]) { |
31 | 0 | fFinishTrackers[fCurrentFlushIdx]->waitTillFinished([this] { tick(); }); Unexecuted instantiation: GraphiteTestContext.cpp:skiatest::graphite::GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context*, skgpu::graphite::Recording*)::$_0::operator()() const Unexecuted instantiation: GraphiteTestContext.cpp:skiatest::graphite::GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context*, skgpu::graphite::Recording*)::$_2::operator()() const |
32 | 0 | } |
33 | |
|
34 | 0 | fFinishTrackers[fCurrentFlushIdx].reset(new sk_gpu_test::FlushFinishTracker(context)); |
35 | | |
36 | | // We add an additional ref to the current flush tracker here. This ref is owned by the finish |
37 | | // callback on the flush call. The finish callback will unref the tracker when called. |
38 | 0 | fFinishTrackers[fCurrentFlushIdx]->ref(); |
39 | |
|
40 | 0 | skgpu::graphite::InsertRecordingInfo info; |
41 | 0 | info.fRecording = recording; |
42 | 0 | info.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get(); |
43 | 0 | info.fFinishedProc = sk_gpu_test::FlushFinishTracker::FlushFinishedResult; |
44 | 0 | context->insertRecording(info); |
45 | |
|
46 | 0 | context->submit(skgpu::graphite::SyncToCpu::kNo); |
47 | |
|
48 | 0 | fCurrentFlushIdx = (fCurrentFlushIdx + 1) % std::size(fFinishTrackers); |
49 | 0 | } Unexecuted instantiation: skiatest::graphite::GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context*, skgpu::graphite::Recording*) Unexecuted instantiation: skiatest::graphite::GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context*, skgpu::graphite::Recording*) |
50 | | |
51 | 0 | void GraphiteTestContext::syncedSubmit(skgpu::graphite::Context* context) { |
52 | 0 | skgpu::graphite::SyncToCpu sync = context->priv().caps()->allowCpuSync() |
53 | 0 | ? skgpu::graphite::SyncToCpu::kYes |
54 | 0 | : skgpu::graphite::SyncToCpu::kNo; |
55 | 0 | context->submit(sync); |
56 | 0 | if (sync == skgpu::graphite::SyncToCpu::kNo) { |
57 | 0 | while (context->hasUnfinishedGpuWork()) { |
58 | 0 | this->tick(); |
59 | 0 | context->checkAsyncWorkCompletion(); |
60 | 0 | } |
61 | 0 | } |
62 | 0 | } |
63 | | |
64 | | } // namespace skiatest::graphite |