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>
This commit is contained in:
Chris Dalton 2020-10-09 17:22:43 -06:00 committed by Skia Commit-Bot
parent f625e4ce45
commit 9213e610ed
2 changed files with 18 additions and 11 deletions

View File

@ -39,26 +39,31 @@ bool GrTessellationPathRenderer::IsSupported(const GrCaps& caps) {
return caps.drawInstancedSupport() && caps.shaderCaps()->vertexIDSupport();
}
GrTessellationPathRenderer::GrTessellationPathRenderer(const GrRecordingContext* rContext)
GrTessellationPathRenderer::GrTessellationPathRenderer(GrRecordingContext* rContext)
: fAtlas(kAtlasAlpha8Type, GrDynamicAtlas::InternalMultisample::kYes, kAtlasInitialSize,
std::min(kMaxAtlasSize, rContext->priv().caps()->maxPreferredRenderTargetSize()),
*rContext->priv().caps(), kAtlasAlgorithm) {
this->initAtlasFlags(rContext);
}
void GrTessellationPathRenderer::initAtlasFlags(const GrRecordingContext* rContext) {
void GrTessellationPathRenderer::initAtlasFlags(GrRecordingContext* rContext) {
fMaxAtlasPathWidth = 0;
if (!rContext->asDirectContext()) {
// The atlas is not compatible with DDL. Leave it disabled on non-direct contexts.
return;
}
const GrCaps& caps = *rContext->priv().caps();
auto atlasFormat = caps.getDefaultBackendFormat(kAtlasAlpha8Type, GrRenderable::kYes);
if (caps.internalMultisampleCount(atlasFormat) <= 1) {
// MSAA is not supported on kAlpha8. Leave the atlas disabled.
return;
}
fStencilAtlasFlags = OpFlags::kStencilOnly | OpFlags::kDisableHWTessellation;
fMaxAtlasPathWidth = fAtlas.maxAtlasSize() / 2;
auto atlasFormat = caps.getDefaultBackendFormat(kAtlasAlpha8Type, GrRenderable::kYes);
if (caps.internalMultisampleCount(atlasFormat) <= 1) {
// MSAA is not supported on kAlpha8. Disable the atlas.
fMaxAtlasPathWidth = 0;
return;
}
// The atlas usually does better with hardware tessellation. If hardware tessellation is
// supported, we will next choose a max atlas path width that is guaranteed to never require
// more tessellation segments than are supported by the hardware.
@ -176,6 +181,8 @@ bool GrTessellationPathRenderer::onDrawPath(const DrawPathArgs& args) {
if (args.fShape->style().isSimpleFill() &&
this->tryAddPathToAtlas(*args.fContext->priv().caps(), *args.fViewMatrix, path, devBounds,
args.fAAType, &devIBounds, &locationInAtlas, &transposedInAtlas)) {
// The atlas is not compatible with DDL. We should only be using it on direct contexts.
SkASSERT(args.fContext->asDirectContext());
#ifdef SK_DEBUG
// If using hardware tessellation in the atlas, make sure the max number of segments is
// sufficient for this path. fMaxAtlasPathWidth should have been tuned for this to always be

View File

@ -45,7 +45,7 @@ public:
static bool IsSupported(const GrCaps&);
GrTessellationPathRenderer(const GrRecordingContext*);
GrTessellationPathRenderer(GrRecordingContext*);
const char* name() const final { return "GrTessellationPathRenderer"; }
StencilSupport onGetStencilSupport(const GrStyledShape& shape) const override {
// TODO: Single-pass (e.g., convex) paths can have full support.
@ -58,7 +58,7 @@ public:
int numOpsTaskIDs) override;
private:
void initAtlasFlags(const GrRecordingContext*);
void initAtlasFlags(GrRecordingContext*);
SkPath* getAtlasUberPath(SkPathFillType fillType, bool antialias) {
int idx = (int)antialias << 1;
idx |= (int)fillType & 1;