struct DrawOpArgs {
GrRenderTarget* fRenderTarget;
const GrAppliedClip* fAppliedClip;
- GrXferProcessor::DstProxy fDstProxy;
+ GrXferProcessor::DstTexture fDstTexture;
};
void setDrawOpArgs(DrawOpArgs* opArgs) { fOpArgs = opArgs; }
const GrAppliedClip* clip() const { return this->state()->drawOpArgs().fAppliedClip; }
- const GrXferProcessor::DstProxy& dstProxy() const {
- return this->state()->drawOpArgs().fDstProxy;
+ const GrXferProcessor::DstTexture& dstTexture() const {
+ return this->state()->drawOpArgs().fDstTexture;
}
template <typename... Args>
fXferProcessor = args.fProcessors->refXferProcessor();
- if (args.fDstProxy.proxy()) {
- if (!args.fDstProxy.proxy()->instantiate(args.fResourceProvider)) {
- this->markAsBad();
- }
-
- fDstTextureProxy.reset(args.fDstProxy.proxy());
- fDstTextureOffset = args.fDstProxy.offset();
+ if (args.fDstTexture.texture()) {
+ fDstTexture.reset(args.fDstTexture.texture());
+ fDstTextureOffset = args.fDstTexture.offset();
}
// Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline, possibly removing some of the
GrFragmentProcessor::TextureAccessIter iter(proc);
while (const GrResourceIOProcessor::TextureSampler* sampler = iter.next()) {
SkASSERT(rtp->getLastOpList());
- rtp->getLastOpList()->addDependency(sampler->proxy());
+ rtp->getLastOpList()->addDependency(sampler->texture());
}
}
#endif
}
#endif
- if (fDstTextureProxy) {
- SkASSERT(rtp->getLastOpList());
+ if (fDstTexture) {
+ //SkASSERT(rtp->getLastOpList());
// MDB TODO: re-enable when TextureSamplers store texture proxies
//rtp->getLastOpList()->addDependency(fDstTexture.get());
}
const GrAppliedClip* fAppliedClip = nullptr;
GrRenderTarget* fRenderTarget = nullptr;
const GrCaps* fCaps = nullptr;
- GrResourceProvider* fResourceProvider = nullptr;
- GrXferProcessor::DstProxy fDstProxy;
+ GrXferProcessor::DstTexture fDstTexture;
};
/**
* 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.
*/
- GrTextureProxy* dstTextureProxy(SkIPoint* offset = nullptr) const {
+ GrTexture* dstTexture(SkIPoint* offset = nullptr) const {
if (offset) {
*offset = fDstTextureOffset;
}
- return fDstTextureProxy.get();
+ return fDstTexture.get();
}
const GrFragmentProcessor& getColorFragmentProcessor(int idx) const {
bool isBad() const { return SkToBool(fFlags & kIsBad_Flag); }
GrXferBarrierType xferBarrierType(const GrCaps& caps) const {
- if (fDstTextureProxy.get() &&
- fDstTextureProxy.get()->priv().peekTexture() == fRenderTarget.get()->asTexture()) {
+ if (fDstTexture.get() && fDstTexture.get() == fRenderTarget.get()->asTexture()) {
return kTexture_GrXferBarrierType;
}
return this->getXferProcessor().xferBarrierType(caps);
};
using RenderTarget = GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>;
- using DstTextureProxy = GrPendingIOResource<GrTextureProxy, kRead_GrIOType>;
+ using DstTexture = GrPendingIOResource<GrTexture, kRead_GrIOType>;
using PendingFragmentProcessor = GrPendingProgramElement<const GrFragmentProcessor>;
using FragmentProcessorArray = SkAutoSTArray<8, PendingFragmentProcessor>;
- DstTextureProxy fDstTextureProxy;
+ DstTexture fDstTexture;
SkIPoint fDstTextureOffset;
RenderTarget fRenderTarget;
GrScissorState fScissorState;
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,
sk_sp<GrTextureProxy> proxy,
const GrSamplerParams& params,
*/
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
TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&);
explicit TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>,
const GrXferProcessor& xp = pipeline.getXferProcessor();
const GrSurfaceOrigin* originIfDstTexture = nullptr;
GrSurfaceOrigin origin;
- if (pipeline.dstTextureProxy()) {
- origin = pipeline.dstTextureProxy()->origin();
+ if (pipeline.dstTexture()) {
+ origin = pipeline.dstTexture()->origin();
originIfDstTexture = &origin;
}
xp.getGLSLProcessorKey(shaderCaps, &b, originIfDstTexture);
}
}
- GrXferProcessor::DstProxy dstProxy;
+ GrXferProcessor::DstTexture dstTexture;
if (op->xpRequiresDstTexture(*this->caps(), &appliedClip)) {
- if (!this->setupDstProxy(this->asRenderTargetProxy(), clip, op->bounds(), &dstProxy)) {
+ if (!this->setupDstTexture(fRenderTargetProxy.get(), clip, op->bounds(), &dstTexture)) {
return SK_InvalidUniqueID;
}
}
op->setClippedBounds(bounds);
- return this->getOpList()->addOp(std::move(op), this, std::move(appliedClip), dstProxy);
+ return this->getOpList()->addOp(std::move(op), this, std::move(appliedClip), dstTexture);
}
uint32_t GrRenderTargetContext::addLegacyMeshDrawOp(GrPipelineBuilder&& pipelineBuilder,
args.fAppliedClip = &appliedClip;
args.fRenderTarget = rt;
args.fCaps = this->caps();
- args.fResourceProvider = fContext->resourceProvider();
if (analysis.requiresDstTexture()) {
- if (!this->setupDstProxy(this->asRenderTargetProxy(), clip, bounds, &args.fDstProxy)) {
+ if (!this->setupDstTexture(fRenderTargetProxy.get(), clip, bounds, &args.fDstTexture)) {
return SK_InvalidUniqueID;
}
}
return this->getOpList()->addOp(std::move(op), this);
}
-bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const GrClip& clip,
+bool GrRenderTargetContext::setupDstTexture(GrRenderTargetProxy* rtProxy, const GrClip& clip,
const SkRect& opBounds,
- GrXferProcessor::DstProxy* dstProxy) {
+ GrXferProcessor::DstTexture* dstTexture) {
if (this->caps()->textureBarrierSupport()) {
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
// will be responsible to detect this situation and request a texture barrier.
- dstProxy->setProxy(sk_ref_sp(texProxy));
- dstProxy->setOffset(0, 0);
+ dstTexture->setTexture(std::move(tex));
+ dstTexture->setOffset(0, 0);
return true;
}
}
return false;
}
- dstProxy->setProxy(sContext->asTextureProxyRef());
- dstProxy->setOffset(dstOffset);
+ GrTextureProxy* copyProxy = sContext->asTextureProxy();
+ // MDB TODO: remove this instantiation once DstTexture is proxy-backed
+ 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;
}
// 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
// value is false then a texture copy could not be made.
- bool SK_WARN_UNUSED_RESULT setupDstProxy(GrRenderTargetProxy*,
- const GrClip&,
- const SkRect& opBounds,
- GrXferProcessor::DstProxy* result);
+ bool SK_WARN_UNUSED_RESULT setupDstTexture(GrRenderTargetProxy*,
+ const GrClip&,
+ const SkRect& opBounds,
+ GrXferProcessor::DstTexture* result);
GrRenderTargetOpList* getOpList();
opArgs = {
fRecordedOps[i].fRenderTarget.get(),
fRecordedOps[i].fAppliedClip,
- fRecordedOps[i].fDstProxy
+ fRecordedOps[i].fDstTexture
};
}
flushState->setDrawOpArgs(&opArgs);
GrOpFlushState::DrawOpArgs opArgs {
fRecordedOps[i].fRenderTarget.get(),
fRecordedOps[i].fAppliedClip,
- fRecordedOps[i].fDstProxy
+ fRecordedOps[i].fDstTexture
};
flushState->setDrawOpArgs(&opArgs);
bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b,
const GrAppliedClip* bClip,
- const DstProxy* bDstProxy,
+ const DstTexture* bDstTexture,
const GrCaps& caps) {
if (a.fAppliedClip) {
if (!bClip) {
} else if (bClip) {
return false;
}
- if (bDstProxy) {
- if (a.fDstProxy != *bDstProxy) {
+ if (bDstTexture) {
+ if (a.fDstTexture != *bDstTexture) {
return false;
}
- } else if (a.fDstProxy.proxy()) {
+ } else if (a.fDstTexture.texture()) {
return false;
}
return a.fOp->combineIfPossible(b, caps);
GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
GrRenderTargetContext* renderTargetContext,
GrAppliedClip* clip,
- const DstProxy* dstProxy) {
+ const DstTexture* dstTexture) {
GrRenderTarget* renderTarget = renderTargetContext->accessRenderTarget();
if (!renderTarget) {
SkASSERT(false);
candidate.fOp->uniqueID());
break;
}
- if (this->combineIfPossible(candidate, op.get(), clip, dstProxy, *caps)) {
+ if (this->combineIfPossible(candidate, op.get(), clip, dstTexture, *caps)) {
GrOP_INFO("\t\tBackward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
GrOP_INFO("\t\t\tBackward: Combined op info:\n");
clip = fClipAllocator.make<GrAppliedClip>(std::move(*clip));
SkDEBUGCODE(fNumClips++;)
}
- fRecordedOps.emplace_back(std::move(op), renderTarget, clip, dstProxy);
+ fRecordedOps.emplace_back(std::move(op), renderTarget, clip, dstTexture);
fRecordedOps.back().fOp->wasRecorded(this);
fLastFullClearOp = nullptr;
fLastFullClearResourceID.makeInvalid();
break;
}
if (this->combineIfPossible(fRecordedOps[i], candidate.fOp.get(),
- candidate.fAppliedClip, &candidate.fDstProxy, caps)) {
+ candidate.fAppliedClip, &candidate.fDstTexture, caps)) {
GrOP_INFO("\t\tForward: Combining with (%s, opID: %u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get());
class GrRenderTargetOpList final : public GrOpList {
private:
- using DstProxy = GrXferProcessor::DstProxy;
+ using DstTexture = GrXferProcessor::DstTexture;
public:
GrRenderTargetOpList(GrRenderTargetProxy*, GrGpu*, GrAuditTrail*);
return this->uniqueID();
}
uint32_t addOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext,
- GrAppliedClip&& clip, const DstProxy& dstProxy) {
+ GrAppliedClip&& clip, const DstTexture& dstTexture) {
this->recordOp(std::move(op), renderTargetContext, clip.doesClip() ? &clip : nullptr,
- &dstProxy);
+ &dstTexture);
return this->uniqueID();
}
RecordedOp(std::unique_ptr<GrOp> op,
GrRenderTarget* rt,
const GrAppliedClip* appliedClip,
- const DstProxy* dstProxy)
+ const DstTexture* dstTexture)
: fOp(std::move(op))
, fRenderTarget(rt)
, fAppliedClip(appliedClip) {
- if (dstProxy) {
- fDstProxy = *dstProxy;
+ if (dstTexture) {
+ fDstTexture = *dstTexture;
}
}
std::unique_ptr<GrOp> fOp;
// TODO: These ops will all to target the same render target and this won't be needed.
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
- DstProxy fDstProxy;
+ DstTexture fDstTexture;
const GrAppliedClip* fAppliedClip;
};
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
// returns the input op.
GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, GrAppliedClip* = nullptr,
- const DstProxy* = nullptr);
+ const DstTexture* = nullptr);
void forwardCombine(const GrCaps&);
// If this returns true then b has been merged into a's op.
bool combineIfPossible(const RecordedOp& a, GrOp* b, const GrAppliedClip* bClip,
- const DstProxy* bDstTexture, const GrCaps&);
+ const DstTexture* bDstTexture, const GrCaps&);
GrClearOp* fLastFullClearOp = nullptr;
GrGpuResource::UniqueID fLastFullClearResourceID = GrGpuResource::UniqueID::InvalidID();
* to the space of the texture. Depending on GPU capabilities a DstTexture may be used by a
* GrXferProcessor for blending in the fragment shader.
*/
- class DstProxy {
+ class DstTexture {
public:
- DstProxy() { fOffset.set(0, 0); }
+ DstTexture() { fOffset.set(0, 0); }
- DstProxy(const DstProxy& other) {
+ DstTexture(const DstTexture& other) {
*this = other;
}
- DstProxy(sk_sp<GrTextureProxy> proxy, const SkIPoint& offset)
- : fProxy(std::move(proxy)) {
- if (fProxy) {
- fOffset = offset;
- } else {
- fOffset.set(0, 0);
- }
- }
+ DstTexture(GrTexture* texture, const SkIPoint& offset)
+ : fTexture(SkSafeRef(texture)), fOffset(texture ? offset : SkIPoint{0, 0}) {}
- DstProxy& operator=(const DstProxy& other) {
- fProxy = other.fProxy;
+ DstTexture& operator=(const DstTexture& other) {
+ fTexture = other.fTexture;
fOffset = other.fOffset;
return *this;
}
- bool operator==(const DstProxy& that) const {
- return fProxy == that.fProxy && fOffset == that.fOffset;
+ bool operator==(const DstTexture& that) const {
+ return fTexture == that.fTexture && fOffset == that.fOffset;
}
- bool operator!=(const DstProxy& that) const { return !(*this == that); }
+ bool operator!=(const DstTexture& that) const { return !(*this == that); }
const SkIPoint& offset() const { return fOffset; }
void setOffset(const SkIPoint& offset) { fOffset = offset; }
void setOffset(int ox, int oy) { fOffset.set(ox, oy); }
- GrTextureProxy* proxy() const { return fProxy.get(); }
+ GrTexture* texture() const { return fTexture.get(); }
- void setProxy(sk_sp<GrTextureProxy> proxy) {
- fProxy = std::move(proxy);
- if (!fProxy) {
+ void setTexture(sk_sp<GrTexture> texture) {
+ fTexture = std::move(texture);
+ if (!fTexture) {
fOffset = {0, 0};
}
}
- bool instantiate(GrResourceProvider* resourceProvider) {
- return SkToBool(fProxy->instantiate(resourceProvider));
- }
-
private:
- sk_sp<GrTextureProxy> fProxy;
- SkIPoint fOffset;
+ sk_sp<GrTexture> fTexture;
+ SkIPoint fOffset;
};
/**
#endif
class GrXPFactory {
public:
- typedef GrXferProcessor::DstProxy DstProxy;
+ typedef GrXferProcessor::DstTexture DstTexture;
enum class AnalysisProperties : unsigned {
kNone = 0x0,
const GrXferProcessor& xp = pipeline.getXferProcessor();
SkIPoint offset;
- GrTextureProxy* dstProxy = pipeline.dstTextureProxy(&offset);
- GrTexture* dstTexture = nullptr;
- if (dstProxy) {
- dstTexture = dstProxy->priv().peekTexture();
- }
-
+ GrTexture* dstTexture = pipeline.dstTexture(&offset);
fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset);
if (dstTexture) {
fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerParams::ClampNoFilter(), true,
SamplerHandle dstTextureSamplerHandle;
GrSurfaceOrigin dstTextureOrigin = kTopLeft_GrSurfaceOrigin;
-
- if (GrTextureProxy* dstTextureProxy = fPipeline.dstTextureProxy()) {
- GrTexture* dstTexture = dstTextureProxy->priv().peekTexture();
-
+ if (GrTexture* dstTexture = fPipeline.dstTexture()) {
// GrProcessor::TextureSampler sampler(dstTexture);
SkString name("DstTextureSampler");
dstTextureSamplerHandle =
GrPipeline::InitArgs args;
args.fAppliedClip = state->drawOpArgs().fAppliedClip;
args.fCaps = &state->caps();
- args.fResourceProvider = state->resourceProvider();
args.fProcessors = &fProcessors;
args.fFlags = GrAATypeIsHW(fInfo.aaType()) ? GrPipeline::kHWAntialias_Flag : 0;
if (fAllowsSRGBInputs) {
args.fFlags |= GrPipeline::kDisableOutputConversionToSRGB_Flag;
}
args.fRenderTarget = state->drawOpArgs().fRenderTarget;
- args.fDstProxy = state->drawOpArgs().fDstProxy;
+ args.fDstTexture = state->drawOpArgs().fDstTexture;
pipeline.init(args);
if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*state->gpu()->caps())) {
args.fAppliedClip = state.drawOpArgs().fAppliedClip;
args.fRenderTarget = state.drawOpArgs().fRenderTarget;
args.fCaps = &state.caps();
- args.fResourceProvider = state.resourceProvider();
- args.fDstProxy = state.drawOpArgs().fDstProxy;
+ args.fDstTexture = state.drawOpArgs().fDstTexture;
return pipeline->init(args);
}
args.fProcessors = &this->processors();
args.fRenderTarget = target->renderTarget();
args.fAppliedClip = target->clip();
- args.fDstProxy = target->dstProxy();
+ args.fDstTexture = target->dstTexture();
args.fCaps = &target->caps();
- args.fResourceProvider = target->resourceProvider();
return args;
}
while (const GrFragmentProcessor* fp = iter.next()) {
prepare_sampled_images(*fp, fGpu);
}
- if (GrTextureProxy* dstTextureProxy = pipeline.dstTextureProxy()) {
- GrVkTexture* dstTexture = static_cast<GrVkTexture*>(dstTextureProxy->priv().peekTexture());
+ if (GrVkTexture* dstTexture = static_cast<GrVkTexture*>(pipeline.dstTexture())) {
set_texture_layout(dstTexture, fGpu);
}
#include "GrVkPipelineState.h"
-#include "GrContext.h"
#include "GrPipeline.h"
#include "GrTexturePriv.h"
#include "GrVkBufferView.h"
SkASSERT(!fp && !glslFP);
SkIPoint offset;
- GrTextureProxy* dstTextureProxy = nullptr;
- GrTexture* dstTexture = nullptr;
- if (dstTextureProxy = pipeline.dstTextureProxy(&offset)) {
- dstTexture = dstTextureProxy->priv().peekTexture();
- }
-
+ GrTexture* dstTexture = pipeline.dstTexture(&offset);
fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset);
GrResourceIOProcessor::TextureSampler dstTextureSampler;
- if (dstTextureProxy) {
+ if (dstTexture) {
// MDB TODO: this is the last usage of a GrTexture-based TextureSampler reset method
- dstTextureSampler.reset(gpu->getContext()->resourceProvider(), sk_ref_sp(dstTextureProxy));
+ dstTextureSampler.reset(dstTexture);
textureBindings.push_back(&dstTextureSampler);
}
kRGBA_8888_GrPixelConfig,
backendTexHandle);
- GrXferProcessor::DstProxy fakeDstProxy;
- {
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrappedBackend(ctx, backendTex,
- kTopLeft_GrSurfaceOrigin);
- fakeDstProxy.setProxy(std::move(proxy));
- }
+ GrXferProcessor::DstTexture fakeDstTexture;
+ fakeDstTexture.setTexture(
+ ctx->resourceProvider()->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
+ kNone_GrBackendTextureFlag, 0,
+ kBorrow_GrWrapOwnership));
static const GrProcessorAnalysisColor colorInputs[] = {
GrProcessorAnalysisColor::Opaque::kNo, GrProcessorAnalysisColor::Opaque::kYes,