Remove IO refs from GrSurfaceProxy only
This CL leaves the Ganesh world in a very odd place. In particular it still:
has pendingIO refs on GrSurfaces
forwards the proxy refs on to the backing GrSurface
Removing everything at once only ends in a mess thus, this goofball CL.
Change-Id: If112ff311bcef2e8d65a36c3b53b0ded4041c24e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210040
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index a0bf114..520bf43 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -91,17 +91,6 @@
return true;
}
-void GrFragmentProcessor::markPendingExecution() const {
- for (int i = 0; i < fTextureSamplerCnt; ++i) {
- auto* ref = this->textureSampler(i).proxyRef();
- ref->markPendingIO();
- ref->removeRef();
- }
- for (int i = 0; i < this->numChildProcessors(); ++i) {
- this->childProcessor(i).markPendingExecution();
- }
-}
-
int GrFragmentProcessor::registerChildProcessor(std::unique_ptr<GrFragmentProcessor> child) {
if (child->usesLocalCoords()) {
fFlags |= kUsesLocalCoords_Flag;
@@ -439,7 +428,7 @@
void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
const GrSamplerState& samplerState) {
- fProxyRef.setProxy(std::move(proxy), kRead_GrIOType);
+ fProxyRef.setProxy(std::move(proxy));
fSamplerState = samplerState;
fSamplerState.setFilterMode(SkTMin(samplerState.filter(), this->proxy()->highestFilterMode()));
}
@@ -447,7 +436,7 @@
void GrFragmentProcessor::TextureSampler::reset(sk_sp<GrTextureProxy> proxy,
GrSamplerState::Filter filterMode,
GrSamplerState::WrapMode wrapXAndY) {
- fProxyRef.setProxy(std::move(proxy), kRead_GrIOType);
+ fProxyRef.setProxy(std::move(proxy));
filterMode = SkTMin(filterMode, this->proxy()->highestFilterMode());
fSamplerState = GrSamplerState(wrapXAndY, filterMode);
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 9ba35af..46333d4 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -125,8 +125,6 @@
bool instantiate(GrResourceProvider*) const;
- void markPendingExecution() const;
-
/** Do any of the coordtransforms for this processor require local coords? */
bool usesLocalCoords() const { return SkToBool(fFlags & kUsesLocalCoords_Flag); }
@@ -414,7 +412,7 @@
* in pending execution state.
*/
explicit TextureSampler(const TextureSampler& that)
- : fProxyRef(sk_ref_sp(that.fProxyRef.get()), that.fProxyRef.ioType())
+ : fProxyRef(sk_ref_sp(that.fProxyRef.get()))
, fSamplerState(that.fSamplerState) {}
TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState&);
diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp
index 56b090a..6bb096d 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -122,13 +122,13 @@
GrDeferredUploadToken token = fTokenTracker->issueDrawToken();
if (fixedDynamicState && fixedDynamicState->fPrimitiveProcessorTextures) {
for (int i = 0; i < gp->numTextureSamplers(); ++i) {
- fixedDynamicState->fPrimitiveProcessorTextures[i]->addPendingRead();
+ fixedDynamicState->fPrimitiveProcessorTextures[i]->ref();
}
}
if (dynamicStateArrays && dynamicStateArrays->fPrimitiveProcessorTextures) {
int n = gp->numTextureSamplers() * meshCnt;
for (int i = 0; i < n; ++i) {
- dynamicStateArrays->fPrimitiveProcessorTextures[i]->addPendingRead();
+ dynamicStateArrays->fPrimitiveProcessorTextures[i]->ref();
}
}
draw.fGeometryProcessor = std::move(gp);
@@ -191,14 +191,14 @@
GrOpFlushState::Draw::~Draw() {
if (fFixedDynamicState && fFixedDynamicState->fPrimitiveProcessorTextures) {
for (int i = 0; i < fGeometryProcessor->numTextureSamplers(); ++i) {
- fFixedDynamicState->fPrimitiveProcessorTextures[i]->completedRead();
+ fFixedDynamicState->fPrimitiveProcessorTextures[i]->unref();
}
}
if (fDynamicStateArrays && fDynamicStateArrays->fPrimitiveProcessorTextures) {
int n = fGeometryProcessor->numTextureSamplers() * fMeshCnt;
const auto* textures = fDynamicStateArrays->fPrimitiveProcessorTextures;
for (int i = 0; i < n; ++i) {
- textures[i]->completedRead();
+ textures[i]->unref();
}
}
}
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index 109289b..6704a43 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -32,10 +32,8 @@
, fUniqueID(CreateUniqueID())
, fFlags(0) {
SkASSERT(fOpMemoryPool);
- fTarget.setProxy(std::move(surfaceProxy), kWrite_GrIOType);
+ fTarget.setProxy(std::move(surfaceProxy));
fTarget.get()->setLastOpList(this);
-
- fTarget.markPendingIO();
}
GrOpList::~GrOpList() {
diff --git a/src/gpu/GrPendingIOResource.h b/src/gpu/GrPendingIOResource.h
index 716abcf..229277b 100644
--- a/src/gpu/GrPendingIOResource.h
+++ b/src/gpu/GrPendingIOResource.h
@@ -10,8 +10,41 @@
#include "include/core/SkRefCnt.h"
#include "include/gpu/GrGpuResource.h"
+#include "include/private/GrSurfaceProxy.h"
#include "include/private/SkNoncopyable.h"
+class GrProxyPendingIO : SkNoncopyable {
+public:
+ GrProxyPendingIO() = default;
+ GrProxyPendingIO(GrSurfaceProxy* resource) { this->reset(resource); }
+ ~GrProxyPendingIO() { this->reset(nullptr); }
+
+ void reset(GrSurfaceProxy* resource = nullptr) {
+ if (resource == fResource) {
+ return;
+ }
+
+ if (fResource) {
+ fResource->unref();
+ }
+
+ fResource = resource;
+ if (fResource) {
+ fResource->ref();
+ }
+ }
+
+ explicit operator bool() const { return SkToBool(fResource); }
+
+ GrSurfaceProxy* get() const { return fResource; }
+ GrSurfaceProxy* operator->() const { return fResource; }
+
+private:
+ bool operator==(const GrProxyPendingIO& other) const = delete;
+
+ GrSurfaceProxy* fResource = nullptr;
+};
+
/**
* Helper for owning a pending read, write, read-write on a GrGpuResource. It never owns a regular
* ref.
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index 0d18fc1..819ef9b 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -136,7 +136,8 @@
if (offset) {
*offset = fDstTextureOffset;
}
- return fDstTextureProxy.get();
+
+ return fDstTextureProxy ? fDstTextureProxy->asTextureProxy() : nullptr;
}
GrTexture* peekDstTexture(SkIPoint* offset = nullptr) const {
@@ -205,10 +206,9 @@
friend bool operator&(Flags, InputFlags);
- using DstTextureProxy = GrPendingIOResource<GrTextureProxy, kRead_GrIOType>;
using FragmentProcessorArray = SkAutoSTArray<8, std::unique_ptr<const GrFragmentProcessor>>;
- DstTextureProxy fDstTextureProxy;
+ GrProxyPendingIO fDstTextureProxy;
SkIPoint fDstTextureOffset;
GrWindowRectsState fWindowRectsState;
const GrUserStencilSettings* fUserStencilSettings;
diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp
index a4d5d15..0a120dd 100644
--- a/src/gpu/GrProcessorSet.cpp
+++ b/src/gpu/GrProcessorSet.cpp
@@ -188,7 +188,6 @@
hasCoverageFP = hasCoverageFP || clip->numClipCoverageFragmentProcessors();
for (int i = 0; i < clip->numClipCoverageFragmentProcessors(); ++i) {
const GrFragmentProcessor* clipFP = clip->clipCoverageFragmentProcessor(i);
- clipFP->markPendingExecution();
analysis.fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
coverageUsesLocalCoords |= clipFP->usesLocalCoords();
}
@@ -231,9 +230,6 @@
for (int i = 0; i < colorFPsToEliminate; ++i) {
fFragmentProcessors[i].reset(nullptr);
}
- for (int i = colorFPsToEliminate; i < fFragmentProcessors.count(); ++i) {
- fFragmentProcessors[i]->markPendingExecution();
- }
fFragmentProcessorOffset = colorFPsToEliminate;
fColorFragmentProcessorCnt -= colorFPsToEliminate;
analysis.fHasColorFragmentProcessor = (fColorFragmentProcessorCnt != 0);
diff --git a/src/gpu/ops/GrCopySurfaceOp.h b/src/gpu/ops/GrCopySurfaceOp.h
index 58e196b..0516a2f 100644
--- a/src/gpu/ops/GrCopySurfaceOp.h
+++ b/src/gpu/ops/GrCopySurfaceOp.h
@@ -62,10 +62,10 @@
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
- GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fSrc;
- GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fDst;
- SkIRect fSrcRect;
- SkIPoint fDstPoint;
+ GrProxyPendingIO fSrc;
+ GrProxyPendingIO fDst;
+ SkIRect fSrcRect;
+ SkIPoint fDstPoint;
typedef GrOp INHERITED;
};
diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp b/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp
index 8498f63..c255365 100644
--- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp
+++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp
@@ -93,13 +93,6 @@
*geometryColor = overrideColor;
}
} else {
- if (clip) {
- for (int i = 0; i < clip->numClipCoverageFragmentProcessors(); ++i) {
- const GrFragmentProcessor* clipFP = clip->clipCoverageFragmentProcessor(i);
- clipFP->markPendingExecution();
- }
- }
-
analysis = GrProcessorSet::EmptySetAnalysis();
}
fUsesLocalCoords = analysis.usesLocalCoords();
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index a7d66dc..790d7e9 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -183,11 +183,7 @@
~TextureOp() override {
for (unsigned p = 0; p < fProxyCnt; ++p) {
- if (fFinalized) {
- fProxies[p].fProxy->completedRead();
- } else {
- fProxies[p].fProxy->unref();
- }
+ fProxies[p].fProxy->unref();
}
}
@@ -228,12 +224,6 @@
GrProcessorSet::Analysis finalize(
const GrCaps& caps, const GrAppliedClip*, GrFSAAType, GrClampType clampType) override {
- SkASSERT(!fFinalized);
- fFinalized = true;
- for (unsigned p = 0; p < fProxyCnt; ++p) {
- fProxies[p].fProxy->addPendingRead();
- fProxies[p].fProxy->unref();
- }
fColorType = static_cast<unsigned>(ColorType::kNone);
for (int q = 0; q < fQuads.count(); ++q) {
const ColorDomainAndAA& info = fQuads.metadata(q);
@@ -263,8 +253,7 @@
GrQuadAAFlags aaFlags, sk_sp<GrColorSpaceXform> textureColorSpaceXform)
: INHERITED(ClassID())
, fTextureColorSpaceXform(std::move(textureColorSpaceXform))
- , fFilter(static_cast<unsigned>(filter))
- , fFinalized(0) {
+ , fFilter(static_cast<unsigned>(filter)) {
// Clean up disparities between the overall aa type and edge configuration and apply
// optimizations based on the rect and matrix when appropriate
GrQuadUtils::ResolveAAType(aaType, aaFlags, dstQuad, &aaType, &aaFlags);
@@ -302,8 +291,7 @@
sk_sp<GrColorSpaceXform> textureColorSpaceXform)
: INHERITED(ClassID())
, fTextureColorSpaceXform(std::move(textureColorSpaceXform))
- , fFilter(static_cast<unsigned>(filter))
- , fFinalized(0) {
+ , fFilter(static_cast<unsigned>(filter)) {
fProxyCnt = SkToUInt(cnt);
SkRect bounds = SkRectPriv::MakeLargestInverted();
GrAAType overallAAType = GrAAType::kNone; // aa type maximally compatible with all dst rects
@@ -655,9 +643,7 @@
unsigned fDomain : 1;
unsigned fColorType : 2;
GR_STATIC_ASSERT(GrQuadPerEdgeAA::kColorTypeCount <= 4);
- // Used to track whether fProxy is ref'ed or has a pending IO after finalize() is called.
- unsigned fFinalized : 1;
- unsigned fProxyCnt : 32 - 8;
+ unsigned fProxyCnt : 32 - 7;
Proxy fProxies[1];
static_assert(GrQuad::kTypeCount <= 4, "GrQuad::Type does not fit in 2 bits");