diff options
author | 2015-11-10 12:49:06 -0800 | |
---|---|---|
committer | 2015-11-10 12:49:06 -0800 | |
commit | d472792a72c0c433a205d42a73e0b77d65f8d76f (patch) | |
tree | c574d4c1a4b4a1e3e2f275da22cd4346beb41662 /src/gpu/gl/GrGLGpu.cpp | |
parent | 091f60c2a0e4504c017b8a67ff96a0e829519b14 (diff) |
Revert of Fix mixed samples stencil clip (patchset #5 id:80001 of https://codereview.chromium.org/1431593006/ )
Reason for revert:
Co-centered sample locations are not needed to do stencil clip with mixed samples.
Original issue's description:
> Fix mixed samples stencil clip
>
> Fixes rendering bugs and nondeterminism in gm.
>
> Before, mixed samples stencil clip would try to infer whether the draw
> wanted co-centered sample locations from within GrGLGpu, which caused
> various errors. This change reworks it so the draw itself can request
> the co-centered sample locations when it knows it will need them.
>
> Also reduces framebuffer binds by moving the code that enables
> GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS into flushRenderTarget.
>
> Committed: https://skia.googlesource.com/skia/+/14184d5567b58085b6d8a6375796d405056f7f73
TBR=bsalomon@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1407063011
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index c9009b81c5..5ae116cef8 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1500,11 +1500,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()); + this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled()); // 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, pipeline.hasCoCenteredSamples()); + this->flushRenderTarget(glRT, nullptr); return true; } @@ -2034,10 +2034,33 @@ bool GrGLGpu::onReadPixels(GrSurface* surface, return true; } -void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound, - bool coCenterSamples) { +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) { + SkASSERT(target); - SkASSERT(!coCenterSamples || this->caps()->programmableSampleLocationsSupport()); uint32_t rtID = target->getUniqueID(); if (fHWBoundRenderTargetUniqueID != rtID) { @@ -2081,19 +2104,6 @@ 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[] = { @@ -2295,10 +2305,20 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { } } -void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { +void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled) { SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); - if (this->caps()->multisampleDisableSupport()) { + 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 (useHWAA) { if (kYes_TriState != fMSAAEnabled) { GL_CALL(Enable(GR_GL_MULTISAMPLE)); @@ -3099,7 +3119,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, this->flushBlend(blendInfo); this->flushColorWrite(true); this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace); - this->flushHWAAState(dstRT, false); + this->flushHWAAState(dstRT, false, false); this->disableScissor(); GrStencilSettings stencil; stencil.setDisabled(); |