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

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

Powered by Google App Engine
This is Rietveld 408576698