diff options
author | Greg Daniel <egdaniel@google.com> | 2017-07-19 14:47:42 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-19 19:13:25 +0000 |
commit | 81e7bf8d6d338d944f3c5075b14c21580398aeb6 (patch) | |
tree | 7c9814e6637dbcdf477f35084381b28f1f98e06a /tests | |
parent | fc3afa921bc42a357120e1e7856b3c256bfe1a6a (diff) |
Update gpu caps for valid sample counts.
Instead of query and maxSampleCount and using that to cap, we now have
each config store its supported values and when requested returns either
the next highest or equal supported value, or if non the max config supported.
Bug: skia:
Change-Id: I8802d44c13b3b1703ee54a7e69b82102d4b8dc2d
Reviewed-on: https://skia-review.googlesource.com/24302
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GLProgramsTest.cpp | 2 | ||||
-rw-r--r-- | tests/GpuSampleLocationsTest.cpp | 3 | ||||
-rw-r--r-- | tests/ProxyTest.cpp | 9 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 38 |
4 files changed, 29 insertions, 23 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 178676431f..f8cb6efb67 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -145,7 +145,7 @@ static sk_sp<GrRenderTargetContext> random_render_target_context(GrContext* cont const GrCaps* caps) { GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; - int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0; + int sampleCnt = random->nextBool() ? caps->getSampleCount(4, kRGBA_8888_GrPixelConfig) : 0; sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext( SkBackingFit::kExact, diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp index ff87a33725..6c5d4a6d37 100644 --- a/tests/GpuSampleLocationsTest.cpp +++ b/tests/GpuSampleLocationsTest.cpp @@ -189,7 +189,8 @@ DEF_GPUTEST(GLSampleLocations, reporter, /*factory*/) { sk_sp<GrContext> ctx(GrContext::Create(kOpenGL_GrBackend, testInterface)); // This test relies on at least 2 samples. - if (ctx->caps()->maxSampleCount() < 2) { + int supportedSample = ctx->caps()->getSampleCount(2, kRGBA_8888_GrPixelConfig); + if (supportedSample < 2) { return; } test_sampleLocations(reporter, &testInterface, ctx.get()); diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index f9cefc5b89..c2a7734901 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -157,9 +157,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { check_surface(reporter, proxy.get(), origin, widthHeight, widthHeight, config, kInvalidResourceID, budgeted); + int supportedSamples = caps.getSampleCount(numSamples, config); check_rendertarget(reporter, caps, provider, proxy->asRenderTargetProxy(), - SkTMin(numSamples, caps.maxSampleCount()), + supportedSamples, fit, caps.maxWindowRectangles(), false); } } @@ -214,9 +215,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) { for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { for (auto numSamples: { 0, 4}) { - if (caps.maxSampleCount() < numSamples) { - continue; - } + int supportedNumSamples = caps.getSampleCount(numSamples, config); bool renderable = caps.isConfigRenderable(config, numSamples > 0); @@ -225,7 +224,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { desc.fWidth = kWidthHeight; desc.fHeight = kWidthHeight; desc.fConfig = config; - desc.fSampleCnt = numSamples; + desc.fSampleCnt = supportedNumSamples; // External on-screen render target. if (renderable && kOpenGL_GrBackend == ctxInfo.backend()) { diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 83d316fcbc..50ddd00e8a 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -150,10 +150,11 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl resourceProvider->attachStencilAttachment(smallRT0->asRenderTarget()) != resourceProvider->attachStencilAttachment(bigRT->asRenderTarget())); - if (context->caps()->maxSampleCount() >= 4) { + int supportedSampleCount = context->caps()->getSampleCount(4, smallDesc.fConfig); + if (supportedSampleCount > 0) { // An RT with a different sample count should not share. GrSurfaceDesc smallMSAADesc = smallDesc; - smallMSAADesc.fSampleCnt = 4; + smallMSAADesc.fSampleCnt = supportedSampleCount; sk_sp<GrTexture> smallMSAART0(resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo)); if (smallMSAART0 && smallMSAART0->asRenderTarget()) { @@ -184,10 +185,10 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl resourceProvider->attachStencilAttachment(smallMSAART1->asRenderTarget())); // But not one with a larger sample count should not. (Also check that the request for 4 // samples didn't get rounded up to >= 8 or else they could share.). - if (context->caps()->maxSampleCount() >= 8 && - smallMSAART0 && smallMSAART0->asRenderTarget() && - smallMSAART0->asRenderTarget()->numColorSamples() < 8) { - smallMSAADesc.fSampleCnt = 8; + supportedSampleCount = context->caps()->getSampleCount(8, smallDesc.fConfig); + if (supportedSampleCount != smallMSAADesc.fSampleCnt && + smallMSAART0 && smallMSAART0->asRenderTarget()) { + smallMSAADesc.fSampleCnt = supportedSampleCount; smallMSAART1 = resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo); sk_sp<GrTexture> smallMSAART1( resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo)); @@ -1700,12 +1701,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) { size_t size = tex->gpuMemorySize(); REPORTER_ASSERT(reporter, kSize*kSize*4 == size); - if (context->caps()->maxSampleCount() >= 4) { - tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4); + size_t sampleCount = (size_t)context->caps()->getSampleCount(4, kRGBA_8888_GrPixelConfig); + if (sampleCount >= 4) { + tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, + sampleCount); size = tex->gpuMemorySize(); - REPORTER_ASSERT(reporter, kSize*kSize*4 == size || // msaa4 failed - kSize*kSize*4*4 == size || // auto-resolving - kSize*kSize*4*5 == size); // explicit resolve buffer + REPORTER_ASSERT(reporter, + kSize*kSize*4 == size || // msaa4 failed + kSize*kSize*4*sampleCount == size || // auto-resolving + kSize*kSize*4*(sampleCount+1) == size); // explicit resolve buffer } tex = make_normal_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0); @@ -1722,13 +1726,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) { size_t size = proxy->gpuMemorySize(); REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size); - if (context->caps()->maxSampleCount() >= 4) { - proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4); + size_t sampleCount = (size_t)context->caps()->getSampleCount(4, kRGBA_8888_GrPixelConfig); + if (sampleCount >= 4) { + proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, + sampleCount); size = proxy->gpuMemorySize(); REPORTER_ASSERT(reporter, - kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed - kSize*kSize*4*4+(kSize*kSize*4)/3 == size || // auto-resolving - kSize*kSize*4*5+(kSize*kSize*4)/3 == size); // explicit resolve buffer + kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed + kSize*kSize*4*sampleCount+(kSize*kSize*4)/3 == size || // auto-resolving + kSize*kSize*4*(sampleCount+1)+(kSize*kSize*4)/3 == size); // explicit resolve buffer } proxy = make_mipmap_proxy(provider, kNone_GrSurfaceFlags, kSize, kSize, 0); |