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

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: tweaks 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
« src/gpu/GrBatch.h ('K') | « src/gpu/GrInOrderCommandBuilder.cpp ('k') | no next file » | 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, %p), RenderTarget %p\nBounds (%f, %f, %f, %f )\n", batch->name(),
30 batch, rt, batch->bounds().fLeft, batch->bounds().fRight,
31 batch->bounds().fTop, batch->bounds().fBottom);
28 if (!this->cmdBuffer()->empty()) { 32 if (!this->cmdBuffer()->empty()) {
29 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ; 33 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ;
30 34
31 do { 35 do {
32 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { 36 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
33 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ; 37 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ;
34 38
35 // We cannot continue to search backwards if the render target c hanges 39 // We cannot continue to search backwards if the render target c hanges
36 if (previous->fBatch->pipeline()->getRenderTarget() != rt) { 40 if (previous->fBatch->pipeline()->getRenderTarget() != rt) {
41 GrBATCH_INFO("\tBreaking because of (%s, %p) Rendertarget\n" ,
42 previous->fBatch->name(), previous->fBatch.get( ));
37 break; 43 break;
38 } 44 }
39 45
40 if (previous->fBatch->combineIfPossible(batch)) { 46 if (previous->fBatch->combineIfPossible(batch)) {
47 GrBATCH_INFO("\tCombining with (%s, %p)\n",
48 previous->fBatch->name(), previous->fBatch.get( ));
41 return NULL; 49 return NULL;
42 } 50 }
43 51
44 if (intersect(previous->fBatch->bounds(), batch->bounds())) { 52 if (intersect(previous->fBatch->bounds(), batch->bounds())) {
53 GrBATCH_INFO("\tIntersects with (%s, %p)\n",
54 previous->fBatch->name(), previous->fBatch.get( ));
45 break; 55 break;
46 } 56 }
47 } else if (Cmd::kClear_CmdType == reverseIter->type()) { 57 } else if (Cmd::kClear_CmdType == reverseIter->type()) {
48 Clear* previous = static_cast<Clear*>(reverseIter.get()); 58 Clear* previous = static_cast<Clear*>(reverseIter.get());
49 59
50 // 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
51 if (previous->renderTarget() != rt) { 61 if (previous->renderTarget() != rt) {
62 GrBATCH_INFO("\tBreaking because of Clear's Rendertarget cha nge\n");
52 break; 63 break;
53 } 64 }
54 65
55 // We set the color to illegal if we are doing a discard. 66 // We set the color to illegal if we are doing a discard.
56 // If we can ignore the rect, then we do a full clear 67 // If we can ignore the rect, then we do a full clear
57 if (previous->fColor == GrColor_ILLEGAL || 68 if (previous->fColor == GrColor_ILLEGAL ||
58 previous->fCanIgnoreRect || 69 previous->fCanIgnoreRect ||
59 intersect(batch->bounds(), previous->fRect)) { 70 intersect(batch->bounds(), previous->fRect)) {
71 GrBATCH_INFO("\tBreaking because of Clear intersection\n");
60 break; 72 break;
61 } 73 }
62 } else { 74 } else {
75 GrBATCH_INFO("\tBreaking because of other %08x\n", reverseIter-> type());
63 // TODO temporary until we can navigate the other types of comma nds 76 // TODO temporary until we can navigate the other types of comma nds
64 break; 77 break;
65 } 78 }
66 } while (reverseIter.previous() && ++i < kMaxLookback); 79 } while (reverseIter.previous() && ++i < kMaxLookback);
67 } 80 }
68 81
69 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch , 82 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch ,
70 this->batchT arget())); 83 this->batchT arget()));
71 } 84 }
OLDNEW
« src/gpu/GrBatch.h ('K') | « src/gpu/GrInOrderCommandBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698