diff options
author | Robert Phillips <robertphillips@google.com> | 2017-07-26 15:48:41 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-26 20:59:00 +0000 |
commit | 2890fbfe1400b81e4d6af98d14dfe757fec93650 (patch) | |
tree | bbc22dc56d4cdb0b1f6b06740c68738808506f67 | |
parent | 480c90afc4382d03fa7cda534a702459ace72953 (diff) |
Make GrPipeline hold a GrRenderTargetProxy (instead of a GrRenderTarget)
In a future world where GrSurface no longer has an origin it will be
useful for the GrPipeline to be holding the GrRenderTargetProxy (which will
still have an origin).
Change-Id: I743a8cc07b6b92f8116227fb77b7c37da43cde8a
Reviewed-on: https://skia-review.googlesource.com/26804
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
43 files changed, 99 insertions, 85 deletions
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index a44f03b404..a6a71af792 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -245,7 +245,7 @@ void CCPRGeometryView::Op::onExecute(GrOpFlushState* state) { return; } - GrPipeline pipeline(state->drawOpArgs().fRenderTarget, GrPipeline::ScissorState::kDisabled, + GrPipeline pipeline(state->drawOpArgs().fProxy, GrPipeline::ScissorState::kDisabled, SkBlendMode::kSrcOver); GrCCPRCoverageProcessor ccprProc(fView->fMode, pointsBuffer.get()); diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index afe3956747..3487f6fea0 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -457,7 +457,7 @@ void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_ } const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(const GrPipeline& pipeline) { - GrRenderTarget* rt = pipeline.getRenderTarget(); + GrRenderTarget* rt = pipeline.renderTarget(); SkASSERT(rt->numStencilSamples() > 1); GrStencilSettings stencil; diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h index a701965d4d..c73fee0a28 100644 --- a/src/gpu/GrOpFlushState.h +++ b/src/gpu/GrOpFlushState.h @@ -97,7 +97,9 @@ public: /** Additional data required on a per-op basis when executing GrDrawOps. */ struct DrawOpArgs { - GrRenderTarget* fRenderTarget; + GrRenderTarget* renderTarget() const { return fProxy->priv().peekRenderTarget(); } + + GrRenderTargetProxy* fProxy; const GrAppliedClip* fAppliedClip; GrXferProcessor::DstProxy fDstProxy; }; @@ -232,7 +234,7 @@ public: this->state()->putBackVertexSpace(vertices * vertexStride); } - GrRenderTarget* renderTarget() const { return this->state()->drawOpArgs().fRenderTarget; } + GrRenderTargetProxy* proxy() const { return this->state()->drawOpArgs().fProxy; } const GrAppliedClip* clip() const { return this->state()->drawOpArgs().fAppliedClip; } @@ -253,7 +255,7 @@ public: GrPipeline::InitArgs pipelineArgs; pipelineArgs.fFlags = pipelineFlags; pipelineArgs.fProcessors = processorSet; - pipelineArgs.fRenderTarget = this->renderTarget(); + pipelineArgs.fProxy = this->proxy(); pipelineArgs.fAppliedClip = this->clip(); pipelineArgs.fDstProxy = this->dstProxy(); pipelineArgs.fCaps = &this->caps(); diff --git a/src/gpu/GrPathRendering.cpp b/src/gpu/GrPathRendering.cpp index 15ae6c1fd3..a40f0af369 100644 --- a/src/gpu/GrPathRendering.cpp +++ b/src/gpu/GrPathRendering.cpp @@ -118,7 +118,7 @@ void GrPathRendering::drawPath(const GrPipeline& pipeline, const GrPath* path) { fGpu->handleDirtyContext(); if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*fGpu->caps())) { - fGpu->xferBarrier(pipeline.getRenderTarget(), barrierType); + fGpu->xferBarrier(pipeline.renderTarget(), barrierType); } this->onDrawPath(pipeline, primProc, stencilPassSettings, path); } @@ -135,7 +135,7 @@ void GrPathRendering::drawPaths(const GrPipeline& pipeline, int count) { fGpu->handleDirtyContext(); if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*fGpu->caps())) { - fGpu->xferBarrier(pipeline.getRenderTarget(), barrierType); + fGpu->xferBarrier(pipeline.renderTarget(), barrierType); } #ifdef SK_DEBUG pathRange->assertPathsLoaded(indices, indexType, count); diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 0483d4289c..c7f131aab2 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -18,11 +18,11 @@ #include "ops/GrOp.h" void GrPipeline::init(const InitArgs& args) { - SkASSERT(args.fRenderTarget); + SkASSERT(args.fProxy); SkASSERT(args.fProcessors); SkASSERT(args.fProcessors->isFinalized()); - fRenderTarget.reset(args.fRenderTarget); + fProxy.reset(args.fProxy); fFlags = args.fFlags; if (args.fAppliedClip) { @@ -99,21 +99,21 @@ void GrPipeline::addDependenciesTo(GrOpList* opList, const GrCaps& caps) const { GrXferBarrierType GrPipeline::xferBarrierType(const GrCaps& caps) const { if (fDstTextureProxy.get() && - fDstTextureProxy.get()->priv().peekTexture() == fRenderTarget.get()->asTexture()) { + fDstTextureProxy.get()->priv().peekTexture() == fProxy.get()->priv().peekTexture()) { return kTexture_GrXferBarrierType; } return this->getXferProcessor().xferBarrierType(caps); } -GrPipeline::GrPipeline(GrRenderTarget* rt, ScissorState scissorState, SkBlendMode blendmode) - : fRenderTarget(rt) - , fScissorState() - , fWindowRectsState() - , fUserStencilSettings(&GrUserStencilSettings::kUnused) - , fFlags() - , fXferProcessor(GrPorterDuffXPFactory::MakeNoCoverageXP(blendmode)) - , fFragmentProcessors() - , fNumColorProcessors(0) { +GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, ScissorState scissorState, SkBlendMode blendmode) + : fProxy(proxy) + , fScissorState() + , fWindowRectsState() + , fUserStencilSettings(&GrUserStencilSettings::kUnused) + , fFlags() + , fXferProcessor(GrPorterDuffXPFactory::MakeNoCoverageXP(blendmode)) + , fFragmentProcessors() + , fNumColorProcessors(0) { if (ScissorState::kEnabled == scissorState) { fScissorState.set({0, 0, 0, 0}); // caller will use the DynamicState struct. } @@ -124,7 +124,7 @@ GrPipeline::GrPipeline(GrRenderTarget* rt, ScissorState scissorState, SkBlendMod bool GrPipeline::AreEqual(const GrPipeline& a, const GrPipeline& b) { SkASSERT(&a != &b); - if (a.getRenderTarget() != b.getRenderTarget() || + if (a.proxy() != b.proxy() || a.fFragmentProcessors.count() != b.fFragmentProcessors.count() || a.fNumColorProcessors != b.fNumColorProcessors || a.fScissorState != b.fScissorState || diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 3a194d6f63..b4423049fb 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -15,7 +15,7 @@ #include "GrProcessorSet.h" #include "GrProgramDesc.h" #include "GrRect.h" -#include "GrRenderTarget.h" +#include "GrRenderTargetProxy.h" #include "GrScissorState.h" #include "GrUserStencilSettings.h" #include "GrWindowRectsState.h" @@ -79,7 +79,7 @@ public: const GrProcessorSet* fProcessors = nullptr; // Must be finalized const GrUserStencilSettings* fUserStencil = &GrUserStencilSettings::kUnused; const GrAppliedClip* fAppliedClip = nullptr; - GrRenderTarget* fRenderTarget = nullptr; + GrRenderTargetProxy* fProxy = nullptr; const GrCaps* fCaps = nullptr; GrResourceProvider* fResourceProvider = nullptr; GrXferProcessor::DstProxy fDstProxy; @@ -105,7 +105,7 @@ public: * must be "Porter Duff" (<= kLastCoeffMode). If using ScissorState::kEnabled, the caller must * specify a scissor rectangle through the DynamicState struct. **/ - GrPipeline(GrRenderTarget*, ScissorState, SkBlendMode); + GrPipeline(GrRenderTargetProxy*, ScissorState, SkBlendMode); GrPipeline(const InitArgs& args) { this->init(args); } @@ -116,7 +116,7 @@ public: void init(const InitArgs&); /** True if the pipeline has been initialized. */ - bool isInitialized() const { return SkToBool(fRenderTarget.get()); } + bool isInitialized() const { return SkToBool(fProxy.get()); } /// @} @@ -212,7 +212,8 @@ public: * * @return The currently set render target. */ - GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } + GrRenderTargetProxy* proxy() const { return fProxy.get(); } + GrRenderTarget* renderTarget() const { return fProxy.get()->priv().peekRenderTarget(); } const GrUserStencilSettings* getUserStencil() const { return fUserStencilSettings; } @@ -270,14 +271,14 @@ private: kIsBad_Flag = 0x40, }; - using RenderTarget = GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>; + using RenderTargetProxy = GrPendingIOResource<GrRenderTargetProxy, kWrite_GrIOType>; using DstTextureProxy = GrPendingIOResource<GrTextureProxy, kRead_GrIOType>; using PendingFragmentProcessor = GrPendingProgramElement<const GrFragmentProcessor>; using FragmentProcessorArray = SkAutoSTArray<8, PendingFragmentProcessor>; DstTextureProxy fDstTextureProxy; SkIPoint fDstTextureOffset; - RenderTarget fRenderTarget; + RenderTargetProxy fProxy; GrScissorState fScissorState; GrWindowRectsState fWindowRectsState; const GrUserStencilSettings* fUserStencilSettings; diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp index ca81e5a793..f40c6b666c 100644 --- a/src/gpu/GrProgramDesc.cpp +++ b/src/gpu/GrProgramDesc.cpp @@ -218,17 +218,19 @@ bool GrProgramDesc::Build(GrProgramDesc* desc, // make sure any padding in the header is zeroed. memset(header, 0, kHeaderSize); - GrRenderTarget* rt = pipeline.getRenderTarget(); + GrRenderTargetProxy* proxy = pipeline.proxy(); if (requiredFeatures & GrProcessor::kSampleLocations_RequiredFeature) { SkASSERT(pipeline.isHWAntialiasState()); + + GrRenderTarget* rt = pipeline.renderTarget(); header->fSamplePatternKey = rt->renderTargetPriv().getMultisampleSpecs(pipeline).fUniqueID; } else { header->fSamplePatternKey = 0; } - header->fOutputSwizzle = shaderCaps.configOutputSwizzle(rt->config()).asKey(); + header->fOutputSwizzle = shaderCaps.configOutputSwizzle(proxy->config()).asKey(); header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); header->fColorFragmentProcessorCnt = pipeline.numColorFragmentProcessors(); diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index ae63c23442..e43c910fd0 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -91,7 +91,7 @@ int GrRenderTargetPriv::numStencilBits() const { const GrGpu::MultisampleSpecs& GrRenderTargetPriv::getMultisampleSpecs(const GrPipeline& pipeline) const { - SkASSERT(fRenderTarget == pipeline.getRenderTarget()); // TODO: remove RT from pipeline. + SkASSERT(fRenderTarget == pipeline.renderTarget()); // TODO: remove RT from pipeline. GrGpu* gpu = fRenderTarget->getGpu(); if (auto id = fRenderTarget->fMultisampleSpecsID) { SkASSERT(gpu->queryMultisampleSpecs(pipeline).fUniqueID == id); diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h index b32eaed189..2cfd5c8679 100644 --- a/src/gpu/GrRenderTargetContextPriv.h +++ b/src/gpu/GrRenderTargetContextPriv.h @@ -14,6 +14,7 @@ class GrFixedClip; class GrPath; +class GrRenderTargetPriv; struct GrUserStencilSettings; /** Class that adds methods to GrRenderTargetContext that are only intended for use internal to diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index d1c1425123..f0c97e48f5 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -68,7 +68,7 @@ void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) { for (int i = 0; i < fRecordedOps.count(); ++i) { if (fRecordedOps[i].fOp) { GrOpFlushState::DrawOpArgs opArgs = { - fTarget.get()->priv().peekRenderTarget(), + fTarget.get()->asRenderTargetProxy(), fRecordedOps[i].fAppliedClip, fRecordedOps[i].fDstProxy }; @@ -138,7 +138,7 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) { } GrOpFlushState::DrawOpArgs opArgs { - fTarget.get()->priv().peekRenderTarget(), + fTarget.get()->asRenderTargetProxy(), fRecordedOps[i].fAppliedClip, fRecordedOps[i].fDstProxy }; diff --git a/src/gpu/ccpr/GrCCPRCoverageOpsBuilder.cpp b/src/gpu/ccpr/GrCCPRCoverageOpsBuilder.cpp index d14cf1e727..5beba4cf76 100644 --- a/src/gpu/ccpr/GrCCPRCoverageOpsBuilder.cpp +++ b/src/gpu/ccpr/GrCCPRCoverageOpsBuilder.cpp @@ -498,9 +498,9 @@ GrCCPRCoverageOpsBuilder::CoverageOp::CoverageOp(const SkISize& drawBounds, void CoverageOp::onExecute(GrOpFlushState* flushState) { using Mode = GrCCPRCoverageProcessor::Mode; - SkDEBUGCODE(GrCCPRCoverageProcessor::Validate(flushState->drawOpArgs().fRenderTarget)); + SkDEBUGCODE(GrCCPRCoverageProcessor::Validate(flushState->drawOpArgs().fProxy)); - GrPipeline pipeline(flushState->drawOpArgs().fRenderTarget, GrPipeline::ScissorState::kEnabled, + GrPipeline pipeline(flushState->drawOpArgs().fProxy, GrPipeline::ScissorState::kEnabled, SkBlendMode::kPlus); fMeshesScratchBuffer.reserve(1 + fScissorBatches.count()); diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp index 5f1833a678..85b989b25f 100644 --- a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp +++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp @@ -7,6 +7,7 @@ #include "GrCCPRCoverageProcessor.h" +#include "GrRenderTargetProxy.h" #include "ccpr/GrCCPRTriangleProcessor.h" #include "ccpr/GrCCPRQuadraticProcessor.h" #include "ccpr/GrCCPRCubicProcessor.h" @@ -346,10 +347,10 @@ int PrimitiveProcessor::defineSoftSampleLocations(GrGLSLFragmentBuilder* f, #include "GrRenderTarget.h" -void GrCCPRCoverageProcessor::Validate(GrRenderTarget* atlasTexture) { - SkASSERT(kAtlasOrigin == atlasTexture->origin()); - SkASSERT(GrPixelConfigIsAlphaOnly(atlasTexture->config())); - SkASSERT(GrPixelConfigIsFloatingPoint(atlasTexture->config())); +void GrCCPRCoverageProcessor::Validate(GrRenderTargetProxy* atlasProxy) { + SkASSERT(kAtlasOrigin == atlasProxy->origin()); + SkASSERT(GrPixelConfigIsAlphaOnly(atlasProxy->config())); + SkASSERT(GrPixelConfigIsFloatingPoint(atlasProxy->config())); } #endif diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.h b/src/gpu/ccpr/GrCCPRCoverageProcessor.h index 86f7d46c0e..574cf4a162 100644 --- a/src/gpu/ccpr/GrCCPRCoverageProcessor.h +++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.h @@ -104,7 +104,7 @@ public: void enableDebugVisualizations() { fDebugVisualizations = true; } bool debugVisualizations() const { return fDebugVisualizations; } - static void Validate(GrRenderTarget* atlasTexture); + static void Validate(GrRenderTargetProxy* atlasProxy); #endif class PrimitiveProcessor; diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp index 45fad1feb0..5a9afa19e3 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp @@ -298,7 +298,7 @@ void DrawPathsOp::onExecute(GrOpFlushState* flushState) { args.fCaps = &flushState->caps(); args.fProcessors = &fProcessors; args.fFlags = fSRGBFlags; - args.fRenderTarget = flushState->drawOpArgs().fRenderTarget; + args.fProxy = flushState->drawOpArgs().fProxy; args.fDstProxy = flushState->drawOpArgs().fDstProxy; pipeline.init(args); diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 5209e3e2c9..412f3c57cb 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1845,13 +1845,13 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso if (blendInfo.fWriteColor) { // Swizzle the blend to match what the shader will output. const GrSwizzle& swizzle = this->caps()->shaderCaps()->configOutputSwizzle( - pipeline.getRenderTarget()->config()); + pipeline.proxy()->config()); this->flushBlend(blendInfo, swizzle); } program->setData(primProc, pipeline); - GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); + GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget()); GrStencilSettings stencil; if (pipeline.isStencilEnabled()) { // TODO: attach stencil and create settings during render target flush. @@ -2546,12 +2546,12 @@ void GrGLGpu::draw(const GrPipeline& pipeline, for (int i = 0; i < meshCount; ++i) { if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps())) { - this->xferBarrier(pipeline.getRenderTarget(), barrierType); + this->xferBarrier(pipeline.renderTarget(), barrierType); } if (dynamicStates) { if (pipeline.getScissorState().enabled()) { - GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); + GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget()); this->flushScissor(dynamicStates[i].fScissorRect, glRT->getViewport(), glRT->origin()); } diff --git a/src/gpu/gl/GrGLGpuCommandBuffer.h b/src/gpu/gl/GrGLGpuCommandBuffer.h index c67aeaf2e1..5ca211a214 100644 --- a/src/gpu/gl/GrGLGpuCommandBuffer.h +++ b/src/gpu/gl/GrGLGpuCommandBuffer.h @@ -55,7 +55,7 @@ private: const GrPipeline::DynamicState dynamicStates[], int meshCount, const SkRect& bounds) override { - GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); + GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(pipeline.renderTarget()); if (!fRenderTarget) { fRenderTarget = target; } diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index 2ff5dc79b4..b79c17feaa 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -82,7 +82,7 @@ GrGLProgram* GrGLGpu::ProgramCache::refProgram(const GrGLGpu* gpu, std::unique_ptr<Entry>* entry = fMap.find(desc); if (!entry) { // Didn't find an origin-independent version, check with the specific origin - GrSurfaceOrigin origin = pipeline.getRenderTarget()->origin(); + GrSurfaceOrigin origin = pipeline.proxy()->origin(); desc.setSurfaceOriginKey(GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(origin)); desc.finalize(); entry = fMap.find(desc); diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index f133c1b377..aa67bed65c 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -70,7 +70,7 @@ void GrGLProgram::abandon() { /////////////////////////////////////////////////////////////////////////////// void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { - this->setRenderTargetState(primProc, pipeline.getRenderTarget()); + this->setRenderTargetState(primProc, pipeline.renderTarget()); // we set the textures, and uniforms for installed processors in a generic way, but subclasses // of GLProgram determine how to set coord transforms diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index dc70bd6b69..8172002a4e 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -90,7 +90,7 @@ bool GrGLProgramBuilder::compileAndAttachShaders(GrGLSLShaderBuilder& shader, if (outInputs->fFlipY) { GrProgramDesc* d = this->desc(); d->setSurfaceOriginKey(GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin( - this->pipeline().getRenderTarget()->origin())); + this->pipeline().proxy()->origin())); d->finalize(); } @@ -113,7 +113,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() { // compile shaders and bind attributes / uniforms SkSL::Program::Settings settings; settings.fCaps = this->gpu()->glCaps().shaderCaps(); - settings.fFlipY = this->pipeline().getRenderTarget()->origin() != kTopLeft_GrSurfaceOrigin; + settings.fFlipY = this->pipeline().proxy()->origin() != kTopLeft_GrSurfaceOrigin; SkSL::Program::Inputs inputs; SkTDArray<GrGLuint> shadersToDelete; if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &shadersToDelete, diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp index 4fd886b4fb..6c0528ee31 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp @@ -300,7 +300,7 @@ void GrGLSLFragmentShaderBuilder::onFinalize() { void GrGLSLFragmentShaderBuilder::defineSampleOffsetArray(const char* name, const SkMatrix& m) { SkASSERT(fProgramBuilder->caps()->sampleLocationsSupport()); const GrPipeline& pipeline = fProgramBuilder->pipeline(); - const GrRenderTargetPriv& rtp = pipeline.getRenderTarget()->renderTargetPriv(); + const GrRenderTargetPriv& rtp = pipeline.renderTarget()->renderTargetPriv(); const GrGpu::MultisampleSpecs& specs = rtp.getMultisampleSpecs(pipeline); SkSTArray<16, SkPoint, true> offsets; offsets.push_back_n(specs.fEffectiveSampleCnt); diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp index 500986ea88..39c1cf2224 100644 --- a/src/gpu/instanced/InstanceProcessor.cpp +++ b/src/gpu/instanced/InstanceProcessor.cpp @@ -1681,7 +1681,7 @@ GLSLInstanceProcessor::Backend* GLSLInstanceProcessor::Backend::Create(const GrP return new BackendCoverage(opInfo, inputs); case GrAAType::kMSAA: case GrAAType::kMixedSamples: { - const GrRenderTargetPriv& rtp = pipeline.getRenderTarget()->renderTargetPriv(); + const GrRenderTargetPriv& rtp = pipeline.renderTarget()->renderTargetPriv(); const GrGpu::MultisampleSpecs& specs = rtp.getMultisampleSpecs(pipeline); return new BackendMultisample(opInfo, inputs, specs.fEffectiveSampleCnt); } diff --git a/src/gpu/instanced/InstancedOp.cpp b/src/gpu/instanced/InstancedOp.cpp index 9b80540fb2..ab2b7583c8 100644 --- a/src/gpu/instanced/InstancedOp.cpp +++ b/src/gpu/instanced/InstancedOp.cpp @@ -238,12 +238,12 @@ void InstancedOp::onExecute(GrOpFlushState* state) { if (fDisableSRGBOutputConversion) { args.fFlags |= GrPipeline::kDisableOutputConversionToSRGB_Flag; } - args.fRenderTarget = state->drawOpArgs().fRenderTarget; + args.fProxy = state->drawOpArgs().fProxy; args.fDstProxy = state->drawOpArgs().fDstProxy; pipeline.init(args); if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*state->gpu()->caps())) { - state->gpu()->xferBarrier(pipeline.getRenderTarget(), barrierType); + state->gpu()->xferBarrier(pipeline.renderTarget(), barrierType); } fInstancedRendering->draw(pipeline, fInfo, this); } diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index d29d4cfa04..a56c2018d2 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -9,6 +9,7 @@ #define GrMockGpu_DEFINED #include "GrGpu.h" +#include "GrRenderTarget.h" #include "GrSemaphore.h" #include "GrTexture.h" #include "SkTHash.h" diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h index 60682b3186..3bccd41d3d 100644 --- a/src/gpu/mock/GrMockTexture.h +++ b/src/gpu/mock/GrMockTexture.h @@ -8,6 +8,7 @@ #define GrMockTexture_DEFINED #include "GrMockGpu.h" +#include "GrRenderTarget.h" #include "GrTexture.h" #include "GrTexturePriv.h" #include "mock/GrMockTypes.h" diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp index e40862b79f..722d1699a3 100644 --- a/src/gpu/ops/GrClearOp.cpp +++ b/src/gpu/ops/GrClearOp.cpp @@ -32,7 +32,7 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro } void GrClearOp::onExecute(GrOpFlushState* state) { - SkASSERT(state->drawOpArgs().fRenderTarget); + SkASSERT(state->drawOpArgs().renderTarget()); - state->commandBuffer()->clear(state->drawOpArgs().fRenderTarget, fClip, fColor); + state->commandBuffer()->clear(state->drawOpArgs().renderTarget(), fClip, fColor); } diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h index 87a2b4d5dd..ac7b0a8de2 100644 --- a/src/gpu/ops/GrClearStencilClipOp.h +++ b/src/gpu/ops/GrClearStencilClipOp.h @@ -55,10 +55,10 @@ private: void onPrepare(GrOpFlushState*) override {} void onExecute(GrOpFlushState* state) override { - SkASSERT(state->drawOpArgs().fRenderTarget); + SkASSERT(state->drawOpArgs().renderTarget()); - state->commandBuffer()->clearStencilClip(state->drawOpArgs().fRenderTarget, - fClip, fInsideStencilMask); + GrRenderTarget* rt = state->drawOpArgs().renderTarget(); + state->commandBuffer()->clearStencilClip(rt, fClip, fInsideStencilMask); } const GrFixedClip fClip; diff --git a/src/gpu/ops/GrDiscardOp.h b/src/gpu/ops/GrDiscardOp.h index 822f818644..dd707e3818 100644 --- a/src/gpu/ops/GrDiscardOp.h +++ b/src/gpu/ops/GrDiscardOp.h @@ -40,9 +40,9 @@ private: void onPrepare(GrOpFlushState*) override {} void onExecute(GrOpFlushState* state) override { - SkASSERT(state->drawOpArgs().fRenderTarget); + SkASSERT(state->drawOpArgs().renderTarget()); - state->commandBuffer()->discard(state->drawOpArgs().fRenderTarget); + state->commandBuffer()->discard(state->drawOpArgs().renderTarget()); } typedef GrOp INHERITED; diff --git a/src/gpu/ops/GrDrawPathOp.cpp b/src/gpu/ops/GrDrawPathOp.cpp index c33af39365..420a3a218e 100644 --- a/src/gpu/ops/GrDrawPathOp.cpp +++ b/src/gpu/ops/GrDrawPathOp.cpp @@ -46,7 +46,7 @@ void GrDrawPathOpBase::initPipeline(const GrOpFlushState& state, GrPipeline* pip } args.fUserStencil = &kCoverPass; args.fAppliedClip = state.drawOpArgs().fAppliedClip; - args.fRenderTarget = state.drawOpArgs().fRenderTarget; + args.fProxy = state.drawOpArgs().fProxy; args.fCaps = &state.caps(); args.fResourceProvider = state.resourceProvider(); args.fDstProxy = state.drawOpArgs().fDstProxy; @@ -61,7 +61,7 @@ void init_stencil_pass_settings(const GrOpFlushState& flushState, const GrAppliedClip* appliedClip = flushState.drawOpArgs().fAppliedClip; bool stencilClip = appliedClip && appliedClip->hasStencilClip(); stencil->reset(GrPathRendering::GetStencilPassSettings(fillType), stencilClip, - flushState.drawOpArgs().fRenderTarget->renderTargetPriv().numStencilBits()); + flushState.drawOpArgs().renderTarget()->renderTargetPriv().numStencilBits()); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp index e42f3197b8..110f6e54d3 100644 --- a/src/gpu/ops/GrMeshDrawOp.cpp +++ b/src/gpu/ops/GrMeshDrawOp.cpp @@ -70,10 +70,10 @@ void GrMeshDrawOp::onExecute(GrOpFlushState* state) { while (currUploadIdx < fInlineUploads.count() && fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) { state->commandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload, - state->drawOpArgs().fRenderTarget); + state->drawOpArgs().renderTarget()); } const QueuedDraw& draw = fQueuedDraws[currDrawIdx]; - SkASSERT(draw.fPipeline->getRenderTarget() == state->drawOpArgs().fRenderTarget); + SkASSERT(draw.fPipeline->proxy() == state->drawOpArgs().fProxy); state->commandBuffer()->draw(*draw.fPipeline, *draw.fGeometryProcessor.get(), fMeshes.begin() + currMeshIdx, nullptr, draw.fMeshCnt, this->bounds()); diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp b/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp index 0d97de4c57..ee59a8e26b 100644 --- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp +++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.cpp @@ -126,7 +126,7 @@ GrPipeline::InitArgs GrSimpleMeshDrawOpHelper::pipelineInitArgs( GrPipeline::InitArgs args; args.fFlags = this->pipelineFlags(); args.fProcessors = &this->processors(); - args.fRenderTarget = target->renderTarget(); + args.fProxy = target->proxy(); args.fAppliedClip = target->clip(); args.fDstProxy = target->dstProxy(); args.fCaps = &target->caps(); diff --git a/src/gpu/ops/GrStencilPathOp.cpp b/src/gpu/ops/GrStencilPathOp.cpp index 01042f6670..41091f30fd 100644 --- a/src/gpu/ops/GrStencilPathOp.cpp +++ b/src/gpu/ops/GrStencilPathOp.cpp @@ -11,9 +11,9 @@ #include "GrOpFlushState.h" void GrStencilPathOp::onExecute(GrOpFlushState* state) { - SkASSERT(state->drawOpArgs().fRenderTarget); + SkASSERT(state->drawOpArgs().renderTarget()); - GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fRenderTarget, + GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().renderTarget(), &fViewMatrix, &fScissor, &fStencil); state->gpu()->pathRendering()->stencilPath(args, fPath.get()); } diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp index 6e9c292f04..6cb1d5bf06 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -493,7 +493,7 @@ sk_sp<GrVkPipelineState> GrVkGpuCommandBuffer::prepareDrawState( pipelineState->bind(fGpu, cbInfo.currentCmdBuf()); - GrRenderTarget* rt = pipeline.getRenderTarget(); + GrRenderTarget* rt = pipeline.renderTarget(); if (!pipeline.getScissorState().enabled()) { GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(), rt, @@ -549,7 +549,7 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline, const GrPipeline::DynamicState dynamicStates[], int meshCount, const SkRect& bounds) { - GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(pipeline.getRenderTarget()); + GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(pipeline.renderTarget()); if (!fRenderTarget) { this->init(target); } diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp index 567d6e89f6..e3561331c2 100644 --- a/src/gpu/vk/GrVkPipeline.cpp +++ b/src/gpu/vk/GrVkPipeline.cpp @@ -239,7 +239,7 @@ static void setup_multisample_state(const GrPipeline& pipeline, multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisampleInfo->pNext = nullptr; multisampleInfo->flags = 0; - int numSamples = pipeline.getRenderTarget()->numColorSamples(); + int numSamples = pipeline.proxy()->numColorSamples(); SkAssertResult(GrSampleCountToVkSampleCount(numSamples, &multisampleInfo->rasterizationSamples)); float sampleShading = primProc.getSampleShading(); diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index e4f6faf624..083d225ff8 100644 --- a/src/gpu/vk/GrVkPipelineState.cpp +++ b/src/gpu/vk/GrVkPipelineState.cpp @@ -236,7 +236,7 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, // freeing the tempData between calls. this->freeTempResources(gpu); - this->setRenderTargetState(pipeline.getRenderTarget()); + this->setRenderTargetState(pipeline.proxy()); SkSTArray<8, const GrResourceIOProcessor::TextureSampler*> textureBindings; SkSTArray<8, const GrResourceIOProcessor::BufferAccess*> bufferAccesses; @@ -461,7 +461,9 @@ void GrVkPipelineState::writeTexelBuffers( } } -void GrVkPipelineState::setRenderTargetState(const GrRenderTarget* rt) { +void GrVkPipelineState::setRenderTargetState(const GrRenderTargetProxy* proxy) { + GrRenderTarget* rt = proxy->priv().peekRenderTarget(); + // Load the RT height uniform if it is needed to y-flip gl_FragCoord. if (fBuiltinUniformHandles.fRTHeightUni.isValid() && fRenderTargetState.fRenderTargetSize.fHeight != rt->height()) { @@ -472,10 +474,10 @@ void GrVkPipelineState::setRenderTargetState(const GrRenderTarget* rt) { SkISize size; size.set(rt->width(), rt->height()); SkASSERT(fBuiltinUniformHandles.fRTAdjustmentUni.isValid()); - if (fRenderTargetState.fRenderTargetOrigin != rt->origin() || + if (fRenderTargetState.fRenderTargetOrigin != proxy->origin() || fRenderTargetState.fRenderTargetSize != size) { fRenderTargetState.fRenderTargetSize = size; - fRenderTargetState.fRenderTargetOrigin = rt->origin(); + fRenderTargetState.fRenderTargetOrigin = proxy->origin(); float rtAdjustmentVec[4]; fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); @@ -576,7 +578,7 @@ bool GrVkPipelineState::Desc::Build(Desc* desc, } GrProcessorKeyBuilder b(&desc->key()); - GrVkRenderTarget* vkRT = (GrVkRenderTarget*)pipeline.getRenderTarget(); + GrVkRenderTarget* vkRT = (GrVkRenderTarget*)pipeline.renderTarget(); vkRT->simpleRenderPass()->genKey(&b); stencil.genKey(&b); diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h index 190ad06e48..9481aa170f 100644 --- a/src/gpu/vk/GrVkPipelineState.h +++ b/src/gpu/vk/GrVkPipelineState.h @@ -152,7 +152,7 @@ private: }; // Helper for setData() that sets the view matrix and loads the render target height uniform - void setRenderTargetState(const GrRenderTarget*); + void setRenderTargetState(const GrRenderTargetProxy*); // GrVkResources GrVkPipeline* fPipeline; diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp index 05a1e958bd..a3528dc77f 100644 --- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp +++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp @@ -80,7 +80,7 @@ bool GrVkPipelineStateBuilder::createVkShaderModule(VkShaderStageFlagBits stage, } if (inputs.fFlipY) { desc->setSurfaceOriginKey(GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin( - this->pipeline().getRenderTarget()->origin())); + this->pipeline().proxy()->origin())); desc->finalize(); } return result; @@ -140,7 +140,7 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s VkPipelineShaderStageCreateInfo shaderStageInfo[3]; SkSL::Program::Settings settings; settings.fCaps = this->caps()->shaderCaps(); - settings.fFlipY = this->pipeline().getRenderTarget()->origin() != kTopLeft_GrSurfaceOrigin; + settings.fFlipY = this->pipeline().proxy()->origin() != kTopLeft_GrSurfaceOrigin; SkAssertResult(this->createVkShaderModule(VK_SHADER_STAGE_VERTEX_BIT, fVS, &vertShaderModule, diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp index f8d77a96d6..66a4bf3162 100644 --- a/src/gpu/vk/GrVkPipelineStateCache.cpp +++ b/src/gpu/vk/GrVkPipelineStateCache.cpp @@ -83,7 +83,7 @@ sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt #endif GrStencilSettings stencil; if (pipeline.isStencilEnabled()) { - GrRenderTarget* rt = pipeline.getRenderTarget(); + GrRenderTarget* rt = pipeline.renderTarget(); // TODO: attach stencil and create settings during render target flush. SkASSERT(rt->renderTargetPriv().getStencilAttachment()); stencil.reset(*pipeline.getUserStencil(), pipeline.hasStencilClip(), @@ -102,7 +102,7 @@ sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt std::unique_ptr<Entry>* entry = fMap.find(desc); if (!entry) { // Didn't find an origin-independent version, check with the specific origin - GrSurfaceOrigin origin = pipeline.getRenderTarget()->origin(); + GrSurfaceOrigin origin = pipeline.proxy()->origin(); desc.setSurfaceOriginKey(GrGLSLFragmentShaderBuilder::KeyForSurfaceOrigin(origin)); desc.finalize(); entry = fMap.find(desc); diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index a474ffe518..37aa07a6ab 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -9,6 +9,7 @@ #include "GrBackendSurface.h" #include "GrContextPriv.h" +#include "GrRenderTarget.h" #include "GrRenderTargetContextPriv.h" #include "GrTexture.h" diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp index 0f8fd7f9b3..b11c0f2beb 100644 --- a/tests/GpuSampleLocationsTest.cpp +++ b/tests/GpuSampleLocationsTest.cpp @@ -132,7 +132,7 @@ void test_sampleLocations(skiatest::Reporter* reporter, TestSampleLocationsInter for (int i = 0; i < numTestPatterns; ++i) { testInterface->overrideSamplePattern(kTestPatterns[i]); for (GrRenderTargetContext* rtc : {bottomUps[i].get(), topDowns[i].get()}) { - GrPipeline dummyPipeline(rtc->accessRenderTarget(), + GrPipeline dummyPipeline(rtc->asRenderTargetProxy(), GrPipeline::ScissorState::kDisabled, SkBlendMode::kSrcOver); GrRenderTarget* rt = rtc->accessRenderTarget(); diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index 0e67acfcfc..922a996499 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -367,8 +367,8 @@ sk_sp<const GrBuffer> DrawMeshHelper::getIndexBuffer() { } void DrawMeshHelper::drawMesh(const GrMesh& mesh) { - GrRenderTarget* rt = fState->drawOpArgs().fRenderTarget; - GrPipeline pipeline(rt, GrPipeline::ScissorState::kDisabled, SkBlendMode::kSrc); + GrRenderTargetProxy* proxy = fState->drawOpArgs().fProxy; + GrPipeline pipeline(proxy, GrPipeline::ScissorState::kDisabled, SkBlendMode::kSrc); GrMeshTestProcessor mtp(mesh.isInstanced(), mesh.hasVertexData()); fState->commandBuffer()->draw(pipeline, mtp, &mesh, nullptr, 1, SkRect::MakeIWH(kImageWidth, kImageHeight)); diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index 007702a2cc..2c9e2c3b17 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -125,8 +125,8 @@ private: bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override { return false; } void onPrepare(GrOpFlushState*) override {} void onExecute(GrOpFlushState* state) override { - GrRenderTarget* rt = state->drawOpArgs().fRenderTarget; - GrPipeline pipeline(rt, fScissorState, SkBlendMode::kSrc); + GrRenderTargetProxy* proxy = state->drawOpArgs().fProxy; + GrPipeline pipeline(proxy, fScissorState, SkBlendMode::kSrc); SkSTArray<kNumMeshes, GrMesh> meshes; for (int i = 0; i < kNumMeshes; ++i) { GrMesh& mesh = meshes.emplace_back(GrPrimitiveType::kTriangleStrip); diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index f1d6a269bc..71575c74f9 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -12,6 +12,7 @@ #include "GrContext.h" #include "GrContextPriv.h" #include "GrGpu.h" +#include "GrRenderTarget.h" #include "GrResourceProvider.h" #include "GrTest.h" #include "GrTexture.h" diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp index 4e363153f0..f64043df62 100644 --- a/tests/VkWrapTests.cpp +++ b/tests/VkWrapTests.cpp @@ -12,6 +12,7 @@ #if SK_SUPPORT_GPU && defined(SK_VULKAN) #include "GrContextFactory.h" +#include "GrRenderTarget.h" #include "GrTest.h" #include "GrTexture.h" |