Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Side by Side Diff: src/gpu/GrDrawTarget.cpp

Issue 2120163002: Enable blend optimizations with instanced draws (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_ingorecov
Patch Set: fixes for perf regressions Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrDrawTarget.h" 8 #include "GrDrawTarget.h"
9 9
10 #include "GrAuditTrail.h" 10 #include "GrAuditTrail.h"
(...skipping 15 matching lines...) Expand all
26 #include "SkStrokeRec.h" 26 #include "SkStrokeRec.h"
27 27
28 #include "batches/GrClearBatch.h" 28 #include "batches/GrClearBatch.h"
29 #include "batches/GrCopySurfaceBatch.h" 29 #include "batches/GrCopySurfaceBatch.h"
30 #include "batches/GrDiscardBatch.h" 30 #include "batches/GrDiscardBatch.h"
31 #include "batches/GrDrawBatch.h" 31 #include "batches/GrDrawBatch.h"
32 #include "batches/GrDrawPathBatch.h" 32 #include "batches/GrDrawPathBatch.h"
33 #include "batches/GrRectBatchFactory.h" 33 #include "batches/GrRectBatchFactory.h"
34 #include "batches/GrStencilPathBatch.h" 34 #include "batches/GrStencilPathBatch.h"
35 35
36 #include "instanced/InstancedRendering.h"
37
36 //////////////////////////////////////////////////////////////////////////////// 38 ////////////////////////////////////////////////////////////////////////////////
37 39
38 // Experimentally we have found that most batching occurs within the first 10 co mparisons. 40 // Experimentally we have found that most batching occurs within the first 10 co mparisons.
39 static const int kDefaultMaxBatchLookback = 10; 41 static const int kDefaultMaxBatchLookback = 10;
40 static const int kDefaultMaxBatchLookahead = 10; 42 static const int kDefaultMaxBatchLookahead = 10;
41 43
42 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider, 44 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider,
43 GrAuditTrail* auditTrail, const Options& options) 45 GrAuditTrail* auditTrail, const Options& options)
44 : fGpu(SkRef(gpu)) 46 : fGpu(SkRef(gpu))
45 , fResourceProvider(resourceProvider) 47 , fResourceProvider(resourceProvider)
46 , fAuditTrail(auditTrail) 48 , fAuditTrail(auditTrail)
47 , fFlags(0) 49 , fFlags(0)
48 , fRenderTarget(rt) { 50 , fRenderTarget(rt)
51 , fInstancedRendering(fGpu->createInstancedRenderingIfSupported()) {
49 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) 52 // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
50 fContext = fGpu->getContext(); 53 fContext = fGpu->getContext();
51 54
52 fClipBatchToBounds = options.fClipBatchToBounds; 55 fClipBatchToBounds = options.fClipBatchToBounds;
53 fDrawBatchBounds = options.fDrawBatchBounds; 56 fDrawBatchBounds = options.fDrawBatchBounds;
54 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck : 57 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck :
55 options.fMaxBatchLookb ack; 58 options.fMaxBatchLookb ack;
56 fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLook ahead : 59 fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLook ahead :
57 options.fMaxBatchLook ahead; 60 options.fMaxBatchLook ahead;
58 61
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // but need to be flushed anyway. Closing such drawTargets here will mean ne w 197 // but need to be flushed anyway. Closing such drawTargets here will mean ne w
195 // drawTargets will be created to replace them if the SkGpuDevice(s) write t o them again. 198 // drawTargets will be created to replace them if the SkGpuDevice(s) write t o them again.
196 this->makeClosed(); 199 this->makeClosed();
197 200
198 // Loop over the batches that haven't yet generated their geometry 201 // Loop over the batches that haven't yet generated their geometry
199 for (int i = 0; i < fBatches.count(); ++i) { 202 for (int i = 0; i < fBatches.count(); ++i) {
200 if (fBatches[i]) { 203 if (fBatches[i]) {
201 fBatches[i]->prepare(flushState); 204 fBatches[i]->prepare(flushState);
202 } 205 }
203 } 206 }
207
208 if (fInstancedRendering) {
209 fInstancedRendering->beginFlush(flushState->resourceProvider());
210 }
204 } 211 }
205 212
206 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { 213 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
207 // Draw all the generated geometry. 214 // Draw all the generated geometry.
208 SkRandom random; 215 SkRandom random;
209 GrRenderTarget* currentRT = nullptr; 216 GrRenderTarget* currentRT = nullptr;
210 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer; 217 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer;
211 SkRect bounds = SkRect::MakeEmpty(); 218 SkRect bounds = SkRect::MakeEmpty();
212 for (int i = 0; i < fBatches.count(); ++i) { 219 for (int i = 0; i < fBatches.count(); ++i) {
213 if (!fBatches[i]) { 220 if (!fBatches[i]) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 commandBuffer->submit(iBounds); 269 commandBuffer->submit(iBounds);
263 } 270 }
264 flushState->setCommandBuffer(nullptr); 271 flushState->setCommandBuffer(nullptr);
265 } 272 }
266 273
267 fGpu->finishDrawTarget(); 274 fGpu->finishDrawTarget();
268 } 275 }
269 276
270 void GrDrawTarget::reset() { 277 void GrDrawTarget::reset() {
271 fBatches.reset(); 278 fBatches.reset();
279 if (fInstancedRendering) {
280 fInstancedRendering->endFlush();
281 }
272 } 282 }
273 283
274 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, 284 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
275 GrDrawContext* drawContext, 285 GrDrawContext* drawContext,
276 const GrClip& clip, 286 const GrClip& clip,
277 GrDrawBatch* batch) { 287 GrDrawBatch* batch) {
278 // Setup clip 288 // Setup clip
279 GrAppliedClip appliedClip; 289 GrAppliedClip appliedClip;
280 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a ppliedClip)) { 290 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a ppliedClip)) {
281 return; 291 return;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 572 }
563 } 573 }
564 574
565 /////////////////////////////////////////////////////////////////////////////// 575 ///////////////////////////////////////////////////////////////////////////////
566 576
567 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 577 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
568 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 578 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
569 this->recordBatch(batch); 579 this->recordBatch(batch);
570 batch->unref(); 580 batch->unref();
571 } 581 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698