Skip to content

Commit

Permalink
Tweak path renderer heuristics
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
csmartdalton committed Apr 1, 2022
1 parent 1695609 commit 67f70c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/gpu/ops/AtlasPathRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ constexpr static int kAtlasInitialSize = 512;
// height, which lends very well to efficient pow2 atlas packing.
constexpr static auto kAtlasAlgorithm = GrDynamicAtlas::RectanizerAlgorithm::kPow2;

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

// If we have MSAA to fall back on, paths are already fast enough that we really only benefit from
// atlasing when they are very small.
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/ops/TriangulatingPathRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <cstdio>

#ifndef GR_AA_TESSELLATOR_MAX_VERB_COUNT
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 10
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 1000
#endif

/*
Expand Down
14 changes: 7 additions & 7 deletions src/gpu/v1/PathRendererChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace skgpu::v1 {

PathRendererChain::PathRendererChain(GrRecordingContext* context, const Options& options) {
const GrCaps& caps = *context->priv().caps();
if (options.fGpuPathRenderers & GpuPathRenderers::kAtlas) {
if (auto atlasPathRenderer = AtlasPathRenderer::Make(context)) {
fAtlasPathRenderer = atlasPathRenderer.get();
context->priv().addOnFlushCallbackObject(atlasPathRenderer.get());
fChain.push_back(std::move(atlasPathRenderer));
}
}
if (options.fGpuPathRenderers & GpuPathRenderers::kDashLine) {
fChain.push_back(sk_make_sp<DashLinePathRenderer>());
}
Expand All @@ -42,13 +49,6 @@ PathRendererChain::PathRendererChain(GrRecordingContext* context, const Options&
if (options.fGpuPathRenderers & GpuPathRenderers::kAALinearizing) {
fChain.push_back(sk_make_sp<AALinearizingConvexPathRenderer>());
}
if (options.fGpuPathRenderers & GpuPathRenderers::kAtlas) {
if (auto atlasPathRenderer = AtlasPathRenderer::Make(context)) {
fAtlasPathRenderer = atlasPathRenderer.get();
context->priv().addOnFlushCallbackObject(atlasPathRenderer.get());
fChain.push_back(std::move(atlasPathRenderer));
}
}
if (options.fGpuPathRenderers & GpuPathRenderers::kSmall) {
fChain.push_back(sk_make_sp<SmallPathRenderer>());
}
Expand Down

0 comments on commit 67f70c5

Please sign in to comment.