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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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/GrResourceCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrReorderCommandBuilder.h"
9 #include "SkStringUtils.h"
10
11 template <class Left, class Right>
12 static bool intersect(const Left& a, const Right& b) {
13 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom &&
14 b.fLeft <= b.fRight && b.fTop <= b.fBottom);
15 return a.fLeft < b.fRight && b.fLeft < a.fRight &&
16 a.fTop < b.fBottom && b.fTop < a.fBottom;
17 }
18
19 GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrBatch* batch,
20 const GrCaps& ca ps) {
21 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either
22 // 1) check every draw
23 // 2) intersect with something
24 // 3) find a 'blocker'
25 // Experimentally we have found that most batching occurs within the first 1 0 comparisons.
26 static const int kMaxLookback = 10;
27 int i = 0;
28
29 //GrRenderTarget* rt = batch->rt2(); //batch->pipeline()->getRenderTarget1() ;
30
31 GrBATCH_INFO("Re-Recording (%s, B%u)\n"
32 "\tBounds (%f, %f, %f, %f)\n",
33 batch->name(),
34 batch->uniqueID(),
35 batch->bounds().fLeft, batch->bounds().fRight,
36 batch->bounds().fTop, batch->bounds().fBottom);
37 GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str());
38 GrBATCH_INFO("\tOutcome:\n");
39 if (!this->cmdBuffer()->empty()) {
40 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer()) ;
41
42 do {
43 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
44 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get()) ;
45
46 if (previous->batch()->renderTargetUniqueID() != batch->renderTa rgetUniqueID()) {
47 GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget \n",
48 previous->batch()->name(), previous->batch()->u niqueID());
49 break;
50 }
51 // We cannot continue to search backwards if the render target c hanges
52 if (previous->batch()->combineIfPossible(batch, caps)) {
53 GrBATCH_INFO("\t\tCombining with (%s, B%u)\n",
54 previous->batch()->name(), previous->batch()->u niqueID());
55 return nullptr;
56 }
57
58 if (intersect(previous->batch()->bounds(), batch->bounds())) {
59 GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n",
60 previous->batch()->name(), previous->batch()->u niqueID());
61 break;
62 }
63 } else {
64 GrBATCH_INFO("\t\tBreaking because of other %08x\n", reverseIter ->type());
65 // TODO temporary until we only have batches.
66 break;
67 }
68 } while (reverseIter.previous() && ++i < kMaxLookback);
69 #if GR_BATCH_SPEW
70 if (!reverseIter.get()) {
71 GrBATCH_INFO("\t\tNo more commands to try and batch with\n");
72 } else if (i >= kMaxLookback) {
73 GrBATCH_INFO("\t\tReached max lookback %d\n", i);
74 }
75 #endif
76 }
77 #if GR_BATCH_SPEW
78 else {
79 GrBATCH_INFO("\t\tBreaking because empty command buffer\n");
80 }
81 #endif
82
83 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch));
84 }
OLDNEW
« no previous file with comments | « src/gpu/GrReorderCommandBuilder.h ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698