Skip to content

Commit 9213e61

Browse files
csmartdalton86Skia Commit-Bot
authored andcommitted
Disable the tessellation atlas on non-direct contexts
The atlas is not compatible with DDL. This is a temporary fix that will allow us to finally enable tessellation. In the near future we plan to remove the atlas entirely by implementing SkRegion batching and reordering instead. Bug: skia:10419 Change-Id: Ie2d1bda31c12cda8ecd4889004483f679f5ba7e9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324976 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
1 parent f625e4c commit 9213e61

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/gpu/tessellate/GrTessellationPathRenderer.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,31 @@ bool GrTessellationPathRenderer::IsSupported(const GrCaps& caps) {
3939
return caps.drawInstancedSupport() && caps.shaderCaps()->vertexIDSupport();
4040
}
4141

42-
GrTessellationPathRenderer::GrTessellationPathRenderer(const GrRecordingContext* rContext)
42+
GrTessellationPathRenderer::GrTessellationPathRenderer(GrRecordingContext* rContext)
4343
: fAtlas(kAtlasAlpha8Type, GrDynamicAtlas::InternalMultisample::kYes, kAtlasInitialSize,
4444
std::min(kMaxAtlasSize, rContext->priv().caps()->maxPreferredRenderTargetSize()),
4545
*rContext->priv().caps(), kAtlasAlgorithm) {
4646
this->initAtlasFlags(rContext);
4747
}
4848

49-
void GrTessellationPathRenderer::initAtlasFlags(const GrRecordingContext* rContext) {
50-
const GrCaps& caps = *rContext->priv().caps();
49+
void GrTessellationPathRenderer::initAtlasFlags(GrRecordingContext* rContext) {
50+
fMaxAtlasPathWidth = 0;
5151

52-
fStencilAtlasFlags = OpFlags::kStencilOnly | OpFlags::kDisableHWTessellation;
53-
fMaxAtlasPathWidth = fAtlas.maxAtlasSize() / 2;
52+
if (!rContext->asDirectContext()) {
53+
// The atlas is not compatible with DDL. Leave it disabled on non-direct contexts.
54+
return;
55+
}
5456

57+
const GrCaps& caps = *rContext->priv().caps();
5558
auto atlasFormat = caps.getDefaultBackendFormat(kAtlasAlpha8Type, GrRenderable::kYes);
5659
if (caps.internalMultisampleCount(atlasFormat) <= 1) {
57-
// MSAA is not supported on kAlpha8. Disable the atlas.
58-
fMaxAtlasPathWidth = 0;
60+
// MSAA is not supported on kAlpha8. Leave the atlas disabled.
5961
return;
6062
}
6163

64+
fStencilAtlasFlags = OpFlags::kStencilOnly | OpFlags::kDisableHWTessellation;
65+
fMaxAtlasPathWidth = fAtlas.maxAtlasSize() / 2;
66+
6267
// The atlas usually does better with hardware tessellation. If hardware tessellation is
6368
// supported, we will next choose a max atlas path width that is guaranteed to never require
6469
// more tessellation segments than are supported by the hardware.
@@ -176,6 +181,8 @@ bool GrTessellationPathRenderer::onDrawPath(const DrawPathArgs& args) {
176181
if (args.fShape->style().isSimpleFill() &&
177182
this->tryAddPathToAtlas(*args.fContext->priv().caps(), *args.fViewMatrix, path, devBounds,
178183
args.fAAType, &devIBounds, &locationInAtlas, &transposedInAtlas)) {
184+
// The atlas is not compatible with DDL. We should only be using it on direct contexts.
185+
SkASSERT(args.fContext->asDirectContext());
179186
#ifdef SK_DEBUG
180187
// If using hardware tessellation in the atlas, make sure the max number of segments is
181188
// sufficient for this path. fMaxAtlasPathWidth should have been tuned for this to always be

src/gpu/tessellate/GrTessellationPathRenderer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GrTessellationPathRenderer : public GrPathRenderer, public GrOnFlushCallba
4545

4646
static bool IsSupported(const GrCaps&);
4747

48-
GrTessellationPathRenderer(const GrRecordingContext*);
48+
GrTessellationPathRenderer(GrRecordingContext*);
4949
const char* name() const final { return "GrTessellationPathRenderer"; }
5050
StencilSupport onGetStencilSupport(const GrStyledShape& shape) const override {
5151
// TODO: Single-pass (e.g., convex) paths can have full support.
@@ -58,7 +58,7 @@ class GrTessellationPathRenderer : public GrPathRenderer, public GrOnFlushCallba
5858
int numOpsTaskIDs) override;
5959

6060
private:
61-
void initAtlasFlags(const GrRecordingContext*);
61+
void initAtlasFlags(GrRecordingContext*);
6262
SkPath* getAtlasUberPath(SkPathFillType fillType, bool antialias) {
6363
int idx = (int)antialias << 1;
6464
idx |= (int)fillType & 1;

0 commit comments

Comments
 (0)