diff options
author | csmartdalton <csmartdalton@google.com> | 2016-11-01 07:03:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-01 07:03:59 -0700 |
commit | c25c5d73e9f4d840dc758c399496d5690709ad58 (patch) | |
tree | 680768a5743ca1ffb54b179006385bbda560df2b /src/gpu | |
parent | 7cdda99ac34dbe249640be04d2e61bfb0f4b3b09 (diff) |
Move memoization of multisample specs id to GrRenderTarget
GrGpu used to perform the memoization on behalf of GrRenderTarget via
a public accessor. This change updates GrRenderTarget to do its own
work.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2467593002
Review-Url: https://codereview.chromium.org/2467593002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrGpu.cpp | 17 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 18 | ||||
-rw-r--r-- | src/gpu/GrRenderTarget.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetPriv.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 4 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 4 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.h | 4 |
8 files changed, 34 insertions, 30 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index f576424889..bee578a764 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -442,21 +442,13 @@ void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_ } } -const GrGpu::MultisampleSpecs& GrGpu::getMultisampleSpecs(GrRenderTarget* rt, - const GrStencilSettings& stencil) { +const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(GrRenderTarget* rt, + const GrStencilSettings& stencil) { SkASSERT(rt->desc().fSampleCnt > 1); -#ifndef SK_DEBUG - // In debug mode we query the multisample info every time to verify the caching is correct. - if (uint8_t id = rt->renderTargetPriv().accessMultisampleSpecsID()) { - SkASSERT(id > 0 && id < fMultisampleSpecs.count()); - return fMultisampleSpecs[id]; - } -#endif - int effectiveSampleCnt; SkSTArray<16, SkPoint, true> pattern; - this->onGetMultisampleSpecs(rt, stencil, &effectiveSampleCnt, &pattern); + this->onQueryMultisampleSpecs(rt, stencil, &effectiveSampleCnt, &pattern); SkASSERT(effectiveSampleCnt >= rt->desc().fSampleCnt); uint8_t id; @@ -479,10 +471,7 @@ const GrGpu::MultisampleSpecs& GrGpu::getMultisampleSpecs(GrRenderTarget* rt, } } SkASSERT(id > 0); - SkASSERT(!rt->renderTargetPriv().accessMultisampleSpecsID() || - rt->renderTargetPriv().accessMultisampleSpecsID() == id); - rt->renderTargetPriv().accessMultisampleSpecsID() = id; return fMultisampleSpecs[id]; } diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 8e9407a458..48005ec16f 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -355,10 +355,16 @@ public: const SkPoint* fSampleLocations; }; - // Finds a render target's multisample specs. The stencil settings are only needed to flush the - // draw state prior to querying multisample information; they should not have any effect on the - // multisample information itself. - const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&); + // Finds a render target's multisample specs. The stencil settings are only needed in case we + // need to flush the draw state prior to querying multisample info. They are not expected to + // affect the multisample information itself. + const MultisampleSpecs& queryMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&); + + // Finds the multisample specs with a given unique id. + const MultisampleSpecs& getMultisampleSpecs(uint8_t uniqueID) { + SkASSERT(uniqueID > 0 && uniqueID < fMultisampleSpecs.count()); + return fMultisampleSpecs[uniqueID]; + } // Creates a GrGpuCommandBuffer in which the GrOpList can send draw commands to instead of // directly to the Gpu object. @@ -581,8 +587,8 @@ private: const SkIPoint& dstPoint) = 0; // overridden by backend specific derived class to perform the multisample queries - virtual void onGetMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&, - int* effectiveSampleCnt, SamplePattern*) = 0; + virtual void onQueryMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&, + int* effectiveSampleCnt, SamplePattern*) = 0; void resetContext() { this->onResetContext(fResetBits); diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index 0bcde3bafe..09d43f99e4 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -105,7 +105,14 @@ int GrRenderTargetPriv::numStencilBits() const { const GrGpu::MultisampleSpecs& GrRenderTargetPriv::getMultisampleSpecs(const GrStencilSettings& stencil) const { - return fRenderTarget->getGpu()->getMultisampleSpecs(fRenderTarget, stencil); + GrGpu* gpu = fRenderTarget->getGpu(); + if (auto id = fRenderTarget->fMultisampleSpecsID) { + SkASSERT(gpu->queryMultisampleSpecs(fRenderTarget, stencil).fUniqueID == id); + return gpu->getMultisampleSpecs(id); + } + const GrGpu::MultisampleSpecs& specs = gpu->queryMultisampleSpecs(fRenderTarget, stencil); + fRenderTarget->fMultisampleSpecsID = specs.fUniqueID; + return specs; } int GrRenderTargetPriv::maxWindowRectangles() const { diff --git a/src/gpu/GrRenderTargetPriv.h b/src/gpu/GrRenderTargetPriv.h index 698288e1cd..922d9b3071 100644 --- a/src/gpu/GrRenderTargetPriv.h +++ b/src/gpu/GrRenderTargetPriv.h @@ -32,8 +32,10 @@ public: int numStencilBits() const; + // Finds a render target's multisample specs. The stencil settings are only needed in case the + // info isn't cached and we need to flush the draw state in order to query it. They are not + // expected to affect the multisample information itself. const GrGpu::MultisampleSpecs& getMultisampleSpecs(const GrStencilSettings& stencil) const; - uint8_t& accessMultisampleSpecsID() { return fRenderTarget->fMultisampleSpecsID; } typedef GrRenderTarget::Flags Flags; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 485a9bd09a..454753c4e9 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4474,8 +4474,8 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) { return true; } -void GrGLGpu::onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings& stencil, - int* effectiveSampleCnt, SamplePattern* samplePattern) { +void GrGLGpu::onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings& stencil, + int* effectiveSampleCnt, SamplePattern* samplePattern) { SkASSERT(!rt->isMixedSampled() || rt->renderTargetPriv().getStencilAttachment() || stencil.isDisabled()); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 4420c658fe..12633eef8b 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -225,8 +225,8 @@ private: const SkIRect& srcRect, const SkIPoint& dstPoint) override; - void onGetMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&, - int* effectiveSampleCnt, SamplePattern*) override; + void onQueryMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&, + int* effectiveSampleCnt, SamplePattern*) override; // binds texture unit in GL void setTextureUnit(int unitIdx); diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index f7239d64ba..f34c76cd92 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1630,8 +1630,8 @@ bool GrVkGpu::initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc) return true; } -void GrVkGpu::onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&, - int* effectiveSampleCnt, SamplePattern*) { +void GrVkGpu::onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&, + int* effectiveSampleCnt, SamplePattern*) { // TODO: stub. SkASSERT(!this->caps()->sampleLocationsSupport()); *effectiveSampleCnt = rt->desc().fSampleCnt; diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index b62278337b..6f0380302b 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -82,8 +82,8 @@ public: const SkIRect& srcRect, const SkIPoint& dstPoint) override; - void onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&, - int* effectiveSampleCnt, SamplePattern*) override; + void onQueryMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings&, + int* effectiveSampleCnt, SamplePattern*) override; bool initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc) const override; |