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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrReorderCommandBuilder.h ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrReorderCommandBuilder.cpp
diff --git a/src/gpu/GrReorderCommandBuilder.cpp b/src/gpu/GrReorderCommandBuilder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b42a8016d8c60e4e64133462b852bd9ec6888c47
--- /dev/null
+++ b/src/gpu/GrReorderCommandBuilder.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrReorderCommandBuilder.h"
+#include "SkStringUtils.h"
+
+template <class Left, class Right>
+static bool intersect(const Left& a, const Right& b) {
+ SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom &&
+ b.fLeft <= b.fRight && b.fTop <= b.fBottom);
+ return a.fLeft < b.fRight && b.fLeft < a.fRight &&
+ a.fTop < b.fBottom && b.fTop < a.fBottom;
+}
+
+GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrBatch* batch,
+ const GrCaps& caps) {
+ // Check if there is a Batch Draw we can batch with by linearly searching back until we either
+ // 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;
+
+ //GrRenderTarget* rt = batch->rt2(); //batch->pipeline()->getRenderTarget1();
+
+ GrBATCH_INFO("Re-Recording (%s, B%u)\n"
+ "\tBounds (%f, %f, %f, %f)\n",
+ batch->name(),
+ batch->uniqueID(),
+ batch->bounds().fLeft, batch->bounds().fRight,
+ batch->bounds().fTop, batch->bounds().fBottom);
+ GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str());
+ GrBATCH_INFO("\tOutcome:\n");
+ if (!this->cmdBuffer()->empty()) {
+ GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
+
+ do {
+ if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
+ DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get());
+
+ if (previous->batch()->renderTargetUniqueID() != batch->renderTargetUniqueID()) {
+ GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n",
+ previous->batch()->name(), previous->batch()->uniqueID());
+ break;
+ }
+ // We cannot continue to search backwards if the render target changes
+ if (previous->batch()->combineIfPossible(batch, caps)) {
+ GrBATCH_INFO("\t\tCombining with (%s, B%u)\n",
+ previous->batch()->name(), previous->batch()->uniqueID());
+ return nullptr;
+ }
+
+ if (intersect(previous->batch()->bounds(), batch->bounds())) {
+ GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n",
+ previous->batch()->name(), previous->batch()->uniqueID());
+ break;
+ }
+ } else {
+ GrBATCH_INFO("\t\tBreaking because of other %08x\n", reverseIter->type());
+ // TODO temporary until we only have batches.
+ break;
+ }
+ } while (reverseIter.previous() && ++i < kMaxLookback);
+#if GR_BATCH_SPEW
+ if (!reverseIter.get()) {
+ GrBATCH_INFO("\t\tNo more commands to try and batch with\n");
+ } else if (i >= kMaxLookback) {
+ GrBATCH_INFO("\t\tReached max lookback %d\n", i);
+ }
+#endif
+ }
+#if GR_BATCH_SPEW
+ else {
+ GrBATCH_INFO("\t\tBreaking because empty command buffer\n");
+ }
+#endif
+
+ return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch));
+}
« 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