Add support for plumbing GrDstSampleType through Ops and Pipeline creation.
This CL adds a new type GrDstSampleType to say how we will sample the dst.
We add tracking of the GrDstSampleType in the recording of GrOps and
then during execution passing the information along to the GrPipeline.
In general the tracking of GrDstSampleType is a global state of a GrOpsTask
so it is kept separate fro the DstProxyView which is more specific to a
single Op on the GrOpsTask.
Bug: skia:10409
Change-Id: Ie843c31f2e48a887daf96cee99ed159b196cb545
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315645
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index cfc7479..a16ee31 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -32,10 +32,13 @@
fXferProcessor = std::move(xferProcessor);
+ SkASSERT((args.fDstProxyView.dstSampleType() != GrDstSampleType::kNone) ==
+ SkToBool(args.fDstProxyView.proxy()));
if (args.fDstProxyView.proxy()) {
fDstProxyView = args.fDstProxyView.proxyView();
fDstTextureOffset = args.fDstProxyView.offset();
}
+ fDstSampleType = args.fDstProxyView.dstSampleType();
}
GrPipeline::GrPipeline(const InitArgs& args, GrProcessorSet&& processors,
@@ -61,9 +64,8 @@
}
}
-GrXferBarrierType GrPipeline::xferBarrierType(GrTexture* texture, const GrCaps& caps) const {
- auto proxy = fDstProxyView.proxy();
- if (proxy && proxy->peekTexture() == texture) {
+GrXferBarrierType GrPipeline::xferBarrierType(const GrCaps& caps) const {
+ if (fDstProxyView.proxy() && GrDstSampleTypeDirectlySamplesDst(fDstSampleType)) {
return kTexture_GrXferBarrierType;
}
return this->getXferProcessor().xferBarrierType(caps);
@@ -97,13 +99,22 @@
static constexpr uint32_t kBlendWriteShift = 1;
static constexpr uint32_t kBlendCoeffShift = 5;
+ static constexpr uint32_t kBlendEquationShift = 5;
+ static constexpr uint32_t kDstSampleTypeInputShift = 1;
static_assert(kLast_GrBlendCoeff < (1 << kBlendCoeffShift));
- static_assert(kFirstAdvancedGrBlendEquation - 1 < 4);
+ static_assert(kLast_GrBlendEquation < (1 << kBlendEquationShift));
+ static_assert(kBlendWriteShift +
+ 2 * kBlendCoeffShift +
+ kBlendEquationShift +
+ kDstSampleTypeInputShift <= 32);
uint32_t blendKey = blendInfo.fWriteColor;
blendKey |= (blendInfo.fSrcBlend << kBlendWriteShift);
blendKey |= (blendInfo.fDstBlend << (kBlendWriteShift + kBlendCoeffShift));
blendKey |= (blendInfo.fEquation << (kBlendWriteShift + 2 * kBlendCoeffShift));
+ // Note that we use the general fDstSampleType here and not localDstSampleType()
+ blendKey |= ((fDstSampleType == GrDstSampleType::kAsInputAttachment)
+ << (kBlendWriteShift + 2 * kBlendCoeffShift + kBlendEquationShift));
b->add32(blendKey);
}
@@ -120,7 +131,7 @@
for (auto& fp : fFragmentProcessors) {
fp->visitProxies(func);
}
- if (fDstProxyView.asTextureProxy()) {
- func(fDstProxyView.asTextureProxy(), GrMipmapped::kNo);
+ if (this->usesDstTexture()) {
+ func(fDstProxyView.proxy(), GrMipmapped::kNo);
}
}