Remove hasMixedSamples() from GrPipelineBuilder
This info is unknown until after any clip has been applied to the stencil settings, so it's misleading to include in the builder. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1952323002 Review-Url: https://codereview.chromium.org/1952323002
This commit is contained in:
parent
73e81abd5e
commit
3ccf2e75ed
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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>();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 &&
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user