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

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

Issue 1278643006: Make GrBatch carry its own GrPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more 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/GrReorderCommandBuilder.h ('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(const State* sta te, 18 GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrBatch* batch) {
19 const GrPipeline Optimizations& opts,
20 GrBatch* batch) {
21 // 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
22 // 1) check every draw 20 // 1) check every draw
23 // 2) intersect with something 21 // 2) intersect with something
24 // 3) find a 'blocker' 22 // 3) find a 'blocker'
25 // 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.
26 static const int kMaxLookback = 10; 24 static const int kMaxLookback = 10;
27 int i = 0; 25 int i = 0;
28 batch->setPipeline(state->getPipeline(), opts); 26
29 GrRenderTarget* rt = state->getPipeline()->getRenderTarget(); 27 GrRenderTarget* rt = batch->pipeline()->getRenderTarget();
30 28
31 GrBATCH_INFO("Re-Recording (%s, B%u)\n" 29 GrBATCH_INFO("Re-Recording (%s, B%u)\n"
32 "\tRenderTarget %p\n" 30 "\tRenderTarget %p\n"
33 "\tBounds (%f, %f, %f, %f)\n", 31 "\tBounds (%f, %f, %f, %f)\n",
34 batch->name(), 32 batch->name(),
35 batch->uniqueID(), rt, 33 batch->uniqueID(), rt,
36 batch->bounds().fLeft, batch->bounds().fRight, 34 batch->bounds().fLeft, batch->bounds().fRight,
37 batch->bounds().fTop, batch->bounds().fBottom); 35 batch->bounds().fTop, batch->bounds().fBottom);
38 if (GR_BATCH_SPEW) { 36 if (GR_BATCH_SPEW) {
39 SkDebugf("\tColorStages:\n"); 37 SkDebugf("\tColorStages:\n");
40 for (int i = 0; i < state->getPipeline()->numColorFragmentStages(); i++) { 38 for (int i = 0; i < batch->pipeline()->numColorFragmentStages(); i++) {
41 SkDebugf("\t\t%s\n", state->getPipeline()->getColorStage(i).processo r()->name()); 39 SkDebugf("\t\t%s\n", batch->pipeline()->getColorStage(i).processor() ->name());
42 } 40 }
43 SkDebugf("\tCoverageStages:\n"); 41 SkDebugf("\tCoverageStages:\n");
44 for (int i = 0; i < state->getPipeline()->numCoverageFragmentStages(); i ++) { 42 for (int i = 0; i < batch->pipeline()->numCoverageFragmentStages(); i++) {
45 SkDebugf("\t\t%s\n", state->getPipeline()->getCoverageStage(i).proce ssor()->name()); 43 SkDebugf("\t\t%s\n", batch->pipeline()->getCoverageStage(i).processo r()->name());
46 } 44 }
47 SkDebugf("\tXP: %s\n", state->getPipeline()->getXferProcessor()->name()) ; 45 SkDebugf("\tXP: %s\n", batch->pipeline()->getXferProcessor()->name());
48 } 46 }
49 GrBATCH_INFO("\tOutcome:\n"); 47 GrBATCH_INFO("\tOutcome:\n");
50 if (!this->cmdBuffer()->empty()) { 48 if (!this->cmdBuffer()->empty()) {
51 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ; 49 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ;
52 50
53 do { 51 do {
54 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { 52 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
55 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ; 53 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ;
56 54
57 if (previous->fBatch->pipeline()->getRenderTarget() != rt) { 55 if (previous->batch()->pipeline()->getRenderTarget() != rt) {
58 GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget \n", 56 GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget \n",
59 previous->fBatch->name(), previous->fBatch->uni queID()); 57 previous->fBatch->name(), previous->fBatch->uni queID());
60 break; 58 break;
61 } 59 }
62 // 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
63 if (previous->fBatch->combineIfPossible(batch)) { 61 if (previous->batch()->combineIfPossible(batch)) {
64 GrBATCH_INFO("\t\tCombining with (%s, B%u)\n", 62 GrBATCH_INFO("\t\tCombining with (%s, B%u)\n",
65 previous->fBatch->name(), previous->fBatch->uni queID()); 63 previous->fBatch->name(), previous->fBatch->uni queID());
66 return NULL; 64 return NULL;
67 } 65 }
68 66
69 if (intersect(previous->fBatch->bounds(), batch->bounds())) { 67 if (intersect(previous->batch()->bounds(), batch->bounds())) {
70 GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n", 68 GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n",
71 previous->fBatch->name(), previous->fBatch->uni queID()); 69 previous->fBatch->name(), previous->fBatch->uni queID());
72 break; 70 break;
73 } 71 }
74 } else if (Cmd::kClear_CmdType == reverseIter->type()) { 72 } else if (Cmd::kClear_CmdType == reverseIter->type()) {
75 Clear* previous = static_cast<Clear*>(reverseIter.get()); 73 Clear* previous = static_cast<Clear*>(reverseIter.get());
76 74
77 // 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
78 if (previous->renderTarget() != rt) { 76 if (previous->renderTarget() != rt) {
79 GrBATCH_INFO("\t\tBreaking because of Clear's Rendertarget c hange\n"); 77 GrBATCH_INFO("\t\tBreaking because of Clear's Rendertarget c hange\n");
(...skipping 19 matching lines...) Expand all
99 GrBATCH_INFO("\t\tReached max lookback %d\n", i); 97 GrBATCH_INFO("\t\tReached max lookback %d\n", i);
100 } 98 }
101 #endif 99 #endif
102 } 100 }
103 #if GR_BATCH_SPEW 101 #if GR_BATCH_SPEW
104 else { 102 else {
105 GrBATCH_INFO("\t\tBreaking because empty command buffer\n"); 103 GrBATCH_INFO("\t\tBreaking because empty command buffer\n");
106 } 104 }
107 #endif 105 #endif
108 106
109 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch , 107 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch, this- >batchTarget()));
110 this->batchT arget()));
111 } 108 }
OLDNEW
« no previous file with comments | « src/gpu/GrReorderCommandBuilder.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698