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

Unified Diff: src/gpu/instanced/InstancedRendering.cpp

Issue 2119123002: Don't batch large instanced rects with other shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Don't batch large instanced rects with other shapes Created 4 years, 5 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/instanced/InstancedRendering.h ('k') | src/gpu/instanced/InstancedRenderingTypes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/instanced/InstancedRendering.cpp
diff --git a/src/gpu/instanced/InstancedRendering.cpp b/src/gpu/instanced/InstancedRendering.cpp
index 165bff494b3fa0ab1f241c844ec59afb8b582da9..12edc986c3534a34906421dff313af830d340af8 100644
--- a/src/gpu/instanced/InstancedRendering.cpp
+++ b/src/gpu/instanced/InstancedRendering.cpp
@@ -184,6 +184,7 @@ InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const
const float* rectAsFloats = localRect.asScalars(); // Ensure SkScalar == float.
memcpy(&instance.fLocalRect, rectAsFloats, 4 * sizeof(float));
+ batch->fPixelLoad = batch->fBounds.height() * batch->fBounds.width();
return batch;
}
@@ -366,14 +367,29 @@ bool InstancedRendering::Batch::onCombineIfPossible(GrBatch* other, const GrCaps
SkASSERT(fTailDraw);
SkASSERT(that->fTailDraw);
- if (!fInfo.canJoin(that->fInfo) ||
+ if (!BatchInfo::CanCombine(fInfo, that->fInfo) ||
!GrPipeline::CanCombine(*this->pipeline(), this->bounds(),
*that->pipeline(), that->bounds(), caps)) {
return false;
}
+ BatchInfo combinedInfo = fInfo | that->fInfo;
+ if (!combinedInfo.isSimpleRects()) {
+ // This threshold was chosen with the "shapes_mixed" bench on a MacBook with Intel graphics.
+ // There seems to be a wide range where it doesn't matter if we combine or not. What matters
+ // is that the itty bitty rects combine with other shapes and the giant ones don't.
+ constexpr SkScalar kMaxPixelsToGeneralizeRects = 256 * 256;
+ if (fInfo.isSimpleRects() && fPixelLoad > kMaxPixelsToGeneralizeRects) {
+ return false;
+ }
+ if (that->fInfo.isSimpleRects() && that->fPixelLoad > kMaxPixelsToGeneralizeRects) {
+ return false;
+ }
+ }
+
fBounds.join(that->fBounds);
- fInfo.join(that->fInfo);
+ fInfo = combinedInfo;
+ fPixelLoad += that->fPixelLoad;
// Adopt the other batch's draws.
fNumDraws += that->fNumDraws;
« no previous file with comments | « src/gpu/instanced/InstancedRendering.h ('k') | src/gpu/instanced/InstancedRenderingTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698