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

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

Issue 885923002: Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Some clean up Created 5 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 draw->fType = add_trace_bit(draw->fType); 240 draw->fType = add_trace_bit(draw->fType);
241 } 241 }
242 } 242 }
243 243
244 return instancesToConcat; 244 return instancesToConcat;
245 } 245 }
246 246
247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder, 247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder,
248 const GrGeometryProcessor* gp, 248 const GrGeometryProcessor* gp,
249 const DrawInfo& info, 249 const DrawInfo& info,
250 const GrScissorState& scissorState, 250 const GrScissorState& scissorState) {
251 const GrDeviceCoordTexture* dstCopy) {
252 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); 251 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
253 252
254 // This closeBatch call is required because we may introduce new draws when we setup clip 253 // This closeBatch call is required because we may introduce new draws when we setup clip
255 this->closeBatch(); 254 this->closeBatch();
256 255
257 if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, dstCo py)) { 256 if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, info. getDevBounds())) {
258 return; 257 return;
259 } 258 }
260 259
261 Draw* draw; 260 Draw* draw;
262 if (info.isInstanced()) { 261 if (info.isInstanced()) {
263 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info) ; 262 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info) ;
264 if (info.instanceCount() > instancesConcated) { 263 if (info.instanceCount() > instancesConcated) {
265 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); 264 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info));
266 draw->fInfo.adjustInstanceCount(-instancesConcated); 265 draw->fInfo.adjustInstanceCount(-instancesConcated);
267 } else { 266 } else {
268 return; 267 return;
269 } 268 }
270 } else { 269 } else {
271 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); 270 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info));
272 } 271 }
273 this->recordTraceMarkersIfNecessary(); 272 this->recordTraceMarkersIfNecessary();
274 } 273 }
275 274
276 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, 275 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,
277 const GrPipelineBuilder& pipelineBuilder, 276 const GrPipelineBuilder& pipelineBuilder,
278 const GrScissorState& scissorState, 277 const GrScissorState& scissorState,
279 const GrDeviceCoordTexture* dstCopy) { 278 const SkRect* devBounds) {
280 if (!this->recordStateAndShouldDraw(batch, pipelineBuilder, scissorState, ds tCopy)) { 279 if (!this->recordStateAndShouldDraw(batch, pipelineBuilder, scissorState, de vBounds)) {
281 return; 280 return;
282 } 281 }
283 282
284 // Check if there is a Batch Draw we can batch with 283 // Check if there is a Batch Draw we can batch with
285 if (kDrawBatch_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) { 284 if (kDrawBatch_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) {
286 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch)); 285 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch));
287 return; 286 return;
288 } 287 }
289 288
290 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); 289 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back());
(...skipping 18 matching lines...) Expand all
309 sp->fViewMatrix = pathProc->viewMatrix(); 308 sp->fViewMatrix = pathProc->viewMatrix();
310 sp->fStencil = stencilSettings; 309 sp->fStencil = stencilSettings;
311 this->recordTraceMarkersIfNecessary(); 310 this->recordTraceMarkersIfNecessary();
312 } 311 }
313 312
314 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder, 313 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder,
315 const GrPathProcessor* pathProc, 314 const GrPathProcessor* pathProc,
316 const GrPath* path, 315 const GrPath* path,
317 const GrScissorState& scissorState, 316 const GrScissorState& scissorState,
318 const GrStencilSettings& stencilSettings, 317 const GrStencilSettings& stencilSettings,
319 const GrDeviceCoordTexture* dstCopy) { 318 const SkRect* devBounds) {
320 this->closeBatch(); 319 this->closeBatch();
321 320
322 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing? 321 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing?
323 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, dstCopy)) { 322 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, devBounds)) {
324 return; 323 return;
325 } 324 }
326 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); 325 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
327 dp->fStencilSettings = stencilSettings; 326 dp->fStencilSettings = stencilSettings;
328 this->recordTraceMarkersIfNecessary(); 327 this->recordTraceMarkersIfNecessary();
329 } 328 }
330 329
331 void GrInOrderDrawBuffer::onDrawPaths(const GrPipelineBuilder& pipelineBuilder, 330 void GrInOrderDrawBuffer::onDrawPaths(const GrPipelineBuilder& pipelineBuilder,
332 const GrPathProcessor* pathProc, 331 const GrPathProcessor* pathProc,
333 const GrPathRange* pathRange, 332 const GrPathRange* pathRange,
334 const void* indices, 333 const void* indices,
335 PathIndexType indexType, 334 PathIndexType indexType,
336 const float transformValues[], 335 const float transformValues[],
337 PathTransformType transformType, 336 PathTransformType transformType,
338 int count, 337 int count,
339 const GrScissorState& scissorState, 338 const GrScissorState& scissorState,
340 const GrStencilSettings& stencilSettings, 339 const GrStencilSettings& stencilSettings,
341 const GrDeviceCoordTexture* dstCopy) { 340 const SkRect* devBounds) {
342 SkASSERT(pathRange); 341 SkASSERT(pathRange);
343 SkASSERT(indices); 342 SkASSERT(indices);
344 SkASSERT(transformValues); 343 SkASSERT(transformValues);
345 344
346 this->closeBatch(); 345 this->closeBatch();
347 346
348 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, dstCopy)) { 347 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, devBounds)) {
349 return; 348 return;
350 } 349 }
351 350
352 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); 351 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType);
353 if (int misalign = fPathIndexBuffer.count() % indexBytes) { 352 if (int misalign = fPathIndexBuffer.count() % indexBytes) {
354 // Add padding to the index buffer so the indices are aligned properly. 353 // Add padding to the index buffer so the indices are aligned properly.
355 fPathIndexBuffer.append(indexBytes - misalign); 354 fPathIndexBuffer.append(indexBytes - misalign);
356 } 355 }
357 356
358 char* savedIndices = fPathIndexBuffer.append(count * indexBytes, 357 char* savedIndices = fPathIndexBuffer.append(count * indexBytes,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 478
480 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType); 479 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType);
481 if (isSetState) { 480 if (isSetState) {
482 SetState* ss = reinterpret_cast<SetState*>(iter.get()); 481 SetState* ss = reinterpret_cast<SetState*>(iter.get());
483 482
484 // TODO sometimes we have a prim proc, othertimes we have a GrBatch. Eventually we will 483 // TODO sometimes we have a prim proc, othertimes we have a GrBatch. Eventually we will
485 // only have GrBatch and we can delete this 484 // only have GrBatch and we can delete this
486 if (ss->fPrimitiveProcessor) { 485 if (ss->fPrimitiveProcessor) {
487 this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProc essor, 486 this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProc essor,
488 ss->fPipeline, 487 ss->fPipeline,
489 ss->fPipeline.descInfo(),
490 ss->fBatchTracker); 488 ss->fBatchTracker);
491 } 489 }
492 currentState = ss; 490 currentState = ss;
493 } else { 491 } else {
494 iter->execute(this, currentState); 492 iter->execute(this, currentState);
495 } 493 }
496 494
497 if (cmd_has_trace_marker(iter->fType)) { 495 if (cmd_has_trace_marker(iter->fType)) {
498 this->getGpu()->removeGpuTraceMarker(&newMarker); 496 this->getGpu()->removeGpuTraceMarker(&newMarker);
499 } 497 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 cs->fDstPoint = dstPoint; 572 cs->fDstPoint = dstPoint;
575 this->recordTraceMarkersIfNecessary(); 573 this->recordTraceMarkersIfNecessary();
576 return true; 574 return true;
577 } 575 }
578 return false; 576 return false;
579 } 577 }
580 578
581 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipe lineBuilder, 579 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipe lineBuilder,
582 const GrPrimitiveProcessor* p rimProc, 580 const GrPrimitiveProcessor* p rimProc,
583 const GrScissorState& scissor , 581 const GrScissorState& scissor ,
584 const GrDeviceCoordTexture* d stCopy) { 582 const SkRect* devBounds) {
583 GrDeviceCoordTexture dstCopy;
584 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
bsalomon 2015/01/30 14:59:14 Is it possible to set up the dst read in GrDrawTar
egdaniel 2015/02/03 16:47:44 Yes it is definitely better to do this in the base
585 return false;
586 }
585 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, 587 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
586 (pipelineBuilder, primProc, *this->g etGpu()->caps(), 588 (pipelineBuilder, primProc, *this->g etGpu()->caps(),
587 scissor, dstCopy)); 589 scissor, &dstCopy));
588 if (ss->fPipeline.mustSkip()) { 590 if (ss->fPipeline.mustSkip()) {
589 fCmdBuffer.pop_back(); 591 fCmdBuffer.pop_back();
590 return false; 592 return false;
591 } 593 }
592 594
593 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, 595 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker,
594 ss->fPipeline.getInitBatchTracker( )); 596 ss->fPipeline.getInitBatchTracker( ));
595 597
596 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && 598 if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
597 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, 599 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
598 *ss->fPrimitiveProcessor, 600 *ss->fPrimitiveProcessor,
599 ss->fBatchTracker) && 601 ss->fBatchTracker) &&
600 fPrevState->fPipeline.isEqual(ss->fPipeline)) { 602 fPrevState->fPipeline.isEqual(ss->fPipeline)) {
601 fCmdBuffer.pop_back(); 603 fCmdBuffer.pop_back();
602 } else { 604 } else {
603 fPrevState = ss; 605 fPrevState = ss;
604 this->recordTraceMarkersIfNecessary(); 606 this->recordTraceMarkersIfNecessary();
605 } 607 }
606 return true; 608 return true;
607 } 609 }
608 610
609 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(GrBatch* batch, 611 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(GrBatch* batch,
610 const GrPipelineBuilder& pipe lineBuilder, 612 const GrPipelineBuilder& pipe lineBuilder,
611 const GrScissorState& scissor , 613 const GrScissorState& scissor ,
612 const GrDeviceCoordTexture* d stCopy) { 614 const SkRect* devBounds) {
615 GrDeviceCoordTexture dstCopy;
616 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
617 return false;
618 }
613 // TODO this gets much simpler when we have batches everywhere. 619 // TODO this gets much simpler when we have batches everywhere.
614 // If the previous command is also a set state, then we check to see if it h as a Batch. If so, 620 // If the previous command is also a set state, then we check to see if it h as a Batch. If so,
615 // and we can make the two batches equal, and we can combine the states, the n we make them equal 621 // and we can make the two batches equal, and we can combine the states, the n we make them equal
616 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, 622 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
617 (batch, pipelineBuilder, *this->getG pu()->caps(), scissor, 623 (batch, pipelineBuilder, *this->getG pu()->caps(), scissor,
618 dstCopy)); 624 &dstCopy));
619 if (ss->fPipeline.mustSkip()) { 625 if (ss->fPipeline.mustSkip()) {
620 fCmdBuffer.pop_back(); 626 fCmdBuffer.pop_back();
621 return false; 627 return false;
622 } 628 }
623 629
624 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker()); 630 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker());
625 631
626 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && 632 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
627 fPrevState->fPipeline.isEqual(ss->fPipeline)) { 633 fPrevState->fPipeline.isEqual(ss->fPipeline)) {
628 fCmdBuffer.pop_back(); 634 fCmdBuffer.pop_back();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 int vcount = vertexCount; 681 int vcount = vertexCount;
676 int icount = indexCount; 682 int icount = indexCount;
677 683
678 if (!insideGeoPush && 684 if (!insideGeoPush &&
679 !unreleasedVertexSpace && 685 !unreleasedVertexSpace &&
680 !unreleasedIndexSpace && 686 !unreleasedIndexSpace &&
681 this->geometryHints(vertexStride, &vcount, &icount)) { 687 this->geometryHints(vertexStride, &vcount, &icount)) {
682 this->flush(); 688 this->flush();
683 } 689 }
684 } 690 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698