Trivial patch to set a max lookback on reordering
authorjoshualitt <joshualitt@chromium.org>
Fri, 22 May 2015 18:19:44 +0000 (11:19 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 22 May 2015 18:19:44 +0000 (11:19 -0700)
BUG=skia:

Review URL: https://codereview.chromium.org/1150253003

src/gpu/GrReorderCommandBuilder.cpp

index 3ba95d7..14279de 100644 (file)
@@ -19,6 +19,9 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr
     // 1) check every draw
     // 2) intersect with something
     // 3) find a 'blocker'
+    // Experimentally we have found that most batching occurs within the first 10 comparisons.
+    static const int kMaxLookback = 10;
+    int i = 0;
     if (!this->cmdBuffer()->empty()) {
         GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
 
@@ -38,7 +41,7 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr
                 // TODO temporary until we can navigate the other types of commands
                 break;
             }
-        } while (reverseIter.previous());
+        } while (reverseIter.previous() && ++i < kMaxLookback);
     }
 
     return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch,