Convert DstTexture to DstProxy

The last GrTexture-based TextureSampler::reset call must be removed before the TextureSamplers can become purely GrTextureProxy-backed

Split out of: https://skia-review.googlesource.com/c/10484/ (Omnibus: Push instantiation of GrTextures later (post TextureSampler))

Change-Id: Ic1435177d8b5d9bd3fc38b4903c9baae8205cfb0
Reviewed-on: https://skia-review.googlesource.com/16908
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2017-05-15 14:56:51 -04:00 committed by Skia Commit-Bot
parent 1314918f90
commit 87f7f1c3ce
19 changed files with 117 additions and 114 deletions

View File

@ -102,7 +102,7 @@ public:
struct DrawOpArgs { struct DrawOpArgs {
GrRenderTarget* fRenderTarget; GrRenderTarget* fRenderTarget;
const GrAppliedClip* fAppliedClip; const GrAppliedClip* fAppliedClip;
GrXferProcessor::DstTexture fDstTexture; GrXferProcessor::DstProxy fDstProxy;
}; };
void setDrawOpArgs(DrawOpArgs* opArgs) { fOpArgs = opArgs; } void setDrawOpArgs(DrawOpArgs* opArgs) { fOpArgs = opArgs; }
@ -224,8 +224,8 @@ public:
const GrAppliedClip* clip() const { return this->state()->drawOpArgs().fAppliedClip; } const GrAppliedClip* clip() const { return this->state()->drawOpArgs().fAppliedClip; }
const GrXferProcessor::DstTexture& dstTexture() const { const GrXferProcessor::DstProxy& dstProxy() const {
return this->state()->drawOpArgs().fDstTexture; return this->state()->drawOpArgs().fDstProxy;
} }
template <typename... Args> template <typename... Args>

View File

@ -44,9 +44,13 @@ void GrPipeline::init(const InitArgs& args) {
fXferProcessor = args.fProcessors->refXferProcessor(); fXferProcessor = args.fProcessors->refXferProcessor();
if (args.fDstTexture.texture()) { if (args.fDstProxy.proxy()) {
fDstTexture.reset(args.fDstTexture.texture()); if (!args.fDstProxy.proxy()->instantiate(args.fResourceProvider)) {
fDstTextureOffset = args.fDstTexture.offset(); this->markAsBad();
}
fDstTextureProxy.reset(args.fDstProxy.proxy());
fDstTextureOffset = args.fDstProxy.offset();
} }
// Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline, possibly removing some of the // Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline, possibly removing some of the
@ -91,7 +95,7 @@ static void add_dependencies_for_processor(const GrFragmentProcessor* proc,
GrFragmentProcessor::TextureAccessIter iter(proc); GrFragmentProcessor::TextureAccessIter iter(proc);
while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) { while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) {
SkASSERT(rtp->getLastOpList()); SkASSERT(rtp->getLastOpList());
rtp->getLastOpList()->addDependency(sampler->texture()); rtp->getLastOpList()->addDependency(sampler->proxy());
} }
} }
#endif #endif
@ -104,8 +108,8 @@ void GrPipeline::addDependenciesTo(GrRenderTargetProxy* rtp) const {
} }
#endif #endif
if (fDstTexture) { if (fDstTextureProxy) {
//SkASSERT(rtp->getLastOpList()); SkASSERT(rtp->getLastOpList());
// MDB TODO: re-enable when TextureSamplers store texture proxies // MDB TODO: re-enable when TextureSamplers store texture proxies
//rtp->getLastOpList()->addDependency(fDstTexture.get()); //rtp->getLastOpList()->addDependency(fDstTexture.get());
} }

View File

@ -75,7 +75,8 @@ public:
const GrAppliedClip* fAppliedClip = nullptr; const GrAppliedClip* fAppliedClip = nullptr;
GrRenderTarget* fRenderTarget = nullptr; GrRenderTarget* fRenderTarget = nullptr;
const GrCaps* fCaps = nullptr; const GrCaps* fCaps = nullptr;
GrXferProcessor::DstTexture fDstTexture; GrResourceProvider* fResourceProvider = nullptr;
GrXferProcessor::DstProxy fDstProxy;
}; };
/** /**
@ -157,11 +158,11 @@ public:
* If the GrXferProcessor uses a texture to access the dst color, then this returns that * If the GrXferProcessor uses a texture to access the dst color, then this returns that
* texture and the offset to the dst contents within that texture. * texture and the offset to the dst contents within that texture.
*/ */
GrTexture* dstTexture(SkIPoint* offset = nullptr) const { GrTextureProxy* dstTextureProxy(SkIPoint* offset = nullptr) const {
if (offset) { if (offset) {
*offset = fDstTextureOffset; *offset = fDstTextureOffset;
} }
return fDstTexture.get(); return fDstTextureProxy.get();
} }
const GrFragmentProcessor& getColorFragmentProcessor(int idx) const { const GrFragmentProcessor& getColorFragmentProcessor(int idx) const {
@ -215,7 +216,8 @@ public:
bool isBad() const { return SkToBool(fFlags & kIsBad_Flag); } bool isBad() const { return SkToBool(fFlags & kIsBad_Flag); }
GrXferBarrierType xferBarrierType(const GrCaps& caps) const { GrXferBarrierType xferBarrierType(const GrCaps& caps) const {
if (fDstTexture.get() && fDstTexture.get() == fRenderTarget.get()->asTexture()) { if (fDstTextureProxy.get() &&
fDstTextureProxy.get()->priv().peekTexture() == fRenderTarget.get()->asTexture()) {
return kTexture_GrXferBarrierType; return kTexture_GrXferBarrierType;
} }
return this->getXferProcessor().xferBarrierType(caps); return this->getXferProcessor().xferBarrierType(caps);
@ -233,11 +235,11 @@ private:
}; };
using RenderTarget = GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>; using RenderTarget = GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>;
using DstTexture = GrPendingIOResource<GrTexture, kRead_GrIOType>; using DstTextureProxy = GrPendingIOResource<GrTextureProxy, kRead_GrIOType>;
using PendingFragmentProcessor = GrPendingProgramElement<const GrFragmentProcessor>; using PendingFragmentProcessor = GrPendingProgramElement<const GrFragmentProcessor>;
using FragmentProcessorArray = SkAutoSTArray<8, PendingFragmentProcessor>; using FragmentProcessorArray = SkAutoSTArray<8, PendingFragmentProcessor>;
DstTexture fDstTexture; DstTextureProxy fDstTextureProxy;
SkIPoint fDstTextureOffset; SkIPoint fDstTextureOffset;
RenderTarget fRenderTarget; RenderTarget fRenderTarget;
GrScissorState fScissorState; GrScissorState fScissorState;

View File

@ -230,18 +230,6 @@ GrResourceIOProcessor::TextureSampler::TextureSampler(GrResourceProvider* resour
this->reset(resourceProvider, std::move(proxy), filterMode, tileXAndY, visibility); this->reset(resourceProvider, std::move(proxy), filterMode, tileXAndY, visibility);
} }
// MDB TODO: remove this!
void GrResourceIOProcessor::TextureSampler::reset(GrTexture* texture,
GrSamplerParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,
GrShaderFlags visibility) {
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode());
fParams.reset(tileXAndY, filterMode);
fVisibility = visibility;
}
void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider, void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider,
sk_sp<GrTextureProxy> proxy, sk_sp<GrTextureProxy> proxy,
const GrSamplerParams& params, const GrSamplerParams& params,

View File

@ -222,12 +222,6 @@ public:
*/ */
TextureSampler(); TextureSampler();
// MDB TODO: this is the last GrTexture-based reset call!
void reset(GrTexture*,
GrSamplerParams::FilterMode = GrSamplerParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
GrShaderFlags visibility = kFragment_GrShaderFlag);
// MDB TODO: ultimately we shouldn't need the resource provider parameter // MDB TODO: ultimately we shouldn't need the resource provider parameter
TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&); TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&);
explicit TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>, explicit TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>,

View File

@ -198,8 +198,8 @@ bool GrProgramDesc::Build(GrProgramDesc* desc,
const GrXferProcessor& xp = pipeline.getXferProcessor(); const GrXferProcessor& xp = pipeline.getXferProcessor();
const GrSurfaceOrigin* originIfDstTexture = nullptr; const GrSurfaceOrigin* originIfDstTexture = nullptr;
GrSurfaceOrigin origin; GrSurfaceOrigin origin;
if (pipeline.dstTexture()) { if (pipeline.dstTextureProxy()) {
origin = pipeline.dstTexture()->origin(); origin = pipeline.dstTextureProxy()->origin();
originIfDstTexture = &origin; originIfDstTexture = &origin;
} }
xp.getGLSLProcessorKey(shaderCaps, &b, originIfDstTexture); xp.getGLSLProcessorKey(shaderCaps, &b, originIfDstTexture);

View File

@ -1598,15 +1598,15 @@ uint32_t GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<Gr
} }
} }
GrXferProcessor::DstTexture dstTexture; GrXferProcessor::DstProxy dstProxy;
if (op->xpRequiresDstTexture(*this->caps(), &appliedClip)) { if (op->xpRequiresDstTexture(*this->caps(), &appliedClip)) {
if (!this->setupDstTexture(fRenderTargetProxy.get(), clip, op->bounds(), &dstTexture)) { if (!this->setupDstProxy(this->asRenderTargetProxy(), clip, op->bounds(), &dstProxy)) {
return SK_InvalidUniqueID; return SK_InvalidUniqueID;
} }
} }
op->setClippedBounds(bounds); op->setClippedBounds(bounds);
return this->getOpList()->addOp(std::move(op), this, std::move(appliedClip), dstTexture); return this->getOpList()->addOp(std::move(op), this, std::move(appliedClip), dstProxy);
} }
uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipelineBuilder, uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipelineBuilder,
@ -1656,9 +1656,10 @@ uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipeline
args.fAppliedClip = &appliedClip; args.fAppliedClip = &appliedClip;
args.fRenderTarget = rt; args.fRenderTarget = rt;
args.fCaps = this->caps(); args.fCaps = this->caps();
args.fResourceProvider = fContext->resourceProvider();
if (analysis.requiresDstTexture()) { if (analysis.requiresDstTexture()) {
if (!this->setupDstTexture(fRenderTargetProxy.get(), clip, bounds, &args.fDstTexture)) { if (!this->setupDstProxy(this->asRenderTargetProxy(), clip, bounds, &args.fDstProxy)) {
return SK_InvalidUniqueID; return SK_InvalidUniqueID;
} }
} }
@ -1671,22 +1672,15 @@ uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipeline
return this->getOpList()->addOp(std::move(op), this); return this->getOpList()->addOp(std::move(op), this);
} }
bool GrRenderTargetContext::setupDstTexture(GrRenderTargetProxy* rtProxy, const GrClip& clip, bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const GrClip& clip,
const SkRect& opBounds, const SkRect& opBounds,
GrXferProcessor::DstTexture* dstTexture) { GrXferProcessor::DstProxy* dstProxy) {
if (this->caps()->textureBarrierSupport()) { if (this->caps()->textureBarrierSupport()) {
if (GrTextureProxy* texProxy = rtProxy->asTextureProxy()) { if (GrTextureProxy* texProxy = rtProxy->asTextureProxy()) {
// MDB TODO: remove this instantiation. Blocked on making DstTexture be proxy-based
sk_sp<GrTexture> tex(sk_ref_sp(texProxy->instantiate(fContext->resourceProvider())));
if (!tex) {
SkDebugf("setupDstTexture: instantiation of src texture failed.\n");
return false; // We have bigger problems now
}
// The render target is a texture, so we can read from it directly in the shader. The XP // The render target is a texture, so we can read from it directly in the shader. The XP
// will be responsible to detect this situation and request a texture barrier. // will be responsible to detect this situation and request a texture barrier.
dstTexture->setTexture(std::move(tex)); dstProxy->setProxy(sk_ref_sp(texProxy));
dstTexture->setOffset(0, 0); dstProxy->setOffset(0, 0);
return true; return true;
} }
} }
@ -1752,15 +1746,7 @@ bool GrRenderTargetContext::setupDstTexture(GrRenderTargetProxy* rtProxy, const
return false; return false;
} }
GrTextureProxy* copyProxy = sContext->asTextureProxy(); dstProxy->setProxy(sContext->asTextureProxyRef());
// MDB TODO: remove this instantiation once DstTexture is proxy-backed dstProxy->setOffset(dstOffset);
sk_sp<GrTexture> copy(sk_ref_sp(copyProxy->instantiate(fContext->resourceProvider())));
if (!copy) {
SkDebugf("setupDstTexture: instantiation of copied texture failed.\n");
return false;
}
dstTexture->setTexture(std::move(copy));
dstTexture->setOffset(dstOffset);
return true; return true;
} }

View File

@ -458,10 +458,10 @@ private:
// Makes a copy of the proxy if it is necessary for the draw and places the texture that should // Makes a copy of the proxy if it is necessary for the draw and places the texture that should
// be used by GrXferProcessor to access the destination color in 'result'. If the return // be used by GrXferProcessor to access the destination color in 'result'. If the return
// value is false then a texture copy could not be made. // value is false then a texture copy could not be made.
bool SK_WARN_UNUSED_RESULT setupDstTexture(GrRenderTargetProxy*, bool SK_WARN_UNUSED_RESULT setupDstProxy(GrRenderTargetProxy*,
const GrClip&, const GrClip&,
const SkRect& opBounds, const SkRect& opBounds,
GrXferProcessor::DstTexture* result); GrXferProcessor::DstProxy* result);
GrRenderTargetOpList* getOpList(); GrRenderTargetOpList* getOpList();

View File

@ -88,7 +88,7 @@ void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) {
opArgs = { opArgs = {
fRecordedOps[i].fRenderTarget.get(), fRecordedOps[i].fRenderTarget.get(),
fRecordedOps[i].fAppliedClip, fRecordedOps[i].fAppliedClip,
fRecordedOps[i].fDstTexture fRecordedOps[i].fDstProxy
}; };
} }
flushState->setDrawOpArgs(&opArgs); flushState->setDrawOpArgs(&opArgs);
@ -167,7 +167,7 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) {
GrOpFlushState::DrawOpArgs opArgs { GrOpFlushState::DrawOpArgs opArgs {
fRecordedOps[i].fRenderTarget.get(), fRecordedOps[i].fRenderTarget.get(),
fRecordedOps[i].fAppliedClip, fRecordedOps[i].fAppliedClip,
fRecordedOps[i].fDstTexture fRecordedOps[i].fDstProxy
}; };
flushState->setDrawOpArgs(&opArgs); flushState->setDrawOpArgs(&opArgs);
@ -273,7 +273,7 @@ static inline bool can_reorder(const SkRect& a, const SkRect& b) { return !GrRec
bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b, bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
const GrAppliedClip* bClip, const GrAppliedClip* bClip,
const DstTexture* bDstTexture, const DstProxy* bDstProxy,
const GrCaps& caps) { const GrCaps& caps) {
if (a.fAppliedClip) { if (a.fAppliedClip) {
if (!bClip) { if (!bClip) {
@ -285,11 +285,11 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
} else if (bClip) { } else if (bClip) {
return false; return false;
} }
if (bDstTexture) { if (bDstProxy) {
if (a.fDstTexture != *bDstTexture) { if (a.fDstProxy != *bDstProxy) {
return false; return false;
} }
} else if (a.fDstTexture.texture()) { } else if (a.fDstProxy.proxy()) {
return false; return false;
} }
return a.fOp->combineIfPossible(b, caps); return a.fOp->combineIfPossible(b, caps);
@ -298,7 +298,7 @@ bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op, GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
GrRenderTargetContext* renderTargetContext, GrRenderTargetContext* renderTargetContext,
GrAppliedClip* clip, GrAppliedClip* clip,
const DstTexture* dstTexture) { const DstProxy* dstProxy) {
GrRenderTarget* renderTarget = renderTargetContext->accessRenderTarget(); GrRenderTarget* renderTarget = renderTargetContext->accessRenderTarget();
if (!renderTarget) { if (!renderTarget) {
SkASSERT(false); SkASSERT(false);
@ -345,7 +345,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
candidate.fOp->uniqueID()); candidate.fOp->uniqueID());
break; break;
} }
if (this->combineIfPossible(candidate, op.get(), clip, dstTexture, *caps)) { if (this->combineIfPossible(candidate, op.get(), clip, dstProxy, *caps)) {
GrOP_INFO("\t\tBackward: Combining with (%s, opID: %u)\n", candidate.fOp->name(), GrOP_INFO("\t\tBackward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID()); candidate.fOp->uniqueID());
GrOP_INFO("\t\t\tBackward: Combined op info:\n"); GrOP_INFO("\t\t\tBackward: Combined op info:\n");
@ -373,7 +373,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
clip = fClipAllocator.make<GrAppliedClip>(std::move(*clip)); clip = fClipAllocator.make<GrAppliedClip>(std::move(*clip));
SkDEBUGCODE(fNumClips++;) SkDEBUGCODE(fNumClips++;)
} }
fRecordedOps.emplace_back(std::move(op), renderTarget, clip, dstTexture); fRecordedOps.emplace_back(std::move(op), renderTarget, clip, dstProxy);
fRecordedOps.back().fOp->wasRecorded(this); fRecordedOps.back().fOp->wasRecorded(this);
fLastFullClearOp = nullptr; fLastFullClearOp = nullptr;
fLastFullClearResourceID.makeInvalid(); fLastFullClearResourceID.makeInvalid();
@ -404,7 +404,7 @@ void GrRenderTargetOpList::forwardCombine(const GrCaps& caps) {
break; break;
} }
if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(), if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(),
candidate.fAppliedClip, &candidate.fDstTexture, caps)) { candidate.fAppliedClip, &candidate.fDstProxy, caps)) {
GrOP_INFO("\t\tForward: Combining with (%s, opID: %u)\n", candidate.fOp->name(), GrOP_INFO("\t\tForward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID()); candidate.fOp->uniqueID());
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get()); GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get());

View File

@ -30,7 +30,7 @@ class GrRenderTargetProxy;
class GrRenderTargetOpList final : public GrOpList { class GrRenderTargetOpList final : public GrOpList {
private: private:
using DstTexture = GrXferProcessor::DstTexture; using DstProxy = GrXferProcessor::DstProxy;
public: public:
GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrAuditTrail*); GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrAuditTrail*);
@ -70,9 +70,9 @@ public:
return this->uniqueID(); return this->uniqueID();
} }
uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext, uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext,
GrAppliedClip&& clip, const DstTexture& dstTexture) { GrAppliedClip&& clip, const DstProxy& dstProxy) {
this->recordOp(std::move(op), renderTargetContext, clip.doesClip() ? &clip : nullptr, this->recordOp(std::move(op), renderTargetContext, clip.doesClip() ? &clip : nullptr,
&dstTexture); &dstProxy);
return this->uniqueID(); return this->uniqueID();
} }
@ -116,31 +116,31 @@ private:
RecordedOp(std::unique_ptr<GrOp> op, RecordedOp(std::unique_ptr<GrOp> op,
GrRenderTarget* rt, GrRenderTarget* rt,
const GrAppliedClip* appliedClip, const GrAppliedClip* appliedClip,
const DstTexture* dstTexture) const DstProxy* dstProxy)
: fOp(std::move(op)) : fOp(std::move(op))
, fRenderTarget(rt) , fRenderTarget(rt)
, fAppliedClip(appliedClip) { , fAppliedClip(appliedClip) {
if (dstTexture) { if (dstProxy) {
fDstTexture = *dstTexture; fDstProxy = *dstProxy;
} }
} }
std::unique_ptr<GrOp> fOp; std::unique_ptr<GrOp> fOp;
// TODO: These ops will all to target the same render target and this won't be needed. // TODO: These ops will all to target the same render target and this won't be needed.
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
DstTexture fDstTexture; DstProxy fDstProxy;
const GrAppliedClip* fAppliedClip; const GrAppliedClip* fAppliedClip;
}; };
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it // If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
// returns the input op. // returns the input op.
GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, GrAppliedClip* = nullptr, GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, GrAppliedClip* = nullptr,
const DstTexture* = nullptr); const DstProxy* = nullptr);
void forwardCombine(const GrCaps&); void forwardCombine(const GrCaps&);
// If this returns true then b has been merged into a's op. // If this returns true then b has been merged into a's op.
bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip, bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip,
const DstTexture* bDstTexture, const GrCaps&); const DstProxy* bDstTexture, const GrCaps&);
GrClearOp* fLastFullClearOp = nullptr; GrClearOp* fLastFullClearOp = nullptr;
GrGpuResource::UniqueID fLastFullClearResourceID = GrGpuResource::UniqueID::InvalidID(); GrGpuResource::UniqueID fLastFullClearResourceID = GrGpuResource::UniqueID::InvalidID();

View File

@ -55,44 +55,54 @@ public:
* to the space of the texture. Depending on GPU capabilities a DstTexture may be used by a * to the space of the texture. Depending on GPU capabilities a DstTexture may be used by a
* GrXferProcessor for blending in the fragment shader. * GrXferProcessor for blending in the fragment shader.
*/ */
class DstTexture { class DstProxy {
public: public:
DstTexture() { fOffset.set(0, 0); } DstProxy() { fOffset.set(0, 0); }
DstTexture(const DstTexture& other) { DstProxy(const DstProxy& other) {
*this = other; *this = other;
} }
DstTexture(GrTexture* texture, const SkIPoint& offset) DstProxy(sk_sp<GrTextureProxy> proxy, const SkIPoint& offset)
: fTexture(SkSafeRef(texture)), fOffset(texture ? offset : SkIPoint{0, 0}) {} : fProxy(std::move(proxy)) {
if (fProxy) {
fOffset = offset;
} else {
fOffset.set(0, 0);
}
}
DstTexture& operator=(const DstTexture& other) { DstProxy& operator=(const DstProxy& other) {
fTexture = other.fTexture; fProxy = other.fProxy;
fOffset = other.fOffset; fOffset = other.fOffset;
return *this; return *this;
} }
bool operator==(const DstTexture& that) const { bool operator==(const DstProxy& that) const {
return fTexture == that.fTexture && fOffset == that.fOffset; return fProxy == that.fProxy && fOffset == that.fOffset;
} }
bool operator!=(const DstTexture& that) const { return !(*this == that); } bool operator!=(const DstProxy& that) const { return !(*this == that); }
const SkIPoint& offset() const { return fOffset; } const SkIPoint& offset() const { return fOffset; }
void setOffset(const SkIPoint& offset) { fOffset = offset; } void setOffset(const SkIPoint& offset) { fOffset = offset; }
void setOffset(int ox, int oy) { fOffset.set(ox, oy); } void setOffset(int ox, int oy) { fOffset.set(ox, oy); }
GrTexture* texture() const { return fTexture.get(); } GrTextureProxy* proxy() const { return fProxy.get(); }
void setTexture(sk_sp<GrTexture> texture) { void setProxy(sk_sp<GrTextureProxy> proxy) {
fTexture = std::move(texture); fProxy = std::move(proxy);
if (!fTexture) { if (!fProxy) {
fOffset = {0, 0}; fOffset = {0, 0};
} }
} }
bool instantiate(GrResourceProvider* resourceProvider) {
return SkToBool(fProxy->instantiate(resourceProvider));
}
private: private:
sk_sp<GrTexture> fTexture; sk_sp<GrTextureProxy> fProxy;
SkIPoint fOffset; SkIPoint fOffset;
}; };
@ -234,7 +244,7 @@ private:
#endif #endif
class GrXPFactory { class GrXPFactory {
public: public:
typedef GrXferProcessor::DstTexture DstTexture; typedef GrXferProcessor::DstProxy DstProxy;
enum class AnalysisProperties : unsigned { enum class AnalysisProperties : unsigned {
kNone = 0x0, kNone = 0x0,

View File

@ -92,7 +92,12 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline
const GrXferProcessor& xp = pipeline.getXferProcessor(); const GrXferProcessor& xp = pipeline.getXferProcessor();
SkIPoint offset; SkIPoint offset;
GrTexture* dstTexture = pipeline.dstTexture(&offset); GrTextureProxy* dstProxy = pipeline.dstTextureProxy(&offset);
GrTexture* dstTexture = nullptr;
if (dstProxy) {
dstTexture = dstProxy->priv().peekTexture();
}
fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset); fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset);
if (dstTexture) { if (dstTexture) {
fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerParams::ClampNoFilter(), true, fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerParams::ClampNoFilter(), true,

View File

@ -237,7 +237,10 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
SamplerHandle dstTextureSamplerHandle; SamplerHandle dstTextureSamplerHandle;
GrSurfaceOrigin dstTextureOrigin = kTopLeft_GrSurfaceOrigin; GrSurfaceOrigin dstTextureOrigin = kTopLeft_GrSurfaceOrigin;
if (GrTexture* dstTexture = fPipeline.dstTexture()) {
if (GrTextureProxy* dstTextureProxy = fPipeline.dstTextureProxy()) {
GrTexture* dstTexture = dstTextureProxy->priv().peekTexture();
// GrProcessor::TextureSampler sampler(dstTexture); // GrProcessor::TextureSampler sampler(dstTexture);
SkString name("DstTextureSampler"); SkString name("DstTextureSampler");
dstTextureSamplerHandle = dstTextureSamplerHandle =

View File

@ -229,6 +229,7 @@ void InstancedOp::onExecute(GrOpFlushState* state) {
GrPipeline::InitArgs args; GrPipeline::InitArgs args;
args.fAppliedClip = state->drawOpArgs().fAppliedClip; args.fAppliedClip = state->drawOpArgs().fAppliedClip;
args.fCaps = &state->caps(); args.fCaps = &state->caps();
args.fResourceProvider = state->resourceProvider();
args.fProcessors = &fProcessors; args.fProcessors = &fProcessors;
args.fFlags = GrAATypeIsHW(fInfo.aaType()) ? GrPipeline::kHWAntialias_Flag : 0; args.fFlags = GrAATypeIsHW(fInfo.aaType()) ? GrPipeline::kHWAntialias_Flag : 0;
if (fAllowsSRGBInputs) { if (fAllowsSRGBInputs) {
@ -238,7 +239,7 @@ void InstancedOp::onExecute(GrOpFlushState* state) {
args.fFlags |= GrPipeline::kDisableOutputConversionToSRGB_Flag; args.fFlags |= GrPipeline::kDisableOutputConversionToSRGB_Flag;
} }
args.fRenderTarget = state->drawOpArgs().fRenderTarget; args.fRenderTarget = state->drawOpArgs().fRenderTarget;
args.fDstTexture = state->drawOpArgs().fDstTexture; args.fDstProxy = state->drawOpArgs().fDstProxy;
pipeline.init(args); pipeline.init(args);
if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*state->gpu()->caps())) { if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*state->gpu()->caps())) {

View File

@ -48,7 +48,8 @@ void GrDrawPathOpBase::initPipeline(const GrOpFlushState& state, GrPipeline* pip
args.fAppliedClip = state.drawOpArgs().fAppliedClip; args.fAppliedClip = state.drawOpArgs().fAppliedClip;
args.fRenderTarget = state.drawOpArgs().fRenderTarget; args.fRenderTarget = state.drawOpArgs().fRenderTarget;
args.fCaps = &state.caps(); args.fCaps = &state.caps();
args.fDstTexture = state.drawOpArgs().fDstTexture; args.fResourceProvider = state.resourceProvider();
args.fDstProxy = state.drawOpArgs().fDstProxy;
return pipeline->init(args); return pipeline->init(args);
} }

View File

@ -137,8 +137,9 @@ protected:
args.fProcessors = &this->processors(); args.fProcessors = &this->processors();
args.fRenderTarget = target->renderTarget(); args.fRenderTarget = target->renderTarget();
args.fAppliedClip = target->clip(); args.fAppliedClip = target->clip();
args.fDstTexture = target->dstTexture(); args.fDstProxy = target->dstProxy();
args.fCaps = &target->caps(); args.fCaps = &target->caps();
args.fResourceProvider = target->resourceProvider();
return args; return args;
} }

View File

@ -533,7 +533,8 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
while (const GrFragmentProcessor* fp = iter.next()) { while (const GrFragmentProcessor* fp = iter.next()) {
prepare_sampled_images(*fp, fGpu); prepare_sampled_images(*fp, fGpu);
} }
if (GrVkTexture* dstTexture = static_cast<GrVkTexture*>(pipeline.dstTexture())) { if (GrTextureProxy* dstTextureProxy = pipeline.dstTextureProxy()) {
GrVkTexture* dstTexture = static_cast<GrVkTexture*>(dstTextureProxy->priv().peekTexture());
set_texture_layout(dstTexture, fGpu); set_texture_layout(dstTexture, fGpu);
} }

View File

@ -7,6 +7,7 @@
#include "GrVkPipelineState.h" #include "GrVkPipelineState.h"
#include "GrContext.h"
#include "GrPipeline.h" #include "GrPipeline.h"
#include "GrTexturePriv.h" #include "GrTexturePriv.h"
#include "GrVkBufferView.h" #include "GrVkBufferView.h"
@ -258,12 +259,17 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
SkASSERT(!fp && !glslFP); SkASSERT(!fp && !glslFP);
SkIPoint offset; SkIPoint offset;
GrTexture* dstTexture = pipeline.dstTexture(&offset); GrTextureProxy* dstTextureProxy = nullptr;
GrTexture* dstTexture = nullptr;
if (dstTextureProxy = pipeline.dstTextureProxy(&offset)) {
dstTexture = dstTextureProxy->priv().peekTexture();
}
fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset); fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset);
GrResourceIOProcessor::TextureSampler dstTextureSampler; GrResourceIOProcessor::TextureSampler dstTextureSampler;
if (dstTexture) { if (dstTextureProxy) {
// MDB TODO: this is the last usage of a GrTexture-based TextureSampler reset method // MDB TODO: this is the last usage of a GrTexture-based TextureSampler reset method
dstTextureSampler.reset(dstTexture); dstTextureSampler.reset(gpu->getContext()->resourceProvider(), sk_ref_sp(dstTextureProxy));
textureBindings.push_back(&dstTextureSampler); textureBindings.push_back(&dstTextureSampler);
} }

View File

@ -1044,11 +1044,12 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
kRGBA_8888_GrPixelConfig, kRGBA_8888_GrPixelConfig,
backendTexHandle); backendTexHandle);
GrXferProcessor::DstTexture fakeDstTexture; GrXferProcessor::DstProxy fakeDstProxy;
fakeDstTexture.setTexture( {
ctx->resourceProvider()->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin, sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrappedBackend(ctx, backendTex,
kNone_GrBackendTextureFlag, 0, kTopLeft_GrSurfaceOrigin);
kBorrow_GrWrapOwnership)); fakeDstProxy.setProxy(std::move(proxy));
}
static const GrProcessorAnalysisColor colorInputs[] = { static const GrProcessorAnalysisColor colorInputs[] = {
GrProcessorAnalysisColor::Opaque::kNo, GrProcessorAnalysisColor::Opaque::kYes, GrProcessorAnalysisColor::Opaque::kNo, GrProcessorAnalysisColor::Opaque::kYes,