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

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

Issue 1276913002: Add Batch logging (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 4 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/GrInOrderCommandBuilder.cpp ('k') | src/gpu/GrTargetCommands.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 2015 Google Inc. 2 * Copyright 2015 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 "GrReorderCommandBuilder.h" 8 #include "GrReorderCommandBuilder.h"
9 9
10 template <class Left, class Right> 10 template <class Left, class Right>
11 static bool intersect(const Left& a, const Right& b) { 11 static bool intersect(const Left& a, const Right& b) {
12 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && 12 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom &&
13 b.fLeft <= b.fRight && b.fTop <= b.fBottom); 13 b.fLeft <= b.fRight && b.fTop <= b.fBottom);
14 return a.fLeft < b.fRight && b.fLeft < a.fRight && 14 return a.fLeft < b.fRight && b.fLeft < a.fRight &&
15 a.fTop < b.fBottom && b.fTop < a.fBottom; 15 a.fTop < b.fBottom && b.fTop < a.fBottom;
16 } 16 }
17 17
18 GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr Batch* batch) { 18 GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr Batch* batch) {
19 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either 19 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either
20 // 1) check every draw 20 // 1) check every draw
21 // 2) intersect with something 21 // 2) intersect with something
22 // 3) find a 'blocker' 22 // 3) find a 'blocker'
23 // Experimentally we have found that most batching occurs within the first 1 0 comparisons. 23 // Experimentally we have found that most batching occurs within the first 1 0 comparisons.
24 static const int kMaxLookback = 10; 24 static const int kMaxLookback = 10;
25 int i = 0; 25 int i = 0;
26 batch->setPipeline(state->getPipeline()); 26 batch->setPipeline(state->getPipeline());
27 GrRenderTarget* rt = state->getPipeline()->getRenderTarget(); 27 GrRenderTarget* rt = state->getPipeline()->getRenderTarget();
28
29 GrBATCH_INFO("Re-Recording (%s, B%u)\n"
30 "\tRenderTarget %p\n"
31 "\tBounds (%f, %f, %f, %f)\n",
32 batch->name(),
33 batch->uniqueID(), rt,
34 batch->bounds().fLeft, batch->bounds().fRight,
35 batch->bounds().fTop, batch->bounds().fBottom);
36 #if GR_BATCH_SPEW
37 SkDebugf("\tColorStages:\n");
38 for (int i = 0; i < state->getPipeline()->numColorFragmentStages(); i++) {
39 SkDebugf("\t\t%s\n", state->getPipeline()->getColorStage(i).processor()- >name());
40 }
41 SkDebugf("\tCoverageStages:\n");
42 for (int i = 0; i < state->getPipeline()->numCoverageFragmentStages(); i++) {
43 SkDebugf("\t\t%s\n", state->getPipeline()->getCoverageStage(i).processor ()->name());
44 }
45 SkDebugf("\tXP: %s\n", state->getPipeline()->getXferProcessor()->name());
46 #endif
47 GrBATCH_INFO("\tOutcome:\n");
28 if (!this->cmdBuffer()->empty()) { 48 if (!this->cmdBuffer()->empty()) {
29 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ; 49 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ;
30 50
31 do { 51 do {
32 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { 52 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
33 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ; 53 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ;
34 54
35 if (previous->fBatch->pipeline()->getRenderTarget() != rt) { 55 if (previous->fBatch->pipeline()->getRenderTarget() != rt) {
56 GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget \n",
57 previous->fBatch->name(), previous->fBatch->uni queID());
36 break; 58 break;
37 } 59 }
38 // We cannot continue to search backwards if the render target c hanges 60 // We cannot continue to search backwards if the render target c hanges
39 if (previous->fBatch->combineIfPossible(batch)) { 61 if (previous->fBatch->combineIfPossible(batch)) {
62 GrBATCH_INFO("\t\tCombining with (%s, B%u)\n",
63 previous->fBatch->name(), previous->fBatch->uni queID());
40 return NULL; 64 return NULL;
41 } 65 }
42 66
43 if (intersect(previous->fBatch->bounds(), batch->bounds())) { 67 if (intersect(previous->fBatch->bounds(), batch->bounds())) {
68 GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n",
69 previous->fBatch->name(), previous->fBatch->uni queID());
44 break; 70 break;
45 } 71 }
46 } else if (Cmd::kClear_CmdType == reverseIter->type()) { 72 } else if (Cmd::kClear_CmdType == reverseIter->type()) {
47 Clear* previous = static_cast<Clear*>(reverseIter.get()); 73 Clear* previous = static_cast<Clear*>(reverseIter.get());
48 74
49 // We cannot continue to search backwards if the render target c hanges 75 // We cannot continue to search backwards if the render target c hanges
50 if (previous->renderTarget() != rt) { 76 if (previous->renderTarget() != rt) {
77 GrBATCH_INFO("\t\tBreaking because of Clear's Rendertarget c hange\n");
51 break; 78 break;
52 } 79 }
53 80
54 // We set the color to illegal if we are doing a discard. 81 // We set the color to illegal if we are doing a discard.
55 if (previous->fColor == GrColor_ILLEGAL || 82 if (previous->fColor == GrColor_ILLEGAL ||
56 intersect(batch->bounds(), previous->fRect)) { 83 intersect(batch->bounds(), previous->fRect)) {
84 GrBATCH_INFO("\t\tBreaking because of Clear intersection\n") ;
57 break; 85 break;
58 } 86 }
59 } else { 87 } else {
88 GrBATCH_INFO("\t\tBreaking because of other %08x\n", reverseIter ->type());
60 // TODO temporary until we can navigate the other types of comma nds 89 // TODO temporary until we can navigate the other types of comma nds
61 break; 90 break;
62 } 91 }
63 } while (reverseIter.previous() && ++i < kMaxLookback); 92 } while (reverseIter.previous() && ++i < kMaxLookback);
93 #if GR_BATCH_SPEW
94 if (!reverseIter.get()) {
95 GrBATCH_INFO("\t\tNo more commands to try and batch with\n");
96 } else if (i >= kMaxLookback) {
97 GrBATCH_INFO("\t\tReached max lookback %d\n", i);
98 }
99 #endif
64 } 100 }
101 #if GR_BATCH_SPEW
102 else {
103 GrBATCH_INFO("\t\tBreaking because empty command buffer\n");
104 }
105 #endif
65 106
66 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch , 107 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch ,
67 this->batchT arget())); 108 this->batchT arget()));
68 } 109 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderCommandBuilder.cpp ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698