diff options
author | Brian Salomon <bsalomon@google.com> | 2018-02-01 13:58:00 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-01 21:56:49 +0000 |
commit | d653cac70ed17983125ceed053138c09f1401846 (patch) | |
tree | 1c9c5395e5e16ba1be082f4160381285a8240a1d /tests | |
parent | 704cff2c0cacdb13b7b0cd8da2cee72f24e4776c (diff) |
More sample count cleanup:
rename getSampleCount -> getRenderTargetSampleCount because it will return
0 when a config is not renderable but *is* supported as a texture format.
(Old name kept around until Chrome stops calling it)
Add virtual GrCaps::maxRenderTargetSampleCount(GrPixelConfig).
Devirtualize isConfigRenderable() and implement as maxRTSC != 0. Separate implementation for version with bool withMSAA param to be removed after Flutter is updated to no longer call.
Consolidate various file static GrSurfaceDesc validators fns into GrCaps::validateSurfaceDesc().
Bug: skia:
Change-Id: Ie30a291aa027e910df3bd90fac8518ccdb39e53f
Reviewed-on: https://skia-review.googlesource.com/102141
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/DeferredDisplayListTest.cpp | 2 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 3 | ||||
-rw-r--r-- | tests/GpuSampleLocationsTest.cpp | 4 | ||||
-rw-r--r-- | tests/GrCCPRTest.cpp | 3 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 18 | ||||
-rw-r--r-- | tests/LazyProxyTest.cpp | 3 | ||||
-rw-r--r-- | tests/ProxyTest.cpp | 11 | ||||
-rw-r--r-- | tests/ResourceAllocatorTest.cpp | 4 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 11 | ||||
-rw-r--r-- | tests/SRGBReadWritePixelsTest.cpp | 2 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 2 |
11 files changed, 34 insertions, 29 deletions
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp index 9938d498ce..b3637cbfa3 100644 --- a/tests/DeferredDisplayListTest.cpp +++ b/tests/DeferredDisplayListTest.cpp @@ -137,7 +137,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(SkSurfaceCharacterization, reporter, ctxInfo) { if (SurfaceParameters::kSampleCount == i) { SkSurface_Gpu* gpuSurf = static_cast<SkSurface_Gpu*>(s.get()); - int supportedSampleCount = context->caps()->getSampleCount( + int supportedSampleCount = context->caps()->getRenderTargetSampleCount( params.sampleCount(), gpuSurf->getDevice()->accessRenderTargetContext()->asRenderTargetProxy()->config()); if (1 == supportedSampleCount) { diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index df35559b25..f625a771bf 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -150,7 +150,8 @@ 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() ? caps->getSampleCount(2, kRGBA_8888_GrPixelConfig) : 1; + int sampleCnt = + random->nextBool() ? caps->getRenderTargetSampleCount(2, kRGBA_8888_GrPixelConfig) : 1; // Above could be 0 if msaa isn't supported. sampleCnt = SkTMax(1, sampleCnt); diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp index 5530539e68..56764cfc9b 100644 --- a/tests/GpuSampleLocationsTest.cpp +++ b/tests/GpuSampleLocationsTest.cpp @@ -113,7 +113,7 @@ static int pick_random_sample_count(int testPatternSize, SkRandom* rand, const G GrAlwaysAssert(testPatternSize > 1 && SkIsPow2(testPatternSize)); int randSampCnt = rand->nextRangeU(1 + testPatternSize / 2, testPatternSize); do { - int cnt = caps->getSampleCount(randSampCnt, kRGBA_8888_GrPixelConfig); + int cnt = caps->getRenderTargetSampleCount(randSampCnt, kRGBA_8888_GrPixelConfig); if (cnt) { return cnt; } @@ -203,7 +203,7 @@ DEF_GPUTEST(GLSampleLocations, reporter, /* options */) { sk_sp<GrContext> ctx(GrContext::MakeGL(testInterface)); // This test relies on at least 2 samples. - int supportedSample = ctx->caps()->getSampleCount(2, kRGBA_8888_GrPixelConfig); + int supportedSample = ctx->caps()->getRenderTargetSampleCount(2, kRGBA_8888_GrPixelConfig); if (supportedSample < 2) { return; } diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp index 9f770d6b50..cba94b4bf5 100644 --- a/tests/GrCCPRTest.cpp +++ b/tests/GrCCPRTest.cpp @@ -119,7 +119,8 @@ public: GrMockOptions mockOptions; mockOptions.fInstanceAttribSupport = true; mockOptions.fMapBufferFlags = GrCaps::kCanMap_MapFlag; - mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fRenderable[0] = true; + mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fRenderability = + GrMockOptions::ConfigOptions::Renderability::kNonMSAA; mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fTexturable = true; mockOptions.fGeometryShaderSupport = true; mockOptions.fIntegerSupport = true; diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 29f4f25695..32ac0c71e6 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -143,17 +143,17 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { desc.fFlags = kRenderTarget_GrSurfaceFlag; tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); - bool icr = caps->isConfigRenderable(config, false); - REPORTER_ASSERT(reporter, SkToBool(tex) == icr, - "config:%d, tex:%d, isConfigRenderable(false):%d", config, - SkToBool(tex), icr); + bool isRenderable = caps->isConfigRenderable(config); + REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable, + "config:%d, tex:%d, isRenderable:%d", config, SkToBool(tex), + isRenderable); desc.fSampleCnt = 2; tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); - icr = caps->isConfigRenderable(config, true); - REPORTER_ASSERT(reporter, SkToBool(tex) == icr, - "config:%d, tex:%d, isConfigRenderable(true):%d", config, SkToBool(tex), - icr); + isRenderable = SkToBool(caps->getRenderTargetSampleCount(2, config)); + REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable, + "config:%d, tex:%d, isRenderable:%d", config, SkToBool(tex), + isRenderable); } } } @@ -178,7 +178,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info) } desc.fFlags = kPerformInitialClear_GrSurfaceFlag; for (bool rt : {false, true}) { - if (rt && !context->caps()->isConfigRenderable(desc.fConfig, false)) { + if (rt && !context->caps()->isConfigRenderable(desc.fConfig)) { continue; } desc.fFlags |= rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags; diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp index f1bffa527b..5c0532701d 100644 --- a/tests/LazyProxyTest.cpp +++ b/tests/LazyProxyTest.cpp @@ -179,7 +179,8 @@ private: DEF_GPUTEST(LazyProxyTest, reporter, /* options */) { GrMockOptions mockOptions; - mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fRenderable[0] = true; + mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fRenderability = + GrMockOptions::ConfigOptions::Renderability::kNonMSAA; mockOptions.fConfigOptions[kAlpha_half_GrPixelConfig].fTexturable = true; sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions()); GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider(); diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 3bde3de7ca..dff230c9bb 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -149,7 +149,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { check_surface(reporter, proxy.get(), origin, widthHeight, widthHeight, config, budgeted); - int supportedSamples = caps.getSampleCount(numSamples, config); + int supportedSamples = + caps.getRenderTargetSampleCount(numSamples, config); check_rendertarget(reporter, caps, resourceProvider, proxy->asRenderTargetProxy(), supportedSamples, @@ -205,9 +206,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 : {1, 4}) { - int supportedNumSamples = caps.getSampleCount(numSamples, config); - - bool renderable = caps.isConfigRenderable(config, numSamples > 1); + int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config); GrSurfaceDesc desc; desc.fOrigin = origin; @@ -217,7 +216,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { desc.fSampleCnt = supportedNumSamples; // External on-screen render target. - if (renderable && kOpenGL_GrBackend == ctxInfo.backend()) { + if (supportedNumSamples && kOpenGL_GrBackend == ctxInfo.backend()) { GrGLFramebufferInfo fboInfo; fboInfo.fFBOID = 0; GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8, @@ -232,7 +231,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { supportedNumSamples, SkBackingFit::kExact, 0, true); } - if (renderable) { + if (supportedNumSamples) { // Internal offscreen render target. desc.fFlags = kRenderTarget_GrSurfaceFlag; diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp index 7dcb0ee942..173696be2b 100644 --- a/tests/ResourceAllocatorTest.cpp +++ b/tests/ResourceAllocatorTest.cpp @@ -148,8 +148,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) { std::move(p1), std::move(p2), test.fExpectation); } - int k2 = ctxInfo.grContext()->caps()->getSampleCount(2, kRGBA); - int k4 = ctxInfo.grContext()->caps()->getSampleCount(4, kRGBA); + int k2 = ctxInfo.grContext()->caps()->getRenderTargetSampleCount(2, kRGBA); + int k4 = ctxInfo.grContext()->caps()->getRenderTargetSampleCount(4, kRGBA); //-------------------------------------------------------------------------------------------- TestCase gNonOverlappingTests[] = { diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index da2e278367..3bd6c4b4e3 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -156,7 +156,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) != get_SB(bigRT.get())); } - int smallSampleCount = context->caps()->getSampleCount(2, kRGBA_8888_GrPixelConfig); + int smallSampleCount = context->caps()->getRenderTargetSampleCount(2, kRGBA_8888_GrPixelConfig); if (smallSampleCount > 1) { // An RT with a different sample count should not share. sk_sp<GrRenderTarget> smallMSAART0 = create_RT_with_SB(resourceProvider, 4, @@ -184,7 +184,8 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl // But one with a larger sample count should not. (Also check that the two requests didn't // rounded up to the same actual sample count or else they could share.). - int bigSampleCount = context->caps()->getSampleCount(5, kRGBA_8888_GrPixelConfig); + int bigSampleCount = + context->caps()->getRenderTargetSampleCount(5, kRGBA_8888_GrPixelConfig); if (bigSampleCount > 0 && bigSampleCount != smallSampleCount) { sk_sp<GrRenderTarget> smallMSAART2 = create_RT_with_SB(resourceProvider, 4, bigSampleCount, @@ -1710,7 +1711,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) { size_t size = tex->gpuMemorySize(); REPORTER_ASSERT(reporter, kSize*kSize*4 == size); - size_t sampleCount = (size_t)context->caps()->getSampleCount(4, kRGBA_8888_GrPixelConfig); + size_t sampleCount = + (size_t)context->caps()->getRenderTargetSampleCount(4, kRGBA_8888_GrPixelConfig); if (sampleCount >= 4) { tex = make_normal_texture(resourceProvider, kRenderTarget_GrSurfaceFlag, kSize, kSize, sampleCount); @@ -1735,7 +1737,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) { size_t size = proxy->gpuMemorySize(); REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size); - size_t sampleCount = (size_t)context->caps()->getSampleCount(4, kRGBA_8888_GrPixelConfig); + size_t sampleCount = + (size_t)context->caps()->getRenderTargetSampleCount(4, kRGBA_8888_GrPixelConfig); if (sampleCount >= 4) { proxy = make_mipmap_proxy(proxyProvider, kRenderTarget_GrSurfaceFlag, kSize, kSize, sampleCount); diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp index 7013971b62..bb7b77c5b9 100644 --- a/tests/SRGBReadWritePixelsTest.cpp +++ b/tests/SRGBReadWritePixelsTest.cpp @@ -172,7 +172,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) { desc.fWidth = kW; desc.fHeight = kH; desc.fConfig = kSRGBA_8888_GrPixelConfig; - if (context->caps()->isConfigRenderable(desc.fConfig, false) && + if (context->caps()->isConfigRenderable(desc.fConfig) && context->caps()->isConfigTexturable(desc.fConfig)) { sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeDeferredSurfaceContext( diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index af73473fad..7acd3ebbe2 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -880,7 +880,7 @@ DEF_TEST(SurfaceCreationWithColorSpace, reporter) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig, false); + bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig); auto surfaceMaker = [context](const SkImageInfo& info) { return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); }; |