aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrXferProcessor.h11
-rw-r--r--include/gpu/effects/GrCoverageSetOpXP.h4
-rw-r--r--include/gpu/effects/GrPorterDuffXferProcessor.h8
-rw-r--r--src/effects/SkArithmeticMode_gpu.h4
-rw-r--r--src/gpu/GrClipMaskManager.cpp9
-rw-r--r--src/gpu/GrPipeline.cpp8
-rw-r--r--src/gpu/GrPipelineBuilder.cpp6
-rw-r--r--src/gpu/GrPipelineBuilder.h9
-rw-r--r--src/gpu/GrXferProcessor.cpp13
-rw-r--r--src/gpu/effects/GrCustomXfermode.cpp7
-rw-r--r--src/gpu/effects/GrDisableColorXP.h4
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp16
-rw-r--r--tests/GrPorterDuffTest.cpp6
-rw-r--r--tools/debugger/SkOverdrawMode.cpp4
14 files changed, 44 insertions, 65 deletions
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index 3a698143c3..1d4717e156 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -323,8 +323,7 @@ public:
virtual void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
InvariantBlendedColor*) const = 0;
- bool willNeedDstTexture(const GrCaps& caps, const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const;
+ bool willNeedDstTexture(const GrCaps& caps, const GrPipelineOptimizations& optimizations) const;
bool isEqual(const GrXPFactory& that) const {
if (this->classID() != that.classID()) {
@@ -358,16 +357,12 @@ private:
virtual bool onIsEqual(const GrXPFactory&) const = 0;
- bool willReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const;
+ bool willReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const;
/**
* Returns true if the XP generated by this factory will explicitly read dst in the fragment
* shader.
*/
- virtual bool onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const = 0;
+ virtual bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const = 0;
static uint32_t GenClassID() {
// fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The
diff --git a/include/gpu/effects/GrCoverageSetOpXP.h b/include/gpu/effects/GrCoverageSetOpXP.h
index 42ac6ac528..06cc759812 100644
--- a/include/gpu/effects/GrCoverageSetOpXP.h
+++ b/include/gpu/effects/GrCoverageSetOpXP.h
@@ -34,9 +34,7 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool onWillReadDstColor(const GrCaps& /*caps*/,
- const GrPipelineOptimizations& /*optimizations*/,
- bool /*hasMixedSamples*/) const override {
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override {
return false;
}
diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h
index 865ef44253..476a039ad2 100644
--- a/include/gpu/effects/GrPorterDuffXferProcessor.h
+++ b/include/gpu/effects/GrPorterDuffXferProcessor.h
@@ -48,9 +48,7 @@ public:
blendedColor->fKnownColorFlags = validColorFlags;
}
- static bool SrcOverWillNeedDstTexture(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples);
+ static bool SrcOverWillNeedDstTexture(const GrCaps&, const GrPipelineOptimizations&);
private:
GrPorterDuffXPFactory(SkXfermode::Mode);
@@ -60,9 +58,7 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override;
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override;
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();
diff --git a/src/effects/SkArithmeticMode_gpu.h b/src/effects/SkArithmeticMode_gpu.h
index a44ac11e74..b8a40cf827 100644
--- a/src/effects/SkArithmeticMode_gpu.h
+++ b/src/effects/SkArithmeticMode_gpu.h
@@ -92,9 +92,7 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override {
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override {
return true;
}
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 3988e67ffe..654b315d52 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -448,7 +448,14 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
SkIntToScalar(-clip.origin().fY) };
// When there are multiple samples we want to do per-sample clipping, not compute a
// fractional pixel coverage.
- bool disallowAnalyticAA = rt->isUnifiedMultisampled() || pipelineBuilder.hasMixedSamples();
+ bool disallowAnalyticAA = rt->isStencilBufferMultisampled();
+ if (disallowAnalyticAA && !rt->numColorSamples()) {
+ // With a single color sample, any coverage info is lost from color once it hits the
+ // color buffer anyway, so we may as well use coverage AA if nothing else in the pipe
+ // is multisampled.
+ disallowAnalyticAA = pipelineBuilder.isHWAntialias() ||
+ !pipelineBuilder.getStencil().isDisabled();
+ }
const GrFragmentProcessor* clipFP = nullptr;
if (elements.isEmpty() ||
(requiresAA &&
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 55cbf345a0..8d384ef9f1 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -21,11 +21,13 @@ GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args,
const GrPipelineBuilder& builder = *args.fPipelineBuilder;
// Create XferProcessor from DS's XPFactory
+ bool hasMixedSamples = builder.getRenderTarget()->hasMixedSamples() &&
+ (builder.isHWAntialias() || !builder.getStencil().isDisabled());
const GrXPFactory* xpFactory = builder.getXPFactory();
SkAutoTUnref<GrXferProcessor> xferProcessor;
if (xpFactory) {
xferProcessor.reset(xpFactory->createXferProcessor(args.fOpts,
- builder.hasMixedSamples(),
+ hasMixedSamples,
&args.fDstTexture,
*args.fCaps));
if (!xferProcessor) {
@@ -36,10 +38,10 @@ GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args,
xferProcessor.reset(GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
*args.fCaps,
args.fOpts,
- builder.hasMixedSamples(),
+ hasMixedSamples,
&args.fDstTexture));
}
- GrColor overrideColor = GrColor_ILLEGAL;
+ GrColor overrideColor = GrColor_ILLEGAL;
if (args.fOpts.fColorPOI.firstEffectiveProcessorIndex() != 0) {
overrideColor = args.fOpts.fColorPOI.inputColorToFirstEffectiveProccesor();
}
diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp
index 252c26577e..1fd568e366 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -55,11 +55,9 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, c
bool GrPipelineBuilder::willXPNeedDstTexture(const GrCaps& caps,
const GrPipelineOptimizations& optimizations) const {
if (this->getXPFactory()) {
- return this->getXPFactory()->willNeedDstTexture(caps, optimizations,
- this->hasMixedSamples());
+ return this->getXPFactory()->willNeedDstTexture(caps, optimizations);
}
- return GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(caps, optimizations,
- this->hasMixedSamples());
+ return GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(caps, optimizations);
}
void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index 08ac5db8b7..2f78fc5198 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -193,15 +193,6 @@ public:
*/
void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef(target)); }
- /**
- * Returns whether the rasterizer and stencil test (if any) will run at a higher sample rate
- * than the color buffer. In is scenario, the higher sample rate is resolved during blending.
- */
- bool hasMixedSamples() const {
- return fRenderTarget->hasMixedSamples() &&
- (this->isHWAntialias() || !fStencilSettings.isDisabled());
- }
-
/// @}
///////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp
index 3e2ffaa660..910b873e86 100644
--- a/src/gpu/GrXferProcessor.cpp
+++ b/src/gpu/GrXferProcessor.cpp
@@ -197,7 +197,7 @@ GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineOptimizations&
const DstTexture* dstTexture,
const GrCaps& caps) const {
#ifdef SK_DEBUG
- if (this->willReadDstColor(caps, optimizations, hasMixedSamples)) {
+ if (this->willReadDstColor(caps, optimizations)) {
if (!caps.shaderCaps()->dstReadInShaderSupport()) {
SkASSERT(dstTexture && dstTexture->texture());
} else {
@@ -212,15 +212,12 @@ GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineOptimizations&
}
bool GrXPFactory::willNeedDstTexture(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const {
- return (this->willReadDstColor(caps, optimizations, hasMixedSamples) &&
+ const GrPipelineOptimizations& optimizations) const {
+ return (this->willReadDstColor(caps, optimizations) &&
!caps.shaderCaps()->dstReadInShaderSupport());
}
bool GrXPFactory::willReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const {
- return optimizations.fOverrides.fUsePLSDstRead || this->onWillReadDstColor(caps, optimizations,
- hasMixedSamples);
+ const GrPipelineOptimizations& optimizations) const {
+ return optimizations.fOverrides.fUsePLSDstRead || this->onWillReadDstColor(caps, optimizations);
}
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index dccec0c599..50fe5cb9e2 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -337,9 +337,7 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override;
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override;
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const CustomXPFactory& xpf = xpfBase.cast<CustomXPFactory>();
@@ -373,8 +371,7 @@ GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps,
}
bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const {
+ const GrPipelineOptimizations& optimizations) const {
return !can_use_hw_blend_equation(fHWBlendEquation, optimizations, caps);
}
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index 3182eef64d..558495451d 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -31,9 +31,7 @@ private:
bool hasMixedSamples,
const DstTexture* dstTexture) const override;
- bool onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override {
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override {
return false;
}
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index 733e552eea..8168de6a5d 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -799,8 +799,7 @@ void GrPorterDuffXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
}
bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const {
+ const GrPipelineOptimizations& optimizations) const {
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
return false;
}
@@ -816,9 +815,12 @@ bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
}
return get_lcd_blend_formula(optimizations.fCoveragePOI, fXfermode).hasSecondaryOutput();
}
+
// We fallback on the shader XP when the blend formula would use dual source blending but we
// don't have support for it.
- return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI, hasMixedSamples,
+ static const bool kHasMixedSamples = false;
+ SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without dual source blending.
+ return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI, kHasMixedSamples,
fXfermode).hasSecondaryOutput();
}
@@ -897,8 +899,7 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
}
bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) {
+ const GrPipelineOptimizations& optimizations) {
if (caps.shaderCaps()->dstReadInShaderSupport() ||
caps.shaderCaps()->dualSourceBlendingSupport()) {
return false;
@@ -915,8 +916,11 @@ bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps,
return get_lcd_blend_formula(optimizations.fCoveragePOI,
SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
}
+
// We fallback on the shader XP when the blend formula would use dual source blending but we
// don't have support for it.
+ static const bool kHasMixedSamples = false;
+ SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without dual source blending.
return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI,
- hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
+ kHasMixedSamples, SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
}
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 835738123e..608e5f2a84 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -72,7 +72,7 @@ public:
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
SkAutoTUnref<GrXferProcessor> xp(
xpf->createXferProcessor(optimizations, false, nullptr, caps));
- TEST_ASSERT(!xpf->willNeedDstTexture(caps, optimizations, false));
+ TEST_ASSERT(!xpf->willNeedDstTexture(caps, optimizations));
xpf->getInvariantBlendedColor(optimizations.fColorPOI, &fBlendedColor);
fOptFlags = xp->getOptimizations(optimizations, false, nullptr, caps);
GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType);
@@ -1122,7 +1122,7 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
SkASSERT(covPOI.isFourChannelOutput());
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode));
- TEST_ASSERT(!xpf->willNeedDstTexture(caps, opts, false));
+ TEST_ASSERT(!xpf->willNeedDstTexture(caps, opts));
SkAutoTUnref<GrXferProcessor> xp(
xpf->createXferProcessor(opts, false, nullptr, caps));
@@ -1200,7 +1200,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
GrXferProcessor::DstTexture* dstTexture =
- xpf->willNeedDstTexture(caps, optimizations, false) ? &fakeDstTexture : 0;
+ xpf->willNeedDstTexture(caps, optimizations) ? &fakeDstTexture : 0;
SkAutoTUnref<GrXferProcessor> xp(
xpf->createXferProcessor(optimizations, false, dstTexture, caps));
if (!xp) {
diff --git a/tools/debugger/SkOverdrawMode.cpp b/tools/debugger/SkOverdrawMode.cpp
index 1e018babdb..bbf61cc76b 100644
--- a/tools/debugger/SkOverdrawMode.cpp
+++ b/tools/debugger/SkOverdrawMode.cpp
@@ -229,9 +229,7 @@ private:
return new OverdrawXP(dstTexture, hasMixedSamples);
}
- bool onWillReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override {
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override {
return true;
}