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

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

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

Powered by Google App Engine
This is Rietveld 408576698