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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/GrOpFlushState.h" |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 9 | |
Adlai Holler | 3d0359a | 2020-07-09 15:35:55 -0400 | [diff] [blame] | 10 | #include "include/gpu/GrDirectContext.h" |
Brian Salomon | 1047a49 | 2019-07-02 12:25:21 -0400 | [diff] [blame] | 11 | #include "src/core/SkConvertPixels.h" |
Robert Phillips | e19babf | 2020-04-06 13:57:30 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrDataUtils.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 13 | #include "src/gpu/GrDirectContextPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/GrDrawOpAtlas.h" |
| 15 | #include "src/gpu/GrGpu.h" |
Brian Salomon | f2ebdd9 | 2019-09-30 12:15:30 -0400 | [diff] [blame] | 16 | #include "src/gpu/GrImageInfo.h" |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 17 | #include "src/gpu/GrProgramInfo.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/gpu/GrResourceProvider.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 19 | #include "src/gpu/GrTexture.h" |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 20 | |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 21 | ////////////////////////////////////////////////////////////////////////////// |
| 22 | |
Brian Salomon | 58f153c | 2018-10-18 21:51:15 -0400 | [diff] [blame] | 23 | GrOpFlushState::GrOpFlushState(GrGpu* gpu, GrResourceProvider* resourceProvider, |
Robert Phillips | e5f7328 | 2019-06-18 17:15:04 -0400 | [diff] [blame] | 24 | GrTokenTracker* tokenTracker, |
Brian Salomon | 601ac80 | 2019-02-07 13:37:16 -0500 | [diff] [blame] | 25 | sk_sp<GrBufferAllocPool::CpuBufferCache> cpuBufferCache) |
| 26 | : fVertexPool(gpu, cpuBufferCache) |
Chris Dalton | 03fdf6a | 2020-04-07 12:31:59 -0600 | [diff] [blame] | 27 | , fIndexPool(gpu, cpuBufferCache) |
| 28 | , fDrawIndirectPool(gpu, std::move(cpuBufferCache)) |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 29 | , fGpu(gpu) |
| 30 | , fResourceProvider(resourceProvider) |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 31 | , fTokenTracker(tokenTracker) {} |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 32 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 33 | const GrCaps& GrOpFlushState::caps() const { |
| 34 | return *fGpu->caps(); |
| 35 | } |
| 36 | |
Robert Phillips | 83c38a8 | 2020-10-28 14:57:53 -0400 | [diff] [blame] | 37 | GrThreadSafeCache* GrOpFlushState::threadSafeCache() const { |
| 38 | return fGpu->getContext()->priv().threadSafeCache(); |
| 39 | } |
| 40 | |
Chris Dalton | 07cdcfc9 | 2019-02-26 11:13:22 -0700 | [diff] [blame] | 41 | void GrOpFlushState::executeDrawsAndUploadsForMeshDrawOp( |
Chris Dalton | 1b6a43c | 2020-09-25 12:21:18 -0600 | [diff] [blame] | 42 | const GrOp* op, const SkRect& chainBounds, const GrPipeline* pipeline, |
| 43 | const GrUserStencilSettings* userStencilSettings) { |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 44 | SkASSERT(this->opsRenderPass()); |
Chris Dalton | 07cdcfc9 | 2019-02-26 11:13:22 -0700 | [diff] [blame] | 45 | |
Brian Osman | e801210 | 2018-11-29 14:05:07 -0500 | [diff] [blame] | 46 | while (fCurrDraw != fDraws.end() && fCurrDraw->fOp == op) { |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 47 | GrDeferredUploadToken drawToken = fTokenTracker->nextTokenToFlush(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 48 | while (fCurrUpload != fInlineUploads.end() && |
| 49 | fCurrUpload->fUploadBeforeToken == drawToken) { |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 50 | this->opsRenderPass()->inlineUpload(this, fCurrUpload->fUpload); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 51 | ++fCurrUpload; |
| 52 | } |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 53 | |
Chris Dalton | 2a26c50 | 2021-08-26 10:05:11 -0600 | [diff] [blame] | 54 | GrProgramInfo programInfo(this->caps(), |
| 55 | this->writeView(), |
| 56 | this->usesMSAASurface(), |
Robert Phillips | 67a625e | 2019-11-15 15:37:07 -0500 | [diff] [blame] | 57 | pipeline, |
Chris Dalton | 1b6a43c | 2020-09-25 12:21:18 -0600 | [diff] [blame] | 58 | userStencilSettings, |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 59 | fCurrDraw->fGeometryProcessor, |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 60 | fCurrDraw->fPrimitiveType, |
| 61 | 0, |
Greg Daniel | 42dbca5 | 2020-11-20 10:22:43 -0500 | [diff] [blame] | 62 | this->renderPassBarriers(), |
| 63 | this->colorLoadOp()); |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 64 | |
Chris Dalton | 304e14d | 2020-03-17 14:29:06 -0600 | [diff] [blame] | 65 | this->bindPipelineAndScissorClip(programInfo, chainBounds); |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 66 | this->bindTextures(programInfo.geomProc(), fCurrDraw->fGeomProcProxies, |
Chris Dalton | 304e14d | 2020-03-17 14:29:06 -0600 | [diff] [blame] | 67 | programInfo.pipeline()); |
Chris Dalton | 765ed36 | 2020-03-16 17:34:44 -0600 | [diff] [blame] | 68 | for (int i = 0; i < fCurrDraw->fMeshCnt; ++i) { |
Chris Dalton | 765ed36 | 2020-03-16 17:34:44 -0600 | [diff] [blame] | 69 | this->drawMesh(fCurrDraw->fMeshes[i]); |
| 70 | } |
| 71 | |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 72 | fTokenTracker->flushToken(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 73 | ++fCurrDraw; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void GrOpFlushState::preExecuteDraws() { |
| 78 | fVertexPool.unmap(); |
| 79 | fIndexPool.unmap(); |
Chris Dalton | 03fdf6a | 2020-04-07 12:31:59 -0600 | [diff] [blame] | 80 | fDrawIndirectPool.unmap(); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 81 | for (auto& upload : fASAPUploads) { |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 82 | this->doUpload(upload); |
| 83 | } |
| 84 | // Setup execution iterators. |
| 85 | fCurrDraw = fDraws.begin(); |
| 86 | fCurrUpload = fInlineUploads.begin(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | void GrOpFlushState::reset() { |
| 90 | SkASSERT(fCurrDraw == fDraws.end()); |
| 91 | SkASSERT(fCurrUpload == fInlineUploads.end()); |
| 92 | fVertexPool.reset(); |
| 93 | fIndexPool.reset(); |
Chris Dalton | 03fdf6a | 2020-04-07 12:31:59 -0600 | [diff] [blame] | 94 | fDrawIndirectPool.reset(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 95 | fArena.reset(); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 96 | fASAPUploads.reset(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 97 | fInlineUploads.reset(); |
| 98 | fDraws.reset(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 99 | fBaseDrawToken = GrDeferredUploadToken::AlreadyFlushedToken(); |
| 100 | } |
| 101 | |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 102 | void GrOpFlushState::doUpload(GrDeferredTextureUploadFn& upload, |
| 103 | bool shouldPrepareSurfaceForSampling) { |
| 104 | GrDeferredTextureUploadWritePixelsFn wp = [this, shouldPrepareSurfaceForSampling]( |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 105 | GrTextureProxy* dstProxy, |
| 106 | SkIRect rect, |
| 107 | GrColorType colorType, |
| 108 | const void* buffer, |
| 109 | size_t rowBytes) { |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 110 | GrSurface* dstSurface = dstProxy->peekSurface(); |
Brian Salomon | 42be09d | 2019-07-26 12:12:26 -0400 | [diff] [blame] | 111 | if (!fGpu->caps()->surfaceSupportsWritePixels(dstSurface)) { |
| 112 | return false; |
| 113 | } |
Brian Salomon | 01915c0 | 2019-08-02 09:57:21 -0400 | [diff] [blame] | 114 | GrCaps::SupportedWrite supportedWrite = fGpu->caps()->supportedWritePixelsColorType( |
| 115 | colorType, dstSurface->backendFormat(), colorType); |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 116 | size_t tightRB = rect.width()*GrColorTypeBytesPerPixel(supportedWrite.fColorType); |
Brian Salomon | 77a684f | 2019-08-01 14:38:04 -0400 | [diff] [blame] | 117 | SkASSERT(rowBytes >= tightRB); |
Brian Salomon | 1047a49 | 2019-07-02 12:25:21 -0400 | [diff] [blame] | 118 | std::unique_ptr<char[]> tmpPixels; |
Brian Salomon | f77c146 | 2019-08-01 15:19:29 -0400 | [diff] [blame] | 119 | if (supportedWrite.fColorType != colorType || |
Brian Salomon | 77a684f | 2019-08-01 14:38:04 -0400 | [diff] [blame] | 120 | (!fGpu->caps()->writePixelsRowBytesSupport() && rowBytes != tightRB)) { |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 121 | tmpPixels.reset(new char[rect.height()*tightRB]); |
Brian Salomon | 5392c94 | 2021-03-30 16:14:37 -0400 | [diff] [blame] | 122 | // Use kUnknown to ensure no alpha type conversions or clamping occur. |
| 123 | static constexpr auto kAT = kUnknown_SkAlphaType; |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 124 | GrImageInfo srcInfo(colorType, kAT, nullptr, rect.size()); |
| 125 | GrImageInfo tmpInfo(supportedWrite.fColorType, kAT, nullptr, rect.size()); |
Brian Salomon | 5392c94 | 2021-03-30 16:14:37 -0400 | [diff] [blame] | 126 | if (!GrConvertPixels( GrPixmap(tmpInfo, tmpPixels.get(), tightRB ), |
| 127 | GrCPixmap(srcInfo, buffer, rowBytes))) { |
Brian Salomon | 77a684f | 2019-08-01 14:38:04 -0400 | [diff] [blame] | 128 | return false; |
| 129 | } |
Brian Salomon | 1047a49 | 2019-07-02 12:25:21 -0400 | [diff] [blame] | 130 | rowBytes = tightRB; |
Brian Salomon | 77a684f | 2019-08-01 14:38:04 -0400 | [diff] [blame] | 131 | buffer = tmpPixels.get(); |
Brian Salomon | 1047a49 | 2019-07-02 12:25:21 -0400 | [diff] [blame] | 132 | } |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 133 | return this->fGpu->writePixels(dstSurface, |
| 134 | rect, |
| 135 | colorType, |
| 136 | supportedWrite.fColorType, |
| 137 | buffer, |
| 138 | rowBytes, |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 139 | shouldPrepareSurfaceForSampling); |
Brian Salomon | 9bada54 | 2017-06-12 12:09:30 -0400 | [diff] [blame] | 140 | }; |
| 141 | upload(wp); |
| 142 | } |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 143 | |
| 144 | GrDeferredUploadToken GrOpFlushState::addInlineUpload(GrDeferredTextureUploadFn&& upload) { |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 145 | return fInlineUploads.append(&fArena, std::move(upload), fTokenTracker->nextDrawToken()) |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 146 | .fUploadBeforeToken; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | GrDeferredUploadToken GrOpFlushState::addASAPUpload(GrDeferredTextureUploadFn&& upload) { |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 150 | fASAPUploads.append(&fArena, std::move(upload)); |
| 151 | return fTokenTracker->nextTokenToFlush(); |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 152 | } |
| 153 | |
Chris Dalton | 07cdcfc9 | 2019-02-26 11:13:22 -0700 | [diff] [blame] | 154 | void GrOpFlushState::recordDraw( |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 155 | const GrGeometryProcessor* geomProc, |
Chris Dalton | eb694b7 | 2020-03-16 09:25:50 -0600 | [diff] [blame] | 156 | const GrSimpleMesh meshes[], |
Robert Phillips | 6c59fe4 | 2020-02-27 09:30:37 -0500 | [diff] [blame] | 157 | int meshCnt, |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 158 | const GrSurfaceProxy* const geomProcProxies[], |
Robert Phillips | cea290f | 2019-11-06 11:21:03 -0500 | [diff] [blame] | 159 | GrPrimitiveType primitiveType) { |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 160 | SkASSERT(fOpArgs); |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 161 | SkDEBUGCODE(fOpArgs->validate()); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 162 | bool firstDraw = fDraws.begin() == fDraws.end(); |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 163 | auto& draw = fDraws.append(&fArena); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 164 | GrDeferredUploadToken token = fTokenTracker->issueDrawToken(); |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 165 | for (int i = 0; i < geomProc->numTextureSamplers(); ++i) { |
| 166 | SkASSERT(geomProcProxies && geomProcProxies[i]); |
| 167 | geomProcProxies[i]->ref(); |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 168 | } |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 169 | draw.fGeometryProcessor = geomProc; |
| 170 | draw.fGeomProcProxies = geomProcProxies; |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 171 | draw.fMeshes = meshes; |
| 172 | draw.fMeshCnt = meshCnt; |
Robert Phillips | 405413f | 2019-10-04 10:39:28 -0400 | [diff] [blame] | 173 | draw.fOp = fOpArgs->op(); |
Robert Phillips | cea290f | 2019-11-06 11:21:03 -0500 | [diff] [blame] | 174 | draw.fPrimitiveType = primitiveType; |
Brian Salomon | 7dc6e75 | 2017-11-02 11:34:51 -0400 | [diff] [blame] | 175 | if (firstDraw) { |
| 176 | fBaseDrawToken = token; |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 180 | void* GrOpFlushState::makeVertexSpace(size_t vertexSize, int vertexCount, |
| 181 | sk_sp<const GrBuffer>* buffer, int* startVertex) { |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 182 | return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex); |
| 183 | } |
| 184 | |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 185 | uint16_t* GrOpFlushState::makeIndexSpace(int indexCount, sk_sp<const GrBuffer>* buffer, |
| 186 | int* startIndex) { |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 187 | return reinterpret_cast<uint16_t*>(fIndexPool.makeSpace(indexCount, buffer, startIndex)); |
| 188 | } |
| 189 | |
| 190 | void* GrOpFlushState::makeVertexSpaceAtLeast(size_t vertexSize, int minVertexCount, |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 191 | int fallbackVertexCount, sk_sp<const GrBuffer>* buffer, |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 192 | int* startVertex, int* actualVertexCount) { |
| 193 | return fVertexPool.makeSpaceAtLeast(vertexSize, minVertexCount, fallbackVertexCount, buffer, |
| 194 | startVertex, actualVertexCount); |
| 195 | } |
| 196 | |
| 197 | uint16_t* GrOpFlushState::makeIndexSpaceAtLeast(int minIndexCount, int fallbackIndexCount, |
Brian Salomon | 12d2264 | 2019-01-29 14:38:50 -0500 | [diff] [blame] | 198 | sk_sp<const GrBuffer>* buffer, int* startIndex, |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 199 | int* actualIndexCount) { |
| 200 | return reinterpret_cast<uint16_t*>(fIndexPool.makeSpaceAtLeast( |
| 201 | minIndexCount, fallbackIndexCount, buffer, startIndex, actualIndexCount)); |
| 202 | } |
| 203 | |
| 204 | void GrOpFlushState::putBackIndices(int indexCount) { |
| 205 | fIndexPool.putBack(indexCount * sizeof(uint16_t)); |
| 206 | } |
| 207 | |
| 208 | void GrOpFlushState::putBackVertices(int vertices, size_t vertexStride) { |
| 209 | fVertexPool.putBack(vertices * vertexStride); |
| 210 | } |
| 211 | |
| 212 | GrAppliedClip GrOpFlushState::detachAppliedClip() { |
Michael Ludwig | d1d997e | 2020-06-04 15:52:44 -0400 | [diff] [blame] | 213 | return fOpArgs->appliedClip() ? std::move(*fOpArgs->appliedClip()) : GrAppliedClip::Disabled(); |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 214 | } |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 215 | |
Robert Phillips | 207d24b | 2020-04-09 10:23:42 -0400 | [diff] [blame] | 216 | GrStrikeCache* GrOpFlushState::strikeCache() const { |
Herb Derby | a00da61 | 2019-03-04 17:10:01 -0500 | [diff] [blame] | 217 | return fGpu->getContext()->priv().getGrStrikeCache(); |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 218 | } |
| 219 | |
Robert Phillips | 5a66efb | 2018-03-07 15:13:18 -0500 | [diff] [blame] | 220 | GrAtlasManager* GrOpFlushState::atlasManager() const { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 221 | return fGpu->getContext()->priv().getAtlasManager(); |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 222 | } |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 223 | |
Robert Phillips | de60d7a | 2021-09-13 17:17:45 -0400 | [diff] [blame] | 224 | skgpu::v1::SmallPathAtlasMgr* GrOpFlushState::smallPathAtlasManager() const { |
Robert Phillips | 5edf510 | 2020-08-10 16:30:36 -0400 | [diff] [blame] | 225 | return fGpu->getContext()->priv().getSmallPathAtlasMgr(); |
| 226 | } |
| 227 | |
Chris Dalton | 765ed36 | 2020-03-16 17:34:44 -0600 | [diff] [blame] | 228 | void GrOpFlushState::drawMesh(const GrSimpleMesh& mesh) { |
| 229 | SkASSERT(mesh.fIsInitialized); |
| 230 | if (!mesh.fIndexBuffer) { |
Greg Daniel | 426274b | 2020-07-20 11:37:38 -0400 | [diff] [blame] | 231 | this->bindBuffers(nullptr, nullptr, mesh.fVertexBuffer); |
Chris Dalton | 765ed36 | 2020-03-16 17:34:44 -0600 | [diff] [blame] | 232 | this->draw(mesh.fVertexCount, mesh.fBaseVertex); |
| 233 | } else { |
Greg Daniel | 426274b | 2020-07-20 11:37:38 -0400 | [diff] [blame] | 234 | this->bindBuffers(mesh.fIndexBuffer, nullptr, mesh.fVertexBuffer, mesh.fPrimitiveRestart); |
Chris Dalton | 765ed36 | 2020-03-16 17:34:44 -0600 | [diff] [blame] | 235 | if (0 == mesh.fPatternRepeatCount) { |
| 236 | this->drawIndexed(mesh.fIndexCount, mesh.fBaseIndex, mesh.fMinIndexValue, |
| 237 | mesh.fMaxIndexValue, mesh.fBaseVertex); |
| 238 | } else { |
| 239 | this->drawIndexPattern(mesh.fIndexCount, mesh.fPatternRepeatCount, |
| 240 | mesh.fMaxPatternRepetitionsInIndexBuffer, mesh.fVertexCount, |
| 241 | mesh.fBaseVertex); |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 246 | ////////////////////////////////////////////////////////////////////////////// |
| 247 | |
| 248 | GrOpFlushState::Draw::~Draw() { |
Chris Dalton | 304e14d | 2020-03-17 14:29:06 -0600 | [diff] [blame] | 249 | for (int i = 0; i < fGeometryProcessor->numTextureSamplers(); ++i) { |
Robert Phillips | 787fd9d | 2021-03-22 14:48:09 -0400 | [diff] [blame] | 250 | SkASSERT(fGeomProcProxies && fGeomProcProxies[i]); |
| 251 | fGeomProcProxies[i]->unref(); |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 252 | } |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 253 | } |