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>
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 83d316f..50ddd00 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -150,10 +150,11 @@
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 @@
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 @@
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 @@
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);