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

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

Issue 1276633003: Fix reording across rendertarget switching (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | 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 if (!this->cmdBuffer()->empty()) { 28 if (!this->cmdBuffer()->empty()) {
28 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ; 29 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ;
29 30
30 do { 31 do {
31 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { 32 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
32 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ; 33 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ;
33 34
35 // We cannot continue to search backwards if the render target c hanges
36 if (previous->fBatch->pipeline()->getRenderTarget() != rt) {
37 break;
38 }
39
34 if (previous->fBatch->combineIfPossible(batch)) { 40 if (previous->fBatch->combineIfPossible(batch)) {
35 return NULL; 41 return NULL;
36 } 42 }
37 43
38 if (intersect(previous->fBatch->bounds(), batch->bounds())) { 44 if (intersect(previous->fBatch->bounds(), batch->bounds())) {
39 break; 45 break;
40 } 46 }
41 } else if (Cmd::kClear_CmdType == reverseIter->type()) { 47 } else if (Cmd::kClear_CmdType == reverseIter->type()) {
42 Clear* previous = static_cast<Clear*>(reverseIter.get()); 48 Clear* previous = static_cast<Clear*>(reverseIter.get());
43 49
44 // We set the color to illegal if we are doing a discard. 50 // We set the color to illegal if we are doing a discard.
45 // If we can ignore the rect, then we do a full clear 51 // If we can ignore the rect, then we do a full clear
46 if (previous->fColor == GrColor_ILLEGAL || 52 if (previous->fColor == GrColor_ILLEGAL ||
47 previous->fCanIgnoreRect || 53 previous->fCanIgnoreRect ||
48 intersect(batch->bounds(), previous->fRect)) { 54 intersect(batch->bounds(), previous->fRect)) {
49 break; 55 break;
50 } 56 }
51 } else { 57 } else {
52 // TODO temporary until we can navigate the other types of comma nds 58 // TODO temporary until we can navigate the other types of comma nds
53 break; 59 break;
54 } 60 }
55 } while (reverseIter.previous() && ++i < kMaxLookback); 61 } while (reverseIter.previous() && ++i < kMaxLookback);
56 } 62 }
57 63
58 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch , 64 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch ,
59 this->batchT arget())); 65 this->batchT arget()));
60 } 66 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698