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 | bdecacf | 2018-02-02 20:32:49 -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); |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame^] | 152 | int supportedSamples = |
| 153 | caps.getRenderTargetSampleCount(numSamples, config); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 154 | check_rendertarget(reporter, caps, resourceProvider, |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 155 | proxy->asRenderTargetProxy(), |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 156 | supportedSamples, |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 157 | fit, caps.maxWindowRectangles(), false); |
| 158 | } |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 161 | desc.fFlags = kNone_GrSurfaceFlags; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 162 | |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 163 | { |
| 164 | sk_sp<GrTexture> tex; |
| 165 | if (SkBackingFit::kApprox == fit) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 166 | tex = resourceProvider->createApproxTexture(desc, 0); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 167 | } else { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 168 | tex = resourceProvider->createTexture(desc, budgeted); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 169 | } |
Robert Phillips | b446088 | 2016-11-17 14:43:51 -0500 | [diff] [blame] | 170 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 171 | sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy( |
| 172 | desc, fit, budgeted)); |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 173 | REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy)); |
| 174 | if (proxy) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 175 | // This forces the proxy to compute and cache its |
| 176 | // pre-instantiation size guess. Later, when it is actually |
| 177 | // instantiated, it checks that the instantiated size is <= to |
| 178 | // the pre-computation. If the proxy never computed its |
| 179 | // pre-instantiation size then the check is skipped. |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 180 | proxy->gpuMemorySize(); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 181 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 182 | check_surface(reporter, proxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 183 | widthHeight, widthHeight, config, budgeted); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 184 | check_texture(reporter, resourceProvider, |
| 185 | proxy->asTextureProxy(), fit, false); |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 186 | } |
Robert Phillips | 40d9495 | 2017-01-30 14:15:59 -0500 | [diff] [blame] | 187 | } |
Robert Phillips | 6520a69 | 2017-02-01 09:20:00 -0500 | [diff] [blame] | 188 | |
| 189 | attempt++; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
egdaniel | ab527a5 | 2016-06-28 08:07:26 -0700 | [diff] [blame] | 198 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 199 | GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 200 | GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 201 | const GrCaps& caps = *ctxInfo.grContext()->caps(); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 202 | |
| 203 | static const int kWidthHeight = 100; |
| 204 | |
| 205 | for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { |
| 206 | for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) { |
| 207 | for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame^] | 208 | for (auto numSamples : {1, 4}) { |
| 209 | int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 210 | |
| 211 | GrSurfaceDesc desc; |
| 212 | desc.fOrigin = origin; |
| 213 | desc.fWidth = kWidthHeight; |
| 214 | desc.fHeight = kWidthHeight; |
| 215 | desc.fConfig = config; |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 216 | desc.fSampleCnt = supportedNumSamples; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 217 | |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 218 | // External on-screen render target. |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame^] | 219 | if (supportedNumSamples && kOpenGL_GrBackend == ctxInfo.backend()) { |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 220 | GrGLFramebufferInfo fboInfo; |
| 221 | fboInfo.fFBOID = 0; |
| 222 | GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8, |
| 223 | config, fboInfo); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 224 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 225 | sk_sp<GrSurfaceProxy> sProxy(proxyProvider->createWrappedRenderTargetProxy( |
| 226 | backendRT, origin)); |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 227 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 228 | kWidthHeight, kWidthHeight, config, SkBudgeted::kNo); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 229 | check_rendertarget(reporter, caps, resourceProvider, |
| 230 | sProxy->asRenderTargetProxy(), |
Greg Daniel | d62f554 | 2017-07-20 09:11:41 -0400 | [diff] [blame] | 231 | supportedNumSamples, SkBackingFit::kExact, 0, true); |
csmartdalton | f963599 | 2016-08-10 11:09:07 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame^] | 234 | if (supportedNumSamples) { |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 235 | // Internal offscreen render target. |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 236 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 237 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 238 | sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy( |
| 239 | desc, SkBackingFit::kExact, budgeted); |
| 240 | if (!sProxy) { |
| 241 | continue; // This can fail on Mesa |
| 242 | } |
| 243 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 244 | check_surface(reporter, sProxy.get(), origin, |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 245 | kWidthHeight, kWidthHeight, config, budgeted); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 246 | check_rendertarget(reporter, caps, resourceProvider, |
| 247 | sProxy->asRenderTargetProxy(), |
Greg Daniel | d62f554 | 2017-07-20 09:11:41 -0400 | [diff] [blame] | 248 | supportedNumSamples, SkBackingFit::kExact, |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 249 | caps.maxWindowRectangles(), true); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 250 | } else { |
| 251 | // Internal offscreen texture |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 252 | SkASSERT(kNone_GrSurfaceFlags == desc.fFlags ); |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame^] | 253 | desc.fSampleCnt = 1; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 254 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 255 | sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy( |
| 256 | desc, SkBackingFit::kExact, budgeted); |
| 257 | if (!sProxy) { |
| 258 | continue; |
| 259 | } |
| 260 | |
| 261 | check_surface(reporter, sProxy.get(), origin, |
| 262 | kWidthHeight, kWidthHeight, config, budgeted); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 263 | check_texture(reporter, resourceProvider, sProxy->asTextureProxy(), |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 264 | SkBackingFit::kExact, true); |
| 265 | } |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 272 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) { |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 273 | GrProxyProvider* provider = ctxInfo.grContext()->contextPriv().proxyProvider(); |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 274 | |
| 275 | for (auto flags : { kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags }) { |
| 276 | for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) { |
| 277 | for (int width : { 0, 100 }) { |
| 278 | for (int height : { 0, 100}) { |
| 279 | if (width && height) { |
| 280 | continue; // not zero-sized |
| 281 | } |
| 282 | |
| 283 | GrSurfaceDesc desc; |
| 284 | desc.fFlags = flags; |
| 285 | desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 286 | desc.fWidth = width; |
| 287 | desc.fHeight = height; |
| 288 | desc.fConfig = kRGBA_8888_GrPixelConfig; |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame^] | 289 | desc.fSampleCnt = 1; |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 290 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 291 | sk_sp<GrTextureProxy> proxy = provider->createProxy(desc, fit, SkBudgeted::kNo); |
Robert Phillips | 78de212 | 2017-04-26 07:44:26 -0400 | [diff] [blame] | 292 | REPORTER_ASSERT(reporter, !proxy); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 299 | #endif |