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/ResourceCacheTest.cpp | |
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/ResourceCacheTest.cpp')
-rw-r--r-- | tests/ResourceCacheTest.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
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); |