reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 8 | #include "src/gpu/GrRenderTargetOpList.h" |
| 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/private/GrRecordingContext.h" |
| 11 | #include "src/core/SkExchange.h" |
| 12 | #include "src/core/SkRectPriv.h" |
| 13 | #include "src/core/SkTraceEvent.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 14 | #include "src/gpu/GrAuditTrail.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/gpu/GrCaps.h" |
| 16 | #include "src/gpu/GrGpu.h" |
| 17 | #include "src/gpu/GrGpuCommandBuffer.h" |
| 18 | #include "src/gpu/GrMemoryPool.h" |
| 19 | #include "src/gpu/GrRecordingContextPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/GrRenderTargetContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 21 | #include "src/gpu/GrResourceAllocator.h" |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 22 | #include "src/gpu/GrTexturePriv.h" |
Michael Ludwig | 663afe5 | 2019-06-03 16:46:19 -0400 | [diff] [blame] | 23 | #include "src/gpu/geometry/GrRect.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 24 | #include "src/gpu/ops/GrClearOp.h" |
| 25 | #include "src/gpu/ops/GrCopySurfaceOp.h" |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 26 | #include "src/gpu/ops/GrTransferFromOp.h" |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 27 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 28 | //////////////////////////////////////////////////////////////////////////////// |
| 29 | |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 30 | // Experimentally we have found that most combining occurs within the first 10 comparisons. |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 31 | static const int kMaxOpMergeDistance = 10; |
| 32 | static const int kMaxOpChainDistance = 10; |
| 33 | |
| 34 | //////////////////////////////////////////////////////////////////////////////// |
| 35 | |
| 36 | using DstProxy = GrXferProcessor::DstProxy; |
| 37 | |
| 38 | //////////////////////////////////////////////////////////////////////////////// |
| 39 | |
| 40 | static inline bool can_reorder(const SkRect& a, const SkRect& b) { return !GrRectsOverlap(a, b); } |
| 41 | |
| 42 | //////////////////////////////////////////////////////////////////////////////// |
| 43 | |
| 44 | inline GrRenderTargetOpList::OpChain::List::List(std::unique_ptr<GrOp> op) |
| 45 | : fHead(std::move(op)), fTail(fHead.get()) { |
| 46 | this->validate(); |
| 47 | } |
| 48 | |
| 49 | inline GrRenderTargetOpList::OpChain::List::List(List&& that) { *this = std::move(that); } |
| 50 | |
| 51 | inline GrRenderTargetOpList::OpChain::List& GrRenderTargetOpList::OpChain::List::operator=( |
| 52 | List&& that) { |
| 53 | fHead = std::move(that.fHead); |
| 54 | fTail = that.fTail; |
| 55 | that.fTail = nullptr; |
| 56 | this->validate(); |
| 57 | return *this; |
| 58 | } |
| 59 | |
| 60 | inline std::unique_ptr<GrOp> GrRenderTargetOpList::OpChain::List::popHead() { |
| 61 | SkASSERT(fHead); |
| 62 | auto temp = fHead->cutChain(); |
| 63 | std::swap(temp, fHead); |
| 64 | if (!fHead) { |
| 65 | SkASSERT(fTail == temp.get()); |
| 66 | fTail = nullptr; |
| 67 | } |
| 68 | return temp; |
| 69 | } |
| 70 | |
| 71 | inline std::unique_ptr<GrOp> GrRenderTargetOpList::OpChain::List::removeOp(GrOp* op) { |
| 72 | #ifdef SK_DEBUG |
| 73 | auto head = op; |
| 74 | while (head->prevInChain()) { head = head->prevInChain(); } |
| 75 | SkASSERT(head == fHead.get()); |
| 76 | #endif |
| 77 | auto prev = op->prevInChain(); |
| 78 | if (!prev) { |
| 79 | SkASSERT(op == fHead.get()); |
| 80 | return this->popHead(); |
| 81 | } |
| 82 | auto temp = prev->cutChain(); |
| 83 | if (auto next = temp->cutChain()) { |
| 84 | prev->chainConcat(std::move(next)); |
| 85 | } else { |
| 86 | SkASSERT(fTail == op); |
| 87 | fTail = prev; |
| 88 | } |
| 89 | this->validate(); |
| 90 | return temp; |
| 91 | } |
| 92 | |
| 93 | inline void GrRenderTargetOpList::OpChain::List::pushHead(std::unique_ptr<GrOp> op) { |
| 94 | SkASSERT(op); |
| 95 | SkASSERT(op->isChainHead()); |
| 96 | SkASSERT(op->isChainTail()); |
| 97 | if (fHead) { |
| 98 | op->chainConcat(std::move(fHead)); |
| 99 | fHead = std::move(op); |
| 100 | } else { |
| 101 | fHead = std::move(op); |
| 102 | fTail = fHead.get(); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | inline void GrRenderTargetOpList::OpChain::List::pushTail(std::unique_ptr<GrOp> op) { |
| 107 | SkASSERT(op->isChainTail()); |
| 108 | fTail->chainConcat(std::move(op)); |
| 109 | fTail = fTail->nextInChain(); |
| 110 | } |
| 111 | |
| 112 | inline void GrRenderTargetOpList::OpChain::List::validate() const { |
| 113 | #ifdef SK_DEBUG |
| 114 | if (fHead) { |
| 115 | SkASSERT(fTail); |
| 116 | fHead->validateChain(fTail); |
| 117 | } |
| 118 | #endif |
| 119 | } |
| 120 | |
| 121 | //////////////////////////////////////////////////////////////////////////////// |
| 122 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 123 | GrRenderTargetOpList::OpChain::OpChain(std::unique_ptr<GrOp> op, |
| 124 | GrProcessorSet::Analysis processorAnalysis, |
| 125 | GrAppliedClip* appliedClip, const DstProxy* dstProxy) |
| 126 | : fList{std::move(op)} |
| 127 | , fProcessorAnalysis(processorAnalysis) |
| 128 | , fAppliedClip(appliedClip) { |
| 129 | if (fProcessorAnalysis.requiresDstTexture()) { |
| 130 | SkASSERT(dstProxy && dstProxy->proxy()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 131 | fDstProxy = *dstProxy; |
| 132 | } |
| 133 | fBounds = fList.head()->bounds(); |
| 134 | } |
| 135 | |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 136 | void GrRenderTargetOpList::OpChain::visitProxies(const GrOp::VisitProxyFunc& func) const { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 137 | if (fList.empty()) { |
| 138 | return; |
| 139 | } |
| 140 | for (const auto& op : GrOp::ChainRange<>(fList.head())) { |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 141 | op.visitProxies(func); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 142 | } |
| 143 | if (fDstProxy.proxy()) { |
Chris Dalton | 7eb5c0f | 2019-05-23 15:15:47 -0600 | [diff] [blame] | 144 | func(fDstProxy.proxy(), GrMipMapped::kNo); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 145 | } |
| 146 | if (fAppliedClip) { |
| 147 | fAppliedClip->visitProxies(func); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | void GrRenderTargetOpList::OpChain::deleteOps(GrOpMemoryPool* pool) { |
| 152 | while (!fList.empty()) { |
| 153 | pool->release(fList.popHead()); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // Concatenates two op chains and attempts to merge ops across the chains. Assumes that we know that |
| 158 | // the two chains are chainable. Returns the new chain. |
| 159 | GrRenderTargetOpList::OpChain::List GrRenderTargetOpList::OpChain::DoConcat( |
| 160 | List chainA, List chainB, const GrCaps& caps, GrOpMemoryPool* pool, |
| 161 | GrAuditTrail* auditTrail) { |
| 162 | // We process ops in chain b from head to tail. We attempt to merge with nodes in a, starting |
| 163 | // at chain a's tail and working toward the head. We produce one of the following outcomes: |
| 164 | // 1) b's head is merged into an op in a. |
| 165 | // 2) An op from chain a is merged into b's head. (In this case b's head gets processed again.) |
| 166 | // 3) b's head is popped from chain a and added at the tail of a. |
| 167 | // After result 3 we don't want to attempt to merge the next head of b with the new tail of a, |
| 168 | // as we assume merges were already attempted when chain b was created. So we keep track of the |
| 169 | // original tail of a and start our iteration of a there. We also track the bounds of the nodes |
| 170 | // appended to chain a that will be skipped for bounds testing. If the original tail of a is |
| 171 | // merged into an op in b (case 2) then we advance the "original tail" towards the head of a. |
| 172 | GrOp* origATail = chainA.tail(); |
| 173 | SkRect skipBounds = SkRectPriv::MakeLargestInverted(); |
| 174 | do { |
| 175 | int numMergeChecks = 0; |
| 176 | bool merged = false; |
| 177 | bool noSkip = (origATail == chainA.tail()); |
| 178 | SkASSERT(noSkip == (skipBounds == SkRectPriv::MakeLargestInverted())); |
| 179 | bool canBackwardMerge = noSkip || can_reorder(chainB.head()->bounds(), skipBounds); |
| 180 | SkRect forwardMergeBounds = skipBounds; |
| 181 | GrOp* a = origATail; |
| 182 | while (a) { |
| 183 | bool canForwardMerge = |
| 184 | (a == chainA.tail()) || can_reorder(a->bounds(), forwardMergeBounds); |
| 185 | if (canForwardMerge || canBackwardMerge) { |
| 186 | auto result = a->combineIfPossible(chainB.head(), caps); |
| 187 | SkASSERT(result != GrOp::CombineResult::kCannotCombine); |
| 188 | merged = (result == GrOp::CombineResult::kMerged); |
Robert Phillips | 9548c3b42 | 2019-01-08 12:35:43 -0500 | [diff] [blame] | 189 | GrOP_INFO("\t\t: (%s opID: %u) -> Combining with (%s, opID: %u)\n", |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 190 | chainB.head()->name(), chainB.head()->uniqueID(), a->name(), |
| 191 | a->uniqueID()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 192 | } |
| 193 | if (merged) { |
Brian Salomon | 52a6ed3 | 2018-11-26 10:30:58 -0500 | [diff] [blame] | 194 | GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(auditTrail, a, chainB.head()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 195 | if (canBackwardMerge) { |
| 196 | pool->release(chainB.popHead()); |
| 197 | } else { |
| 198 | // We merged the contents of b's head into a. We will replace b's head with a in |
| 199 | // chain b. |
| 200 | SkASSERT(canForwardMerge); |
| 201 | if (a == origATail) { |
| 202 | origATail = a->prevInChain(); |
| 203 | } |
| 204 | std::unique_ptr<GrOp> detachedA = chainA.removeOp(a); |
| 205 | pool->release(chainB.popHead()); |
| 206 | chainB.pushHead(std::move(detachedA)); |
| 207 | if (chainA.empty()) { |
| 208 | // We merged all the nodes in chain a to chain b. |
| 209 | return chainB; |
| 210 | } |
| 211 | } |
| 212 | break; |
| 213 | } else { |
| 214 | if (++numMergeChecks == kMaxOpMergeDistance) { |
| 215 | break; |
| 216 | } |
| 217 | forwardMergeBounds.joinNonEmptyArg(a->bounds()); |
| 218 | canBackwardMerge = |
| 219 | canBackwardMerge && can_reorder(chainB.head()->bounds(), a->bounds()); |
| 220 | a = a->prevInChain(); |
| 221 | } |
| 222 | } |
| 223 | // If we weren't able to merge b's head then pop b's head from chain b and make it the new |
| 224 | // tail of a. |
| 225 | if (!merged) { |
| 226 | chainA.pushTail(chainB.popHead()); |
| 227 | skipBounds.joinNonEmptyArg(chainA.tail()->bounds()); |
| 228 | } |
| 229 | } while (!chainB.empty()); |
| 230 | return chainA; |
| 231 | } |
| 232 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 233 | // Attempts to concatenate the given chain onto our own and merge ops across the chains. Returns |
| 234 | // whether the operation succeeded. On success, the provided list will be returned empty. |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 235 | bool GrRenderTargetOpList::OpChain::tryConcat( |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 236 | List* list, GrProcessorSet::Analysis processorAnalysis, const DstProxy& dstProxy, |
| 237 | const GrAppliedClip* appliedClip, const SkRect& bounds, const GrCaps& caps, |
| 238 | GrOpMemoryPool* pool, GrAuditTrail* auditTrail) { |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 239 | SkASSERT(!fList.empty()); |
| 240 | SkASSERT(!list->empty()); |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 241 | SkASSERT(fProcessorAnalysis.requiresDstTexture() == SkToBool(fDstProxy.proxy())); |
| 242 | SkASSERT(processorAnalysis.requiresDstTexture() == SkToBool(dstProxy.proxy())); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 243 | // All returns use explicit tuple constructor rather than {a, b} to work around old GCC bug. |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 244 | if (fList.head()->classID() != list->head()->classID() || |
| 245 | SkToBool(fAppliedClip) != SkToBool(appliedClip) || |
| 246 | (fAppliedClip && *fAppliedClip != *appliedClip) || |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 247 | (fProcessorAnalysis.requiresNonOverlappingDraws() != |
| 248 | processorAnalysis.requiresNonOverlappingDraws()) || |
| 249 | (fProcessorAnalysis.requiresNonOverlappingDraws() && |
| 250 | // Non-overlaping draws are only required when Ganesh will either insert a barrier, |
| 251 | // or read back a new dst texture between draws. In either case, we can neither |
| 252 | // chain nor combine overlapping Ops. |
| 253 | GrRectsTouchOrOverlap(fBounds, bounds)) || |
| 254 | (fProcessorAnalysis.requiresDstTexture() != processorAnalysis.requiresDstTexture()) || |
| 255 | (fProcessorAnalysis.requiresDstTexture() && fDstProxy != dstProxy)) { |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 256 | return false; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 257 | } |
Chris Dalton | ee21e6b | 2019-01-22 14:04:43 -0700 | [diff] [blame] | 258 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 259 | SkDEBUGCODE(bool first = true;) |
| 260 | do { |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 261 | switch (fList.tail()->combineIfPossible(list->head(), caps)) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 262 | case GrOp::CombineResult::kCannotCombine: |
| 263 | // If an op supports chaining then it is required that chaining is transitive and |
| 264 | // that if any two ops in two different chains can merge then the two chains |
| 265 | // may also be chained together. Thus, we should only hit this on the first |
| 266 | // iteration. |
| 267 | SkASSERT(first); |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 268 | return false; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 269 | case GrOp::CombineResult::kMayChain: |
Chris Dalton | ee21e6b | 2019-01-22 14:04:43 -0700 | [diff] [blame] | 270 | fList = DoConcat(std::move(fList), skstd::exchange(*list, List()), caps, pool, |
| 271 | auditTrail); |
| 272 | // The above exchange cleared out 'list'. The list needs to be empty now for the |
| 273 | // loop to terminate. |
| 274 | SkASSERT(list->empty()); |
| 275 | break; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 276 | case GrOp::CombineResult::kMerged: { |
Robert Phillips | 9548c3b42 | 2019-01-08 12:35:43 -0500 | [diff] [blame] | 277 | GrOP_INFO("\t\t: (%s opID: %u) -> Combining with (%s, opID: %u)\n", |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 278 | list->tail()->name(), list->tail()->uniqueID(), list->head()->name(), |
| 279 | list->head()->uniqueID()); |
| 280 | GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(auditTrail, fList.tail(), list->head()); |
| 281 | pool->release(list->popHead()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 282 | break; |
| 283 | } |
| 284 | } |
| 285 | SkDEBUGCODE(first = false); |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 286 | } while (!list->empty()); |
Chris Dalton | ee21e6b | 2019-01-22 14:04:43 -0700 | [diff] [blame] | 287 | |
| 288 | // The new ops were successfully merged and/or chained onto our own. |
| 289 | fBounds.joinPossiblyEmptyRect(bounds); |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 290 | return true; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | bool GrRenderTargetOpList::OpChain::prependChain(OpChain* that, const GrCaps& caps, |
| 294 | GrOpMemoryPool* pool, GrAuditTrail* auditTrail) { |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 295 | if (!that->tryConcat( |
| 296 | &fList, fProcessorAnalysis, fDstProxy, fAppliedClip, fBounds, caps, pool, auditTrail)) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 297 | this->validate(); |
| 298 | // append failed |
| 299 | return false; |
| 300 | } |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 301 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 302 | // 'that' owns the combined chain. Move it into 'this'. |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 303 | SkASSERT(fList.empty()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 304 | fList = std::move(that->fList); |
Chris Dalton | ee21e6b | 2019-01-22 14:04:43 -0700 | [diff] [blame] | 305 | fBounds = that->fBounds; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 306 | |
| 307 | that->fDstProxy.setProxy(nullptr); |
| 308 | if (that->fAppliedClip) { |
| 309 | for (int i = 0; i < that->fAppliedClip->numClipCoverageFragmentProcessors(); ++i) { |
| 310 | that->fAppliedClip->detachClipCoverageFragmentProcessor(i); |
| 311 | } |
| 312 | } |
| 313 | this->validate(); |
| 314 | return true; |
| 315 | } |
| 316 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 317 | std::unique_ptr<GrOp> GrRenderTargetOpList::OpChain::appendOp( |
| 318 | std::unique_ptr<GrOp> op, GrProcessorSet::Analysis processorAnalysis, |
| 319 | const DstProxy* dstProxy, const GrAppliedClip* appliedClip, const GrCaps& caps, |
| 320 | GrOpMemoryPool* pool, GrAuditTrail* auditTrail) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 321 | const GrXferProcessor::DstProxy noDstProxy; |
| 322 | if (!dstProxy) { |
| 323 | dstProxy = &noDstProxy; |
| 324 | } |
| 325 | SkASSERT(op->isChainHead() && op->isChainTail()); |
| 326 | SkRect opBounds = op->bounds(); |
| 327 | List chain(std::move(op)); |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 328 | if (!this->tryConcat( |
| 329 | &chain, processorAnalysis, *dstProxy, appliedClip, opBounds, caps, pool, auditTrail)) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 330 | // append failed, give the op back to the caller. |
| 331 | this->validate(); |
| 332 | return chain.popHead(); |
| 333 | } |
Chris Dalton | 6f6ae6a | 2019-01-18 12:10:36 -0700 | [diff] [blame] | 334 | |
| 335 | SkASSERT(chain.empty()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 336 | this->validate(); |
| 337 | return nullptr; |
| 338 | } |
| 339 | |
| 340 | inline void GrRenderTargetOpList::OpChain::validate() const { |
| 341 | #ifdef SK_DEBUG |
| 342 | fList.validate(); |
| 343 | for (const auto& op : GrOp::ChainRange<>(fList.head())) { |
| 344 | // Not using SkRect::contains because we allow empty rects. |
| 345 | SkASSERT(fBounds.fLeft <= op.bounds().fLeft && fBounds.fTop <= op.bounds().fTop && |
| 346 | fBounds.fRight >= op.bounds().fRight && fBounds.fBottom >= op.bounds().fBottom); |
| 347 | } |
| 348 | #endif |
| 349 | } |
| 350 | |
| 351 | //////////////////////////////////////////////////////////////////////////////// |
bsalomon | 489147c | 2015-12-14 12:13:09 -0800 | [diff] [blame] | 352 | |
Robert Phillips | 12c4629 | 2019-04-23 07:36:17 -0400 | [diff] [blame] | 353 | GrRenderTargetOpList::GrRenderTargetOpList(sk_sp<GrOpMemoryPool> opMemoryPool, |
Robert Phillips | 831a293 | 2019-04-12 17:18:39 -0400 | [diff] [blame] | 354 | sk_sp<GrRenderTargetProxy> proxy, |
Robert Phillips | 8185f59 | 2017-04-26 08:31:08 -0400 | [diff] [blame] | 355 | GrAuditTrail* auditTrail) |
Robert Phillips | 12c4629 | 2019-04-23 07:36:17 -0400 | [diff] [blame] | 356 | : INHERITED(std::move(opMemoryPool), std::move(proxy), auditTrail) |
Brian Salomon | c3833b4 | 2018-07-09 18:23:58 +0000 | [diff] [blame] | 357 | , fLastClipStackGenID(SK_InvalidUniqueID) |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 358 | SkDEBUGCODE(, fNumClips(0)) { |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame^] | 359 | if (GrTextureProxy* textureProxy = fTarget->asTextureProxy()) { |
| 360 | if (GrMipMapped::kYes == textureProxy->mipMapped()) { |
| 361 | textureProxy->markMipMapsDirty(); |
| 362 | } |
| 363 | } |
| 364 | fTarget->setLastRenderTask(this); |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 367 | void GrRenderTargetOpList::deleteOps() { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 368 | for (auto& chain : fOpChains) { |
| 369 | chain.deleteOps(fOpMemoryPool.get()); |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 370 | } |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 371 | fOpChains.reset(); |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 372 | } |
| 373 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 374 | GrRenderTargetOpList::~GrRenderTargetOpList() { |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 375 | this->deleteOps(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | //////////////////////////////////////////////////////////////////////////////// |
| 379 | |
robertphillips | 4beb5c1 | 2015-10-20 07:50:00 -0700 | [diff] [blame] | 380 | #ifdef SK_DEBUG |
Robert Phillips | 2748391 | 2018-04-20 12:43:18 -0400 | [diff] [blame] | 381 | void GrRenderTargetOpList::dump(bool printDependencies) const { |
| 382 | INHERITED::dump(printDependencies); |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 383 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 384 | SkDebugf("ops (%d):\n", fOpChains.count()); |
| 385 | for (int i = 0; i < fOpChains.count(); ++i) { |
robertphillips | 4beb5c1 | 2015-10-20 07:50:00 -0700 | [diff] [blame] | 386 | SkDebugf("*******************************\n"); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 387 | if (!fOpChains[i].head()) { |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 388 | SkDebugf("%d: <combined forward or failed instantiation>\n", i); |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 389 | } else { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 390 | SkDebugf("%d: %s\n", i, fOpChains[i].head()->name()); |
| 391 | SkRect bounds = fOpChains[i].bounds(); |
Brian Salomon | 9e50f7b | 2017-03-06 12:02:34 -0500 | [diff] [blame] | 392 | SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", bounds.fLeft, |
| 393 | bounds.fTop, bounds.fRight, bounds.fBottom); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 394 | for (const auto& op : GrOp::ChainRange<>(fOpChains[i].head())) { |
| 395 | SkString info = SkTabString(op.dumpInfo(), 1); |
| 396 | SkDebugf("%s\n", info.c_str()); |
| 397 | bounds = op.bounds(); |
| 398 | SkDebugf("\tClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", bounds.fLeft, |
| 399 | bounds.fTop, bounds.fRight, bounds.fBottom); |
| 400 | } |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 401 | } |
robertphillips | 4beb5c1 | 2015-10-20 07:50:00 -0700 | [diff] [blame] | 402 | } |
| 403 | } |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 404 | |
| 405 | void GrRenderTargetOpList::visitProxies_debugOnly(const GrOp::VisitProxyFunc& func) const { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 406 | for (const OpChain& chain : fOpChains) { |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 407 | chain.visitProxies(func); |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 408 | } |
| 409 | } |
Brian Salomon | c525d4f | 2018-09-17 15:48:20 -0400 | [diff] [blame] | 410 | |
robertphillips | 4beb5c1 | 2015-10-20 07:50:00 -0700 | [diff] [blame] | 411 | #endif |
| 412 | |
Brian Osman | 407b342 | 2017-08-22 15:01:32 -0400 | [diff] [blame] | 413 | void GrRenderTargetOpList::onPrepare(GrOpFlushState* flushState) { |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 414 | SkASSERT(fTarget->peekRenderTarget()); |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 415 | SkASSERT(this->isClosed()); |
Stan Iliev | 2af578d | 2017-08-16 13:00:28 -0400 | [diff] [blame] | 416 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
Brian Salomon | 5f39427 | 2019-07-02 14:07:49 -0400 | [diff] [blame] | 417 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
Stan Iliev | 2af578d | 2017-08-16 13:00:28 -0400 | [diff] [blame] | 418 | #endif |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 419 | |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 420 | // Loop over the ops that haven't yet been prepared. |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 421 | for (const auto& chain : fOpChains) { |
| 422 | if (chain.head()) { |
Stan Iliev | 2af578d | 2017-08-16 13:00:28 -0400 | [diff] [blame] | 423 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
Brian Salomon | 5f39427 | 2019-07-02 14:07:49 -0400 | [diff] [blame] | 424 | TRACE_EVENT0("skia.gpu", chain.head()->name()); |
Stan Iliev | 2af578d | 2017-08-16 13:00:28 -0400 | [diff] [blame] | 425 | #endif |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 426 | GrOpFlushState::OpArgs opArgs = { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 427 | chain.head(), |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 428 | fTarget->asRenderTargetProxy(), |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 429 | chain.appliedClip(), |
Greg Daniel | 2c3398d | 2019-06-19 11:58:01 -0400 | [diff] [blame] | 430 | fTarget.get()->asRenderTargetProxy()->outputSwizzle(), |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 431 | chain.dstProxy() |
Robert Phillips | 318c419 | 2017-05-17 09:36:38 -0400 | [diff] [blame] | 432 | }; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 433 | flushState->setOpArgs(&opArgs); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 434 | chain.head()->prepare(flushState); |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 435 | flushState->setOpArgs(nullptr); |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 436 | } |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 437 | } |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 438 | } |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 439 | |
Michael Ludwig | 6e17f1d | 2019-05-15 14:00:20 +0000 | [diff] [blame] | 440 | static GrGpuRTCommandBuffer* create_command_buffer(GrGpu* gpu, |
| 441 | GrRenderTarget* rt, |
| 442 | GrSurfaceOrigin origin, |
| 443 | const SkRect& bounds, |
| 444 | GrLoadOp colorLoadOp, |
| 445 | const SkPMColor4f& loadClearColor, |
| 446 | GrLoadOp stencilLoadOp) { |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 447 | const GrGpuRTCommandBuffer::LoadAndStoreInfo kColorLoadStoreInfo { |
Robert Phillips | 6b47c7d | 2017-08-29 07:24:09 -0400 | [diff] [blame] | 448 | colorLoadOp, |
| 449 | GrStoreOp::kStore, |
| 450 | loadClearColor |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 451 | }; |
| 452 | |
Robert Phillips | 9521447 | 2017-08-08 18:00:03 -0400 | [diff] [blame] | 453 | // TODO: |
| 454 | // We would like to (at this level) only ever clear & discard. We would need |
| 455 | // to stop splitting up higher level opLists for copyOps to achieve that. |
| 456 | // Note: we would still need SB loads and stores but they would happen at a |
| 457 | // lower level (inside the VK command buffer). |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 458 | const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo stencilLoadAndStoreInfo { |
Robert Phillips | 6b47c7d | 2017-08-29 07:24:09 -0400 | [diff] [blame] | 459 | stencilLoadOp, |
Michael Ludwig | 6e17f1d | 2019-05-15 14:00:20 +0000 | [diff] [blame] | 460 | GrStoreOp::kStore, |
Robert Phillips | 9521447 | 2017-08-08 18:00:03 -0400 | [diff] [blame] | 461 | }; |
| 462 | |
Ethan Nicholas | 56d19a5 | 2018-10-15 11:26:20 -0400 | [diff] [blame] | 463 | return gpu->getCommandBuffer(rt, origin, bounds, kColorLoadStoreInfo, stencilLoadAndStoreInfo); |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 464 | } |
| 465 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 466 | // TODO: this is where GrOp::renderTarget is used (which is fine since it |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 467 | // is at flush time). However, we need to store the RenderTargetProxy in the |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 468 | // Ops and instantiate them here. |
Brian Osman | 407b342 | 2017-08-22 15:01:32 -0400 | [diff] [blame] | 469 | bool GrRenderTargetOpList::onExecute(GrOpFlushState* flushState) { |
Greg Daniel | dbdba60 | 2018-04-20 11:52:43 -0400 | [diff] [blame] | 470 | // TODO: Forcing the execution of the discard here isn't ideal since it will cause us to do a |
| 471 | // discard and then store the data back in memory so that the load op on future draws doesn't |
| 472 | // think the memory is unitialized. Ideally we would want a system where we are tracking whether |
| 473 | // the proxy itself has valid data or not, and then use that as a signal on whether we should be |
| 474 | // loading or discarding. In that world we wouldni;t need to worry about executing oplists with |
| 475 | // no ops just to do a discard. |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 476 | if (fOpChains.empty() && GrLoadOp::kClear != fColorLoadOp && |
Greg Daniel | dbdba60 | 2018-04-20 11:52:43 -0400 | [diff] [blame] | 477 | GrLoadOp::kDiscard != fColorLoadOp) { |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 478 | // TEMPORARY: We are in the process of moving GrMipMapsStatus from the texture to the proxy. |
| 479 | // During this time we want to assert that the proxy resolves mipmaps at the exact same |
| 480 | // times the old code would have. A null opList is very exceptional, and the proxy will have |
| 481 | // assumed mipmaps are dirty in this scenario. We mark them dirty here on the texture as |
| 482 | // well, in order to keep the assert passing. |
| 483 | GrTexture* tex = fTarget->peekTexture(); |
| 484 | if (tex && GrMipMapped::kYes == tex->texturePriv().mipMapped()) { |
| 485 | tex->texturePriv().markMipMapsDirty(); |
| 486 | } |
bsalomon | dc43898 | 2016-08-31 11:53:49 -0700 | [diff] [blame] | 487 | return false; |
egdaniel | b4021cf | 2016-07-28 08:53:07 -0700 | [diff] [blame] | 488 | } |
Robert Phillips | 4a39504 | 2017-04-24 16:27:17 +0000 | [diff] [blame] | 489 | |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 490 | SkASSERT(fTarget->peekRenderTarget()); |
Brian Salomon | 5f39427 | 2019-07-02 14:07:49 -0400 | [diff] [blame] | 491 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 492 | |
Michael Ludwig | 6e17f1d | 2019-05-15 14:00:20 +0000 | [diff] [blame] | 493 | // TODO: at the very least, we want the stencil store op to always be discard (at this |
| 494 | // level). In Vulkan, sub-command buffers would still need to load & store the stencil buffer. |
| 495 | |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 496 | // Make sure load ops are not kClear if the GPU needs to use draws for clears |
| 497 | SkASSERT(fColorLoadOp != GrLoadOp::kClear || |
| 498 | !flushState->gpu()->caps()->performColorClearsAsDraws()); |
| 499 | SkASSERT(fStencilLoadOp != GrLoadOp::kClear || |
| 500 | !flushState->gpu()->caps()->performStencilClearsAsDraws()); |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 501 | GrGpuRTCommandBuffer* commandBuffer = create_command_buffer( |
Michael Ludwig | 6e17f1d | 2019-05-15 14:00:20 +0000 | [diff] [blame] | 502 | flushState->gpu(), |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 503 | fTarget->peekRenderTarget(), |
| 504 | fTarget->origin(), |
| 505 | fTarget->getBoundsRect(), |
Michael Ludwig | 6e17f1d | 2019-05-15 14:00:20 +0000 | [diff] [blame] | 506 | fColorLoadOp, |
| 507 | fLoadClearColor, |
| 508 | fStencilLoadOp); |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 509 | flushState->setCommandBuffer(commandBuffer); |
Robert Phillips | 9521447 | 2017-08-08 18:00:03 -0400 | [diff] [blame] | 510 | commandBuffer->begin(); |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 511 | |
| 512 | // Draw all the generated geometry. |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 513 | for (const auto& chain : fOpChains) { |
| 514 | if (!chain.head()) { |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 515 | continue; |
| 516 | } |
Stan Iliev | 2af578d | 2017-08-16 13:00:28 -0400 | [diff] [blame] | 517 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
Brian Salomon | 5f39427 | 2019-07-02 14:07:49 -0400 | [diff] [blame] | 518 | TRACE_EVENT0("skia.gpu", chain.head()->name()); |
Stan Iliev | 2af578d | 2017-08-16 13:00:28 -0400 | [diff] [blame] | 519 | #endif |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 520 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 521 | GrOpFlushState::OpArgs opArgs { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 522 | chain.head(), |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 523 | fTarget->asRenderTargetProxy(), |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 524 | chain.appliedClip(), |
Greg Daniel | 2c3398d | 2019-06-19 11:58:01 -0400 | [diff] [blame] | 525 | fTarget.get()->asRenderTargetProxy()->outputSwizzle(), |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 526 | chain.dstProxy() |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 527 | }; |
| 528 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 529 | flushState->setOpArgs(&opArgs); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 530 | chain.head()->execute(flushState, chain.bounds()); |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 531 | flushState->setOpArgs(nullptr); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 532 | } |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 533 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 534 | commandBuffer->end(); |
| 535 | flushState->gpu()->submit(commandBuffer); |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 536 | flushState->setCommandBuffer(nullptr); |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 537 | |
bsalomon | dc43898 | 2016-08-31 11:53:49 -0700 | [diff] [blame] | 538 | return true; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 539 | } |
| 540 | |
Chris Dalton | a84cacf | 2017-10-04 10:30:29 -0600 | [diff] [blame] | 541 | void GrRenderTargetOpList::endFlush() { |
Brian Salomon | c3833b4 | 2018-07-09 18:23:58 +0000 | [diff] [blame] | 542 | fLastClipStackGenID = SK_InvalidUniqueID; |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 543 | this->deleteOps(); |
Chris Dalton | c82dd4e | 2017-11-20 18:20:28 -0700 | [diff] [blame] | 544 | fClipAllocator.reset(); |
Chris Dalton | a84cacf | 2017-10-04 10:30:29 -0600 | [diff] [blame] | 545 | INHERITED::endFlush(); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Robert Phillips | 380b90c | 2017-08-30 07:41:07 -0400 | [diff] [blame] | 548 | void GrRenderTargetOpList::discard() { |
| 549 | // Discard calls to in-progress opLists are ignored. Calls at the start update the |
| 550 | // opLists' color & stencil load ops. |
| 551 | if (this->isEmpty()) { |
| 552 | fColorLoadOp = GrLoadOp::kDiscard; |
| 553 | fStencilLoadOp = GrLoadOp::kDiscard; |
| 554 | } |
| 555 | } |
| 556 | |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 557 | void GrRenderTargetOpList::setColorLoadOp(GrLoadOp op, const SkPMColor4f& color) { |
| 558 | fColorLoadOp = op; |
| 559 | fLoadClearColor = color; |
| 560 | } |
| 561 | |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 562 | bool GrRenderTargetOpList::resetForFullscreenClear(CanDiscardPreviousOps canDiscardPreviousOps) { |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 563 | // Mark the color load op as discard (this may be followed by a clearColorOnLoad call to make |
| 564 | // the load op kClear, or it may be followed by an explicit op). In the event of an absClear() |
| 565 | // after a regular clear(), we could end up with a clear load op and a real clear op in the list |
| 566 | // if the load op were not reset here. |
| 567 | fColorLoadOp = GrLoadOp::kDiscard; |
| 568 | |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 569 | // If we previously recorded a wait op, we cannot delete the wait op. Until we track the wait |
| 570 | // ops separately from normal ops, we have to avoid clearing out any ops in this case as well. |
| 571 | if (fHasWaitOp) { |
| 572 | canDiscardPreviousOps = CanDiscardPreviousOps::kNo; |
| 573 | } |
| 574 | |
| 575 | if (CanDiscardPreviousOps::kYes == canDiscardPreviousOps || this->isEmpty()) { |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 576 | this->deleteOps(); |
Brian Osman | 099fa0f | 2017-10-02 16:38:32 -0400 | [diff] [blame] | 577 | fDeferredProxies.reset(); |
Greg Daniel | 070cbaf | 2019-01-03 17:35:54 -0500 | [diff] [blame] | 578 | |
| 579 | // If the opList is using a render target which wraps a vulkan command buffer, we can't do a |
| 580 | // clear load since we cannot change the render pass that we are using. Thus we fall back to |
| 581 | // making a clear op in this case. |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 582 | return !fTarget->asRenderTargetProxy()->wrapsVkSecondaryCB(); |
bsalomon | fd8d013 | 2016-08-11 11:25:33 -0700 | [diff] [blame] | 583 | } |
Robert Phillips | 380b90c | 2017-08-30 07:41:07 -0400 | [diff] [blame] | 584 | |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 585 | // Could not empty the list, so an op must be added to handle the clear |
| 586 | return false; |
bsalomon | 9f129de | 2016-08-10 16:31:05 -0700 | [diff] [blame] | 587 | } |
| 588 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 589 | //////////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 590 | |
Robert Phillips | 81dd3e0 | 2017-06-23 11:59:24 -0400 | [diff] [blame] | 591 | // This closely parallels GrTextureOpList::copySurface but renderTargetOpLists |
| 592 | // also store the applied clip and dest proxy with the op |
Robert Phillips | be9aff2 | 2019-02-15 11:33:22 -0500 | [diff] [blame] | 593 | bool GrRenderTargetOpList::copySurface(GrRecordingContext* context, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 594 | GrSurfaceProxy* src, |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 595 | const SkIRect& srcRect, |
| 596 | const SkIPoint& dstPoint) { |
Chris Dalton | f8e5aad | 2019-08-02 12:55:23 -0600 | [diff] [blame] | 597 | std::unique_ptr<GrOp> op = GrCopySurfaceOp::Make( |
| 598 | context, fTarget.get(), src, srcRect, dstPoint); |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 599 | if (!op) { |
bsalomon | b8fea97 | 2016-02-16 07:34:17 -0800 | [diff] [blame] | 600 | return false; |
| 601 | } |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 602 | |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 603 | this->addOp(std::move(op), GrTextureResolveManager(context->priv().drawingManager()), |
| 604 | *context->priv().caps()); |
bsalomon | b8fea97 | 2016-02-16 07:34:17 -0800 | [diff] [blame] | 605 | return true; |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 606 | } |
| 607 | |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 608 | void GrRenderTargetOpList::transferFrom(GrRecordingContext* context, |
| 609 | const SkIRect& srcRect, |
Brian Salomon | f77c146 | 2019-08-01 15:19:29 -0400 | [diff] [blame] | 610 | GrColorType surfaceColorType, |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 611 | GrColorType dstColorType, |
| 612 | sk_sp<GrGpuBuffer> dst, |
| 613 | size_t dstOffset) { |
Brian Salomon | f77c146 | 2019-08-01 15:19:29 -0400 | [diff] [blame] | 614 | auto op = GrTransferFromOp::Make(context, srcRect, surfaceColorType, dstColorType, |
| 615 | std::move(dst), dstOffset); |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 616 | this->addOp(std::move(op), GrTextureResolveManager(context->priv().drawingManager()), |
| 617 | *context->priv().caps()); |
Brian Salomon | 4d2d6f4 | 2019-07-26 14:15:11 -0400 | [diff] [blame] | 618 | } |
| 619 | |
Chris Dalton | 6b49810 | 2019-08-01 14:14:52 -0600 | [diff] [blame] | 620 | void GrRenderTargetOpList::handleInternalAllocationFailure() { |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 621 | bool hasUninstantiatedProxy = false; |
Chris Dalton | 7eb5c0f | 2019-05-23 15:15:47 -0600 | [diff] [blame] | 622 | auto checkInstantiation = [&hasUninstantiatedProxy](GrSurfaceProxy* p, GrMipMapped) { |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 623 | if (!p->isInstantiated()) { |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 624 | hasUninstantiatedProxy = true; |
| 625 | } |
| 626 | }; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 627 | for (OpChain& recordedOp : fOpChains) { |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 628 | hasUninstantiatedProxy = false; |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 629 | recordedOp.visitProxies(checkInstantiation); |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 630 | if (hasUninstantiatedProxy) { |
| 631 | // When instantiation of the proxy fails we drop the Op |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 632 | recordedOp.deleteOps(fOpMemoryPool.get()); |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 633 | } |
| 634 | } |
| 635 | } |
| 636 | |
Robert Phillips | 9313aa7 | 2019-04-09 18:41:27 -0400 | [diff] [blame] | 637 | bool GrRenderTargetOpList::onIsUsed(GrSurfaceProxy* proxyToCheck) const { |
| 638 | bool used = false; |
| 639 | |
Chris Dalton | 7eb5c0f | 2019-05-23 15:15:47 -0600 | [diff] [blame] | 640 | auto visit = [ proxyToCheck, &used ] (GrSurfaceProxy* p, GrMipMapped) { |
Robert Phillips | 9313aa7 | 2019-04-09 18:41:27 -0400 | [diff] [blame] | 641 | if (p == proxyToCheck) { |
| 642 | used = true; |
| 643 | } |
| 644 | }; |
| 645 | for (const OpChain& recordedOp : fOpChains) { |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 646 | recordedOp.visitProxies(visit); |
Robert Phillips | 9313aa7 | 2019-04-09 18:41:27 -0400 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | return used; |
| 650 | } |
| 651 | |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 652 | void GrRenderTargetOpList::gatherProxyIntervals(GrResourceAllocator* alloc) const { |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 653 | |
Robert Phillips | 51b20f2 | 2017-12-01 15:32:35 -0500 | [diff] [blame] | 654 | for (int i = 0; i < fDeferredProxies.count(); ++i) { |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 655 | SkASSERT(!fDeferredProxies[i]->isInstantiated()); |
Robert Phillips | 51b20f2 | 2017-12-01 15:32:35 -0500 | [diff] [blame] | 656 | // We give all the deferred proxies a write usage at the very start of flushing. This |
| 657 | // locks them out of being reused for the entire flush until they are read - and then |
| 658 | // they can be recycled. This is a bit unfortunate because a flush can proceed in waves |
| 659 | // with sub-flushes. The deferred proxies only need to be pinned from the start of |
| 660 | // the sub-flush in which they appear. |
Robert Phillips | c73666f | 2019-04-24 08:49:48 -0400 | [diff] [blame] | 661 | alloc->addInterval(fDeferredProxies[i], 0, 0, GrResourceAllocator::ActualUse::kNo); |
Robert Phillips | 51b20f2 | 2017-12-01 15:32:35 -0500 | [diff] [blame] | 662 | } |
| 663 | |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 664 | // Add the interval for all the writes to this opList's target |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 665 | if (fOpChains.count()) { |
Robert Phillips | 3bf3d4a | 2019-03-27 07:09:09 -0400 | [diff] [blame] | 666 | unsigned int cur = alloc->curOp(); |
| 667 | |
Robert Phillips | c73666f | 2019-04-24 08:49:48 -0400 | [diff] [blame] | 668 | alloc->addInterval(fTarget.get(), cur, cur + fOpChains.count() - 1, |
| 669 | GrResourceAllocator::ActualUse::kYes); |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 670 | } else { |
| 671 | // This can happen if there is a loadOp (e.g., a clear) but no other draws. In this case we |
| 672 | // still need to add an interval for the destination so we create a fake op# for |
| 673 | // the missing clear op. |
Robert Phillips | c73666f | 2019-04-24 08:49:48 -0400 | [diff] [blame] | 674 | alloc->addInterval(fTarget.get(), alloc->curOp(), alloc->curOp(), |
| 675 | GrResourceAllocator::ActualUse::kYes); |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 676 | alloc->incOps(); |
| 677 | } |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 678 | |
Chris Dalton | 7eb5c0f | 2019-05-23 15:15:47 -0600 | [diff] [blame] | 679 | auto gather = [ alloc SkDEBUGCODE(, this) ] (GrSurfaceProxy* p, GrMipMapped) { |
Robert Phillips | c73666f | 2019-04-24 08:49:48 -0400 | [diff] [blame] | 680 | alloc->addInterval(p, alloc->curOp(), alloc->curOp(), GrResourceAllocator::ActualUse::kYes |
| 681 | SkDEBUGCODE(, fTarget.get() == p)); |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 682 | }; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 683 | for (const OpChain& recordedOp : fOpChains) { |
Brian Salomon | 7d94bb5 | 2018-10-12 14:37:19 -0400 | [diff] [blame] | 684 | // only diff from the GrTextureOpList version |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 685 | recordedOp.visitProxies(gather); |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 686 | |
Robert Phillips | 3bf3d4a | 2019-03-27 07:09:09 -0400 | [diff] [blame] | 687 | // Even though the op may have been (re)moved we still need to increment the op count to |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 688 | // keep all the math consistent. |
| 689 | alloc->incOps(); |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 690 | } |
| 691 | } |
| 692 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 693 | void GrRenderTargetOpList::recordOp( |
| 694 | std::unique_ptr<GrOp> op, GrProcessorSet::Analysis processorAnalysis, GrAppliedClip* clip, |
| 695 | const DstProxy* dstProxy, const GrCaps& caps) { |
Ethan Nicholas | 029b22c | 2018-10-18 16:49:56 -0400 | [diff] [blame] | 696 | SkDEBUGCODE(op->validate();) |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 697 | SkASSERT(processorAnalysis.requiresDstTexture() == (dstProxy && dstProxy->proxy())); |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 698 | SkASSERT(fTarget); |
Robert Phillips | ee68365 | 2017-04-26 11:53:10 -0400 | [diff] [blame] | 699 | |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 700 | // A closed GrOpList should never receive new/more ops |
robertphillips | 6a18665 | 2015-10-20 07:37:58 -0700 | [diff] [blame] | 701 | SkASSERT(!this->isClosed()); |
Brian Salomon | 19ec80f | 2018-11-16 13:27:30 -0500 | [diff] [blame] | 702 | if (!op->bounds().isFinite()) { |
| 703 | fOpMemoryPool->release(std::move(op)); |
| 704 | return; |
| 705 | } |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 706 | |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 707 | // Check if there is an op we can combine with by linearly searching back until we either |
| 708 | // 1) check every op |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 709 | // 2) intersect with something |
| 710 | // 3) find a 'blocker' |
Robert Phillips | b520476 | 2019-06-19 14:12:13 -0400 | [diff] [blame] | 711 | GR_AUDIT_TRAIL_ADD_OP(fAuditTrail, op.get(), fTarget->uniqueID()); |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 712 | GrOP_INFO("opList: %d Recording (%s, opID: %u)\n" |
| 713 | "\tBounds [L: %.2f, T: %.2f R: %.2f B: %.2f]\n", |
| 714 | this->uniqueID(), |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 715 | op->name(), |
| 716 | op->uniqueID(), |
Robert Phillips | 1119dc3 | 2017-04-11 12:54:57 -0400 | [diff] [blame] | 717 | op->bounds().fLeft, op->bounds().fTop, |
| 718 | op->bounds().fRight, op->bounds().fBottom); |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 719 | GrOP_INFO(SkTabString(op->dumpInfo(), 1).c_str()); |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 720 | GrOP_INFO("\tOutcome:\n"); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 721 | int maxCandidates = SkTMin(kMaxOpChainDistance, fOpChains.count()); |
Robert Phillips | 318c419 | 2017-05-17 09:36:38 -0400 | [diff] [blame] | 722 | if (maxCandidates) { |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 723 | int i = 0; |
| 724 | while (true) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 725 | OpChain& candidate = fOpChains.fromBack(i); |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 726 | op = candidate.appendOp(std::move(op), processorAnalysis, dstProxy, clip, caps, |
| 727 | fOpMemoryPool.get(), fAuditTrail); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 728 | if (!op) { |
| 729 | return; |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 730 | } |
Brian Salomon | a7682c8 | 2018-10-24 10:04:37 -0400 | [diff] [blame] | 731 | // Stop going backwards if we would cause a painter's order violation. |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 732 | if (!can_reorder(candidate.bounds(), op->bounds())) { |
| 733 | GrOP_INFO("\t\tBackward: Intersects with chain (%s, head opID: %u)\n", |
| 734 | candidate.head()->name(), candidate.head()->uniqueID()); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 735 | break; |
| 736 | } |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 737 | if (++i == maxCandidates) { |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 738 | GrOP_INFO("\t\tBackward: Reached max lookback or beginning of op array %d\n", i); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 739 | break; |
| 740 | } |
| 741 | } |
| 742 | } else { |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 743 | GrOP_INFO("\t\tBackward: FirstOp\n"); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 744 | } |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 745 | if (clip) { |
| 746 | clip = fClipAllocator.make<GrAppliedClip>(std::move(*clip)); |
Robert Phillips | c84c030 | 2017-05-08 15:35:11 -0400 | [diff] [blame] | 747 | SkDEBUGCODE(fNumClips++;) |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 748 | } |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 749 | fOpChains.emplace_back(std::move(op), processorAnalysis, clip, dstProxy); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 750 | } |
| 751 | |
Robert Phillips | ee68365 | 2017-04-26 11:53:10 -0400 | [diff] [blame] | 752 | void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) { |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 753 | SkASSERT(!this->isClosed()); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 754 | GrOP_INFO("opList: %d ForwardCombine %d ops:\n", this->uniqueID(), fOpChains.count()); |
Robert Phillips | 48567ac | 2017-06-01 08:46:00 -0400 | [diff] [blame] | 755 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 756 | for (int i = 0; i < fOpChains.count() - 1; ++i) { |
| 757 | OpChain& chain = fOpChains[i]; |
| 758 | int maxCandidateIdx = SkTMin(i + kMaxOpChainDistance, fOpChains.count() - 1); |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 759 | int j = i + 1; |
| 760 | while (true) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 761 | OpChain& candidate = fOpChains[j]; |
| 762 | if (candidate.prependChain(&chain, caps, fOpMemoryPool.get(), fAuditTrail)) { |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 763 | break; |
| 764 | } |
Robert Phillips | c84c030 | 2017-05-08 15:35:11 -0400 | [diff] [blame] | 765 | // Stop traversing if we would cause a painter's order violation. |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 766 | if (!can_reorder(chain.bounds(), candidate.bounds())) { |
| 767 | GrOP_INFO( |
| 768 | "\t\t%d: chain (%s head opID: %u) -> " |
| 769 | "Intersects with chain (%s, head opID: %u)\n", |
| 770 | i, chain.head()->name(), chain.head()->uniqueID(), candidate.head()->name(), |
| 771 | candidate.head()->uniqueID()); |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 772 | break; |
| 773 | } |
Brian Salomon | a7682c8 | 2018-10-24 10:04:37 -0400 | [diff] [blame] | 774 | if (++j > maxCandidateIdx) { |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 775 | GrOP_INFO("\t\t%d: chain (%s opID: %u) -> Reached max lookahead or end of array\n", |
| 776 | i, chain.head()->name(), chain.head()->uniqueID()); |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 777 | break; |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | |