diff options
-rw-r--r-- | include/gpu/GrCaps.h | 6 | ||||
-rw-r--r-- | src/gpu/GrCaps.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 18 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.h | 12 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 26 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 4 | ||||
-rw-r--r-- | src/gpu/GrPipeline.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrPipeline.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 24 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 62 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPathRendering.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.h | 36 |
15 files changed, 111 insertions, 121 deletions
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h index 572b9caea7..b75e0ef497 100644 --- a/include/gpu/GrCaps.h +++ b/include/gpu/GrCaps.h @@ -62,7 +62,6 @@ public: bool pathRenderingSupport() const { return fPathRenderingSupport; } bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; } bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; } - bool programmableSampleLocationsSupport() const { return fProgrammableSampleLocationsSupport; } /** * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a @@ -92,7 +91,6 @@ protected: bool fPathRenderingSupport : 1; bool fDstReadInShaderSupport : 1; bool fDualSourceBlendingSupport : 1; - bool fProgrammableSampleLocationsSupport : 1; bool fShaderPrecisionVaries; PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount]; @@ -128,6 +126,8 @@ public: bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; } bool oversizedStencilSupport() const { return fOversizedStencilSupport; } bool textureBarrierSupport() const { return fTextureBarrierSupport; } + bool multisampleDisableSupport() const { return fMultisampleDisableSupport; } + bool programmableSampleLocationsSupport() const { return fProgrammableSampleLocationsSupport; } bool mixedSamplesSupport() const { return fMixedSamplesSupport; } bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; } @@ -246,6 +246,8 @@ protected: bool fCompressedTexSubImageSupport : 1; bool fOversizedStencilSupport : 1; bool fTextureBarrierSupport : 1; + bool fMultisampleDisableSupport : 1; + bool fProgrammableSampleLocationsSupport : 1; bool fMixedSamplesSupport : 1; bool fSupportsInstancedDraws : 1; bool fFullClearIsFree : 1; diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 3331db5567..1020add31d 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -15,7 +15,6 @@ GrShaderCaps::GrShaderCaps() { fPathRenderingSupport = false; fDstReadInShaderSupport = false; fDualSourceBlendingSupport = false; - fProgrammableSampleLocationsSupport = false; fShaderPrecisionVaries = false; } @@ -51,7 +50,6 @@ SkString GrShaderCaps::dump() const { r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]); r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]); - r.appendf("Programmable Sample Locations Support : %s\n", gNY[fProgrammableSampleLocationsSupport]); r.appendf("Shader Float Precisions (varies: %s) :\n", gNY[fShaderPrecisionVaries]); @@ -92,6 +90,8 @@ GrCaps::GrCaps(const GrContextOptions& options) { fCompressedTexSubImageSupport = false; fOversizedStencilSupport = false; fTextureBarrierSupport = false; + fMultisampleDisableSupport = false; + fProgrammableSampleLocationsSupport = false; fMixedSamplesSupport = false; fSupportsInstancedDraws = false; fFullClearIsFree = false; @@ -164,6 +164,9 @@ SkString GrCaps::dump() const { r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSubImageSupport]); r.appendf("Oversized Stencil Support : %s\n", gNY[fOversizedStencilSupport]); r.appendf("Texture Barrier Support : %s\n", gNY[fTextureBarrierSupport]); + r.appendf("Multisample Disable Support : %s\n", gNY[fMultisampleDisableSupport]); + r.appendf("Programmable Sample Locations Support : %s\n", + gNY[fProgrammableSampleLocationsSupport]); r.appendf("Mixed Samples Support : %s\n", gNY[fMixedSamplesSupport]); r.appendf("Supports instanced draws : %s\n", gNY[fSupportsInstancedDraws]); r.appendf("Full screen clear is free : %s\n", gNY[fFullClearIsFree]); diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 3e802d7135..82fccc0527 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -368,8 +368,22 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, } } - // If MSAA is enabled we can do everything in the stencil buffer. - if (0 == rt->numStencilSamples() && requiresAA) { + SkASSERT(!pipelineBuilder.isHWAntialias() || rt->isStencilBufferMultisampled()); + + bool hasHWAntialias = pipelineBuilder.isHWAntialias(); + + if (rt->isStencilBufferMultisampled() && !hasHWAntialias) { + if (!this->caps()->multisampleDisableSupport()) { + hasHWAntialias = true; // This will be on regardless, it's impossible to turn it off. + } else if (this->caps()->programmableSampleLocationsSupport()) { + // Enable HW antialias, but leave the draw non-antialiased by co-centering the samples. + out->fIsCoCenteredMultisampledDraw = true; + hasHWAntialias = true; + } + } + + // If we have HW antialias, or don't need AA, we can do everything in the stencil buffer. + if (!hasHWAntialias && requiresAA) { SkAutoTUnref<GrTexture> result; // The top-left of the mask corresponds to the top-left corner of the bounds. diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h index 98fd3af351..a0d742769c 100644 --- a/src/gpu/GrClipMaskManager.h +++ b/src/gpu/GrClipMaskManager.h @@ -33,13 +33,23 @@ class SkPath; */ class GrAppliedClip : public SkNoncopyable { public: - GrAppliedClip() {} + GrAppliedClip() : fIsCoCenteredMultisampledDraw(false) {} + const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP; } const GrScissorState& scissorState() const { return fScissorState; } + /** + * This is used to perform a multisampled clip test when the draw requires MSAA to be disabled. + * It will allow the stencil test to run multisampled by turning on hardware MSAA, but co-locate + * the draw's samples at pixel center so it will still feel like MSAA is disabled. + */ + bool isCoCenteredMultisampledDraw() const { return fIsCoCenteredMultisampledDraw; } + private: SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; GrScissorState fScissorState; + bool fIsCoCenteredMultisampledDraw; + friend class GrClipMaskManager; typedef SkNoncopyable INHERITED; diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 7b1464ca7f..e13d9b81a7 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -221,14 +221,9 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds(), &clip)) { return; } - GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; - if (clip.clipCoverageFragmentProcessor()) { - arfps.set(&pipelineBuilder); - arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor()); - } GrPipeline::CreateArgs args; - if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), batch)) { + if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip, batch)) { return; } @@ -351,12 +346,6 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, return; } - GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; - if (clip.clipCoverageFragmentProcessor()) { - arfps.set(&pipelineBuilder); - arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor()); - } - // Ensure the render target has a stencil buffer and get the stencil settings. GrStencilSettings stencilSettings; GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); @@ -365,7 +354,7 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, batch->setStencilSettings(stencilSettings); GrPipeline::CreateArgs args; - if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), batch)) { + if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip, batch)) { return; } @@ -545,14 +534,19 @@ void GrDrawTarget::recordBatch(GrBatch* batch) { /////////////////////////////////////////////////////////////////////////////// bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, - const GrScissorState* scissor, - GrDrawBatch* batch) { + const GrAppliedClip* clip, GrDrawBatch* batch) { + GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; + if (clip->clipCoverageFragmentProcessor()) { + arfps.set(pipelineBuilder); + arfps.addCoverageFragmentProcessor(clip->clipCoverageFragmentProcessor()); + } + GrPipeline::CreateArgs args; args.fPipelineBuilder = pipelineBuilder; args.fCaps = this->caps(); - args.fScissor = scissor; args.fColorPOI = pipelineBuilder->colorProcInfo(batch); args.fCoveragePOI = pipelineBuilder->coverageProcInfo(batch); + args.fClip = clip; if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fColorPOI, args.fCoveragePOI, &args.fDstTexture, batch->bounds())) { diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index d77615e655..635080337b 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -278,9 +278,7 @@ private: }; void recordBatch(GrBatch*); - bool installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, - const GrScissorState* scissor, - GrDrawBatch* batch); + bool installPipelineInDrawBatch(const GrPipelineBuilder*, const GrAppliedClip*, GrDrawBatch*); // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required // but couldn't be made. Otherwise, returns true. This method needs to be protected because it diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 073349be1e..3662f6a180 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -59,12 +59,15 @@ GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, pipeline->fRenderTarget.reset(builder.fRenderTarget.get()); SkASSERT(pipeline->fRenderTarget); - pipeline->fScissorState = *args.fScissor; + pipeline->fScissorState = args.fClip->scissorState(); pipeline->fStencilSettings = builder.getStencil(); pipeline->fDrawFace = builder.getDrawFace(); pipeline->fFlags = 0; - if (builder.isHWAntialias()) { + if (args.fClip->isCoCenteredMultisampledDraw()) { + SkASSERT(args.fCaps->programmableSampleLocationsSupport() && !builder.isHWAntialias()); + pipeline->fFlags |= (kHWAA_Flag | kCoCenteredSamples_Flag); + } else if (builder.isHWAntialias()) { pipeline->fFlags |= kHWAA_Flag; } if (builder.snapVerticesToPixelCenters()) { diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 8781058247..772fc452d7 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -20,6 +20,7 @@ #include "SkMatrix.h" #include "SkRefCnt.h" +class GrAppliedClip; class GrBatch; class GrDeviceCoordTexture; class GrPipelineBuilder; @@ -38,7 +39,7 @@ public: const GrCaps* fCaps; GrProcOptInfo fColorPOI; GrProcOptInfo fCoveragePOI; - const GrScissorState* fScissor; + const GrAppliedClip* fClip; GrXferProcessor::DstTexture fDstTexture; }; @@ -125,6 +126,7 @@ public: bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); } bool snapVerticesToPixelCenters() const { return SkToBool(fFlags & kSnapVertices_Flag); } + bool hasCoCenteredSamples() const { return SkToBool(fFlags & kCoCenteredSamples_Flag); } GrXferBarrierType xferBarrierType(const GrCaps& caps) const { return fXferProcessor->xferBarrierType(fRenderTarget.get(), caps); @@ -166,6 +168,7 @@ private: enum Flags { kHWAA_Flag = 0x1, kSnapVertices_Flag = 0x2, + kCoCenteredSamples_Flag = 0x4 }; typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget; diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index f5ce0afff2..f9bd64062a 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -43,7 +43,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fDirectStateAccessSupport = false; fDebugSupport = false; fES2CompatibilitySupport = false; - fMultisampleDisableSupport = false; fUseNonVBOVertexAndIndexDynamicData = false; fIsCoreProfile = false; fBindFragDataLocationSupport = false; @@ -253,6 +252,17 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, } if (kGL_GrGLStandard == standard) { + fProgrammableSampleLocationsSupport = + ctxInfo.version() >= GR_GL_VER(4, 3) && + (ctxInfo.hasExtension("GL_ARB_sample_locations") || + ctxInfo.hasExtension("GL_NV_sample_locations")); + } else { + fProgrammableSampleLocationsSupport = + ctxInfo.version() >= GR_GL_VER(3, 1) && + ctxInfo.hasExtension("GL_NV_sample_locations"); + } + + if (kGL_GrGLStandard == standard) { if (version >= GR_GL_VER(3, 0)) { fBindFragDataLocationSupport = true; } @@ -310,17 +320,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, ctxInfo.hasExtension("GL_OES_standard_derivatives"); } - if (kGL_GrGLStandard == standard) { - glslCaps->fProgrammableSampleLocationsSupport = - ctxInfo.version() >= GR_GL_VER(4, 3) && - (ctxInfo.hasExtension("GL_ARB_sample_locations") || - ctxInfo.hasExtension("GL_NV_sample_locations")); - } else { - glslCaps->fProgrammableSampleLocationsSupport = - ctxInfo.version() >= GR_GL_VER(3, 1) && - ctxInfo.hasExtension("GL_NV_sample_locations"); - } - /************************************************************************** * GrCaps fields **************************************************************************/ @@ -1183,7 +1182,6 @@ SkString GrGLCaps::dump() const { r.appendf("Instanced drawing support: %s\n", (fInstancedDrawingSupport ? "YES": "NO")); r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ? "YES": "NO")); r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); - r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ? "YES" : "NO")); r.appendf("Use non-VBO for dynamic data: %s\n", (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 10d62b0298..1eb1496730 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -213,11 +213,6 @@ public: /// Is there support for ES2 compatability? bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } - /// Can we call glDisable(GL_MULTISAMPLE)? - bool multisampleDisableSupport() const { - return fMultisampleDisableSupport; - } - /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; @@ -356,7 +351,6 @@ private: bool fDirectStateAccessSupport : 1; bool fDebugSupport : 1; bool fES2CompatibilitySupport : 1; - bool fMultisampleDisableSupport : 1; bool fUseNonVBOVertexAndIndexDynamicData : 1; bool fIsCoreProfile : 1; bool fBindFragDataLocationSupport : 1; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 8bd0663852..fc9675fdda 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1492,11 +1492,11 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) { GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); this->flushStencil(pipeline.getStencil()); this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin()); - this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled()); + this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); // This must come after textures are flushed because a texture may need // to be msaa-resolved (which will modify bound FBO state). - this->flushRenderTarget(glRT, nullptr); + this->flushRenderTarget(glRT, nullptr, pipeline.hasCoCenteredSamples()); return true; } @@ -2026,33 +2026,10 @@ bool GrGLGpu::onReadPixels(GrSurface* surface, return true; } -void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedSampleLocations) { - GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget()); - SkASSERT(0 != target->renderFBOID()); - - if (!rt->isStencilBufferMultisampled() || - useColocatedSampleLocations == target->usesColocatedSampleLocations()) { - return; - } - - if (kGL_GrGLStandard == this->glStandard() && this->glVersion() >= GR_GL_VER(4,5)) { - GL_CALL(NamedFramebufferParameteri(target->renderFBOID(), - GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS, - useColocatedSampleLocations)); - } else { - GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); - GL_CALL(FramebufferParameteri(GR_GL_FRAMEBUFFER, - GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS, - useColocatedSampleLocations)); - fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; - } - - target->flagAsUsingColocatedSampleLocations(useColocatedSampleLocations); -} - -void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) { - +void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound, + bool coCenterSamples) { SkASSERT(target); + SkASSERT(!coCenterSamples || this->caps()->programmableSampleLocationsSupport()); uint32_t rtID = target->getUniqueID(); if (fHWBoundRenderTargetUniqueID != rtID) { @@ -2096,6 +2073,19 @@ void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) if (texture) { texture->texturePriv().dirtyMipMaps(true); } + + if (this->caps()->programmableSampleLocationsSupport()) { + ResetTimestamp timestamp; + bool hasCoCenteredSamples = target->getCachedCoCenteredSamplesState(×tamp); + if (timestamp < this->getResetTimestamp() || hasCoCenteredSamples != coCenterSamples) { + // The default state for programmable sample locations is already at pixel center, so we + // don't assign them. This assumes the client does not modify them outside of Skia. + GL_CALL(FramebufferParameteri(GR_GL_FRAMEBUFFER, + GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS, + coCenterSamples)); + target->setCachedCoCenteredSamplesState(coCenterSamples, this->getResetTimestamp()); + } + } } GrGLenum gPrimitiveType2GLMode[] = { @@ -2297,20 +2287,10 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { } } -void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled) { +void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); - if (rt->hasMixedSamples() && stencilEnabled && - this->glCaps().glslCaps()->programmableSampleLocationsSupport()) { - if (useHWAA) { - this->setColocatedSampleLocations(rt, false); - } else { - this->setColocatedSampleLocations(rt, true); - } - useHWAA = true; - } - - if (this->glCaps().multisampleDisableSupport()) { + if (this->caps()->multisampleDisableSupport()) { if (useHWAA) { if (kYes_TriState != fMSAAEnabled) { GL_CALL(Enable(GR_GL_MULTISAMPLE)); @@ -3111,7 +3091,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, this->flushBlend(blendInfo); this->flushColorWrite(true); this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); - this->flushHWAAState(dstRT, false, false); + this->flushHWAAState(dstRT, false); this->disableScissor(); GrStencilSettings stencil; stencil.setDisabled(); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 396d488174..8dbf5936fb 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -269,16 +269,12 @@ private: // ensures that such operations don't negatively interact with tracking bound textures. void setScratchTextureUnit(); - // colocates all samples at pixel center for render target, if MSAA. - // allows drawing coverage based AA shapes in MSAA mode. - void setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedSampleLocations); - // bounds is region that may be modified and therefore has to be resolved. // nullptr means whole target. Can be an empty rect. - void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); + void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds, bool coCenterSamples = false); void flushStencil(const GrStencilSettings&); - void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled); + void flushHWAAState(GrRenderTarget* rt, bool useHWAA); bool configToGLFormats(GrPixelConfig config, bool getSizedInternal, diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp index f18a4c671b..4c9ef86786 100644 --- a/src/gpu/gl/GrGLPathRendering.cpp +++ b/src/gpu/gl/GrGLPathRendering.cpp @@ -100,7 +100,7 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* SkISize size = SkISize::Make(rt->width(), rt->height()); this->setProjectionMatrix(*args.fViewMatrix, size, rt->origin()); gpu->flushScissor(*args.fScissor, rt->getViewport(), rt->origin()); - gpu->flushHWAAState(rt, args.fUseHWAA, true); + gpu->flushHWAAState(rt, args.fUseHWAA); gpu->flushRenderTarget(rt, nullptr); const GrGLPath* glPath = static_cast<const GrGLPath*>(path); diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index d4585f6402..2c15887259 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -34,10 +34,11 @@ GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, cons } void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { - fRTFBOID = idDesc.fRTFBOID; - fTexFBOID = idDesc.fTexFBOID; - fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; - fRTLifecycle = idDesc.fLifeCycle; + fRTFBOID = idDesc.fRTFBOID; + fTexFBOID = idDesc.fTexFBOID; + fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; + fRTLifecycle = idDesc.fLifeCycle; + fHasCoCenteredSamplesTimestamp = GrGpu::kExpiredTimestamp; fViewport.fLeft = 0; fViewport.fBottom = 0; diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h index ce04ae017d..b298676a47 100644 --- a/src/gpu/gl/GrGLRenderTarget.h +++ b/src/gpu/gl/GrGLRenderTarget.h @@ -9,6 +9,7 @@ #ifndef GrGLRenderTarget_DEFINED #define GrGLRenderTarget_DEFINED +#include "GrGpu.h" #include "GrGLIRect.h" #include "GrRenderTarget.h" #include "SkScalar.h" @@ -70,19 +71,14 @@ public: // components seperately. void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; - /** - * @return true if sample locations colocated at pixel center have been set for this - * render target. Requires support for NV_sample_locations. - */ - bool usesColocatedSampleLocations() const { - return fUsesColocatedSampleLocations; + bool getCachedCoCenteredSamplesState(GrGpu::ResetTimestamp* stamp) const { + *stamp = fHasCoCenteredSamplesTimestamp; + return fHasCoCenteredSamples; } - /** - * Flag render target as using or not using sample locations colocated at pixel center. - */ - void flagAsUsingColocatedSampleLocations(bool useColocatedSampleLocations) { - fUsesColocatedSampleLocations = useColocatedSampleLocations; + void setCachedCoCenteredSamplesState(bool hasCoCenteredSamples, GrGpu::ResetTimestamp stamp) { + fHasCoCenteredSamples = hasCoCenteredSamples; + fHasCoCenteredSamplesTimestamp = stamp; } protected: @@ -114,26 +110,24 @@ private: // The number total number of samples, including both MSAA and resolve texture samples. int totalSamples() const; - GrGLuint fRTFBOID; - GrGLuint fTexFBOID; - GrGLuint fMSColorRenderbufferID; + GrGLuint fRTFBOID; + GrGLuint fTexFBOID; + GrGLuint fMSColorRenderbufferID; + bool fHasCoCenteredSamples; + GrGpu::ResetTimestamp fHasCoCenteredSamplesTimestamp; // We track this separately from GrGpuResource because this may be both a texture and a render // target, and the texture may be wrapped while the render target is not. - LifeCycle fRTLifecycle; + LifeCycle fRTLifecycle; // when we switch to this render target we want to set the viewport to // only render to content area (as opposed to the whole allocation) and // we want the rendering to be at top left (GL has origin in bottom left) - GrGLIRect fViewport; + GrGLIRect fViewport; // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However, abandon and // release zero out the IDs and the cache needs to know the size even after those actions. - size_t fGpuMemorySize; - - // True if sample locations colocated at pixel center are currently in use, false if default - // sample locations are currently in use. - bool fUsesColocatedSampleLocations; + size_t fGpuMemorySize; typedef GrRenderTarget INHERITED; }; |