blob: 93fe6de9cf5837a36ea9705777ea11d0e7b8036d [file] [log] [blame]
Greg Danielc30f1a92019-09-06 15:28:58 -04001/*
2 * Copyright 2019 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/GrWaitRenderTask.h"
9
10#include "src/gpu/GrGpu.h"
11#include "src/gpu/GrOpFlushState.h"
12#include "src/gpu/GrResourceAllocator.h"
13
14void GrWaitRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
15 // This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so
16 // fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that
Adlai Holler33d569e2020-06-16 14:30:08 -040017 // we manipulate our target's proxy.
18 SkASSERT(0 == this->numTargets());
19 auto fakeOp = alloc->curOp();
Adlai Hollerb80fb082021-02-08 12:47:00 -050020 alloc->addInterval(fWaitedOn.proxy(), fakeOp, fakeOp);
Greg Danielc30f1a92019-09-06 15:28:58 -040021 alloc->incOps();
22}
23
24bool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) {
25 for (int i = 0; i < fNumSemaphores; ++i) {
Greg Daniel0106fcc2020-07-01 17:40:12 -040026 // If we don't have a semaphore here it means we failed to wrap it. That happens if the
27 // client didn't give us a valid semaphore to begin with. Therefore, it is fine to not wait
28 // on it.
John Stilesa008b0f2020-08-16 08:48:02 -040029 if (fSemaphores[i]) {
Greg Daniel0106fcc2020-07-01 17:40:12 -040030 flushState->gpu()->waitSemaphore(fSemaphores[i].get());
31 }
Greg Danielc30f1a92019-09-06 15:28:58 -040032 }
33 return true;
34}