blob: 92a3cba6d64a6d1cb78c012a5fde6cb90bde3ad3 [file] [log] [blame]
robertphillips76948d42016-05-04 12:47:41 -07001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "tests/Test.h"
robertphillips76948d42016-05-04 12:47:41 -070011
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/gpu/GrBackendSurface.h"
Robert Phillips6d344c32020-07-06 10:56:46 -040013#include "include/gpu/GrDirectContext.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/GrContextPriv.h"
15#include "src/gpu/GrProxyProvider.h"
16#include "src/gpu/GrRenderTargetPriv.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040017#include "src/gpu/GrRenderTargetProxy.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050018#include "src/gpu/GrResourceProvider.h"
19#include "src/gpu/GrSurfacePriv.h"
20#include "src/gpu/GrSurfaceProxyPriv.h"
Greg Daniel456f9b52020-03-05 19:14:18 +000021#include "src/gpu/GrTexture.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040022#include "src/gpu/GrTextureProxy.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050023#include "src/gpu/SkGr.h"
John Rosascoa9b348f2019-11-08 13:18:15 -080024#ifdef SK_GL
Mike Kleinc0bd9f92019-04-23 12:05:21 -050025#include "src/gpu/gl/GrGLDefines.h"
Brian Salomond4764a12019-08-08 12:08:24 -040026#include "src/gpu/gl/GrGLUtil.h"
John Rosascoa9b348f2019-11-08 13:18:15 -080027#endif
robertphillips76948d42016-05-04 12:47:41 -070028
Greg Danielc1ad77c2020-05-06 11:40:03 -040029#include "tests/TestUtils.h"
30
robertphillips8abb3702016-08-31 14:04:06 -070031// Check that the surface proxy's member vars are set as expected
robertphillips76948d42016-05-04 12:47:41 -070032static void check_surface(skiatest::Reporter* reporter,
33 GrSurfaceProxy* proxy,
Greg Danielbcf612b2017-05-01 13:50:58 +000034 int width, int height,
Robert Phillipsabacf092016-11-02 10:23:32 -040035 SkBudgeted budgeted) {
robertphillips76948d42016-05-04 12:47:41 -070036 REPORTER_ASSERT(reporter, proxy->width() == width);
37 REPORTER_ASSERT(reporter, proxy->height() == height);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050038 REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
Robert Phillipsabacf092016-11-02 10:23:32 -040039 REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
robertphillips76948d42016-05-04 12:47:41 -070040}
41
42static void check_rendertarget(skiatest::Reporter* reporter,
Robert Phillipsec2249f2016-11-09 08:54:35 -050043 const GrCaps& caps,
Brian Osman32342f02017-03-04 08:12:46 -050044 GrResourceProvider* provider,
robertphillips76948d42016-05-04 12:47:41 -070045 GrRenderTargetProxy* rtProxy,
Robert Phillipsabacf092016-11-02 10:23:32 -040046 int numSamples,
Robert Phillipsec2249f2016-11-09 08:54:35 -050047 SkBackingFit fit,
Greg Daniel2a303902018-02-20 10:25:54 -050048 int expectedMaxWindowRects) {
Robert Phillipsec2249f2016-11-09 08:54:35 -050049 REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
Chris Dalton6ce447a2019-06-23 18:07:38 -060050 REPORTER_ASSERT(reporter, rtProxy->numSamples() == numSamples);
Robert Phillipsabacf092016-11-02 10:23:32 -040051
Robert Phillips294870f2016-11-11 12:38:40 -050052 GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
Brian Salomonfd98c2c2018-07-31 17:25:29 -040053 bool preinstantiated = rtProxy->isInstantiated();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040054 REPORTER_ASSERT(reporter, rtProxy->instantiate(provider));
Brian Salomonfd98c2c2018-07-31 17:25:29 -040055 GrRenderTarget* rt = rtProxy->peekRenderTarget();
robertphillips76948d42016-05-04 12:47:41 -070056
Robert Phillips294870f2016-11-11 12:38:40 -050057 REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
Greg Daniel2a303902018-02-20 10:25:54 -050058 // Deferred resources should always have a different ID from their instantiated rendertarget
Brian Salomonf7778972018-03-08 10:13:17 -050059 if (preinstantiated) {
60 REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
61 } else {
62 REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
63 }
Robert Phillips294870f2016-11-11 12:38:40 -050064
robertphillips76948d42016-05-04 12:47:41 -070065 if (SkBackingFit::kExact == fit) {
Brian Salomon9f2b86c2019-10-22 10:37:46 -040066 REPORTER_ASSERT(reporter, rt->dimensions() == rtProxy->dimensions());
robertphillips76948d42016-05-04 12:47:41 -070067 } else {
68 REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
Robert Phillips294870f2016-11-11 12:38:40 -050069 REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
robertphillips76948d42016-05-04 12:47:41 -070070 }
Greg Danield51fa2f2020-01-22 16:53:38 -050071 REPORTER_ASSERT(reporter, rt->backendFormat() == rtProxy->backendFormat());
robertphillips76948d42016-05-04 12:47:41 -070072
Chris Dalton6ce447a2019-06-23 18:07:38 -060073 REPORTER_ASSERT(reporter, rt->numSamples() == rtProxy->numSamples());
Robert Phillipsfe0253f2018-03-16 16:47:25 -040074 REPORTER_ASSERT(reporter, rt->surfacePriv().flags() == rtProxy->testingOnly_getFlags());
robertphillips76948d42016-05-04 12:47:41 -070075}
76
77static void check_texture(skiatest::Reporter* reporter,
Brian Osman32342f02017-03-04 08:12:46 -050078 GrResourceProvider* provider,
robertphillips76948d42016-05-04 12:47:41 -070079 GrTextureProxy* texProxy,
Greg Daniel2a303902018-02-20 10:25:54 -050080 SkBackingFit fit) {
Robert Phillips294870f2016-11-11 12:38:40 -050081 GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040082
Brian Salomonfd98c2c2018-07-31 17:25:29 -040083 bool preinstantiated = texProxy->isInstantiated();
Michael Ludwigbd2f0702019-09-13 15:29:41 -040084 // The instantiated texture should have these dimensions. If the fit is kExact, then
Robert Phillipse9462dd2019-10-23 12:41:29 -040085 // 'backingStoreDimensions' reports the original WxH. If it is kApprox, make sure that
86 // the texture is that size and didn't reuse one of the kExact surfaces in the provider.
87 // This is important because upstream usage (e.g. SkImage) reports size based on the
88 // backingStoreDimensions and client code may rely on that if they are creating backend
89 // resources.
90 // NOTE: we store these before instantiating, since after instantiation backingStoreDimensions
91 // just returns the target's dimensions. In this instance, we want to ensure the target's
Brian Salomon9f2b86c2019-10-22 10:37:46 -040092 // dimensions are no different from the original approximate (or exact) dimensions.
Robert Phillipse9462dd2019-10-23 12:41:29 -040093 SkISize expectedSize = texProxy->backingStoreDimensions();
Michael Ludwigbd2f0702019-09-13 15:29:41 -040094
Robert Phillipseee4d6e2017-06-05 09:26:07 -040095 REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
Brian Salomonfd98c2c2018-07-31 17:25:29 -040096 GrTexture* tex = texProxy->peekTexture();
robertphillips76948d42016-05-04 12:47:41 -070097
Robert Phillips294870f2016-11-11 12:38:40 -050098 REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
Greg Daniel2a303902018-02-20 10:25:54 -050099 // Deferred resources should always have a different ID from their instantiated texture
Brian Salomonf7778972018-03-08 10:13:17 -0500100 if (preinstantiated) {
101 REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
102 } else {
103 REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
104 }
Robert Phillips294870f2016-11-11 12:38:40 -0500105
Brian Salomon9f2b86c2019-10-22 10:37:46 -0400106 REPORTER_ASSERT(reporter, tex->dimensions() == expectedSize);
Michael Ludwigbd2f0702019-09-13 15:29:41 -0400107
Greg Danield51fa2f2020-01-22 16:53:38 -0500108 REPORTER_ASSERT(reporter, tex->backendFormat() == texProxy->backendFormat());
robertphillips76948d42016-05-04 12:47:41 -0700109}
110
111
robertphillips8abb3702016-08-31 14:04:06 -0700112DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400113 auto direct = ctxInfo.directContext();
114 GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
115 GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
116 const GrCaps& caps = *direct->priv().caps();
robertphillips76948d42016-05-04 12:47:41 -0700117
Robert Phillips6520a692017-02-01 09:20:00 -0500118 int attempt = 0; // useful for debugging
119
Greg Daniel3a365112020-02-14 10:47:18 -0500120 for (auto widthHeight : {100, 128, 1048576}) {
121 for (auto ct : {GrColorType::kAlpha_8, GrColorType::kBGR_565, GrColorType::kRGBA_8888,
122 GrColorType::kRGBA_1010102}) {
123 for (auto fit : {SkBackingFit::kExact, SkBackingFit::kApprox}) {
124 for (auto budgeted : {SkBudgeted::kYes, SkBudgeted::kNo}) {
125 for (auto numSamples : {1, 4, 16, 128}) {
126 SkISize dims = {widthHeight, widthHeight};
robertphillips76948d42016-05-04 12:47:41 -0700127
Greg Daniel3a365112020-02-14 10:47:18 -0500128 auto format = caps.getDefaultBackendFormat(ct, GrRenderable::kYes);
129 if (!format.isValid()) {
130 continue;
robertphillips76948d42016-05-04 12:47:41 -0700131 }
Greg Daniel3a365112020-02-14 10:47:18 -0500132
133 // Renderable
134 {
135 sk_sp<GrTexture> tex;
136 if (SkBackingFit::kApprox == fit) {
137 tex = resourceProvider->createApproxTexture(
138 dims, format, GrRenderable::kYes, numSamples,
139 GrProtected::kNo);
140 } else {
141 tex = resourceProvider->createTexture(
142 dims, format, GrRenderable::kYes, numSamples,
143 GrMipMapped::kNo, budgeted, GrProtected::kNo);
144 }
145
146 sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400147 format, dims, GrRenderable::kYes, numSamples, GrMipMapped::kNo,
148 fit, budgeted, GrProtected::kNo);
Greg Daniel3a365112020-02-14 10:47:18 -0500149 REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
150 if (proxy) {
151 REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
152 // This forces the proxy to compute and cache its
153 // pre-instantiation size guess. Later, when it is actually
154 // instantiated, it checks that the instantiated size is <= to
155 // the pre-computation. If the proxy never computed its
156 // pre-instantiation size then the check is skipped.
157 proxy->gpuMemorySize(caps);
158
159 check_surface(reporter, proxy.get(), widthHeight, widthHeight,
160 budgeted);
161 int supportedSamples =
162 caps.getRenderTargetSampleCount(numSamples, format);
163 check_rendertarget(reporter, caps, resourceProvider,
164 proxy->asRenderTargetProxy(), supportedSamples,
165 fit, caps.maxWindowRectangles());
166 }
167 }
168
169 // Not renderable
170 {
171 sk_sp<GrTexture> tex;
172 if (SkBackingFit::kApprox == fit) {
173 tex = resourceProvider->createApproxTexture(
174 dims, format, GrRenderable::kNo, numSamples,
175 GrProtected::kNo);
176 } else {
177 tex = resourceProvider->createTexture(
178 dims, format, GrRenderable::kNo, numSamples,
179 GrMipMapped::kNo, budgeted, GrProtected::kNo);
180 }
181
182 sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy(
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400183 format, dims, GrRenderable::kNo, numSamples, GrMipMapped::kNo,
184 fit, budgeted, GrProtected::kNo));
Greg Daniel3a365112020-02-14 10:47:18 -0500185 REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
186 if (proxy) {
187 // This forces the proxy to compute and cache its
188 // pre-instantiation size guess. Later, when it is actually
189 // instantiated, it checks that the instantiated size is <= to
190 // the pre-computation. If the proxy never computed its
191 // pre-instantiation size then the check is skipped.
192 proxy->gpuMemorySize(caps);
193
194 check_surface(reporter, proxy.get(), widthHeight, widthHeight,
195 budgeted);
196 check_texture(reporter, resourceProvider, proxy->asTextureProxy(),
197 fit);
198 }
199 }
200
201 attempt++;
robertphillips76948d42016-05-04 12:47:41 -0700202 }
203 }
204 }
205 }
206 }
207}
208
egdanielab527a52016-06-28 08:07:26 -0700209DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400210 auto direct = ctxInfo.directContext();
211 GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
212 GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
213 GrGpu* gpu = direct->priv().getGpu();
214 const GrCaps& caps = *direct->priv().caps();
robertphillips76948d42016-05-04 12:47:41 -0700215
216 static const int kWidthHeight = 100;
217
Greg Daniel3a365112020-02-14 10:47:18 -0500218 for (auto colorType :
219 {kAlpha_8_SkColorType, kRGBA_8888_SkColorType, kRGBA_1010102_SkColorType}) {
220 GrColorType grColorType = SkColorTypeToGrColorType(colorType);
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400221
Greg Daniel3a365112020-02-14 10:47:18 -0500222 // External on-screen render target.
223 // Tests wrapBackendRenderTarget with a GrBackendRenderTarget
224 // Our test-only function that creates a backend render target doesn't currently support
225 // sample counts :(.
Robert Phillips6d344c32020-07-06 10:56:46 -0400226 if (direct->colorTypeSupportedAsSurface(colorType)) {
Greg Daniel3a365112020-02-14 10:47:18 -0500227 GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
228 kWidthHeight, kWidthHeight, grColorType);
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400229 sk_sp<GrSurfaceProxy> sProxy(
Robert Phillipsa1121332020-06-29 13:05:29 -0400230 proxyProvider->wrapBackendRenderTarget(backendRT, nullptr));
Greg Daniel3a365112020-02-14 10:47:18 -0500231 check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
232 static constexpr int kExpectedNumSamples = 1;
233 check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
234 kExpectedNumSamples, SkBackingFit::kExact,
235 caps.maxWindowRectangles());
236 gpu->deleteTestingOnlyBackendRenderTarget(backendRT);
237 }
238
239 for (auto numSamples : {1, 4}) {
240 auto beFormat = caps.getDefaultBackendFormat(grColorType, GrRenderable::kYes);
241 int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, beFormat);
242 if (!supportedNumSamples) {
243 continue;
Brian Salomon52e943a2018-03-13 09:32:39 -0400244 }
245
Greg Daniel3a365112020-02-14 10:47:18 -0500246#ifdef SK_GL
247 // Test wrapping FBO 0 (with made up properties). This tests sample count and the
248 // special case where FBO 0 doesn't support window rectangles.
249 if (GrBackendApi::kOpenGL == ctxInfo.backend()) {
250 GrGLFramebufferInfo fboInfo;
251 fboInfo.fFBOID = 0;
252 fboInfo.fFormat = GrGLFormatToEnum(beFormat.asGLFormat());
253 SkASSERT(fboInfo.fFormat);
254 static constexpr int kStencilBits = 8;
255 GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
256 kStencilBits, fboInfo);
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400257 sk_sp<GrSurfaceProxy> sProxy(
Robert Phillipsa1121332020-06-29 13:05:29 -0400258 proxyProvider->wrapBackendRenderTarget(backendRT, nullptr));
Greg Daniel3a365112020-02-14 10:47:18 -0500259 check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
260 check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
261 supportedNumSamples, SkBackingFit::kExact, 0);
262 }
263#endif
264
265 // Tests wrapBackendRenderTarget with a GrBackendTexture
266 {
Greg Danielc1ad77c2020-05-06 11:40:03 -0400267 GrBackendTexture backendTex;
Robert Phillips6d344c32020-07-06 10:56:46 -0400268 CreateBackendTexture(direct, &backendTex, kWidthHeight, kWidthHeight, colorType,
Greg Danielc1ad77c2020-05-06 11:40:03 -0400269 SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
270 GrProtected::kNo);
Greg Daniel3a365112020-02-14 10:47:18 -0500271 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400272 backendTex, supportedNumSamples);
Greg Daniel3a365112020-02-14 10:47:18 -0500273 if (!sProxy) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400274 direct->deleteBackendTexture(backendTex);
Greg Daniel3a365112020-02-14 10:47:18 -0500275 continue; // This can fail on Mesa
276 }
277
278 check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
279 check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
280 supportedNumSamples, SkBackingFit::kExact,
281 caps.maxWindowRectangles());
282
Robert Phillips6d344c32020-07-06 10:56:46 -0400283 direct->deleteBackendTexture(backendTex);
Greg Daniel3a365112020-02-14 10:47:18 -0500284 }
285
286 // Tests wrapBackendTexture that is only renderable
287 {
Greg Danielc1ad77c2020-05-06 11:40:03 -0400288 GrBackendTexture backendTex;
Robert Phillips6d344c32020-07-06 10:56:46 -0400289 CreateBackendTexture(direct, &backendTex, kWidthHeight, kWidthHeight, colorType,
Greg Danielc1ad77c2020-05-06 11:40:03 -0400290 SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kYes,
291 GrProtected::kNo);
Greg Daniel3a365112020-02-14 10:47:18 -0500292
293 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400294 backendTex, supportedNumSamples, kBorrow_GrWrapOwnership,
Robert Phillipsa1121332020-06-29 13:05:29 -0400295 GrWrapCacheable::kNo, nullptr);
Greg Daniel3a365112020-02-14 10:47:18 -0500296 if (!sProxy) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400297 direct->deleteBackendTexture(backendTex);
Greg Daniel3a365112020-02-14 10:47:18 -0500298 continue; // This can fail on Mesa
299 }
300
301 check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
302 check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
303 supportedNumSamples, SkBackingFit::kExact,
304 caps.maxWindowRectangles());
305
Robert Phillips6d344c32020-07-06 10:56:46 -0400306 direct->deleteBackendTexture(backendTex);
Greg Daniel3a365112020-02-14 10:47:18 -0500307 }
308
309 // Tests wrapBackendTexture that is only textureable
310 {
311 // Internal offscreen texture
Greg Danielc1ad77c2020-05-06 11:40:03 -0400312 GrBackendTexture backendTex;
Robert Phillips6d344c32020-07-06 10:56:46 -0400313 CreateBackendTexture(direct, &backendTex, kWidthHeight, kWidthHeight, colorType,
Greg Danielc1ad77c2020-05-06 11:40:03 -0400314 SkColors::kTransparent, GrMipMapped::kNo, GrRenderable::kNo,
315 GrProtected::kNo);
Greg Daniel3a365112020-02-14 10:47:18 -0500316
317 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
Brian Salomon8a78e9c2020-03-27 10:42:15 -0400318 backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType);
Greg Daniel3a365112020-02-14 10:47:18 -0500319 if (!sProxy) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400320 direct->deleteBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500321 continue;
322 }
robertphillips76948d42016-05-04 12:47:41 -0700323
Greg Daniel3a365112020-02-14 10:47:18 -0500324 check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
325 check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
326 SkBackingFit::kExact);
Greg Daniel2a303902018-02-20 10:25:54 -0500327
Robert Phillips6d344c32020-07-06 10:56:46 -0400328 direct->deleteBackendTexture(backendTex);
robertphillips76948d42016-05-04 12:47:41 -0700329 }
330 }
331 }
332}
333
Robert Phillips78de2122017-04-26 07:44:26 -0400334DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400335 auto direct = ctxInfo.directContext();
336 GrProxyProvider* provider = direct->priv().proxyProvider();
Robert Phillips78de2122017-04-26 07:44:26 -0400337
Brian Salomonf2c2ba92019-07-17 09:59:59 -0400338 for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
Robert Phillips78de2122017-04-26 07:44:26 -0400339 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
340 for (int width : { 0, 100 }) {
341 for (int height : { 0, 100}) {
342 if (width && height) {
343 continue; // not zero-sized
344 }
345
Greg Daniel4065d452018-11-16 15:43:41 -0500346 const GrBackendFormat format =
Robert Phillips6d344c32020-07-06 10:56:46 -0400347 direct->priv().caps()->getDefaultBackendFormat(
Robert Phillips0a15cc62019-07-30 12:49:10 -0400348 GrColorType::kRGBA_8888,
349 renderable);
Greg Daniel4065d452018-11-16 15:43:41 -0500350
Greg Daniel3a365112020-02-14 10:47:18 -0500351 sk_sp<GrTextureProxy> proxy = provider->createProxy(
Brian Salomondf1bd6d2020-03-26 20:37:01 -0400352 format, {width, height}, renderable, 1, GrMipMapped::kNo, fit,
Greg Daniel3a365112020-02-14 10:47:18 -0500353 SkBudgeted::kNo, GrProtected::kNo);
Robert Phillips78de2122017-04-26 07:44:26 -0400354 REPORTER_ASSERT(reporter, !proxy);
355 }
356 }
357 }
358 }
359}