aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ProxyConversionTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-13 09:32:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-13 15:02:57 +0000
commit52e943a4693af75b40b62200191981da7458db62 (patch)
tree50449983945bb8ed6eabc8c71ed4ad8f33aa8918 /tests/ProxyConversionTest.cpp
parent65247e595d8e67ebc2857a8c3bb5ed53893b500d (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/ProxyConversionTest.cpp')
-rw-r--r--tests/ProxyConversionTest.cpp58
1 files changed, 35 insertions, 23 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();