[graphite] Add limit to number of paths added to small path atlas per flush
This is a short term solution to avoid regressions with the small path
atlas hybrid strategy. Longer term, the plan is to configure the
RasterPathAtlas differently depending on whether or not MSAA is
available, and then fall back to MSAA automatically if there's no room
in the atlas.
The limit of 256 appears to avoid regressions in MotionMark for a
variety of different minPathSizeForMSAA options.
Bug: 441466076
Fixed: 446475682
Change-Id: Ic26bff39a739bf2050a124dec3d80c7bcb49ff70
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1058036
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Nicolette Prevost <nicolettep@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
(cherry picked from commit d31a6ef0e4eb30c6e782a90682111a802a0c8ba9)
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1058876
Commit-Queue: Thomas Smith <thomsmit@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Thomas Smith <thomsmit@google.com>
diff --git a/src/gpu/graphite/Device.cpp b/src/gpu/graphite/Device.cpp
index f1157cc..275879d 100644
--- a/src/gpu/graphite/Device.cpp
+++ b/src/gpu/graphite/Device.cpp
@@ -1621,6 +1621,7 @@
}
// Since addShape() was successful we should have a valid Renderer now.
SkASSERT(renderer && renderer->numRenderSteps() == 1 && !renderer->emitsPrimitiveColor());
+ fAtlasedPathCount++;
}
#if defined(SK_DEBUG)
@@ -1916,9 +1917,11 @@
// Fall back to CPU rendered paths when multisampling is disabled and the compute atlas is not
// available.
+ static constexpr int kMaxSmallPathAtlasCount = 256;
const float minPathSizeForMSAA = fRecorder->priv().caps()->minPathSizeForMSAA();
- const bool useRasterAtlasByDefault =
- !fMSAASupported || all(drawBounds.size() <= minPathSizeForMSAA);
+ const bool useRasterAtlasByDefault = !fMSAASupported ||
+ (fAtlasedPathCount < kMaxSmallPathAtlasCount &&
+ all(drawBounds.size() <= minPathSizeForMSAA));
if (!pathAtlas && atlasProvider->isAvailable(AtlasProvider::PathAtlasFlags::kRaster) &&
(strategy == PathRendererStrategy::kRasterAA ||
(strategy == PathRendererStrategy::kDefault && useRasterAtlasByDefault))) {
@@ -2054,6 +2057,7 @@
fColorDepthBoundsManager->reset();
fDisjointStencilSet->reset();
fCurrentDepth = DrawOrder::kClearDepth;
+ fAtlasedPathCount = 0;
// Any cleanup in the AtlasProvider
fRecorder->priv().atlasProvider()->compact();
diff --git a/src/gpu/graphite/Device.h b/src/gpu/graphite/Device.h
index 40e1b75..8584d94 100644
--- a/src/gpu/graphite/Device.h
+++ b/src/gpu/graphite/Device.h
@@ -357,6 +357,10 @@
// The DrawContext's target supports MSAA
bool fMSAASupported = false;
+ // Even when MSAA is supported, small paths may be sent to the atlas for higher quality and to
+ // avoid triggering MSAA overhead on a render pass. However, the number of paths is capped
+ // per Device flush.
+ int fAtlasedPathCount = 0;
// TODO(b/330864257): Clean up once flushPendingWorkToRecorder() doesn't have to be re-entrant
bool fIsFlushing = false;