Greg Daniel | c30f1a9 | 2019-09-06 15:28:58 -0400 | [diff] [blame] | 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/GrWaitRenderTask.h" |
| 9 | |
| 10 | #include "src/gpu/GrGpu.h" |
| 11 | #include "src/gpu/GrOpFlushState.h" |
| 12 | #include "src/gpu/GrResourceAllocator.h" |
| 13 | |
| 14 | void 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 Holler | 33d569e | 2020-06-16 14:30:08 -0400 | [diff] [blame] | 17 | // we manipulate our target's proxy. |
| 18 | SkASSERT(0 == this->numTargets()); |
| 19 | auto fakeOp = alloc->curOp(); |
Adlai Holler | 7f7a5df | 2021-02-09 17:41:10 +0000 | [diff] [blame] | 20 | alloc->addInterval(fWaitedOn.proxy(), fakeOp, fakeOp, |
| 21 | GrResourceAllocator::ActualUse::kYes); |
Greg Daniel | c30f1a9 | 2019-09-06 15:28:58 -0400 | [diff] [blame] | 22 | alloc->incOps(); |
| 23 | } |
| 24 | |
| 25 | bool GrWaitRenderTask::onExecute(GrOpFlushState* flushState) { |
| 26 | for (int i = 0; i < fNumSemaphores; ++i) { |
Greg Daniel | 0106fcc | 2020-07-01 17:40:12 -0400 | [diff] [blame] | 27 | // If we don't have a semaphore here it means we failed to wrap it. That happens if the |
| 28 | // client didn't give us a valid semaphore to begin with. Therefore, it is fine to not wait |
| 29 | // on it. |
John Stiles | a008b0f | 2020-08-16 08:48:02 -0400 | [diff] [blame] | 30 | if (fSemaphores[i]) { |
Greg Daniel | 0106fcc | 2020-07-01 17:40:12 -0400 | [diff] [blame] | 31 | flushState->gpu()->waitSemaphore(fSemaphores[i].get()); |
| 32 | } |
Greg Daniel | c30f1a9 | 2019-09-06 15:28:58 -0400 | [diff] [blame] | 33 | } |
| 34 | return true; |
| 35 | } |