diff options
author | cdalton <cdalton@nvidia.com> | 2016-03-07 13:58:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-07 13:58:26 -0800 |
commit | 28f45b949acc746849100fbe112ee5280f0594c9 (patch) | |
tree | b350d442680ef996ab6097433ab0cf960d3680b6 /src/gpu/gl/GrGLGpu.cpp | |
parent | b3b13b7edeabad4c8e53b0d309b0a44668d1e68f (diff) |
Add "sample locations" feature to GrProcessor
Adds a "sample locations" feature to GrProcessor. When enabled, this
allows a processor to know inside the shader where all the samples are
located. Also adds various infastructure to query, cache, and identify
multisample data.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1717393002
Review URL: https://codereview.chromium.org/1717393002
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index dc50c1429c..95f34a9cf9 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4141,6 +4141,39 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, return true; } +void GrGLGpu::onGetMultisampleSpecs(GrRenderTarget* rt, + const GrStencilSettings& stencil, + int* effectiveSampleCnt, + SkAutoTDeleteArray<SkPoint>* sampleLocations) { + SkASSERT(!rt->hasMixedSamples() || rt->renderTargetPriv().getStencilAttachment() || + stencil.isDisabled()); + + this->flushStencil(stencil); + this->flushHWAAState(rt, true, !stencil.isDisabled()); + this->flushRenderTarget(static_cast<GrGLRenderTarget*>(rt), &SkIRect::EmptyIRect()); + + if (0 != this->caps()->maxRasterSamples()) { + GR_GL_GetIntegerv(this->glInterface(), GR_GL_EFFECTIVE_RASTER_SAMPLES, effectiveSampleCnt); + } else { + GR_GL_GetIntegerv(this->glInterface(), GR_GL_SAMPLES, effectiveSampleCnt); + } + + SkASSERT(*effectiveSampleCnt >= rt->desc().fSampleCnt); + + if (this->caps()->sampleLocationsSupport()) { + sampleLocations->reset(new SkPoint[*effectiveSampleCnt]); + for (int i = 0; i < *effectiveSampleCnt; ++i) { + GrGLfloat pos[2]; + GL_CALL(GetMultisamplefv(GR_GL_SAMPLE_POSITION, i, pos)); + if (kTopLeft_GrSurfaceOrigin == rt->origin()) { + (*sampleLocations)[i].set(pos[0], pos[1]); + } else { + (*sampleLocations)[i].set(pos[0], 1 - pos[1]); + } + } + } +} + void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) { SkASSERT(type); switch (type) { |