From 09d49a3bfe2d1e652a648ce1ea0962b38d10d166 Mon Sep 17 00:00:00 2001 From: csmartdalton Date: Mon, 4 Jul 2016 15:55:17 -0700 Subject: Fix caching of sample locations The original caching logic for sample locations wishfully assumed that the GPU would always use the same sample pattern for render targets that had the same number of samples. It turns out we can't rely on that. This change improves the caching logic to handle mismatched simple patterns with the same count, and adds a unit test that emulates different sample patterns observed on real hardware. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2111423002 Review-Url: https://codereview.chromium.org/2111423002 --- src/gpu/gl/GrGLGpu.cpp | 12 +++++------- src/gpu/gl/GrGLGpu.h | 6 ++---- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/gpu/gl') diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 2fb66804e0..9972690487 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4432,10 +4432,8 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) { return true; } -void GrGLGpu::onGetMultisampleSpecs(GrRenderTarget* rt, - const GrStencilSettings& stencil, - int* effectiveSampleCnt, - SkAutoTDeleteArray* sampleLocations) { +void GrGLGpu::onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings& stencil, + int* effectiveSampleCnt, SamplePattern* samplePattern) { SkASSERT(!rt->hasMixedSamples() || rt->renderTargetPriv().getStencilAttachment() || stencil.isDisabled()); @@ -4452,14 +4450,14 @@ void GrGLGpu::onGetMultisampleSpecs(GrRenderTarget* rt, SkASSERT(*effectiveSampleCnt >= rt->desc().fSampleCnt); if (this->caps()->sampleLocationsSupport()) { - sampleLocations->reset(new SkPoint[*effectiveSampleCnt]); + samplePattern->reset(*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]); + (*samplePattern)[i].set(pos[0], pos[1]); } else { - (*sampleLocations)[i].set(pos[0], 1 - pos[1]); + (*samplePattern)[i].set(pos[0], 1 - pos[1]); } } } diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index b7daa431d8..5cc0facea6 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -220,10 +220,8 @@ private: const SkIRect& srcRect, const SkIPoint& dstPoint) override; - void onGetMultisampleSpecs(GrRenderTarget*, - const GrStencilSettings&, - int* effectiveSampleCnt, - SkAutoTDeleteArray* sampleLocations) override; + void onGetMultisampleSpecs(GrRenderTarget*, const GrStencilSettings&, + int* effectiveSampleCnt, SamplePattern*) override; // binds texture unit in GL void setTextureUnit(int unitIdx); -- cgit v1.2.3