diff options
author | Brian Salomon <bsalomon@google.com> | 2018-03-13 09:32:39 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-13 15:02:57 +0000 |
commit | 52e943a4693af75b40b62200191981da7458db62 (patch) | |
tree | 50449983945bb8ed6eabc8c71ed4ad8f33aa8918 /tests | |
parent | 65247e595d8e67ebc2857a8c3bb5ed53893b500d (diff) |
Add testing-only backend render target support to GrVkGpu.
Update unit tests to use backend render targets on non-GL contexts
Add named DM configs for rendering to Vulkan backend render targets and textures.
Make src data ptr param to createTestingOnlyBackendTexture be const.
Change-Id: I17f5375ed9bb08422006698956469d3151c4954c
Reviewed-on: https://skia-review.googlesource.com/113276
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ProxyConversionTest.cpp | 58 | ||||
-rw-r--r-- | tests/ProxyTest.cpp | 34 |
2 files changed, 60 insertions, 32 deletions
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp index 3ebfbf4778..7103403d43 100644 --- a/tests/ProxyConversionTest.cpp +++ b/tests/ProxyConversionTest.cpp @@ -12,6 +12,7 @@ #if SK_SUPPORT_GPU #include "GrBackendSurface.h" #include "GrContextPriv.h" +#include "GrGpu.h" #include "GrProxyProvider.h" #include "GrRenderTarget.h" #include "GrRenderTargetProxy.h" @@ -19,36 +20,46 @@ #include "GrTexture.h" #include "GrTextureProxy.h" -static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrProxyProvider* provider, - skiatest::Reporter* reporter, - const GrSurfaceDesc& desc, - GrSurfaceOrigin origin) { - GrGLFramebufferInfo fboInfo; - fboInfo.fFBOID = 0; - GrBackendRenderTarget backendRT(desc.fWidth, desc.fHeight, desc.fSampleCnt, 8, - desc.fConfig, fboInfo); - +static sk_sp<GrSurfaceProxy> make_wrapped_rt(GrProxyProvider* provider, + GrGpu* gpu, + skiatest::Reporter* reporter, + const GrSurfaceDesc& desc, + GrSurfaceOrigin origin) { + // We don't currently have a way of making MSAA backend render targets. + SkASSERT(1 == desc.fSampleCnt); + GrSRGBEncoded srgbEncoded; + auto ct = GrPixelConfigToColorTypeAndEncoding(desc.fConfig, &srgbEncoded); + auto backendRT = gpu->createTestingOnlyBackendRenderTarget(desc.fWidth, desc.fHeight, ct, + GrSRGBEncoded::kNo); return provider->wrapBackendRenderTarget(backendRT, origin); } -static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrProxyProvider* provider, - const GrSurfaceDesc& desc, - GrSurfaceOrigin origin) { +void clean_up_wrapped_rt(GrGpu* gpu, sk_sp<GrSurfaceProxy> proxy) { + SkASSERT(proxy->isUnique_debugOnly()); + SkASSERT(proxy->priv().peekRenderTarget()); + GrBackendRenderTarget rt = proxy->priv().peekRenderTarget()->getBackendRenderTarget(); + proxy.reset(); + gpu->deleteTestingOnlyBackendRenderTarget(rt); +} + +static sk_sp<GrSurfaceProxy> make_offscreen_rt(GrProxyProvider* provider, + const GrSurfaceDesc& desc, + GrSurfaceOrigin origin) { SkASSERT(kRenderTarget_GrSurfaceFlag == desc.fFlags); return provider->createInstantiatedProxy(desc, origin, SkBackingFit::kExact, SkBudgeted::kYes); } -static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrProxyProvider* provider, - const GrSurfaceDesc& desc, - GrSurfaceOrigin origin) { +static sk_sp<GrSurfaceProxy> make_texture(GrProxyProvider* provider, + const GrSurfaceDesc& desc, + GrSurfaceOrigin origin) { return provider->createInstantiatedProxy(desc, origin, SkBackingFit::kExact, SkBudgeted::kYes); } -// Test converting between RenderTargetProxies and TextureProxies for wrapped -// Proxies -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo) { +// Test converting between RenderTargetProxies and TextureProxies for preinstantiated Proxies +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PreinstantiatedProxyConversionTest, reporter, ctxInfo) { GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); + GrGpu* gpu = ctxInfo.grContext()->contextPriv().getGpu(); GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; @@ -56,23 +67,24 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo desc.fHeight = 64; desc.fConfig = kRGBA_8888_GrPixelConfig; - if (kOpenGL_GrBackend == ctxInfo.backend()) { + { // External on-screen render target. sk_sp<GrSurfaceProxy> sProxy( - make_wrapped_FBO0(proxyProvider, reporter, desc, kBottomLeft_GrSurfaceOrigin)); + make_wrapped_rt(proxyProvider, gpu, reporter, desc, kBottomLeft_GrSurfaceOrigin)); if (sProxy) { // RenderTarget-only GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy(); REPORTER_ASSERT(reporter, rtProxy); REPORTER_ASSERT(reporter, !rtProxy->asTextureProxy()); REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy); + clean_up_wrapped_rt(gpu, std::move(sProxy)); } } { // Internal offscreen render target. sk_sp<GrSurfaceProxy> sProxy( - make_wrapped_offscreen_rt(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin)); + make_offscreen_rt(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin)); if (sProxy) { // Both RenderTarget and Texture GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy(); @@ -87,7 +99,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo { // Internal offscreen render target - but through GrTextureProxy sk_sp<GrSurfaceProxy> sProxy( - make_wrapped_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin)); + make_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin)); if (sProxy) { // Both RenderTarget and Texture GrTextureProxy* tProxy = sProxy->asTextureProxy(); @@ -103,7 +115,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo desc.fFlags = kNone_GrSurfaceFlags; // force no-RT sk_sp<GrSurfaceProxy> sProxy( - make_wrapped_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin)); + make_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin)); if (sProxy) { // Texture-only GrTextureProxy* tProxy = sProxy->asTextureProxy(); diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 911c430dc1..4970e43a20 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -201,12 +201,28 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { static const int kWidthHeight = 100; - if (kOpenGL_GrBackend != ctxInfo.backend()) { - return; - } for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType, kRGBA_1010102_SkColorType }) { + // External on-screen render target. + // Tests wrapBackendRenderTarget with a GrBackendRenderTarget + // Our test-only function that creates a backend render target doesn't currently support + // sample counts :(. + if (ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType)) { + GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget( + kWidthHeight, kWidthHeight, SkColorTypeToGrColorType(colorType), + GrSRGBEncoded::kNo); + sk_sp<GrSurfaceProxy> sProxy( + proxyProvider->wrapBackendRenderTarget(backendRT, origin)); + check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, + backendRT.testingOnly_getPixelConfig(), SkBudgeted::kNo); + static constexpr int kExpectedNumSamples = 1; + check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(), + kExpectedNumSamples, SkBackingFit::kExact, + caps.maxWindowRectangles()); + gpu->deleteTestingOnlyBackendRenderTarget(backendRT); + } + for (auto numSamples : {1, 4}) { GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps); SkASSERT(kUnknown_GrPixelConfig != config); @@ -216,14 +232,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { continue; } - // External on-screen render target. - // Tests wrapBackendRenderTarget with a GrBackendRenderTarget - { + // Test wrapping FBO 0 (with made up properties). This tests sample count and the + // special case where FBO 0 doesn't support window rectangles. + if (kOpenGL_GrBackend == ctxInfo.backend()) { GrGLFramebufferInfo fboInfo; fboInfo.fFBOID = 0; - GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8, - config, fboInfo); - + static constexpr int kStencilBits = 8; + GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, + kStencilBits, config, fboInfo); sk_sp<GrSurfaceProxy> sProxy( proxyProvider->wrapBackendRenderTarget(backendRT, origin)); check_surface(reporter, sProxy.get(), origin, |