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/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 1786764..f8cb6ef 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -145,7 +145,7 @@
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 ff87a33..6c5d4a6 100644
--- a/tests/GpuSampleLocationsTest.cpp
+++ b/tests/GpuSampleLocationsTest.cpp
@@ -189,7 +189,8 @@
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 f9cefc5..c2a7734 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -157,9 +157,10 @@
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 @@
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 @@
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 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);