robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | // This is a GPU-backend specific test. |
| 9 | |
| 10 | #include "Test.h" |
| 11 | |
| 12 | #if SK_SUPPORT_GPU |
Robert Phillips | 8bf1f9f | 2017-05-31 15:01:20 -0400 | [diff] [blame] | 13 | |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 14 | #include "GrBackendSurface.h" |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 15 | #include "GrContextPriv.h" |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 16 | #include "GrProxyProvider.h" |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 17 | #include "GrRenderTargetPriv.h" |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 18 | #include "GrRenderTargetProxy.h" |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 19 | #include "GrResourceProvider.h" |
Robert Phillips | f95b175 | 2017-08-31 08:56:07 -0400 | [diff] [blame] | 20 | #include "GrSurfaceProxyPriv.h" |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 21 | #include "GrTexture.h" |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 22 | #include "GrTextureProxy.h" |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 23 | |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 24 | // Check that the surface proxy's member vars are set as expected |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 25 | static void check_surface(skiatest::Reporter* reporter, |
| 26 | GrSurfaceProxy* proxy, |
| 27 | GrSurfaceOrigin origin, |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 28 | int width, int height, |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 29 | GrPixelConfig config, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 30 | SkBudgeted budgeted) { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 31 | REPORTER_ASSERT(reporter, proxy->origin() == origin); |
| 32 | REPORTER_ASSERT(reporter, proxy->width() == width); |
| 33 | REPORTER_ASSERT(reporter, proxy->height() == height); |
| 34 | REPORTER_ASSERT(reporter, proxy->config() == config); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 35 | REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid()); |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 36 | REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static void check_rendertarget(skiatest::Reporter* reporter, |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 40 | const GrCaps& caps, |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 41 | GrResourceProvider* provider, |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 42 | GrRenderTargetProxy* rtProxy, |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 43 | int numSamples, |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 44 | SkBackingFit fit, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 45 | int expectedMaxWindowRects, |
| 46 | bool wasWrapped) { |
Robert Phillips | ec2249f | 2016-11-09 08:54:35 -0500 | [diff] [blame] | 47 | REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects); |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 48 | REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples); |
| 49 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 50 | GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID(); |
Robert Phillips | eee4d6e | 2017-06-05 09:26:07 -0400 | [diff] [blame] | 51 | REPORTER_ASSERT(reporter, rtProxy->instantiate(provider)); |
| 52 | GrRenderTarget* rt = rtProxy->priv().peekRenderTarget(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 53 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 54 | REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore); |
| 55 | if (wasWrapped) { |
| 56 | // Wrapped resources share their uniqueID with the wrapping RenderTargetProxy |
| 57 | REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt()); |
| 58 | } else { |
| 59 | // Deferred resources should always have a different ID from their instantiated rendertarget |
| 60 | REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt()); |
| 61 | } |
| 62 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 63 | if (SkBackingFit::kExact == fit) { |
| 64 | REPORTER_ASSERT(reporter, rt->width() == rtProxy->width()); |
| 65 | REPORTER_ASSERT(reporter, rt->height() == rtProxy->height()); |
| 66 | } else { |
| 67 | REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width()); |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 68 | REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height()); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 69 | } |
| 70 | REPORTER_ASSERT(reporter, rt->config() == rtProxy->config()); |
| 71 | |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 72 | REPORTER_ASSERT(reporter, rt->fsaaType() == rtProxy->fsaaType()); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 73 | REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples()); |
| 74 | REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamples()); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 75 | REPORTER_ASSERT(reporter, rt->renderTargetPriv().flags() == rtProxy->testingOnly_getFlags()); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static void check_texture(skiatest::Reporter* reporter, |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 79 | GrResourceProvider* provider, |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 80 | GrTextureProxy* texProxy, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 81 | SkBackingFit fit, |
| 82 | bool wasWrapped) { |
| 83 | GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID(); |
Robert Phillips | eee4d6e | 2017-06-05 09:26:07 -0400 | [diff] [blame] | 84 | |
| 85 | REPORTER_ASSERT(reporter, texProxy->instantiate(provider)); |
| 86 | GrTexture* tex = texProxy->priv().peekTexture(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 87 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 88 | REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore); |
| 89 | if (wasWrapped) { |
| 90 | // Wrapped resources share their uniqueID with the wrapping TextureProxy |
| 91 | REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt()); |
| 92 | } else { |
| 93 | // Deferred resources should always have a different ID from their instantiated texture |
| 94 | REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt()); |
| 95 | } |
| 96 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 97 | if (SkBackingFit::kExact == fit) { |
| 98 | REPORTER_ASSERT(reporter, tex->width() == texProxy->width()); |
| 99 | REPORTER_ASSERT(reporter, tex->height() == texProxy->height()); |
| 100 | } else { |
| 101 | REPORTER_ASSERT(reporter, tex->width() >= texProxy->width()); |
| 102 | REPORTER_ASSERT(reporter, tex->height() >= texProxy->height()); |
| 103 | } |
| 104 | REPORTER_ASSERT(reporter, tex->config() == texProxy->config()); |
| 105 | } |
| 106 | |
| 107 | |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 108 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 109 | GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 110 | GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); |
Robert Phillips | abacf09 | 2016-11-02 10:23:32 -0400 | [diff] [blame] | 111 | const GrCaps& caps = *ctxInfo.grContext()->caps(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 112 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 113 | int attempt = 0; // useful for debugging |
| 114 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 115 | for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 116 | for (auto widthHeight : { 100, 128, 1048576 }) { |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 117 | for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig, |
Robert Phillips | 92de631 | 2017-05-23 07:43:48 -0400 | [diff] [blame] | 118 | kRGBA_8888_GrPixelConfig }) { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 119 | for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) { |
| 120 | for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { |
Brian Salomon | d0d7270 | 2018-02-01 14:16:02 -0500 | [diff] [blame^] | 121 | for (auto numSamples : {1, 4, 16, 128}) { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 122 | GrSurfaceDesc desc; |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 123 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 124 | desc.fOrigin = origin; |
| 125 | desc.fWidth = widthHeight; |
| 126 | desc.fHeight = widthHeight; |
| 127 | desc.fConfig = config; |
| 128 | desc.fSampleCnt = numSamples; |
| 129 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 130 | { |
| 131 | sk_sp<GrTexture> tex; |
| 132 | if (SkBackingFit::kApprox == fit) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 133 | tex = resourceProvider->createApproxTexture(desc, 0); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 134 | } else { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 135 | tex = resourceProvider->createTexture(desc, budgeted); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 136 | } |
| 137 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 138 | sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy( |
| 139 | desc, fit, budgeted); |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 140 | REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); |
| 141 | if (proxy) { |
| 142 | REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy()); |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 143 | // This forces the proxy to compute and cache its |
| 144 | // pre-instantiation size guess. Later, when it is actually |
| 145 | // instantiated, it checks that the instantiated size is <= to |
| 146 | // the pre-computation. If the proxy never computed its |
| 147 | // pre-instantiation size then the check is skipped. |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 148 | proxy->gpuMemorySize(); |
Robert Phillips | b446088 | 2016-11-17 14:43:51 -0500 | [diff] [blame] | 149 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 150 | check_surface(reporter, proxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 151 | widthHeight, widthHeight, config, budgeted); |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 152 | int supportedSamples = caps.getSampleCount(numSamples, config); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 153 | check_rendertarget(reporter, caps, resourceProvider, |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 154 | proxy->asRenderTargetProxy(), |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 155 | supportedSamples, |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 156 | fit, caps.maxWindowRectangles(), false); |
| 157 | } |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 160 | desc.fFlags = kNone_GrSurfaceFlags; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 161 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 162 | { |
| 163 | sk_sp<GrTexture> tex; |
| 164 | if (SkBackingFit::kApprox == fit) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 165 | tex = resourceProvider->createApproxTexture(desc, 0); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 166 | } else { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 167 | tex = resourceProvider->createTexture(desc, budgeted); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 168 | } |
Robert Phillips | b446088 | 2016-11-17 14:43:51 -0500 | [diff] [blame] | 169 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 170 | sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy( |
| 171 | desc, fit, budgeted)); |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 172 | REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); |
| 173 | if (proxy) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 174 | // This forces the proxy to compute and cache its |
| 175 | // pre-instantiation size guess. Later, when it is actually |
| 176 | // instantiated, it checks that the instantiated size is <= to |
| 177 | // the pre-computation. If the proxy never computed its |
| 178 | // pre-instantiation size then the check is skipped. |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 179 | proxy->gpuMemorySize(); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 180 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 181 | check_surface(reporter, proxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 182 | widthHeight, widthHeight, config, budgeted); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 183 | check_texture(reporter, resourceProvider, |
| 184 | proxy->asTextureProxy(), fit, false); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 185 | } |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 186 | } |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 187 | |
| 188 | attempt++; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
egdaniel | ab527a5 | 2016-06-28 08:07:26 -0700 | [diff] [blame] | 197 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 198 | GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 199 | GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 200 | const GrCaps& caps = *ctxInfo.grContext()->caps(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 201 | |
| 202 | static const int kWidthHeight = 100; |
| 203 | |
| 204 | for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { |
| 205 | for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) { |
| 206 | for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { |
Brian Salomon | d0d7270 | 2018-02-01 14:16:02 -0500 | [diff] [blame^] | 207 | for (auto numSamples : {1, 4}) { |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 208 | int supportedNumSamples = caps.getSampleCount(numSamples, config); |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 209 | |
Brian Salomon | d0d7270 | 2018-02-01 14:16:02 -0500 | [diff] [blame^] | 210 | bool renderable = caps.isConfigRenderable(config, numSamples > 1); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 211 | |
| 212 | GrSurfaceDesc desc; |
| 213 | desc.fOrigin = origin; |
| 214 | desc.fWidth = kWidthHeight; |
| 215 | desc.fHeight = kWidthHeight; |
| 216 | desc.fConfig = config; |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 217 | desc.fSampleCnt = supportedNumSamples; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 218 | |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 219 | // External on-screen render target. |
| 220 | if (renderable && kOpenGL_GrBackend == ctxInfo.backend()) { |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 221 | GrGLFramebufferInfo fboInfo; |
| 222 | fboInfo.fFBOID = 0; |
| 223 | GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8, |
| 224 | config, fboInfo); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 225 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 226 | sk_sp<GrSurfaceProxy> sProxy(proxyProvider->createWrappedRenderTargetProxy( |
| 227 | backendRT, origin)); |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 228 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 229 | kWidthHeight, kWidthHeight, config, SkBudgeted::kNo); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 230 | check_rendertarget(reporter, caps, resourceProvider, |
| 231 | sProxy->asRenderTargetProxy(), |
Greg Daniel | d62f554 | 2017-07-20 09:11:41 -0400 | [diff] [blame] | 232 | supportedNumSamples, SkBackingFit::kExact, 0, true); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 233 | } |
| 234 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 235 | if (renderable) { |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 236 | // Internal offscreen render target. |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 237 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 238 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 239 | sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy( |
| 240 | desc, SkBackingFit::kExact, budgeted); |
| 241 | if (!sProxy) { |
| 242 | continue; // This can fail on Mesa |
| 243 | } |
| 244 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 245 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 246 | kWidthHeight, kWidthHeight, config, budgeted); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 247 | check_rendertarget(reporter, caps, resourceProvider, |
| 248 | sProxy->asRenderTargetProxy(), |
Greg Daniel | d62f554 | 2017-07-20 09:11:41 -0400 | [diff] [blame] | 249 | supportedNumSamples, SkBackingFit::kExact, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 250 | caps.maxWindowRectangles(), true); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 251 | } else { |
| 252 | // Internal offscreen texture |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 253 | SkASSERT(kNone_GrSurfaceFlags == desc.fFlags ); |
Brian Salomon | d0d7270 | 2018-02-01 14:16:02 -0500 | [diff] [blame^] | 254 | desc.fSampleCnt = 1; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 255 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 256 | sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy( |
| 257 | desc, SkBackingFit::kExact, budgeted); |
| 258 | if (!sProxy) { |
| 259 | continue; |
| 260 | } |
| 261 | |
| 262 | check_surface(reporter, sProxy.get(), origin, |
| 263 | kWidthHeight, kWidthHeight, config, budgeted); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 264 | check_texture(reporter, resourceProvider, sProxy->asTextureProxy(), |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 265 | SkBackingFit::kExact, true); |
| 266 | } |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 273 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 274 | GrProxyProvider* provider = ctxInfo.grContext()->contextPriv().proxyProvider(); |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 275 | |
| 276 | for (auto flags : { kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags }) { |
| 277 | for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) { |
| 278 | for (int width : { 0, 100 }) { |
| 279 | for (int height : { 0, 100}) { |
| 280 | if (width && height) { |
| 281 | continue; // not zero-sized |
| 282 | } |
| 283 | |
| 284 | GrSurfaceDesc desc; |
| 285 | desc.fFlags = flags; |
| 286 | desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 287 | desc.fWidth = width; |
| 288 | desc.fHeight = height; |
| 289 | desc.fConfig = kRGBA_8888_GrPixelConfig; |
Brian Salomon | d0d7270 | 2018-02-01 14:16:02 -0500 | [diff] [blame^] | 290 | desc.fSampleCnt = 1; |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 291 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 292 | sk_sp<GrTextureProxy> proxy = provider->createProxy(desc, fit, SkBudgeted::kNo); |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 293 | REPORTER_ASSERT(reporter, !proxy); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 300 | #endif |