| 1 |
/* |
| 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/ganesh/GrWaitRenderTask.h" |
| 9 |
|
| 10 |
#include "include/private/base/SkAssert.h" |
| 11 |
#include "src/gpu/ganesh/GrGpu.h" |
| 12 |
#include "src/gpu/ganesh/GrOpFlushState.h" |
| 13 |
#include "src/gpu/ganesh/GrResourceAllocator.h" |
| 14 |
|
| 15 |
void GrWaitRenderTask::gatherProxyIntervals(GrResourceAllocator* alloc) const { |
| 16 |
// This renderTask doesn't have "normal" ops. In this case we still need to add an interval (so |
| 17 |
// fEndOfOpsTaskOpIndices will remain in sync), so we create a fake op# to capture the fact that |
| 18 |
// we manipulate our target's proxy. |
| 19 |
SkASSERT(0 == this->numTargets()); |
| 20 |
auto fakeOp = alloc->curOp(); |
| 21 |
alloc->addInterval(fWaitedOn.proxy(), fakeOp, fakeOp, |
| 22 |
GrResourceAllocator::ActualUse::kYes, |
| 23 |
GrResourceAllocator::AllowRecycling::kYes); |
| 24 |
alloc->incOps(); |
| 25 |
} |
| 26 |
|
| 27 |
bool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) { |
| 28 |
for (int i = 0; i < fNumSemaphores; ++i) { |
| 29 |
// If we don't have a semaphore here it means we failed to wrap it. That happens if the |
| 30 |
// client didn't give us a valid semaphore to begin with. Therefore, it is fine to not wait |
| 31 |
// on it. |
| 32 |
if (fSemaphores[i]) { |
| 33 |
flushState->gpu()->waitSemaphore(fSemaphores[i].get()); |
| 34 |
} |
| 35 |
} |
| 36 |
return true; |
| 37 |
} |