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

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: Back to bool 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) {
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 481
483 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType); 482 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType);
484 if (isSetState) { 483 if (isSetState) {
485 SetState* ss = reinterpret_cast<SetState*>(iter.get()); 484 SetState* ss = reinterpret_cast<SetState*>(iter.get());
486 485
487 // TODO sometimes we have a prim proc, othertimes we have a GrBatch. Eventually we will 486 // TODO sometimes we have a prim proc, othertimes we have a GrBatch. Eventually we will
488 // only have GrBatch and we can delete this 487 // only have GrBatch and we can delete this
489 if (ss->fPrimitiveProcessor) { 488 if (ss->fPrimitiveProcessor) {
490 this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProc essor, 489 this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProc essor,
491 ss->fPipeline, 490 ss->fPipeline,
492 ss->fPipeline.descInfo(),
493 ss->fBatchTracker); 491 ss->fBatchTracker);
494 } 492 }
495 currentState = ss; 493 currentState = ss;
496 } else { 494 } else {
497 iter->execute(this, currentState); 495 iter->execute(this, currentState);
498 } 496 }
499 497
500 if (cmd_has_trace_marker(iter->fType)) { 498 if (cmd_has_trace_marker(iter->fType)) {
501 this->getGpu()->removeGpuTraceMarker(&newMarker); 499 this->getGpu()->removeGpuTraceMarker(&newMarker);
502 } 500 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 cs->fDstPoint = dstPoint; 575 cs->fDstPoint = dstPoint;
578 this->recordTraceMarkersIfNecessary(); 576 this->recordTraceMarkersIfNecessary();
579 return true; 577 return true;
580 } 578 }
581 return false; 579 return false;
582 } 580 }
583 581
584 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipe lineBuilder, 582 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipe lineBuilder,
585 const GrPrimitiveProcessor* p rimProc, 583 const GrPrimitiveProcessor* p rimProc,
586 const GrScissorState& scissor , 584 const GrScissorState& scissor ,
587 const GrDeviceCoordTexture* d stCopy) { 585 const SkRect* devBounds) {
586 GrDeviceCoordTexture dstCopy;
587 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
588 return false;
589 }
588 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, 590 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
589 (pipelineBuilder, primProc, *this->g etGpu()->caps(), 591 (pipelineBuilder, primProc, *this->g etGpu()->caps(),
590 scissor, dstCopy)); 592 scissor, &dstCopy));
591 if (ss->fPipeline.mustSkip()) { 593 if (ss->fPipeline.mustSkip()) {
592 fCmdBuffer.pop_back(); 594 fCmdBuffer.pop_back();
593 return false; 595 return false;
594 } 596 }
595 597
596 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, 598 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker,
597 ss->fPipeline.getInitBatchTracker( )); 599 ss->fPipeline.getInitBatchTracker( ));
598 600
599 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && 601 if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
600 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, 602 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
601 *ss->fPrimitiveProcessor, 603 *ss->fPrimitiveProcessor,
602 ss->fBatchTracker) && 604 ss->fBatchTracker) &&
603 fPrevState->fPipeline.isEqual(ss->fPipeline)) { 605 fPrevState->fPipeline.isEqual(ss->fPipeline)) {
604 fCmdBuffer.pop_back(); 606 fCmdBuffer.pop_back();
605 } else { 607 } else {
606 fPrevState = ss; 608 fPrevState = ss;
607 this->recordTraceMarkersIfNecessary(); 609 this->recordTraceMarkersIfNecessary();
608 } 610 }
609 return true; 611 return true;
610 } 612 }
611 613
612 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(GrBatch* batch, 614 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(GrBatch* batch,
613 const GrPipelineBuilder& pipe lineBuilder, 615 const GrPipelineBuilder& pipe lineBuilder,
614 const GrScissorState& scissor , 616 const GrScissorState& scissor ,
615 const GrDeviceCoordTexture* d stCopy) { 617 const SkRect* devBounds) {
618 GrDeviceCoordTexture dstCopy;
619 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) {
620 return false;
621 }
616 // TODO this gets much simpler when we have batches everywhere. 622 // TODO this gets much simpler when we have batches everywhere.
617 // If the previous command is also a set state, then we check to see if it h as a Batch. If so, 623 // If the previous command is also a set state, then we check to see if it h as a Batch. If so,
618 // and we can make the two batches equal, and we can combine the states, the n we make them equal 624 // and we can make the two batches equal, and we can combine the states, the n we make them equal
619 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, 625 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
620 (batch, pipelineBuilder, *this->getG pu()->caps(), scissor, 626 (batch, pipelineBuilder, *this->getG pu()->caps(), scissor,
621 dstCopy)); 627 &dstCopy));
622 if (ss->fPipeline.mustSkip()) { 628 if (ss->fPipeline.mustSkip()) {
623 fCmdBuffer.pop_back(); 629 fCmdBuffer.pop_back();
624 return false; 630 return false;
625 } 631 }
626 632
627 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker()); 633 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker());
628 634
629 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && 635 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
630 fPrevState->fPipeline.isEqual(ss->fPipeline)) { 636 fPrevState->fPipeline.isEqual(ss->fPipeline)) {
631 fCmdBuffer.pop_back(); 637 fCmdBuffer.pop_back();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 int vcount = vertexCount; 686 int vcount = vertexCount;
681 int icount = indexCount; 687 int icount = indexCount;
682 688
683 if (!insideGeoPush && 689 if (!insideGeoPush &&
684 !unreleasedVertexSpace && 690 !unreleasedVertexSpace &&
685 !unreleasedIndexSpace && 691 !unreleasedIndexSpace &&
686 this->geometryHints(vertexStride, &vcount, &icount)) { 692 this->geometryHints(vertexStride, &vcount, &icount)) {
687 this->flush(); 693 this->flush();
688 } 694 }
689 } 695 }
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