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 | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 11 | #include <utility> |
Ben Wagner | 729a23f | 2019-05-17 16:29:34 -0400 | [diff] [blame] | 12 | #include "src/core/SkArenaAlloc.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/core/SkArenaAllocList.h" |
| 14 | #include "src/gpu/GrAppliedClip.h" |
| 15 | #include "src/gpu/GrBufferAllocPool.h" |
| 16 | #include "src/gpu/GrDeferredUpload.h" |
Chris Dalton | aa0e45c | 2020-03-16 10:05:11 -0600 | [diff] [blame] | 17 | #include "src/gpu/GrProgramInfo.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 18 | #include "src/gpu/GrRenderTargetProxy.h" |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 19 | #include "src/gpu/GrSurfaceProxyView.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/ops/GrMeshDrawOp.h" |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 21 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 22 | class GrGpu; |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 23 | class GrOpsRenderPass; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 24 | class GrResourceProvider; |
| 25 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 26 | /** Tracks the state across all the GrOps (really just the GrDrawOps) in a GrOpsTask flush. */ |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 27 | class GrOpFlushState final : public GrDeferredUploadTarget, public GrMeshDrawOp::Target { |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 28 | public: |
Brian Salomon | 58f153c | 2018-10-18 21:51:15 -0400 | [diff] [blame] | 29 | // vertexSpace and indexSpace may either be null or an alloation of size |
| 30 | // GrBufferAllocPool::kDefaultBufferSize. If the latter, then CPU memory is only allocated for |
| 31 | // vertices/indices when a buffer larger than kDefaultBufferSize is required. |
Robert Phillips | e5f7328 | 2019-06-18 17:15:04 -0400 | [diff] [blame] | 32 | GrOpFlushState(GrGpu*, GrResourceProvider*, GrTokenTracker*, |
Brian Salomon | 601ac80 | 2019-02-07 13:37:16 -0500 | [diff] [blame] | 33 | sk_sp<GrBufferAllocPool::CpuBufferCache> = nullptr); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 34 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 35 | ~GrOpFlushState() final { this->reset(); } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 36 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 37 | /** This is called after each op has a chance to prepare its draws and before the draws are |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 38 | executed. */ |
| 39 | void preExecuteDraws(); |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 40 | |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 41 | /** Called to upload data to a texture using the GrDeferredTextureUploadFn. If the uploaded |
| 42 | surface needs to be prepared for being sampled in a draw after the upload, the caller |
| 43 | should pass in true for shouldPrepareSurfaceForSampling. This feature is needed for Vulkan |
| 44 | when doing inline uploads to reset the image layout back to sampled. */ |
| 45 | void doUpload(GrDeferredTextureUploadFn&, bool shouldPrepareSurfaceForSampling = false); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 46 | |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 47 | /** Called as ops are executed. Must be called in the same order as the ops were prepared. */ |
Robert Phillips | 3968fcb | 2019-12-05 16:40:31 -0500 | [diff] [blame] | 48 | void executeDrawsAndUploadsForMeshDrawOp(const GrOp* op, const SkRect& chainBounds, |
| 49 | const GrPipeline*); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 50 | |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 51 | GrOpsRenderPass* opsRenderPass() { return fOpsRenderPass; } |
| 52 | void setOpsRenderPass(GrOpsRenderPass* renderPass) { fOpsRenderPass = renderPass; } |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 53 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 54 | GrGpu* gpu() { return fGpu; } |
| 55 | |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 56 | void reset(); |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 57 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 58 | /** Additional data required on a per-op basis when executing GrOps. */ |
| 59 | struct OpArgs { |
Robert Phillips | 8053c97 | 2019-11-21 10:44:53 -0500 | [diff] [blame] | 60 | // TODO: why does OpArgs have the op we're going to pass it to as a member? Remove it. |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 61 | explicit OpArgs(GrOp* op, GrSurfaceProxyView* surfaceView, GrAppliedClip* appliedClip, |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 62 | const GrXferProcessor::DstProxyView& dstProxyView) |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 63 | : fOp(op) |
| 64 | , fSurfaceView(surfaceView) |
Chris Dalton | 5e8cdfd | 2019-11-11 15:23:30 -0700 | [diff] [blame] | 65 | , fRenderTargetProxy(surfaceView->asRenderTargetProxy()) |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 66 | , fAppliedClip(appliedClip) |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 67 | , fDstProxyView(dstProxyView) { |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 68 | SkASSERT(surfaceView->asRenderTargetProxy()); |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 69 | } |
Robert Phillips | 2890fbf | 2017-07-26 15:48:41 -0400 | [diff] [blame] | 70 | |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 71 | GrSurfaceOrigin origin() const { return fSurfaceView->origin(); } |
| 72 | GrSwizzle outputSwizzle() const { return fSurfaceView->swizzle(); } |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 73 | |
| 74 | GrOp* op() { return fOp; } |
Robert Phillips | b58098f | 2020-03-02 16:25:29 -0500 | [diff] [blame] | 75 | const GrSurfaceProxyView* outputView() const { return fSurfaceView; } |
Chris Dalton | 5e8cdfd | 2019-11-11 15:23:30 -0700 | [diff] [blame] | 76 | GrRenderTargetProxy* proxy() const { return fRenderTargetProxy; } |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 77 | GrAppliedClip* appliedClip() { return fAppliedClip; } |
| 78 | const GrAppliedClip* appliedClip() const { return fAppliedClip; } |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 79 | const GrXferProcessor::DstProxyView& dstProxyView() const { return fDstProxyView; } |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 80 | |
| 81 | #ifdef SK_DEBUG |
| 82 | void validate() const { |
| 83 | SkASSERT(fOp); |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 84 | SkASSERT(fSurfaceView); |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 85 | } |
| 86 | #endif |
| 87 | |
| 88 | private: |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 89 | GrOp* fOp; |
| 90 | GrSurfaceProxyView* fSurfaceView; |
Chris Dalton | 5e8cdfd | 2019-11-11 15:23:30 -0700 | [diff] [blame] | 91 | GrRenderTargetProxy* fRenderTargetProxy; |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 92 | GrAppliedClip* fAppliedClip; |
| 93 | GrXferProcessor::DstProxyView fDstProxyView; // TODO: do we still need the dst proxy here? |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 94 | }; |
| 95 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 96 | void setOpArgs(OpArgs* opArgs) { fOpArgs = opArgs; } |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 97 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 98 | const OpArgs& drawOpArgs() const { |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 99 | SkASSERT(fOpArgs); |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 100 | SkDEBUGCODE(fOpArgs->validate()); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 101 | return *fOpArgs; |
| 102 | } |
| 103 | |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 104 | void setSampledProxyArray(SkTArray<GrSurfaceProxy*, true>* sampledProxies) { |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 105 | fSampledProxies = sampledProxies; |
| 106 | } |
| 107 | |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 108 | SkTArray<GrSurfaceProxy*, true>* sampledProxyArray() override { |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 109 | return fSampledProxies; |
| 110 | } |
| 111 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 112 | /** Overrides of GrDeferredUploadTarget. */ |
Brian Salomon | bfd18cd | 2017-08-09 16:27:09 -0400 | [diff] [blame] | 113 | |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 114 | const GrTokenTracker* tokenTracker() final { return fTokenTracker; } |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 115 | GrDeferredUploadToken addInlineUpload(GrDeferredTextureUploadFn&&) final; |
| 116 | GrDeferredUploadToken addASAPUpload(GrDeferredTextureUploadFn&&) final; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 117 | |
| 118 | /** Overrides of GrMeshDrawOp::Target. */ |
Robert Phillips | 6c59fe4 | 2020-02-27 09:30:37 -0500 | [diff] [blame] | 119 | void recordDraw(const GrGeometryProcessor*, |
Chris Dalton | eb694b7 | 2020-03-16 09:25:50 -0600 | [diff] [blame] | 120 | const GrSimpleMesh[], |
Robert Phillips | 6c59fe4 | 2020-02-27 09:30:37 -0500 | [diff] [blame] | 121 | int meshCnt, |
Chris Dalton | 304e14d | 2020-03-17 14:29:06 -0600 | [diff] [blame^] | 122 | const GrSurfaceProxy* const primProcProxies[], |
Robert Phillips | 6c59fe4 | 2020-02-27 09:30:37 -0500 | [diff] [blame] | 123 | GrPrimitiveType) final; |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 124 | void* makeVertexSpace(size_t vertexSize, int vertexCount, sk_sp<const GrBuffer>*, |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 125 | int* startVertex) final; |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 126 | uint16_t* makeIndexSpace(int indexCount, sk_sp<const GrBuffer>*, int* startIndex) final; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 127 | void* makeVertexSpaceAtLeast(size_t vertexSize, int minVertexCount, int fallbackVertexCount, |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 128 | sk_sp<const GrBuffer>*, int* startVertex, |
| 129 | int* actualVertexCount) final; |
| 130 | uint16_t* makeIndexSpaceAtLeast(int minIndexCount, int fallbackIndexCount, |
| 131 | sk_sp<const GrBuffer>*, int* startIndex, |
| 132 | int* actualIndexCount) final; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 133 | void putBackIndices(int indexCount) final; |
| 134 | void putBackVertices(int vertices, size_t vertexStride) final; |
Robert Phillips | b58098f | 2020-03-02 16:25:29 -0500 | [diff] [blame] | 135 | const GrSurfaceProxyView* outputView() const final { return this->drawOpArgs().outputView(); } |
Chris Dalton | 5e8cdfd | 2019-11-11 15:23:30 -0700 | [diff] [blame] | 136 | GrRenderTargetProxy* proxy() const final { return this->drawOpArgs().proxy(); } |
Robert Phillips | 8053c97 | 2019-11-21 10:44:53 -0500 | [diff] [blame] | 137 | const GrAppliedClip* appliedClip() const final { return this->drawOpArgs().appliedClip(); } |
Chris Dalton | aa0e45c | 2020-03-16 10:05:11 -0600 | [diff] [blame] | 138 | const GrAppliedHardClip& appliedHardClip() const { |
| 139 | return (fOpArgs->appliedClip()) ? |
| 140 | fOpArgs->appliedClip()->hardClip() : GrAppliedHardClip::Disabled(); |
Chris Dalton | 78dac6d | 2020-03-09 14:40:22 -0600 | [diff] [blame] | 141 | } |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 142 | GrAppliedClip detachAppliedClip() final; |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 143 | const GrXferProcessor::DstProxyView& dstProxyView() const final { |
Chris Dalton | 5e8cdfd | 2019-11-11 15:23:30 -0700 | [diff] [blame] | 144 | return this->drawOpArgs().dstProxyView(); |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 145 | } |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 146 | GrDeferredUploadTarget* deferredUploadTarget() final { return this; } |
| 147 | const GrCaps& caps() const final; |
| 148 | GrResourceProvider* resourceProvider() const final { return fResourceProvider; } |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 149 | |
Herb Derby | 081e6f3 | 2019-01-16 13:46:02 -0500 | [diff] [blame] | 150 | GrStrikeCache* glyphCache() const final; |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 151 | |
| 152 | // At this point we know we're flushing so full access to the GrAtlasManager is required (and |
| 153 | // permissible). |
Robert Phillips | 5a66efb | 2018-03-07 15:13:18 -0500 | [diff] [blame] | 154 | GrAtlasManager* atlasManager() const final; |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 155 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 156 | /** GrMeshDrawOp::Target override. */ |
Chris Dalton | 07cdcfc9 | 2019-02-26 11:13:22 -0700 | [diff] [blame] | 157 | SkArenaAlloc* allocator() override { return &fArena; } |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 158 | |
Chris Dalton | aa0e45c | 2020-03-16 10:05:11 -0600 | [diff] [blame] | 159 | // This is a convenience method that binds the given pipeline, and then, if our applied clip has |
| 160 | // a scissor, sets the scissor rect from the applied clip. |
| 161 | void bindPipelineAndScissorClip(const GrProgramInfo& programInfo, const SkRect& drawBounds) { |
| 162 | SkASSERT((programInfo.pipeline().isScissorTestEnabled()) == |
| 163 | (this->appliedClip() && this->appliedClip()->scissorState().enabled())); |
| 164 | this->bindPipeline(programInfo, drawBounds); |
| 165 | if (programInfo.pipeline().isScissorTestEnabled()) { |
| 166 | this->setScissorRect(this->appliedClip()->scissorState().rect()); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // This is a convenience method for when the primitive processor has exactly one texture. It |
| 171 | // binds one texture for the primitive processor, and any others for FPs on the pipeline. |
| 172 | void bindTextures(const GrPrimitiveProcessor& primProc, |
| 173 | const GrSurfaceProxy& singlePrimProcTexture, const GrPipeline& pipeline) { |
| 174 | SkASSERT(primProc.numTextureSamplers() == 1); |
| 175 | const GrSurfaceProxy* ptr = &singlePrimProcTexture; |
| 176 | this->bindTextures(primProc, &ptr, pipeline); |
| 177 | } |
| 178 | |
Chris Dalton | 765ed36 | 2020-03-16 17:34:44 -0600 | [diff] [blame] | 179 | // Makes the appropriate bindBuffers() and draw*() calls for the provided mesh. |
| 180 | void drawMesh(const GrSimpleMesh& mesh); |
| 181 | |
Chris Dalton | aa0e45c | 2020-03-16 10:05:11 -0600 | [diff] [blame] | 182 | // Pass-through methods to GrOpsRenderPass. |
| 183 | void bindPipeline(const GrProgramInfo& programInfo, const SkRect& drawBounds) { |
| 184 | fOpsRenderPass->bindPipeline(programInfo, drawBounds); |
| 185 | } |
| 186 | void setScissorRect(const SkIRect& scissorRect) { |
| 187 | fOpsRenderPass->setScissorRect(scissorRect); |
| 188 | } |
| 189 | void bindTextures(const GrPrimitiveProcessor& primProc, |
| 190 | const GrSurfaceProxy* const primProcTextures[], const GrPipeline& pipeline) { |
| 191 | fOpsRenderPass->bindTextures(primProc, primProcTextures, pipeline); |
| 192 | } |
| 193 | void bindBuffers(const GrBuffer* indexBuffer, const GrBuffer* instanceBuffer, |
| 194 | const GrBuffer* vertexBuffer, |
| 195 | GrPrimitiveRestart primitiveRestart = GrPrimitiveRestart::kNo) { |
| 196 | fOpsRenderPass->bindBuffers(indexBuffer, instanceBuffer, vertexBuffer, primitiveRestart); |
| 197 | } |
| 198 | void draw(int vertexCount, int baseVertex) { |
| 199 | fOpsRenderPass->draw(vertexCount, baseVertex); |
| 200 | } |
| 201 | void drawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, |
| 202 | int baseVertex) { |
| 203 | fOpsRenderPass->drawIndexed(indexCount, baseIndex, minIndexValue, maxIndexValue, |
| 204 | baseVertex); |
| 205 | } |
| 206 | void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex) { |
| 207 | fOpsRenderPass->drawInstanced(instanceCount, baseInstance, vertexCount, baseVertex); |
| 208 | } |
| 209 | void drawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, |
| 210 | int baseVertex) { |
| 211 | fOpsRenderPass->drawIndexedInstanced(indexCount, baseIndex, instanceCount, baseInstance, |
| 212 | baseVertex); |
| 213 | } |
| 214 | void drawIndexPattern(int patternIndexCount, int patternRepeatCount, |
| 215 | int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, |
| 216 | int baseVertex) { |
| 217 | fOpsRenderPass->drawIndexPattern(patternIndexCount, patternRepeatCount, |
| 218 | maxPatternRepetitionsInIndexBuffer, patternVertexCount, |
| 219 | baseVertex); |
| 220 | } |
| 221 | |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 222 | private: |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 223 | struct InlineUpload { |
| 224 | InlineUpload(GrDeferredTextureUploadFn&& upload, GrDeferredUploadToken token) |
| 225 | : fUpload(std::move(upload)), fUploadBeforeToken(token) {} |
| 226 | GrDeferredTextureUploadFn fUpload; |
| 227 | GrDeferredUploadToken fUploadBeforeToken; |
| 228 | }; |
| 229 | |
| 230 | // A set of contiguous draws that share a draw token, geometry processor, and pipeline. The |
| 231 | // meshes for the draw are stored in the fMeshes array. The reason for coalescing meshes |
| 232 | // that share a geometry processor into a Draw is that it allows the Gpu object to setup |
| 233 | // the shared state once and then issue draws for each mesh. |
| 234 | struct Draw { |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 235 | ~Draw(); |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 236 | // The geometry processor is always forced to be in an arena allocation or appears on |
| 237 | // the stack (for CCPR). In either case this object does not need to manage its |
| 238 | // lifetime. |
| 239 | const GrGeometryProcessor* fGeometryProcessor = nullptr; |
Chris Dalton | 304e14d | 2020-03-17 14:29:06 -0600 | [diff] [blame^] | 240 | // Must have GrPrimitiveProcessor::numTextureSamplers() entries. Can be null if no samplers. |
| 241 | const GrSurfaceProxy* const* fPrimProcProxies = nullptr; |
Chris Dalton | eb694b7 | 2020-03-16 09:25:50 -0600 | [diff] [blame] | 242 | const GrSimpleMesh* fMeshes = nullptr; |
Brian Osman | e801210 | 2018-11-29 14:05:07 -0500 | [diff] [blame] | 243 | const GrOp* fOp = nullptr; |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 244 | int fMeshCnt = 0; |
Robert Phillips | cea290f | 2019-11-06 11:21:03 -0500 | [diff] [blame] | 245 | GrPrimitiveType fPrimitiveType; |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 246 | }; |
| 247 | |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 248 | // Storage for ops' pipelines, draws, and inline uploads. |
| 249 | SkArenaAlloc fArena{sizeof(GrPipeline) * 100}; |
| 250 | |
| 251 | // Store vertex and index data on behalf of ops that are flushed. |
| 252 | GrVertexBufferAllocPool fVertexPool; |
| 253 | GrIndexBufferAllocPool fIndexPool; |
| 254 | |
| 255 | // Data stored on behalf of the ops being flushed. |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 256 | SkArenaAllocList<GrDeferredTextureUploadFn> fASAPUploads; |
Brian Salomon | cbcb0a1 | 2017-11-19 13:20:13 -0500 | [diff] [blame] | 257 | SkArenaAllocList<InlineUpload> fInlineUploads; |
| 258 | SkArenaAllocList<Draw> fDraws; |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 259 | |
| 260 | // All draws we store have an implicit draw token. This is the draw token for the first draw |
| 261 | // in fDraws. |
| 262 | GrDeferredUploadToken fBaseDrawToken = GrDeferredUploadToken::AlreadyFlushedToken(); |
| 263 | |
| 264 | // Info about the op that is currently preparing or executing using the flush state or null if |
| 265 | // an op is not currently preparing of executing. |
| 266 | OpArgs* fOpArgs = nullptr; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 267 | |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 268 | // This field is only transiently set during flush. Each GrOpsTask will set it to point to an |
| 269 | // array of proxies it uses before call onPrepare and onExecute. |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 270 | SkTArray<GrSurfaceProxy*, true>* fSampledProxies; |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 271 | |
Brian Salomon | 6d4b65e | 2017-05-03 17:06:09 -0400 | [diff] [blame] | 272 | GrGpu* fGpu; |
| 273 | GrResourceProvider* fResourceProvider; |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 274 | GrTokenTracker* fTokenTracker; |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 275 | GrOpsRenderPass* fOpsRenderPass = nullptr; |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 276 | |
| 277 | // Variables that are used to track where we are in lists as ops are executed |
Brian Salomon | cbcb0a1 | 2017-11-19 13:20:13 -0500 | [diff] [blame] | 278 | SkArenaAllocList<Draw>::Iter fCurrDraw; |
Brian Salomon | cbcb0a1 | 2017-11-19 13:20:13 -0500 | [diff] [blame] | 279 | SkArenaAllocList<InlineUpload>::Iter fCurrUpload; |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 280 | }; |
| 281 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 282 | #endif |