Skip to content

Commit 67f70c5

Browse files
committed
Tweak path renderer heuristics
* Move the atlas path renderer to the top of the chain. The batching abilities and low CPU footprint of this path renderer make it especially ideal for WASM/WebGL. * Bump the atlas path renderer's max path height from 256 to 512. In WASM/WebGL, the CPU/mem bandwidth tradeoff skews more toward minimizing CPU load and putting more stress on memory bandwidth. * Bump the AA triangulator's max verb count from 10 to 1000. This path renderer has always been under-utilized in Skia, IMO, when the only alternative is to render the path in software and upload a texture. In WASM, a software render is especially expensive. The type of paths created by Rive (fewer verbs that cover more length) are also the type of path that this path renderer is naturally good at.
1 parent 1695609 commit 67f70c5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/gpu/ops/AtlasPathRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ constexpr static int kAtlasInitialSize = 512;
9090
// height, which lends very well to efficient pow2 atlas packing.
9191
constexpr static auto kAtlasAlgorithm = GrDynamicAtlas::RectanizerAlgorithm::kPow2;
9292

93-
// Ensure every path in the atlas falls in or below the 256px high rectanizer band.
94-
constexpr static int kAtlasMaxPathHeight = 256;
93+
// Ensure every path in the atlas falls in or below the 512px high rectanizer band.
94+
constexpr static int kAtlasMaxPathHeight = 512;
9595

9696
// If we have MSAA to fall back on, paths are already fast enough that we really only benefit from
9797
// atlasing when they are very small.

src/gpu/ops/TriangulatingPathRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <cstdio>
3434

3535
#ifndef GR_AA_TESSELLATOR_MAX_VERB_COUNT
36-
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 10
36+
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 1000
3737
#endif
3838

3939
/*

src/gpu/v1/PathRendererChain.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ namespace skgpu::v1 {
3030

3131
PathRendererChain::PathRendererChain(GrRecordingContext* context, const Options& options) {
3232
const GrCaps& caps = *context->priv().caps();
33+
if (options.fGpuPathRenderers & GpuPathRenderers::kAtlas) {
34+
if (auto atlasPathRenderer = AtlasPathRenderer::Make(context)) {
35+
fAtlasPathRenderer = atlasPathRenderer.get();
36+
context->priv().addOnFlushCallbackObject(atlasPathRenderer.get());
37+
fChain.push_back(std::move(atlasPathRenderer));
38+
}
39+
}
3340
if (options.fGpuPathRenderers & GpuPathRenderers::kDashLine) {
3441
fChain.push_back(sk_make_sp<DashLinePathRenderer>());
3542
}
@@ -42,13 +49,6 @@ PathRendererChain::PathRendererChain(GrRecordingContext* context, const Options&
4249
if (options.fGpuPathRenderers & GpuPathRenderers::kAALinearizing) {
4350
fChain.push_back(sk_make_sp<AALinearizingConvexPathRenderer>());
4451
}
45-
if (options.fGpuPathRenderers & GpuPathRenderers::kAtlas) {
46-
if (auto atlasPathRenderer = AtlasPathRenderer::Make(context)) {
47-
fAtlasPathRenderer = atlasPathRenderer.get();
48-
context->priv().addOnFlushCallbackObject(atlasPathRenderer.get());
49-
fChain.push_back(std::move(atlasPathRenderer));
50-
}
51-
}
5252
if (options.fGpuPathRenderers & GpuPathRenderers::kSmall) {
5353
fChain.push_back(sk_make_sp<SmallPathRenderer>());
5454
}

0 commit comments

Comments
 (0)