bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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. |
| 6 | */ |
| 7 | |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 8 | #ifndef GrOpFlushState_DEFINED |
| 9 | #define GrOpFlushState_DEFINED |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 10 | |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 11 | #include "GrAppliedClip.h" |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 12 | #include "GrBufferAllocPool.h" |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 13 | #include "SkArenaAlloc.h" |
Brian Salomon | 8952743 | 2016-12-16 09:52:16 -0500 | [diff] [blame] | 14 | #include "ops/GrMeshDrawOp.h" |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 15 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 16 | class GrGpu; |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 17 | class GrGpuCommandBuffer; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 18 | class GrResourceProvider; |
| 19 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 20 | /** Tracks the state across all the GrOps (really just the GrDrawOps) in a GrOpList flush. */ |
| 21 | class GrOpFlushState { |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 22 | public: |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 23 | GrOpFlushState(GrGpu*, GrResourceProvider*); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 24 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 25 | ~GrOpFlushState() { this->reset(); } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 26 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 27 | /** Inserts an upload to be executed after all ops in the flush prepared their draws but before |
| 28 | the draws are executed to the backend 3D API. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 29 | void addASAPUpload(GrDrawOp::DeferredUploadFn&& upload) { |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 30 | fAsapUploads.emplace_back(std::move(upload)); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 33 | const GrCaps& caps() const; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 34 | GrResourceProvider* resourceProvider() const { return fResourceProvider; } |
| 35 | |
| 36 | /** Has the token been flushed to the backend 3D API. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 37 | bool hasDrawBeenFlushed(GrDrawOpUploadToken token) const { |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 38 | return token.fSequenceNumber <= fLastFlushedToken.fSequenceNumber; |
| 39 | } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 40 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 41 | /** Issue a token to an operation that is being enqueued. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 42 | GrDrawOpUploadToken issueDrawToken() { |
| 43 | return GrDrawOpUploadToken(++fLastIssuedToken.fSequenceNumber); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | /** Call every time a draw that was issued a token is flushed */ |
| 47 | void flushToken() { ++fLastFlushedToken.fSequenceNumber; } |
| 48 | |
| 49 | /** Gets the next draw token that will be issued. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 50 | GrDrawOpUploadToken nextDrawToken() const { |
| 51 | return GrDrawOpUploadToken(fLastIssuedToken.fSequenceNumber + 1); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 52 | } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 53 | |
| 54 | /** The last token flushed to all the way to the backend API. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 55 | GrDrawOpUploadToken nextTokenToFlush() const { |
| 56 | return GrDrawOpUploadToken(fLastFlushedToken.fSequenceNumber + 1); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 57 | } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 58 | |
| 59 | void* makeVertexSpace(size_t vertexSize, int vertexCount, |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 60 | const GrBuffer** buffer, int* startVertex); |
| 61 | uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* startIndex); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 62 | |
Brian Osman | 49b7b6f | 2017-06-20 14:43:58 -0400 | [diff] [blame] | 63 | void* makeVertexSpaceAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, |
| 64 | const GrBuffer** buffer, int* startVertex, int* actualVertexCount); |
| 65 | uint16_t* makeIndexSpaceAtLeast(int minIndexCount, int fallbackIndexCount, |
| 66 | const GrBuffer** buffer, int* startIndex, |
| 67 | int* actualIndexCount); |
| 68 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 69 | /** This is called after each op has a chance to prepare its draws and before the draws are |
| 70 | issued. */ |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 71 | void preIssueDraws() { |
| 72 | fVertexPool.unmap(); |
| 73 | fIndexPool.unmap(); |
| 74 | int uploadCount = fAsapUploads.count(); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 75 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 76 | for (int i = 0; i < uploadCount; i++) { |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 77 | this->doUpload(fAsapUploads[i]); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 78 | } |
| 79 | fAsapUploads.reset(); |
| 80 | } |
| 81 | |
Brian Salomon | 9bada54 | 2017-06-12 12:09:30 -0400 | [diff] [blame] | 82 | void doUpload(GrDrawOp::DeferredUploadFn&); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 83 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 84 | void putBackIndices(size_t indices) { fIndexPool.putBack(indices * sizeof(uint16_t)); } |
| 85 | |
| 86 | void putBackVertexSpace(size_t sizeInBytes) { fVertexPool.putBack(sizeInBytes); } |
| 87 | |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 88 | GrGpuCommandBuffer* commandBuffer() { return fCommandBuffer; } |
| 89 | void setCommandBuffer(GrGpuCommandBuffer* buffer) { fCommandBuffer = buffer; } |
| 90 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 91 | GrGpu* gpu() { return fGpu; } |
| 92 | |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 93 | void reset() { |
| 94 | fVertexPool.reset(); |
| 95 | fIndexPool.reset(); |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 96 | fPipelines.reset(); |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 99 | /** Additional data required on a per-op basis when executing GrDrawOps. */ |
| 100 | struct DrawOpArgs { |
Robert Phillips | 2890fbf | 2017-07-26 15:48:41 -0400 | [diff] [blame] | 101 | GrRenderTarget* renderTarget() const { return fProxy->priv().peekRenderTarget(); } |
| 102 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 103 | // TODO: do we still need the dst proxy here? |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 104 | GrRenderTargetProxy* fProxy; |
| 105 | GrAppliedClip* fAppliedClip; |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 106 | GrXferProcessor::DstProxy fDstProxy; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | void setDrawOpArgs(DrawOpArgs* opArgs) { fOpArgs = opArgs; } |
| 110 | |
| 111 | const DrawOpArgs& drawOpArgs() const { |
| 112 | SkASSERT(fOpArgs); |
| 113 | return *fOpArgs; |
| 114 | } |
| 115 | |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 116 | GrAppliedClip detachAppliedClip() { |
| 117 | SkASSERT(fOpArgs); |
| 118 | return fOpArgs->fAppliedClip ? std::move(*fOpArgs->fAppliedClip) : GrAppliedClip(); |
| 119 | } |
| 120 | |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 121 | template <typename... Args> |
Brian Salomon | 91326c3 | 2017-08-09 16:02:19 -0400 | [diff] [blame] | 122 | GrPipeline* allocPipeline(Args&&... args) { |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 123 | return fPipelines.make<GrPipeline>(std::forward<Args>(args)...); |
| 124 | } |
| 125 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 126 | private: |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 127 | GrGpu* fGpu; |
| 128 | GrResourceProvider* fResourceProvider; |
| 129 | GrGpuCommandBuffer* fCommandBuffer; |
| 130 | GrVertexBufferAllocPool fVertexPool; |
| 131 | GrIndexBufferAllocPool fIndexPool; |
| 132 | SkSTArray<4, GrDrawOp::DeferredUploadFn> fAsapUploads; |
| 133 | GrDrawOpUploadToken fLastIssuedToken; |
| 134 | GrDrawOpUploadToken fLastFlushedToken; |
| 135 | DrawOpArgs* fOpArgs; |
| 136 | SkArenaAlloc fPipelines{sizeof(GrPipeline) * 100}; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 137 | }; |
| 138 | |
| 139 | /** |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 140 | * A word about uploads and tokens: Ops should usually schedule their uploads to occur at the |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 141 | * begining of a frame whenever possible. These are called ASAP uploads. Of course, this requires |
| 142 | * that there are no draws that have yet to be flushed that rely on the old texture contents. In |
| 143 | * that case the ASAP upload would happen prior to the previous draw causing the draw to read the |
| 144 | * new (wrong) texture data. In that case they should schedule an inline upload. |
| 145 | * |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 146 | * Ops, in conjunction with helpers such as GrDrawOpAtlas, can use the token system to know |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 147 | * what the most recent draw was that referenced a resource (or portion of a resource). Each draw |
| 148 | * is assigned a token. A resource (or portion) can be tagged with the most recent draw's |
| 149 | * token. The target provides a facility for testing whether the draw corresponding to the token |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 150 | * has been flushed. If it has not been flushed then the op must perform an inline upload instead. |
| 151 | * When scheduling an inline upload the op provides the token of the draw that the upload must occur |
| 152 | * before. The upload will then occur between the draw that requires the new data but after the |
| 153 | * token that requires the old data. |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 154 | * |
Brian Salomon | dad2923 | 2016-12-01 16:40:24 -0500 | [diff] [blame] | 155 | * TODO: Currently the token/upload interface is spread over GrDrawOp, GrMeshDrawOp, |
| 156 | * GrDrawOp::Target, and GrMeshDrawOp::Target. However, the interface at the GrDrawOp level is not |
| 157 | * complete and isn't useful. We should push it down to GrMeshDrawOp until it is required at the |
| 158 | * GrDrawOp level. |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 159 | */ |
Brian Salomon | dad2923 | 2016-12-01 16:40:24 -0500 | [diff] [blame] | 160 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 161 | /** |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 162 | * GrDrawOp instances use this object to allocate space for their geometry and to issue the draws |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 163 | * that render their op. |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 164 | */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 165 | class GrDrawOp::Target { |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 166 | public: |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 167 | Target(GrOpFlushState* state, GrDrawOp* op) : fState(state), fOp(op) {} |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 168 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 169 | /** Returns the token of the draw that this upload will occur before. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 170 | GrDrawOpUploadToken addInlineUpload(DeferredUploadFn&& upload) { |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 171 | fOp->fInlineUploads.emplace_back(std::move(upload), fState->nextDrawToken()); |
| 172 | return fOp->fInlineUploads.back().fUploadBeforeToken; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 173 | } |
| 174 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 175 | /** Returns the token of the draw that this upload will occur before. Since ASAP uploads |
| 176 | are done first during a flush, this will be the first token since the most recent |
| 177 | flush. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 178 | GrDrawOpUploadToken addAsapUpload(DeferredUploadFn&& upload) { |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 179 | fState->addASAPUpload(std::move(upload)); |
| 180 | return fState->nextTokenToFlush(); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 181 | } |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 182 | |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 183 | bool hasDrawBeenFlushed(GrDrawOpUploadToken token) const { |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 184 | return fState->hasDrawBeenFlushed(token); |
| 185 | } |
| 186 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 187 | /** Gets the next draw token that will be issued by this target. This can be used by an op |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 188 | to record that the next draw it issues will use a resource (e.g. texture) while preparing |
| 189 | that draw. */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 190 | GrDrawOpUploadToken nextDrawToken() const { return fState->nextDrawToken(); } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 191 | |
| 192 | const GrCaps& caps() const { return fState->caps(); } |
| 193 | |
| 194 | GrResourceProvider* resourceProvider() const { return fState->resourceProvider(); } |
| 195 | |
| 196 | protected: |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 197 | GrDrawOp* op() { return fOp; } |
| 198 | GrOpFlushState* state() { return fState; } |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 199 | const GrOpFlushState* state() const { return fState; } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 200 | |
| 201 | private: |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 202 | GrOpFlushState* fState; |
| 203 | GrDrawOp* fOp; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 204 | }; |
| 205 | |
Brian Salomon | dad2923 | 2016-12-01 16:40:24 -0500 | [diff] [blame] | 206 | /** Extension of GrDrawOp::Target for use by GrMeshDrawOp. Adds the ability to create vertex |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 207 | draws. */ |
Brian Salomon | dad2923 | 2016-12-01 16:40:24 -0500 | [diff] [blame] | 208 | class GrMeshDrawOp::Target : public GrDrawOp::Target { |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 209 | public: |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 210 | Target(GrOpFlushState* state, GrMeshDrawOp* op) : INHERITED(state, op) {} |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 211 | |
Brian Salomon | d3ccb0a | 2017-04-03 10:38:00 -0400 | [diff] [blame] | 212 | void draw(const GrGeometryProcessor* gp, const GrPipeline* pipeline, const GrMesh& mesh); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 213 | |
| 214 | void* makeVertexSpace(size_t vertexSize, int vertexCount, |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 215 | const GrBuffer** buffer, int* startVertex) { |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 216 | return this->state()->makeVertexSpace(vertexSize, vertexCount, buffer, startVertex); |
| 217 | } |
| 218 | |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 219 | uint16_t* makeIndexSpace(int indexCount, const GrBuffer** buffer, int* startIndex) { |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 220 | return this->state()->makeIndexSpace(indexCount, buffer, startIndex); |
| 221 | } |
| 222 | |
Brian Osman | 49b7b6f | 2017-06-20 14:43:58 -0400 | [diff] [blame] | 223 | void* makeVertexSpaceAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, |
| 224 | const GrBuffer** buffer, int* startVertex, |
| 225 | int* actualVertexCount) { |
| 226 | return this->state()->makeVertexSpaceAtLeast(vertexSize, minVertexCount, |
| 227 | fallbackVertexCount, buffer, startVertex, |
| 228 | actualVertexCount); |
| 229 | } |
| 230 | |
| 231 | uint16_t* makeIndexSpaceAtLeast(int minIndexCount, int fallbackIndexCount, |
| 232 | const GrBuffer** buffer, int* startIndex, |
| 233 | int* actualIndexCount) { |
| 234 | return this->state()->makeIndexSpaceAtLeast(minIndexCount, fallbackIndexCount, buffer, |
| 235 | startIndex, actualIndexCount); |
| 236 | } |
| 237 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 238 | /** Helpers for ops which over-allocate and then return data to the pool. */ |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 239 | void putBackIndices(int indices) { this->state()->putBackIndices(indices); } |
| 240 | void putBackVertices(int vertices, size_t vertexStride) { |
| 241 | this->state()->putBackVertexSpace(vertices * vertexStride); |
| 242 | } |
| 243 | |
Robert Phillips | 2890fbf | 2017-07-26 15:48:41 -0400 | [diff] [blame] | 244 | GrRenderTargetProxy* proxy() const { return this->state()->drawOpArgs().fProxy; } |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 245 | |
| 246 | const GrAppliedClip* clip() const { return this->state()->drawOpArgs().fAppliedClip; } |
| 247 | |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 248 | GrAppliedClip detachAppliedClip() { return this->state()->detachAppliedClip(); } |
| 249 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 250 | const GrXferProcessor::DstProxy& dstProxy() const { |
| 251 | return this->state()->drawOpArgs().fDstProxy; |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | template <typename... Args> |
Brian Salomon | 91326c3 | 2017-08-09 16:02:19 -0400 | [diff] [blame] | 255 | GrPipeline* allocPipeline(Args&&... args) { |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 256 | return this->state()->allocPipeline(std::forward<Args>(args)...); |
| 257 | } |
| 258 | |
Brian Salomon | 0596909 | 2017-07-13 11:20:51 -0400 | [diff] [blame] | 259 | /** |
| 260 | * Helper that makes a pipeline targeting the op's render target that incorporates the op's |
| 261 | * GrAppliedClip. |
| 262 | * */ |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 263 | GrPipeline* makePipeline(uint32_t pipelineFlags, GrProcessorSet&& processorSet, |
| 264 | GrAppliedClip&& clip) { |
Brian Salomon | 98222ac | 2017-07-12 15:27:54 -0400 | [diff] [blame] | 265 | GrPipeline::InitArgs pipelineArgs; |
| 266 | pipelineArgs.fFlags = pipelineFlags; |
Robert Phillips | 2890fbf | 2017-07-26 15:48:41 -0400 | [diff] [blame] | 267 | pipelineArgs.fProxy = this->proxy(); |
Brian Salomon | 98222ac | 2017-07-12 15:27:54 -0400 | [diff] [blame] | 268 | pipelineArgs.fDstProxy = this->dstProxy(); |
| 269 | pipelineArgs.fCaps = &this->caps(); |
| 270 | pipelineArgs.fResourceProvider = this->resourceProvider(); |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 271 | return this->allocPipeline(pipelineArgs, std::move(processorSet), std::move(clip)); |
Brian Salomon | 98222ac | 2017-07-12 15:27:54 -0400 | [diff] [blame] | 272 | } |
| 273 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 274 | private: |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 275 | GrMeshDrawOp* meshDrawOp() { return static_cast<GrMeshDrawOp*>(this->op()); } |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 276 | typedef GrDrawOp::Target INHERITED; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 277 | }; |
| 278 | |
| 279 | #endif |