blob: 577496d1b697dc678fb2c3697ed0d1d85ad5b0e6 [file] [log] [blame]
Robert Phillips0c6daf02019-05-16 12:43:11 -04001/*
2 * Copyright 2019 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
Robert Phillipse19babf2020-04-06 13:57:30 -04008#include "include/core/SkCanvas.h"
Mike Kleinfe0aeb32019-05-20 10:55:11 -05009#include "include/core/SkSurface.h"
Robert Phillips02dc0302019-07-02 17:58:27 -040010#include "include/core/SkSurfaceCharacterization.h"
Robert Phillips6d344c32020-07-06 10:56:46 -040011#include "include/gpu/GrDirectContext.h"
Robert Phillips459b2952019-05-23 09:38:27 -040012#include "src/core/SkAutoPixmapStorage.h"
Adlai Hollera0693042020-10-14 11:23:11 -040013#include "src/gpu/GrDirectContextPriv.h"
Brian Salomon04e3e502020-12-16 15:55:25 -050014#include "src/gpu/GrProxyProvider.h"
15#include "src/gpu/GrSurfaceFillContext.h"
16#include "src/gpu/effects/GrBlendFragmentProcessor.h"
17#include "src/gpu/effects/generated/GrConstColorProcessor.h"
Robert Phillipsefb9f142019-05-17 14:19:44 -040018#include "src/image/SkImage_Base.h"
Robert Phillips0c6daf02019-05-16 12:43:11 -040019#include "tests/Test.h"
Robert Phillipse3b6fe42019-09-11 11:26:46 -040020#include "tests/TestUtils.h"
21#include "tools/ToolUtils.h"
Brian Salomon20f1b342020-12-15 20:23:03 -050022#include "tools/gpu/ManagedBackendTexture.h"
Brian Salomone6662542021-02-23 10:45:39 -050023#include "tools/gpu/ProxyUtils.h"
Robert Phillips0c6daf02019-05-16 12:43:11 -040024
Robert Phillips27eb5252019-06-03 12:59:40 -040025#ifdef SK_GL
Robert Phillipsee946932019-12-18 11:16:17 -050026#include "src/gpu/gl/GrGLCaps.h"
27#include "src/gpu/gl/GrGLDefines.h"
Robert Phillips27eb5252019-06-03 12:59:40 -040028#include "src/gpu/gl/GrGLGpu.h"
29#include "src/gpu/gl/GrGLUtil.h"
30#endif
31
Robert Phillips7f367982019-09-26 14:01:36 -040032#ifdef SK_METAL
33#include "include/gpu/mtl/GrMtlTypes.h"
34#include "src/gpu/mtl/GrMtlCppUtil.h"
35#endif
36
Brian Salomon20f1b342020-12-15 20:23:03 -050037using sk_gpu_test::ManagedBackendTexture;
Greg Danielb2365d82020-05-13 15:32:04 -040038
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -040039// Test wrapping of GrBackendObjects in SkSurfaces and SkImages (non-static since used in Mtl test)
Robert Phillipsfe4b4812020-07-17 14:15:51 -040040void test_wrapping(GrDirectContext* dContext,
41 skiatest::Reporter* reporter,
Brian Salomon20f1b342020-12-15 20:23:03 -050042 std::function<sk_sp<ManagedBackendTexture>(GrDirectContext*,
43 GrMipmapped,
44 GrRenderable)> create,
Robert Phillipsfe4b4812020-07-17 14:15:51 -040045 GrColorType grColorType,
Brian Salomon7e67dca2020-07-21 09:27:25 -040046 GrMipmapped mipMapped,
Brian Salomon20f1b342020-12-15 20:23:03 -050047 GrRenderable renderable) {
Robert Phillipsfe4b4812020-07-17 14:15:51 -040048 GrResourceCache* cache = dContext->priv().getResourceCache();
Robert Phillips0c6daf02019-05-16 12:43:11 -040049
50 const int initialCount = cache->getResourceCount();
51
Brian Salomon20f1b342020-12-15 20:23:03 -050052 sk_sp<ManagedBackendTexture> mbet = create(dContext, mipMapped, renderable);
53 if (!mbet) {
Robert Phillipsb7f95d12019-07-26 11:13:19 -040054 ERRORF(reporter, "Couldn't create backendTexture for grColorType %d renderable %s\n",
55 grColorType,
Robert Phillips0c6daf02019-05-16 12:43:11 -040056 GrRenderable::kYes == renderable ? "yes" : "no");
57 return;
58 }
Robert Phillipsb04b6942019-05-21 17:24:31 -040059
Robert Phillips0c6daf02019-05-16 12:43:11 -040060 // Skia proper should know nothing about the new backend object
61 REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount());
62
Robert Phillipsb7f95d12019-07-26 11:13:19 -040063 SkColorType skColorType = GrColorTypeToSkColorType(grColorType);
64
Brian Salomon04e3e502020-12-16 15:55:25 -050065 // Wrapping a backendTexture in an SkImage/SkSurface requires an SkColorType
66 if (skColorType == kUnknown_SkColorType) {
Robert Phillipsb04b6942019-05-21 17:24:31 -040067 return;
68 }
69
Robert Phillipsfe4b4812020-07-17 14:15:51 -040070 if (GrRenderable::kYes == renderable && dContext->colorTypeSupportedAsSurface(skColorType)) {
71 sk_sp<SkSurface> surf = SkSurface::MakeFromBackendTexture(dContext,
Brian Salomon20f1b342020-12-15 20:23:03 -050072 mbet->texture(),
Robert Phillips459b2952019-05-23 09:38:27 -040073 kTopLeft_GrSurfaceOrigin,
74 0,
Robert Phillipsb7f95d12019-07-26 11:13:19 -040075 skColorType,
Robert Phillips459b2952019-05-23 09:38:27 -040076 nullptr, nullptr);
Robert Phillipsb04b6942019-05-21 17:24:31 -040077 if (!surf) {
Brian Salomon04e3e502020-12-16 15:55:25 -050078 ERRORF(reporter, "Couldn't make SkSurface from backendTexture for %s\n",
Robert Phillips9a30ee02020-04-29 08:58:39 -040079 ToolUtils::colortype_name(skColorType));
Robert Phillipsb04b6942019-05-21 17:24:31 -040080 } else {
81 REPORTER_ASSERT(reporter, initialCount+1 == cache->getResourceCount());
Robert Phillips0c6daf02019-05-16 12:43:11 -040082 }
Robert Phillipsb04b6942019-05-21 17:24:31 -040083 }
Robert Phillips0c6daf02019-05-16 12:43:11 -040084
Robert Phillipsb04b6942019-05-21 17:24:31 -040085 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -040086 sk_sp<SkImage> img = SkImage::MakeFromTexture(dContext,
Brian Salomon20f1b342020-12-15 20:23:03 -050087 mbet->texture(),
Robert Phillips459b2952019-05-23 09:38:27 -040088 kTopLeft_GrSurfaceOrigin,
Robert Phillipsb7f95d12019-07-26 11:13:19 -040089 skColorType,
Brian Salomon04e3e502020-12-16 15:55:25 -050090 kUnpremul_SkAlphaType,
Robert Phillips459b2952019-05-23 09:38:27 -040091 nullptr);
Robert Phillipsb04b6942019-05-21 17:24:31 -040092 if (!img) {
Brian Salomon04e3e502020-12-16 15:55:25 -050093 ERRORF(reporter, "Couldn't make SkImage from backendTexture for %s\n",
Robert Phillips9a30ee02020-04-29 08:58:39 -040094 ToolUtils::colortype_name(skColorType));
Robert Phillipsb04b6942019-05-21 17:24:31 -040095 } else {
Brian Salomone6662542021-02-23 10:45:39 -050096 GrTextureProxy* proxy = sk_gpu_test::GetTextureImageProxy(img.get(), dContext);
Robert Phillipsb04b6942019-05-21 17:24:31 -040097 REPORTER_ASSERT(reporter, proxy);
Robert Phillipsefb9f142019-05-17 14:19:44 -040098
Brian Salomon8c82a872020-07-21 12:09:58 -040099 REPORTER_ASSERT(reporter, mipMapped == proxy->proxyMipmapped());
Robert Phillipsb04b6942019-05-21 17:24:31 -0400100 REPORTER_ASSERT(reporter, proxy->isInstantiated());
Brian Salomon8c82a872020-07-21 12:09:58 -0400101 REPORTER_ASSERT(reporter, mipMapped == proxy->mipmapped());
Robert Phillipsefb9f142019-05-17 14:19:44 -0400102
Robert Phillipsb04b6942019-05-21 17:24:31 -0400103 REPORTER_ASSERT(reporter, initialCount+1 == cache->getResourceCount());
Robert Phillips0c6daf02019-05-16 12:43:11 -0400104 }
105 }
106
107 REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount());
Robert Phillips0c6daf02019-05-16 12:43:11 -0400108}
109
Robert Phillips9a30ee02020-04-29 08:58:39 -0400110static bool isBGRA8(const GrBackendFormat& format) {
Robert Phillips7f367982019-09-26 14:01:36 -0400111 switch (format.backend()) {
Robert Phillips7f367982019-09-26 14:01:36 -0400112 case GrBackendApi::kOpenGL:
113#ifdef SK_GL
114 return format.asGLFormat() == GrGLFormat::kBGRA8;
115#else
116 return false;
117#endif
118 case GrBackendApi::kVulkan: {
119#ifdef SK_VULKAN
120 VkFormat vkFormat;
121 format.asVkFormat(&vkFormat);
122 return vkFormat == VK_FORMAT_B8G8R8A8_UNORM;
123#else
124 return false;
125#endif
126 }
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500127 case GrBackendApi::kMetal:
128#ifdef SK_METAL
Robert Phillips9a30ee02020-04-29 08:58:39 -0400129 return GrMtlFormatIsBGRA8(format.asMtlFormat());
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500130#else
131 return false;
132#endif
133 case GrBackendApi::kDirect3D:
134#ifdef SK_DIRECT3D
135 return false; // TODO
136#else
137 return false;
138#endif
139 case GrBackendApi::kDawn:
Stephen White36248742020-06-10 22:24:57 -0400140#ifdef SK_DAWN
141 wgpu::TextureFormat dawnFormat;
142 format.asDawnFormat(&dawnFormat);
143 return dawnFormat == wgpu::TextureFormat::BGRA8Unorm;
144#else
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500145 return false;
Stephen White36248742020-06-10 22:24:57 -0400146#endif
Robert Phillipsa27d6252019-12-10 14:48:36 -0500147 case GrBackendApi::kMock: {
148 SkImage::CompressionType compression = format.asMockCompressionType();
149 if (compression != SkImage::CompressionType::kNone) {
150 return false; // No compressed formats are BGRA
151 }
152
Robert Phillips7f367982019-09-26 14:01:36 -0400153 return format.asMockColorType() == GrColorType::kBGRA_8888;
Robert Phillipsa27d6252019-12-10 14:48:36 -0500154 }
Robert Phillips7f367982019-09-26 14:01:36 -0400155 }
156 SkUNREACHABLE;
157}
158
159static bool isRGB(const GrBackendFormat& format) {
160 switch (format.backend()) {
Robert Phillips7f367982019-09-26 14:01:36 -0400161 case GrBackendApi::kOpenGL:
162#ifdef SK_GL
163 return format.asGLFormat() == GrGLFormat::kRGB8;
164#else
165 return false;
166#endif
167 case GrBackendApi::kVulkan: {
168#ifdef SK_VULKAN
169 VkFormat vkFormat;
170 format.asVkFormat(&vkFormat);
171 return vkFormat == VK_FORMAT_R8G8B8_UNORM;
172#else
173 return false;
174#endif
175 }
Jim Van Verthb01e12b2020-02-18 14:34:38 -0500176 case GrBackendApi::kMetal:
177 return false; // Metal doesn't even pretend to support this
178 case GrBackendApi::kDirect3D:
179 return false; // Not supported in Direct3D 12
180 case GrBackendApi::kDawn:
181 return false;
Robert Phillips7f367982019-09-26 14:01:36 -0400182 case GrBackendApi::kMock:
183 return false; // No GrColorType::kRGB_888
184 }
185 SkUNREACHABLE;
186}
187
Robert Phillipse3b6fe42019-09-11 11:26:46 -0400188static void check_solid_pixmap(skiatest::Reporter* reporter,
Brian Salomon04e3e502020-12-16 15:55:25 -0500189 const SkColor4f& expected,
190 const SkPixmap& actual,
191 GrColorType ct,
192 const char* label1,
193 const char* label2) {
Robert Phillipse3b6fe42019-09-11 11:26:46 -0400194 // we need 0.001f across the board just for noise
195 // we need 0.01f across the board for 1010102
Robert Phillips7f367982019-09-26 14:01:36 -0400196 const float tols[4] = { 0.01f, 0.01f, 0.01f, 0.01f };
Robert Phillips27eb5252019-06-03 12:59:40 -0400197
Robert Phillipse3b6fe42019-09-11 11:26:46 -0400198 auto error = std::function<ComparePixmapsErrorReporter>(
Robert Phillips7f367982019-09-26 14:01:36 -0400199 [reporter, ct, label1, label2](int x, int y, const float diffs[4]) {
Robert Phillipse3b6fe42019-09-11 11:26:46 -0400200 SkASSERT(x >= 0 && y >= 0);
Brian Salomon04e3e502020-12-16 15:55:25 -0500201 ERRORF(reporter, "%s %s %s - mismatch at %d, %d (%f, %f, %f %f)", GrColorTypeToStr(ct),
202 label1, label2, x, y, diffs[0], diffs[1], diffs[2], diffs[3]);
Robert Phillipse3b6fe42019-09-11 11:26:46 -0400203 });
204
Brian Salomon28a8f282019-10-24 20:07:39 -0400205 CheckSolidPixels(expected, actual, tols, error);
Robert Phillips27eb5252019-06-03 12:59:40 -0400206}
207
Brian Salomon04e3e502020-12-16 15:55:25 -0500208// Determine what color we expect if we store 'orig' in 'ct' converted back to SkColor4f.
209static SkColor4f get_expected_color(SkColor4f orig, GrColorType ct) {
210 GrImageInfo ii(ct, kUnpremul_SkAlphaType, nullptr, {1, 1});
211 std::unique_ptr<char[]> data(new char[ii.minRowBytes()]);
212 GrClearImage(ii, data.get(), ii.minRowBytes(), orig);
Robert Phillipse3b6fe42019-09-11 11:26:46 -0400213
Brian Salomon04e3e502020-12-16 15:55:25 -0500214 // Read back to SkColor4f.
215 SkColor4f result;
216 GrImageInfo resultII(GrColorType::kRGBA_F32, kUnpremul_SkAlphaType, nullptr, {1, 1});
217 GrConvertPixels(resultII, &result.fR, sizeof(result), ii, data.get(), ii.minRowBytes());
218 return result;
Robert Phillips459b2952019-05-23 09:38:27 -0400219}
220
Brian Salomon04e3e502020-12-16 15:55:25 -0500221static void check_mipmaps(GrDirectContext*,
222 const GrBackendTexture&,
223 GrColorType,
224 const SkColor4f expectedColors[6],
225 skiatest::Reporter*,
226 const char* label);
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400227
Brian Salomon04e3e502020-12-16 15:55:25 -0500228static void check_base_readbacks(GrDirectContext* dContext,
229 const GrBackendTexture& backendTex,
230 GrColorType colorType,
231 GrRenderable renderableTexture,
232 const SkColor4f& color,
233 skiatest::Reporter* reporter,
Robert Phillips7f367982019-09-26 14:01:36 -0400234 const char* label) {
235 if (isRGB(backendTex.getBackendFormat())) {
236 // readPixels is busted for the RGB backend format (skbug.com/8862)
237 // TODO: add a GrColorType::kRGB_888 to fix the situation
238 return;
239 }
Robert Phillips0ee10342019-09-25 09:55:16 -0400240
Brian Salomon04e3e502020-12-16 15:55:25 -0500241 SkColor4f expectedColor = get_expected_color(color, colorType);
Robert Phillips0ee10342019-09-25 09:55:16 -0400242
243 SkAutoPixmapStorage actual;
244
245 {
Brian Salomon04e3e502020-12-16 15:55:25 -0500246 SkImageInfo readBackII = SkImageInfo::Make(32, 32,
247 kRGBA_8888_SkColorType,
Robert Phillips7f367982019-09-26 14:01:36 -0400248 kUnpremul_SkAlphaType);
Robert Phillips0ee10342019-09-25 09:55:16 -0400249
250 SkAssertResult(actual.tryAlloc(readBackII));
251 }
Brian Salomon04e3e502020-12-16 15:55:25 -0500252 for (GrRenderable renderableCtx : {GrRenderable::kNo, GrRenderable::kYes}) {
253 if (renderableCtx == GrRenderable::kYes && renderableTexture == GrRenderable::kNo) {
254 continue;
Brian Salomon0263bff2020-12-16 08:41:39 -0500255 }
Brian Salomon04e3e502020-12-16 15:55:25 -0500256 sk_sp<GrSurfaceProxy> proxy;
257 if (renderableCtx == GrRenderable::kYes) {
258 proxy = dContext->priv().proxyProvider()->wrapRenderableBackendTexture(
259 backendTex, 1, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, nullptr);
260 } else {
261 proxy = dContext->priv().proxyProvider()->wrapBackendTexture(
262 backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
263 }
264 if (!proxy) {
265 ERRORF(reporter, "Could not make proxy from backend texture");
266 return;
267 }
268 auto swizzle = dContext->priv().caps()->getReadSwizzle(backendTex.getBackendFormat(),
269 colorType);
270 GrSurfaceProxyView readView(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
271 GrColorInfo info(colorType, kUnpremul_SkAlphaType, nullptr);
272 auto surfaceContext = GrSurfaceContext::Make(dContext, readView, info);
273 if (!surfaceContext) {
274 ERRORF(reporter, "Could not create surface context for colorType: %d\n", colorType);
275 }
Brian Salomon0263bff2020-12-16 08:41:39 -0500276
Brian Salomondd4087d2020-12-23 20:36:44 -0500277 if (!surfaceContext->readPixels(dContext, actual, {0, 0})) {
Brian Salomon04e3e502020-12-16 15:55:25 -0500278 // TODO: we need a better way to tell a priori if readPixels will work for an
279 // arbitrary colorType
280#if 0
281 ERRORF(reporter, "Couldn't readback from GrSurfaceContext for colorType: %d\n",
282 colorType);
283#endif
284 } else {
285 auto name = SkStringPrintf("%s::readPixels",
286 (renderableCtx == GrRenderable::kYes ? "GrSurfaceFillContext"
287 : "GrSurfaceContext"));
288 check_solid_pixmap(reporter, expectedColor, actual, colorType, label, name.c_str());
Robert Phillips7f367982019-09-26 14:01:36 -0400289 }
290 }
Robert Phillips0ee10342019-09-25 09:55:16 -0400291}
292
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400293// Test initialization of GrBackendObjects to a specific color (non-static since used in Mtl test)
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400294void test_color_init(GrDirectContext* dContext,
295 skiatest::Reporter* reporter,
Brian Salomon20f1b342020-12-15 20:23:03 -0500296 std::function<sk_sp<ManagedBackendTexture>(GrDirectContext*,
297 const SkColor4f&,
298 GrMipmapped,
299 GrRenderable)> create,
Brian Salomon04e3e502020-12-16 15:55:25 -0500300 GrColorType colorType,
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400301 const SkColor4f& color,
Brian Salomon01ff5382020-12-15 16:06:26 -0500302 GrMipmapped mipmapped,
Brian Salomon20f1b342020-12-15 20:23:03 -0500303 GrRenderable renderable) {
Brian Salomon01ff5382020-12-15 16:06:26 -0500304 sk_sp<ManagedBackendTexture> mbet = create(dContext, color, mipmapped, renderable);
Brian Salomon20f1b342020-12-15 20:23:03 -0500305 if (!mbet) {
Robert Phillips459b2952019-05-23 09:38:27 -0400306 // errors here should be reported by the test_wrapping test
307 return;
308 }
309
Greg Danielb2365d82020-05-13 15:32:04 -0400310 auto checkBackendTexture = [&](const SkColor4f& testColor) {
Brian Salomon01ff5382020-12-15 16:06:26 -0500311 if (mipmapped == GrMipmapped::kYes) {
Brian Salomon04e3e502020-12-16 15:55:25 -0500312 SkColor4f expectedColor = get_expected_color(testColor, colorType);
Greg Danielb2365d82020-05-13 15:32:04 -0400313 SkColor4f expectedColors[6] = {expectedColor, expectedColor, expectedColor,
314 expectedColor, expectedColor, expectedColor};
Brian Salomon20f1b342020-12-15 20:23:03 -0500315 check_mipmaps(dContext, mbet->texture(), colorType, expectedColors, reporter,
316 "colorinit");
Greg Danielb2365d82020-05-13 15:32:04 -0400317 }
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400318
Greg Danielb2365d82020-05-13 15:32:04 -0400319 // The last step in this test will dirty the mipmaps so do it last
Brian Salomon20f1b342020-12-15 20:23:03 -0500320 check_base_readbacks(dContext, mbet->texture(), colorType, renderable, testColor, reporter,
Brian Salomon04e3e502020-12-16 15:55:25 -0500321 "colorinit");
Greg Danielb2365d82020-05-13 15:32:04 -0400322 };
323
324 checkBackendTexture(color);
325
Greg Danielb2365d82020-05-13 15:32:04 -0400326 SkColor4f newColor = {color.fB , color.fR, color.fG, color.fA };
327
Brian Salomon04e3e502020-12-16 15:55:25 -0500328 SkColorType skColorType = GrColorTypeToSkColorType(colorType);
Brian Salomon04e3e502020-12-16 15:55:25 -0500329 // Our update method only works with SkColorTypes.
330 if (skColorType != kUnknown_SkColorType) {
Brian Salomon20f1b342020-12-15 20:23:03 -0500331 dContext->updateBackendTexture(mbet->texture(),
332 skColorType,
333 newColor,
334 ManagedBackendTexture::ReleaseProc,
335 mbet->releaseContext());
Brian Salomon04e3e502020-12-16 15:55:25 -0500336 checkBackendTexture(newColor);
337 }
Robert Phillips459b2952019-05-23 09:38:27 -0400338}
339
Brian Salomon04e3e502020-12-16 15:55:25 -0500340// Draw the backend texture into an RGBA surface fill context, attempting to access all the mipMap
341// levels.
342static void check_mipmaps(GrDirectContext* dContext,
343 const GrBackendTexture& backendTex,
344 GrColorType colorType,
345 const SkColor4f expectedColors[6],
346 skiatest::Reporter* reporter,
347 const char* label) {
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400348#ifdef SK_GL
349 // skbug.com/9141 (RGBA_F32 mipmaps appear to be broken on some Mali devices)
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400350 if (GrBackendApi::kOpenGL == dContext->backend()) {
351 GrGLGpu* glGPU = static_cast<GrGLGpu*>(dContext->priv().getGpu());
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400352
Brian Salomon04e3e502020-12-16 15:55:25 -0500353 if (colorType == GrColorType::kRGBA_F32 &&
354 glGPU->ctxInfo().standard() == kGLES_GrGLStandard) {
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400355 return;
356 }
357 }
358#endif
359
Robert Phillips7f367982019-09-26 14:01:36 -0400360 if (isRGB(backendTex.getBackendFormat())) {
361 // readPixels is busted for the RGB backend format (skbug.com/8862)
362 // TODO: add a GrColorType::kRGB_888 to fix the situation
363 return;
364 }
365
Brian Salomon04e3e502020-12-16 15:55:25 -0500366 GrImageInfo info(GrColorType::kRGBA_8888, kUnpremul_SkAlphaType, nullptr, {32, 32});
367 auto dstFillContext = GrSurfaceFillContext::Make(dContext, info);
368 if (!dstFillContext) {
369 ERRORF(reporter, "Could not make dst fill context.");
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400370 return;
371 }
372
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400373 int numMipLevels = 6;
374
Brian Salomon04e3e502020-12-16 15:55:25 -0500375 auto proxy = dContext->priv().proxyProvider()->wrapBackendTexture(backendTex,
376 kBorrow_GrWrapOwnership,
377 GrWrapCacheable::kNo,
378 kRW_GrIOType);
379 if (!proxy) {
380 ERRORF(reporter, "Could not make proxy from backend texture");
381 return;
382 }
383 auto swizzle = dContext->priv().caps()->getReadSwizzle(backendTex.getBackendFormat(),
384 colorType);
385 GrSurfaceProxyView readView(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
386
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400387 for (int i = 0, rectSize = 32; i < numMipLevels; ++i, rectSize /= 2) {
388 SkASSERT(rectSize >= 1);
Brian Salomon04e3e502020-12-16 15:55:25 -0500389 dstFillContext->clear(SK_PMColor4fTRANSPARENT);
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400390
Brian Salomon04e3e502020-12-16 15:55:25 -0500391 SkMatrix texMatrix;
392 texMatrix.setScale(1 << i, 1 << i);
393 static constexpr GrSamplerState kNearestNearest(GrSamplerState::Filter::kNearest,
394 GrSamplerState::MipmapMode::kNearest);
395 auto fp = GrTextureEffect::Make(readView,
396 kUnpremul_SkAlphaType,
397 texMatrix,
398 kNearestNearest,
399 *dstFillContext->caps());
400 // Our swizzles for alpha color types currently produce (a, a, a, a) in the shader. Remove
401 // this once they are correctly (0, 0, 0, a).
402 if (GrColorTypeIsAlphaOnly(colorType)) {
403 auto black = GrConstColorProcessor::Make(SK_PMColor4fBLACK);
404 fp = GrBlendFragmentProcessor::Make(std::move(fp),
405 std::move(black),
406 SkBlendMode::kModulate);
407 }
408 dstFillContext->fillRectWithFP(SkIRect::MakeWH(rectSize, rectSize), std::move(fp));
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400409
410 SkImageInfo readbackII = SkImageInfo::Make(rectSize, rectSize,
411 kRGBA_8888_SkColorType,
Robert Phillips7f367982019-09-26 14:01:36 -0400412 kUnpremul_SkAlphaType);
Brian Salomon04e3e502020-12-16 15:55:25 -0500413 SkAutoPixmapStorage actual;
414 SkAssertResult(actual.tryAlloc(readbackII));
415 actual.erase(SkColors::kTransparent);
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400416
Brian Salomondd4087d2020-12-23 20:36:44 -0500417 bool result = dstFillContext->readPixels(dContext, actual, {0, 0});
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400418 REPORTER_ASSERT(reporter, result);
419
Robert Phillipsee946932019-12-18 11:16:17 -0500420 SkString str;
421 str.appendf("mip-level %d", i);
422
Brian Salomon04e3e502020-12-16 15:55:25 -0500423 check_solid_pixmap(reporter, expectedColors[i], actual, colorType, label, str.c_str());
Robert Phillipsc1dbb4b2019-09-24 16:32:35 -0400424 }
425}
426
Brian Salomon759217e2021-01-31 13:16:39 -0500427static int make_pixmaps(SkColorType skColorType,
428 GrMipmapped mipmapped,
429 const SkColor4f colors[6],
430 SkPixmap pixmaps[6],
431 std::unique_ptr<char[]>* mem) {
Robert Phillips7f367982019-09-26 14:01:36 -0400432 int levelSize = 32;
Brian Salomon759217e2021-01-31 13:16:39 -0500433 int numMipLevels = mipmapped == GrMipmapped::kYes ? 6 : 1;
434 size_t size = 0;
435 SkImageInfo ii[6];
436 size_t rowBytes[6];
Robert Phillips7f367982019-09-26 14:01:36 -0400437 for (int level = 0; level < numMipLevels; ++level) {
Brian Salomon759217e2021-01-31 13:16:39 -0500438 ii[level] = SkImageInfo::Make(levelSize, levelSize, skColorType, kUnpremul_SkAlphaType);
439 rowBytes[level] = ii[level].minRowBytes();
440 // Make sure we test row bytes that aren't tight.
441 if (!(level % 2)) {
442 rowBytes[level] += (level + 1)*SkColorTypeBytesPerPixel(ii[level].colorType());
443 }
444 size += rowBytes[level]*ii[level].height();
445 levelSize /= 2;
446 }
447 mem->reset(new char[size]);
448 char* addr = mem->get();
449 for (int level = 0; level < numMipLevels; ++level) {
450 pixmaps[level].reset(ii[level], addr, rowBytes[level]);
451 addr += rowBytes[level]*ii[level].height();
Robert Phillips7f367982019-09-26 14:01:36 -0400452 pixmaps[level].erase(colors[level]);
453 levelSize /= 2;
454 }
455 return numMipLevels;
456}
457
458// Test initialization of GrBackendObjects using SkPixmaps
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400459static void test_pixmap_init(GrDirectContext* dContext,
460 skiatest::Reporter* reporter,
Brian Salomon20f1b342020-12-15 20:23:03 -0500461 std::function<sk_sp<ManagedBackendTexture>(GrDirectContext*,
462 const SkPixmap srcData[],
463 int numLevels,
464 GrSurfaceOrigin,
465 GrRenderable)> create,
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400466 SkColorType skColorType,
Brian Salomonb5f880a2020-12-07 11:30:16 -0500467 GrSurfaceOrigin origin,
Brian Salomon759217e2021-01-31 13:16:39 -0500468 GrMipmapped mipmapped,
Brian Salomon20f1b342020-12-15 20:23:03 -0500469 GrRenderable renderable) {
Brian Salomon759217e2021-01-31 13:16:39 -0500470 SkPixmap pixmaps[6];
471 std::unique_ptr<char[]> memForPixmaps;
Robert Phillips7f367982019-09-26 14:01:36 -0400472 SkColor4f colors[6] = {
473 { 1.0f, 0.0f, 0.0f, 1.0f }, // R
474 { 0.0f, 1.0f, 0.0f, 0.9f }, // G
475 { 0.0f, 0.0f, 1.0f, 0.7f }, // B
476 { 0.0f, 1.0f, 1.0f, 0.5f }, // C
477 { 1.0f, 0.0f, 1.0f, 0.3f }, // M
478 { 1.0f, 1.0f, 0.0f, 0.2f }, // Y
479 };
480
Brian Salomon759217e2021-01-31 13:16:39 -0500481 int numMipLevels = make_pixmaps(skColorType, mipmapped, colors, pixmaps, &memForPixmaps);
Robert Phillips7f367982019-09-26 14:01:36 -0400482 SkASSERT(numMipLevels);
483
Brian Salomon20f1b342020-12-15 20:23:03 -0500484 sk_sp<ManagedBackendTexture> mbet = create(dContext, pixmaps, numMipLevels, origin, renderable);
485 if (!mbet) {
Robert Phillips7f367982019-09-26 14:01:36 -0400486 // errors here should be reported by the test_wrapping test
487 return;
488 }
489
Brian Salomon20f1b342020-12-15 20:23:03 -0500490 if (skColorType == kBGRA_8888_SkColorType && !isBGRA8(mbet->texture().getBackendFormat())) {
Robert Phillips7f367982019-09-26 14:01:36 -0400491 // When kBGRA is backed by an RGBA something goes wrong in the swizzling
492 return;
493 }
494
Greg Danielb2365d82020-05-13 15:32:04 -0400495 auto checkBackendTexture = [&](SkColor4f colors[6]) {
Brian Salomon04e3e502020-12-16 15:55:25 -0500496 GrColorType grColorType = SkColorTypeToGrColorType(skColorType);
Brian Salomon759217e2021-01-31 13:16:39 -0500497 if (mipmapped == GrMipmapped::kYes) {
Greg Danielb2365d82020-05-13 15:32:04 -0400498 SkColor4f expectedColors[6] = {
Brian Salomon04e3e502020-12-16 15:55:25 -0500499 get_expected_color(colors[0], grColorType),
500 get_expected_color(colors[1], grColorType),
501 get_expected_color(colors[2], grColorType),
502 get_expected_color(colors[3], grColorType),
503 get_expected_color(colors[4], grColorType),
504 get_expected_color(colors[5], grColorType),
Greg Danielb2365d82020-05-13 15:32:04 -0400505 };
Robert Phillips7f367982019-09-26 14:01:36 -0400506
Brian Salomon20f1b342020-12-15 20:23:03 -0500507 check_mipmaps(dContext, mbet->texture(), grColorType, expectedColors, reporter,
508 "pixmap");
Greg Danielb2365d82020-05-13 15:32:04 -0400509 }
510
511 // The last step in this test will dirty the mipmaps so do it last
Brian Salomon20f1b342020-12-15 20:23:03 -0500512 check_base_readbacks(dContext, mbet->texture(), grColorType, renderable, colors[0],
513 reporter, "pixmap");
Greg Danielb2365d82020-05-13 15:32:04 -0400514 };
515
516 checkBackendTexture(colors);
517
Greg Danielb2365d82020-05-13 15:32:04 -0400518 SkColor4f colorsNew[6] = {
519 {1.0f, 1.0f, 0.0f, 0.2f}, // Y
520 {1.0f, 0.0f, 0.0f, 1.0f}, // R
521 {0.0f, 1.0f, 0.0f, 0.9f}, // G
522 {0.0f, 0.0f, 1.0f, 0.7f}, // B
523 {0.0f, 1.0f, 1.0f, 0.5f}, // C
524 {1.0f, 0.0f, 1.0f, 0.3f}, // M
525 };
Brian Salomon759217e2021-01-31 13:16:39 -0500526 make_pixmaps(skColorType, mipmapped, colorsNew, pixmaps, &memForPixmaps);
Robert Phillips7f367982019-09-26 14:01:36 -0400527
Greg Danielb2365d82020-05-13 15:32:04 -0400528 // Upload new data and make sure everything still works
Brian Salomon20f1b342020-12-15 20:23:03 -0500529 dContext->updateBackendTexture(mbet->texture(),
530 pixmaps,
531 numMipLevels,
532 origin,
533 ManagedBackendTexture::ReleaseProc,
534 mbet->releaseContext());
Greg Danielb2365d82020-05-13 15:32:04 -0400535
536 checkBackendTexture(colorsNew);
Robert Phillips7f367982019-09-26 14:01:36 -0400537}
538
Robert Phillips02dc0302019-07-02 17:58:27 -0400539enum class VkLayout {
540 kUndefined,
541 kReadOnlyOptimal,
Robert Phillips02dc0302019-07-02 17:58:27 -0400542};
543
544void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) {
545#if defined(SK_VULKAN) && defined(SK_DEBUG)
546 VkImageLayout expected;
547
548 switch (layout) {
549 case VkLayout::kUndefined:
550 expected = VK_IMAGE_LAYOUT_UNDEFINED;
551 break;
552 case VkLayout::kReadOnlyOptimal:
553 expected = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
554 break;
Robert Phillips02dc0302019-07-02 17:58:27 -0400555 default:
556 SkUNREACHABLE;
557 }
558
559 GrVkImageInfo vkII;
560
561 if (backendTex.getVkImageInfo(&vkII)) {
562 SkASSERT(expected == vkII.fImageLayout);
563 SkASSERT(VK_IMAGE_TILING_OPTIMAL == vkII.fImageTiling);
564 }
565#endif
566}
567
568///////////////////////////////////////////////////////////////////////////////
Brian Salomon759217e2021-01-31 13:16:39 -0500569void color_type_backend_allocation_test(const sk_gpu_test::ContextInfo& ctxInfo,
570 skiatest::Reporter* reporter) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400571 auto context = ctxInfo.directContext();
Robert Phillips0c6daf02019-05-16 12:43:11 -0400572 const GrCaps* caps = context->priv().caps();
573
Robert Phillips459b2952019-05-23 09:38:27 -0400574 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
Robert Phillipsbd1ef682019-05-31 12:48:49 -0400575 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 0.75f };
Robert Phillips459b2952019-05-23 09:38:27 -0400576
Robert Phillips0c6daf02019-05-16 12:43:11 -0400577 struct {
578 SkColorType fColorType;
Robert Phillips459b2952019-05-23 09:38:27 -0400579 SkColor4f fColor;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400580 } combinations[] = {
Robert Phillipsea1b30b2019-09-19 16:05:48 -0400581 { kAlpha_8_SkColorType, kTransCol },
582 { kRGB_565_SkColorType, SkColors::kRed },
583 { kARGB_4444_SkColorType, SkColors::kGreen },
584 { kRGBA_8888_SkColorType, SkColors::kBlue },
585 { kRGB_888x_SkColorType, SkColors::kCyan },
Robert Phillips459b2952019-05-23 09:38:27 -0400586 // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul)
Robert Phillipsea1b30b2019-09-19 16:05:48 -0400587 { kBGRA_8888_SkColorType, { 1, 0, 0, 1.0f } },
Robert Phillips9a30ee02020-04-29 08:58:39 -0400588 // TODO: readback is busted for *10A2 when alpha = 0.5f (perhaps premul vs. unpremul)
589 { kRGBA_1010102_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }},
590 { kBGRA_1010102_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }},
591 // RGB/BGR 101010x have no Ganesh correlate
Robert Phillipsea1b30b2019-09-19 16:05:48 -0400592 { kRGB_101010x_SkColorType, { 0, 0.5f, 0, 0.5f } },
Mike Kleinf7eb0542020-02-11 12:19:08 -0600593 { kBGR_101010x_SkColorType, { 0, 0.5f, 0, 0.5f } },
Robert Phillipsea1b30b2019-09-19 16:05:48 -0400594 { kGray_8_SkColorType, kGrayCol },
595 { kRGBA_F16Norm_SkColorType, SkColors::kLtGray },
596 { kRGBA_F16_SkColorType, SkColors::kYellow },
597 { kRGBA_F32_SkColorType, SkColors::kGray },
Robert Phillips7f367982019-09-26 14:01:36 -0400598 { kR8G8_unorm_SkColorType, { .25f, .75f, 0, 1 } },
Robert Phillipsea1b30b2019-09-19 16:05:48 -0400599 { kR16G16_unorm_SkColorType, SkColors::kGreen },
600 { kA16_unorm_SkColorType, kTransCol },
601 { kA16_float_SkColorType, kTransCol },
Robert Phillips7f367982019-09-26 14:01:36 -0400602 { kR16G16_float_SkColorType, { .25f, .75f, 0, 1 } },
Robert Phillipsea1b30b2019-09-19 16:05:48 -0400603 { kR16G16B16A16_unorm_SkColorType,{ .25f, .5f, .75f, 1 } },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400604 };
605
Brian Salomon4dea72a2019-12-18 10:43:10 -0500606 static_assert(kLastEnum_SkColorType == SK_ARRAY_COUNT(combinations));
Robert Phillips0c6daf02019-05-16 12:43:11 -0400607
608 for (auto combo : combinations) {
609 SkColorType colorType = combo.fColorType;
610
Robert Phillips0c6daf02019-05-16 12:43:11 -0400611 if (GrBackendApi::kMetal == context->backend()) {
612 // skbug.com/9086 (Metal caps may not be handling RGBA32 correctly)
613 if (kRGBA_F32_SkColorType == combo.fColorType) {
614 continue;
615 }
616 }
617
Brian Salomon04e3e502020-12-16 15:55:25 -0500618 for (auto mipmapped : {GrMipmapped::kNo, GrMipmapped::kYes}) {
619 if (GrMipmapped::kYes == mipmapped && !caps->mipmapSupport()) {
Robert Phillipsefb9f142019-05-17 14:19:44 -0400620 continue;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400621 }
622
Robert Phillipsefb9f142019-05-17 14:19:44 -0400623 for (auto renderable : { GrRenderable::kNo, GrRenderable::kYes }) {
Greg Daniel7bfc9132019-08-14 14:23:53 -0400624 if (!caps->getDefaultBackendFormat(SkColorTypeToGrColorType(colorType),
625 renderable).isValid()) {
626 continue;
627 }
Robert Phillips7f367982019-09-26 14:01:36 -0400628
Robert Phillipsefb9f142019-05-17 14:19:44 -0400629 if (GrRenderable::kYes == renderable) {
630 if (kRGB_888x_SkColorType == combo.fColorType) {
631 // Ganesh can't perform the blends correctly when rendering this format
632 continue;
633 }
Robert Phillipsefb9f142019-05-17 14:19:44 -0400634 }
Robert Phillips0c6daf02019-05-16 12:43:11 -0400635
Robert Phillipsb04b6942019-05-21 17:24:31 -0400636 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400637 auto uninitCreateMtd = [colorType](GrDirectContext* dContext,
Brian Salomon04e3e502020-12-16 15:55:25 -0500638 GrMipmapped mipmapped,
Robert Phillipsb04b6942019-05-21 17:24:31 -0400639 GrRenderable renderable) {
Brian Salomon20f1b342020-12-15 20:23:03 -0500640 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
641 32, 32,
642 colorType,
643 mipmapped,
644 renderable,
645 GrProtected::kNo);
646 check_vk_layout(mbet->texture(), VkLayout::kUndefined);
Robert Phillipsd5e80ca2019-07-29 14:11:35 -0400647#ifdef SK_DEBUG
648 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400649 GrBackendFormat format = dContext->defaultBackendFormat(colorType,
650 renderable);
Brian Salomon20f1b342020-12-15 20:23:03 -0500651 SkASSERT(format == mbet->texture().getBackendFormat());
Robert Phillipsd5e80ca2019-07-29 14:11:35 -0400652 }
653#endif
654
Brian Salomon20f1b342020-12-15 20:23:03 -0500655 return mbet;
Robert Phillipsb04b6942019-05-21 17:24:31 -0400656 };
Robert Phillipsefb9f142019-05-17 14:19:44 -0400657
Robert Phillipsb04b6942019-05-21 17:24:31 -0400658 test_wrapping(context, reporter, uninitCreateMtd,
Brian Salomon20f1b342020-12-15 20:23:03 -0500659 SkColorTypeToGrColorType(colorType), mipmapped, renderable);
Robert Phillipsb04b6942019-05-21 17:24:31 -0400660 }
Robert Phillips459b2952019-05-23 09:38:27 -0400661
662 {
Brian Salomon20f1b342020-12-15 20:23:03 -0500663 auto createWithColorMtd = [colorType](GrDirectContext* dContext,
664 const SkColor4f& color,
665 GrMipmapped mipmapped,
666 GrRenderable renderable) {
667 auto mbet = ManagedBackendTexture::MakeWithData(dContext,
668 32, 32,
669 colorType,
670 color,
671 mipmapped,
672 renderable,
673 GrProtected::kNo);
674 check_vk_layout(mbet->texture(), VkLayout::kReadOnlyOptimal);
Robert Phillipsd5e80ca2019-07-29 14:11:35 -0400675
676#ifdef SK_DEBUG
677 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400678 GrBackendFormat format = dContext->defaultBackendFormat(colorType,
Robert Phillipsd5e80ca2019-07-29 14:11:35 -0400679 renderable);
Brian Salomon20f1b342020-12-15 20:23:03 -0500680 SkASSERT(format == mbet->texture().getBackendFormat());
Robert Phillipsd5e80ca2019-07-29 14:11:35 -0400681 }
682#endif
683
Brian Salomon20f1b342020-12-15 20:23:03 -0500684 return mbet;
Robert Phillips459b2952019-05-23 09:38:27 -0400685 };
Robert Phillips459b2952019-05-23 09:38:27 -0400686 test_color_init(context, reporter, createWithColorMtd,
Brian Salomon04e3e502020-12-16 15:55:25 -0500687 SkColorTypeToGrColorType(colorType), combo.fColor, mipmapped,
Brian Salomon20f1b342020-12-15 20:23:03 -0500688 renderable);
Robert Phillips459b2952019-05-23 09:38:27 -0400689 }
Robert Phillips7f367982019-09-26 14:01:36 -0400690
Brian Salomonb5f880a2020-12-07 11:30:16 -0500691 for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
Brian Salomon20f1b342020-12-15 20:23:03 -0500692 auto createWithSrcDataMtd = [](GrDirectContext* dContext,
693 const SkPixmap srcData[],
694 int numLevels,
695 GrSurfaceOrigin origin,
696 GrRenderable renderable) {
Robert Phillips9a30ee02020-04-29 08:58:39 -0400697 SkASSERT(srcData && numLevels);
Brian Salomon20f1b342020-12-15 20:23:03 -0500698 auto mbet = ManagedBackendTexture::MakeWithData(dContext,
699 srcData,
700 numLevels,
701 origin,
702 renderable,
703 GrProtected::kNo);
704 check_vk_layout(mbet->texture(), VkLayout::kReadOnlyOptimal);
Robert Phillips7f367982019-09-26 14:01:36 -0400705#ifdef SK_DEBUG
Robert Phillips9a30ee02020-04-29 08:58:39 -0400706 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400707 auto format = dContext->defaultBackendFormat(srcData[0].colorType(),
708 renderable);
Brian Salomon20f1b342020-12-15 20:23:03 -0500709 SkASSERT(format == mbet->texture().getBackendFormat());
Robert Phillips9a30ee02020-04-29 08:58:39 -0400710 }
Robert Phillips7f367982019-09-26 14:01:36 -0400711#endif
Brian Salomon20f1b342020-12-15 20:23:03 -0500712 return mbet;
Robert Phillips9a30ee02020-04-29 08:58:39 -0400713 };
Robert Phillips7f367982019-09-26 14:01:36 -0400714
Brian Salomonb5f880a2020-12-07 11:30:16 -0500715 test_pixmap_init(context,
716 reporter,
717 createWithSrcDataMtd,
718 colorType,
719 origin,
Brian Salomon04e3e502020-12-16 15:55:25 -0500720 mipmapped,
Brian Salomon20f1b342020-12-15 20:23:03 -0500721 renderable);
Robert Phillips9a30ee02020-04-29 08:58:39 -0400722 }
Robert Phillipsefb9f142019-05-17 14:19:44 -0400723 }
Robert Phillips0c6daf02019-05-16 12:43:11 -0400724 }
725 }
Robert Phillips0c6daf02019-05-16 12:43:11 -0400726}
727
Brian Salomon759217e2021-01-31 13:16:39 -0500728DEF_GPUTEST(ColorTypeBackendAllocationTest, reporter, options) {
729 for (int t = 0; t < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++t) {
730 auto type = static_cast<sk_gpu_test::GrContextFactory::ContextType>(t);
731 if (!sk_gpu_test::GrContextFactory::IsRenderingContext(type)) {
732 continue;
733 }
734 sk_gpu_test::GrContextFactory factory(options);
735 sk_gpu_test::ContextInfo info = factory.getContextInfo(type);
736 if (!info.directContext()) {
737 continue;
738 }
739 color_type_backend_allocation_test(info, reporter);
740 // The GL backend must support contexts that don't allow GL_UNPACK_ROW_LENGTH. Other
741 // backends are not required to work with this cap disabled.
742 if (info.directContext()->priv().caps()->writePixelsRowBytesSupport() &&
743 info.directContext()->backend() == GrBackendApi::kOpenGL) {
744 GrContextOptions overrideOptions = options;
745 overrideOptions.fDisallowWritePixelRowBytes = true;
746 sk_gpu_test::GrContextFactory overrideFactory(overrideOptions);
747 info = overrideFactory.getContextInfo(type);
748 color_type_backend_allocation_test(info, reporter);
749 }
750 }
751}
752
Robert Phillipsefb9f142019-05-17 14:19:44 -0400753///////////////////////////////////////////////////////////////////////////////
754#ifdef SK_GL
755
Robert Phillips0c6daf02019-05-16 12:43:11 -0400756DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) {
757 sk_gpu_test::GLTestContext* glCtx = ctxInfo.glContext();
758 GrGLStandard standard = glCtx->gl()->fStandard;
Robert Phillips6d344c32020-07-06 10:56:46 -0400759 auto context = ctxInfo.directContext();
Robert Phillipsefb9f142019-05-17 14:19:44 -0400760 const GrGLCaps* glCaps = static_cast<const GrGLCaps*>(context->priv().caps());
Robert Phillips0c6daf02019-05-16 12:43:11 -0400761
Brian Salomon01ff5382020-12-15 16:06:26 -0500762 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
763 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1.f };
764 constexpr SkColor4f kTransGrayCol { 0.5f, 0.5f, 0.5f, .8f };
Robert Phillips459b2952019-05-23 09:38:27 -0400765
Robert Phillips0c6daf02019-05-16 12:43:11 -0400766 struct {
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400767 GrColorType fColorType;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400768 GrGLenum fFormat;
Robert Phillips459b2952019-05-23 09:38:27 -0400769 SkColor4f fColor;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400770 } combinations[] = {
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400771 { GrColorType::kRGBA_8888, GR_GL_RGBA8, SkColors::kRed },
772 { GrColorType::kRGBA_8888_SRGB, GR_GL_SRGB8_ALPHA8, SkColors::kRed },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400773
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400774 { GrColorType::kRGB_888x, GR_GL_RGBA8, SkColors::kYellow },
775 { GrColorType::kRGB_888x, GR_GL_RGB8, SkColors::kCyan },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400776
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400777 { GrColorType::kBGRA_8888, GR_GL_RGBA8, SkColors::kBlue },
778 { GrColorType::kBGRA_8888, GR_GL_BGRA8, SkColors::kBlue },
779 // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul)
Robert Phillips9a30ee02020-04-29 08:58:39 -0400780 { GrColorType::kRGBA_1010102, GR_GL_RGB10_A2, { 0.25f, 0.5f, 0.75f, 1.f }},
781 { GrColorType::kBGRA_1010102, GR_GL_RGB10_A2, { 0.25f, 0.5f, 0.75f, 1.f }},
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400782 { GrColorType::kBGR_565, GR_GL_RGB565, SkColors::kRed },
783 { GrColorType::kABGR_4444, GR_GL_RGBA4, SkColors::kGreen },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400784
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400785 { GrColorType::kAlpha_8, GR_GL_ALPHA8, kTransCol },
786 { GrColorType::kAlpha_8, GR_GL_R8, kTransCol },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400787
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400788 { GrColorType::kGray_8, GR_GL_LUMINANCE8, kGrayCol },
789 { GrColorType::kGray_8, GR_GL_R8, kGrayCol },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400790
Brian Salomon01ff5382020-12-15 16:06:26 -0500791 { GrColorType::kGrayAlpha_88, GR_GL_LUMINANCE8_ALPHA8, kTransGrayCol },
792
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400793 { GrColorType::kRGBA_F32, GR_GL_RGBA32F, SkColors::kRed },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400794
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400795 { GrColorType::kRGBA_F16_Clamped, GR_GL_RGBA16F, SkColors::kLtGray },
796 { GrColorType::kRGBA_F16, GR_GL_RGBA16F, SkColors::kYellow },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400797
Robert Phillipsd470e1b2019-09-04 15:05:35 -0400798 { GrColorType::kRG_88, GR_GL_RG8, { 1, 0.5f, 0, 1 } },
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400799 { GrColorType::kAlpha_F16, GR_GL_R16F, { 1.0f, 0, 0, 0.5f } },
800 { GrColorType::kAlpha_F16, GR_GL_LUMINANCE16F, kGrayCol },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400801
Robert Phillips429f0d32019-09-11 17:03:28 -0400802 { GrColorType::kAlpha_16, GR_GL_R16, kTransCol },
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400803 { GrColorType::kRG_1616, GR_GL_RG16, SkColors::kYellow },
Robert Phillips66a46032019-06-18 08:00:42 -0400804
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400805 { GrColorType::kRGBA_16161616, GR_GL_RGBA16, SkColors::kLtGray },
806 { GrColorType::kRG_F16, GR_GL_RG16F, SkColors::kYellow },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400807 };
808
809 for (auto combo : combinations) {
Brian Salomon0f396992020-06-19 19:51:21 -0400810 for (GrGLenum target : {GR_GL_TEXTURE_2D, GR_GL_TEXTURE_RECTANGLE}) {
811 GrBackendFormat format = GrBackendFormat::MakeGL(combo.fFormat, target);
Robert Phillips0c6daf02019-05-16 12:43:11 -0400812
Brian Salomon0f396992020-06-19 19:51:21 -0400813 if (!glCaps->isFormatTexturable(format)) {
Robert Phillipsefb9f142019-05-17 14:19:44 -0400814 continue;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400815 }
816
Brian Salomon0f396992020-06-19 19:51:21 -0400817 if (GrColorType::kBGRA_8888 == combo.fColorType ||
818 GrColorType::kBGRA_1010102 == combo.fColorType) {
819 // We allow using a GL_RGBA8 or GR_GL_RGB10_A2 texture as BGRA on desktop GL but not
820 // ES
821 if (kGL_GrGLStandard != standard &&
822 (GR_GL_RGBA8 == combo.fFormat || GR_GL_RGB10_A2 == combo.fFormat)) {
823 continue;
824 }
825 }
Robert Phillips0c6daf02019-05-16 12:43:11 -0400826
Brian Salomon7e67dca2020-07-21 09:27:25 -0400827 for (auto mipMapped : {GrMipmapped::kNo, GrMipmapped::kYes}) {
828 if (GrMipmapped::kYes == mipMapped &&
Brian Salomon69100f02020-07-21 10:49:25 -0400829 (!glCaps->mipmapSupport() || target == GR_GL_TEXTURE_RECTANGLE)) {
Brian Salomon0f396992020-06-19 19:51:21 -0400830 continue;
Robert Phillipsefb9f142019-05-17 14:19:44 -0400831 }
832
Brian Salomon0f396992020-06-19 19:51:21 -0400833 for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
834 if (GrRenderable::kYes == renderable) {
835 if (!glCaps->isFormatAsColorTypeRenderable(combo.fColorType, format)) {
836 continue;
837 }
Robert Phillips459b2952019-05-23 09:38:27 -0400838 }
839
Brian Salomon0f396992020-06-19 19:51:21 -0400840 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400841 auto uninitCreateMtd = [format](GrDirectContext* dContext,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400842 GrMipmapped mipMapped,
Brian Salomon0f396992020-06-19 19:51:21 -0400843 GrRenderable renderable) {
Brian Salomon20f1b342020-12-15 20:23:03 -0500844 return ManagedBackendTexture::MakeWithoutData(dContext,
845 32, 32,
846 format,
847 mipMapped,
848 renderable,
849 GrProtected::kNo);
Brian Salomon0f396992020-06-19 19:51:21 -0400850 };
Greg Danielc1ad77c2020-05-06 11:40:03 -0400851
Brian Salomon0f396992020-06-19 19:51:21 -0400852 test_wrapping(context, reporter, uninitCreateMtd, combo.fColorType,
Brian Salomon20f1b342020-12-15 20:23:03 -0500853 mipMapped, renderable);
Brian Salomon85c3d682019-11-04 15:04:54 -0500854 }
Robert Phillips459b2952019-05-23 09:38:27 -0400855
Brian Salomon0f396992020-06-19 19:51:21 -0400856 {
857 // We're creating backend textures without specifying a color type "view" of
858 // them at the public API level. Therefore, Ganesh will not apply any
859 // swizzles before writing the color to the texture. However, our validation
860 // code does rely on interpreting the texture contents via a SkColorType and
861 // therefore swizzles may be applied during the read step. Ideally we'd
862 // update our validation code to use a "raw" read that doesn't impose a
863 // color type but for now we just munge the data we upload to match the
864 // expectation.
865 GrSwizzle swizzle;
866 switch (combo.fColorType) {
867 case GrColorType::kAlpha_8:
868 swizzle = GrSwizzle("aaaa");
869 break;
870 case GrColorType::kAlpha_16:
871 swizzle = GrSwizzle("aaaa");
872 break;
873 case GrColorType::kAlpha_F16:
874 swizzle = GrSwizzle("aaaa");
875 break;
876 default:
877 break;
878 }
Brian Salomon20f1b342020-12-15 20:23:03 -0500879 auto createWithColorMtd = [format, swizzle](GrDirectContext* dContext,
880 const SkColor4f& color,
881 GrMipmapped mipmapped,
882 GrRenderable renderable) {
Brian Salomon0f396992020-06-19 19:51:21 -0400883 auto swizzledColor = swizzle.applyTo(color);
Brian Salomon20f1b342020-12-15 20:23:03 -0500884 return ManagedBackendTexture::MakeWithData(dContext,
885 32, 32,
886 format,
887 swizzledColor,
888 mipmapped,
889 renderable,
890 GrProtected::kNo);
Brian Salomon0f396992020-06-19 19:51:21 -0400891 };
Brian Salomon0f396992020-06-19 19:51:21 -0400892 test_color_init(context, reporter, createWithColorMtd, combo.fColorType,
Brian Salomon20f1b342020-12-15 20:23:03 -0500893 combo.fColor, mipMapped, renderable);
Brian Salomon0f396992020-06-19 19:51:21 -0400894 }
Robert Phillips459b2952019-05-23 09:38:27 -0400895 }
Robert Phillipsefb9f142019-05-17 14:19:44 -0400896 }
Robert Phillips0c6daf02019-05-16 12:43:11 -0400897 }
898 }
899}
900
Robert Phillipsefb9f142019-05-17 14:19:44 -0400901#endif
902
903///////////////////////////////////////////////////////////////////////////////
Robert Phillips0c6daf02019-05-16 12:43:11 -0400904
905#ifdef SK_VULKAN
906
907#include "src/gpu/vk/GrVkCaps.h"
908
909DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) {
Robert Phillips6d344c32020-07-06 10:56:46 -0400910 auto context = ctxInfo.directContext();
Robert Phillips0c6daf02019-05-16 12:43:11 -0400911 const GrVkCaps* vkCaps = static_cast<const GrVkCaps*>(context->priv().caps());
912
Robert Phillips459b2952019-05-23 09:38:27 -0400913 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
Robert Phillips7f367982019-09-26 14:01:36 -0400914 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1 };
Robert Phillips459b2952019-05-23 09:38:27 -0400915
Robert Phillips0c6daf02019-05-16 12:43:11 -0400916 struct {
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400917 GrColorType fColorType;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400918 VkFormat fFormat;
Robert Phillips459b2952019-05-23 09:38:27 -0400919 SkColor4f fColor;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400920 } combinations[] = {
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400921 { GrColorType::kRGBA_8888, VK_FORMAT_R8G8B8A8_UNORM, SkColors::kRed },
922 { GrColorType::kRGBA_8888_SRGB, VK_FORMAT_R8G8B8A8_SRGB, SkColors::kRed },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400923
Robert Phillipsbd1ef682019-05-31 12:48:49 -0400924 // In this configuration (i.e., an RGB_888x colortype with an RGBA8 backing format),
925 // there is nothing to tell Skia to make the provided color opaque. Clients will need
926 // to provide an opaque initialization color in this case.
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400927 { GrColorType::kRGB_888x, VK_FORMAT_R8G8B8A8_UNORM, SkColors::kYellow },
928 { GrColorType::kRGB_888x, VK_FORMAT_R8G8B8_UNORM, SkColors::kCyan },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400929
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400930 { GrColorType::kBGRA_8888, VK_FORMAT_B8G8R8A8_UNORM, SkColors::kBlue },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400931
Robert Phillips9a30ee02020-04-29 08:58:39 -0400932 { GrColorType::kRGBA_1010102, VK_FORMAT_A2B10G10R10_UNORM_PACK32,
933 { 0.25f, 0.5f, 0.75f, 1.0f }},
934 { GrColorType::kBGRA_1010102, VK_FORMAT_A2R10G10B10_UNORM_PACK32,
935 { 0.25f, 0.5f, 0.75f, 1.0f }},
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400936 { GrColorType::kBGR_565, VK_FORMAT_R5G6B5_UNORM_PACK16, SkColors::kRed },
Robert Phillipsefb9f142019-05-17 14:19:44 -0400937
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400938 { GrColorType::kABGR_4444, VK_FORMAT_R4G4B4A4_UNORM_PACK16, SkColors::kCyan },
939 { GrColorType::kABGR_4444, VK_FORMAT_B4G4R4A4_UNORM_PACK16, SkColors::kYellow },
Robert Phillipsefb9f142019-05-17 14:19:44 -0400940
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400941 { GrColorType::kAlpha_8, VK_FORMAT_R8_UNORM, kTransCol },
Robert Phillipsbd1ef682019-05-31 12:48:49 -0400942 // In this config (i.e., a Gray8 color type with an R8 backing format), there is nothing
943 // to tell Skia this isn't an Alpha8 color type (so it will initialize the texture with
944 // the alpha channel of the color). Clients should, in general, fill all the channels
945 // of the provided color with the same value in such cases.
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400946 { GrColorType::kGray_8, VK_FORMAT_R8_UNORM, kGrayCol },
Robert Phillipsbd1ef682019-05-31 12:48:49 -0400947
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400948 { GrColorType::kRGBA_F16_Clamped, VK_FORMAT_R16G16B16A16_SFLOAT, SkColors::kLtGray },
949 { GrColorType::kRGBA_F16, VK_FORMAT_R16G16B16A16_SFLOAT, SkColors::kYellow },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400950
Robert Phillipsd470e1b2019-09-04 15:05:35 -0400951 { GrColorType::kRG_88, VK_FORMAT_R8G8_UNORM, { 1, 0.5f, 0, 1 } },
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400952 { GrColorType::kAlpha_F16, VK_FORMAT_R16_SFLOAT, { 1.0f, 0, 0, 0.5f }},
953
Robert Phillips429f0d32019-09-11 17:03:28 -0400954 { GrColorType::kAlpha_16, VK_FORMAT_R16_UNORM, kTransCol },
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400955 { GrColorType::kRG_1616, VK_FORMAT_R16G16_UNORM, SkColors::kYellow },
Robert Phillipsb7f95d12019-07-26 11:13:19 -0400956 { GrColorType::kRGBA_16161616, VK_FORMAT_R16G16B16A16_UNORM, SkColors::kLtGray },
957 { GrColorType::kRG_F16, VK_FORMAT_R16G16_SFLOAT, SkColors::kYellow },
Robert Phillips0c6daf02019-05-16 12:43:11 -0400958 };
959
960 for (auto combo : combinations) {
Greg Daniel2f2caea2019-07-08 14:24:47 -0400961 if (!vkCaps->isVkFormatTexturable(combo.fFormat)) {
Robert Phillips0c6daf02019-05-16 12:43:11 -0400962 continue;
963 }
964
965 GrBackendFormat format = GrBackendFormat::MakeVk(combo.fFormat);
966
Brian Salomon7e67dca2020-07-21 09:27:25 -0400967 for (auto mipMapped : { GrMipmapped::kNo, GrMipmapped::kYes }) {
Brian Salomon69100f02020-07-21 10:49:25 -0400968 if (GrMipmapped::kYes == mipMapped && !vkCaps->mipmapSupport()) {
Robert Phillipsefb9f142019-05-17 14:19:44 -0400969 continue;
Robert Phillips0c6daf02019-05-16 12:43:11 -0400970 }
971
Robert Phillipsefb9f142019-05-17 14:19:44 -0400972 for (auto renderable : { GrRenderable::kNo, GrRenderable::kYes }) {
Robert Phillips0c6daf02019-05-16 12:43:11 -0400973
Robert Phillipsefb9f142019-05-17 14:19:44 -0400974 if (GrRenderable::kYes == renderable) {
Brian Salomon4eb38b72019-08-05 12:58:39 -0400975 // We must also check whether we allow rendering to the format using the
976 // color type.
Greg Daniel900583a2019-08-06 12:05:31 -0400977 if (!vkCaps->isFormatAsColorTypeRenderable(
978 combo.fColorType, GrBackendFormat::MakeVk(combo.fFormat), 1)) {
Brian Salomon4eb38b72019-08-05 12:58:39 -0400979 continue;
980 }
Robert Phillipsefb9f142019-05-17 14:19:44 -0400981 }
982
Robert Phillipsd34691b2019-09-24 13:38:43 -0400983 {
Robert Phillipsfe4b4812020-07-17 14:15:51 -0400984 auto uninitCreateMtd = [format](GrDirectContext* dContext,
Brian Salomon7e67dca2020-07-21 09:27:25 -0400985 GrMipmapped mipMapped,
Robert Phillips459b2952019-05-23 09:38:27 -0400986 GrRenderable renderable) {
Brian Salomon20f1b342020-12-15 20:23:03 -0500987 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
988 32, 32,
989 format,
990 mipMapped,
991 renderable,
992 GrProtected::kNo);
993 check_vk_layout(mbet->texture(), VkLayout::kUndefined);
994 return mbet;
Robert Phillipsb04b6942019-05-21 17:24:31 -0400995 };
Robert Phillipsefb9f142019-05-17 14:19:44 -0400996
Brian Salomon20f1b342020-12-15 20:23:03 -0500997 test_wrapping(context, reporter, uninitCreateMtd, combo.fColorType, mipMapped,
998 renderable);
Robert Phillipsb04b6942019-05-21 17:24:31 -0400999 }
Robert Phillips459b2952019-05-23 09:38:27 -04001000
Robert Phillips459b2952019-05-23 09:38:27 -04001001 {
Brian Salomonb450f3b2019-07-09 09:36:51 -04001002 // We're creating backend textures without specifying a color type "view" of
1003 // them at the public API level. Therefore, Ganesh will not apply any swizzles
1004 // before writing the color to the texture. However, our validation code does
1005 // rely on interpreting the texture contents via a SkColorType and therefore
1006 // swizzles may be applied during the read step.
1007 // Ideally we'd update our validation code to use a "raw" read that doesn't
1008 // impose a color type but for now we just munge the data we upload to match the
1009 // expectation.
1010 GrSwizzle swizzle;
1011 switch (combo.fColorType) {
Robert Phillipsb7f95d12019-07-26 11:13:19 -04001012 case GrColorType::kAlpha_8:
Brian Salomonb450f3b2019-07-09 09:36:51 -04001013 SkASSERT(combo.fFormat == VK_FORMAT_R8_UNORM);
1014 swizzle = GrSwizzle("aaaa");
1015 break;
Robert Phillips429f0d32019-09-11 17:03:28 -04001016 case GrColorType::kAlpha_16:
1017 SkASSERT(combo.fFormat == VK_FORMAT_R16_UNORM);
1018 swizzle = GrSwizzle("aaaa");
1019 break;
Robert Phillips17a3a0b2019-09-18 13:56:54 -04001020 case GrColorType::kAlpha_F16:
1021 SkASSERT(combo.fFormat == VK_FORMAT_R16_SFLOAT);
1022 swizzle = GrSwizzle("aaaa");
1023 break;
Robert Phillipsb7f95d12019-07-26 11:13:19 -04001024 case GrColorType::kABGR_4444:
Brian Salomonb450f3b2019-07-09 09:36:51 -04001025 if (combo.fFormat == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
1026 swizzle = GrSwizzle("bgra");
1027 }
1028 break;
1029 default:
1030 swizzle = GrSwizzle("rgba");
1031 break;
1032 }
Greg Danielc1ad77c2020-05-06 11:40:03 -04001033
Brian Salomon20f1b342020-12-15 20:23:03 -05001034 auto createWithColorMtd = [format, swizzle](GrDirectContext* dContext,
1035 const SkColor4f& color,
1036 GrMipmapped mipMapped,
1037 GrRenderable renderable) {
Brian Salomonb450f3b2019-07-09 09:36:51 -04001038 auto swizzledColor = swizzle.applyTo(color);
Brian Salomon20f1b342020-12-15 20:23:03 -05001039 auto mbet = ManagedBackendTexture::MakeWithData(dContext,
1040 32, 32,
1041 format,
1042 swizzledColor,
1043 mipMapped,
1044 renderable,
1045 GrProtected::kNo);
1046 check_vk_layout(mbet->texture(), VkLayout::kReadOnlyOptimal);
1047 return mbet;
Robert Phillips459b2952019-05-23 09:38:27 -04001048 };
Brian Salomon20f1b342020-12-15 20:23:03 -05001049 test_color_init(context, reporter, createWithColorMtd, combo.fColorType,
1050 combo.fColor, mipMapped, renderable);
Robert Phillips459b2952019-05-23 09:38:27 -04001051 }
Robert Phillipsefb9f142019-05-17 14:19:44 -04001052 }
Robert Phillips0c6daf02019-05-16 12:43:11 -04001053 }
1054 }
1055}
1056
1057#endif