1 /*
2 * Copyright 2015 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 #include "src/gpu/ganesh/GrCaps.h"
9
10 #include "include/core/SkColor.h"
11 #include "include/core/SkRect.h"
12 #include "include/core/SkSize.h"
13 #include "include/gpu/GpuTypes.h"
14 #include "include/gpu/GrBackendSurface.h"
15 #include "include/gpu/GrContextOptions.h"
16 #include "include/private/base/SkDebug.h"
17 #include "include/private/gpu/ganesh/GrTypesPriv.h"
18 #include "src/core/SkCompressedDataUtils.h"
19 #include "src/gpu/ganesh/GrBackendUtils.h"
20 #include "src/gpu/ganesh/GrRenderTargetProxy.h"
21 #include "src/gpu/ganesh/GrSurface.h"
22 #include "src/gpu/ganesh/GrSurfaceProxy.h"
23 #include "src/gpu/ganesh/GrWindowRectangles.h"
24
GrCaps(const GrContextOptions & options)25 GrCaps::GrCaps(const GrContextOptions& options) {
26 fNPOTTextureTileSupport = false;
27 fMipmapSupport = false;
28 fAnisoSupport = false;
29 fReuseScratchTextures = true;
30 fReuseScratchBuffers = true;
31 fGpuTracingSupport = false;
32 fOversizedStencilSupport = false;
33 fTextureBarrierSupport = false;
34 fSampleLocationsSupport = false;
35 fDrawInstancedSupport = false;
36 fNativeDrawIndirectSupport = false;
37 fUseClientSideIndirectBuffers = false;
38 fConservativeRasterSupport = false;
39 fWireframeSupport = false;
40 fMSAAResolvesAutomatically = false;
41 fPreferDiscardableMSAAAttachment = false;
42 fUsePrimitiveRestart = false;
43 fPreferClientSideDynamicBuffers = false;
44 fPreferFullscreenClears = false;
45 fTwoSidedStencilRefsAndMasksMustMatch = false;
46 fMustClearUploadedBufferData = false;
47 fShouldInitializeTextures = false;
48 fBuffersAreInitiallyZero = false;
49 fSupportsAHardwareBufferImages = false;
50 fFenceSyncSupport = false;
51 fSemaphoreSupport = false;
52 fCrossContextTextureSupport = false;
53 fHalfFloatVertexAttributeSupport = false;
54 fDynamicStateArrayGeometryProcessorTextureSupport = false;
55 fPerformPartialClearsAsDraws = false;
56 fPerformColorClearsAsDraws = false;
57 fAvoidLargeIndexBufferDraws = false;
58 fPerformStencilClearsAsDraws = false;
59 fTransferFromBufferToTextureSupport = false;
60 fTransferFromSurfaceToBufferSupport = false;
61 fTransferFromBufferToBufferSupport = false;
62 fWritePixelsRowBytesSupport = false;
63 fTransferPixelsToRowBytesSupport = false;
64 fReadPixelsRowBytesSupport = false;
65 fShouldCollapseSrcOverToSrcWhenAble = false;
66 fMustSyncGpuDuringAbandon = true;
67 fDisableTessellationPathRenderer = false;
68
69 fBlendEquationSupport = kBasic_BlendEquationSupport;
70 fAdvBlendEqDisableFlags = 0;
71
72 fMapBufferFlags = kNone_MapFlags;
73
74 fMaxVertexAttributes = 0;
75 fMaxRenderTargetSize = 1;
76 fMaxPreferredRenderTargetSize = 1;
77 fMaxTextureSize = 1;
78 fMaxWindowRectangles = 0;
79 fInternalMultisampleCount = 0;
80
81 fSuppressPrints = options.fSuppressPrints;
82 #if GR_TEST_UTILS
83 fWireframeMode = options.fWireframeMode;
84 #else
85 fWireframeMode = false;
86 #endif
87 fBufferMapThreshold = options.fBufferMapThreshold;
88 fAvoidStencilBuffers = false;
89 fAvoidWritePixelsFastPath = false;
90 fNativeDrawIndexedIndirectIsBroken = false;
91 fAvoidReorderingRenderTasks = false;
92 fAvoidDithering = false;
93 fDisablePerspectiveSDFText = false;
94
95 fPreferVRAMUseOverFlushes = true;
96
97 // Default to true, allow older versions of OpenGL to disable explicitly
98 fClampToBorderSupport = true;
99
100 fDriverBugWorkarounds = options.fDriverBugWorkarounds;
101 }
102
finishInitialization(const GrContextOptions & options)103 void GrCaps::finishInitialization(const GrContextOptions& options) {
104 if (!fNativeDrawIndirectSupport) {
105 // We will implement indirect draws with a polyfill, so the commands need to reside in CPU
106 // memory.
107 fUseClientSideIndirectBuffers = true;
108 }
109
110 this->applyOptionsOverrides(options);
111
112 // Our render targets are always created with textures as the color attachment, hence this min:
113 fMaxRenderTargetSize = std::min(fMaxRenderTargetSize, fMaxTextureSize);
114 fMaxPreferredRenderTargetSize = std::min(fMaxPreferredRenderTargetSize, fMaxRenderTargetSize);
115
116 this->initSkCaps(this->shaderCaps());
117 }
118
applyOptionsOverrides(const GrContextOptions & options)119 void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
120 fShaderCaps->applyOptionsOverrides(options);
121 this->onApplyOptionsOverrides(options);
122 if (options.fDisableDriverCorrectnessWorkarounds) {
123 SkASSERT(!fDisableTessellationPathRenderer);
124 SkASSERT(!fAvoidStencilBuffers);
125 SkASSERT(!fAvoidWritePixelsFastPath);
126 SkASSERT(!fNativeDrawIndexedIndirectIsBroken);
127 SkASSERT(!fAdvBlendEqDisableFlags);
128 SkASSERT(!fPerformColorClearsAsDraws);
129 SkASSERT(!fPerformStencilClearsAsDraws);
130 // Don't check the partial-clear workaround, since that is a backend limitation, not a
131 // driver workaround (it just so happens the fallbacks are the same).
132 }
133 if (GrContextOptions::Enable::kNo == options.fUseDrawInsteadOfClear) {
134 fPerformColorClearsAsDraws = false;
135 fPerformStencilClearsAsDraws = false;
136 } else if (GrContextOptions::Enable::kYes == options.fUseDrawInsteadOfClear) {
137 fPerformColorClearsAsDraws = true;
138 fPerformStencilClearsAsDraws = true;
139 }
140
141 fMaxTextureSize = std::min(fMaxTextureSize, options.fMaxTextureSizeOverride);
142 #if GR_TEST_UTILS
143 if (options.fSuppressAdvancedBlendEquations) {
144 fBlendEquationSupport = kBasic_BlendEquationSupport;
145 }
146 if (options.fClearAllTextures) {
147 fShouldInitializeTextures = true;
148 }
149 if (options.fDisallowWriteAndTransferPixelRowBytes) {
150 fWritePixelsRowBytesSupport = false;
151 fTransferPixelsToRowBytesSupport = false;
152 }
153 #endif
154 if (options.fSuppressMipmapSupport) {
155 fMipmapSupport = false;
156 }
157
158 if (fMaxWindowRectangles > GrWindowRectangles::kMaxWindows) {
159 SkDebugf("WARNING: capping window rectangles at %i. HW advertises support for %i.\n",
160 GrWindowRectangles::kMaxWindows, fMaxWindowRectangles);
161 fMaxWindowRectangles = GrWindowRectangles::kMaxWindows;
162 }
163
164 fInternalMultisampleCount = options.fInternalMultisampleCount;
165
166 fAvoidStencilBuffers = options.fAvoidStencilBuffers;
167
168 fDriverBugWorkarounds.applyOverrides(options.fDriverBugWorkarounds);
169
170 if (options.fDisableTessellationPathRenderer) {
171 fDisableTessellationPathRenderer = true;
172 }
173 }
174
175
176 #ifdef SK_ENABLE_DUMP_GPU
177 #include "src/gpu/ganesh/GrTestUtils.h"
178 #include "src/utils/SkJSONWriter.h"
179
map_flags_to_string(uint32_t flags)180 static SkString map_flags_to_string(uint32_t flags) {
181 SkString str;
182 if (GrCaps::kNone_MapFlags == flags) {
183 str = "none";
184 } else {
185 SkASSERT(GrCaps::kCanMap_MapFlag & flags);
186 SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag);
187 str = "can_map";
188
189 if (GrCaps::kSubset_MapFlag & flags) {
190 str.append(" partial");
191 } else {
192 str.append(" full");
193 }
194 SkDEBUGCODE(flags &= ~GrCaps::kSubset_MapFlag);
195 if (GrCaps::kAsyncRead_MapFlag & flags) {
196 str.append(" async_read");
197 } else {
198 str.append(" sync_read");
199 }
200 SkDEBUGCODE(flags &= ~GrCaps::kAsyncRead_MapFlag);
201 }
202 SkASSERT(0 == flags); // Make sure we handled all the flags.
203 return str;
204 }
205
dumpJSON(SkJSONWriter * writer) const206 void GrCaps::dumpJSON(SkJSONWriter* writer) const {
207 writer->beginObject();
208
209 writer->appendBool("NPOT Texture Tile Support", fNPOTTextureTileSupport);
210 writer->appendBool("MIP Map Support", fMipmapSupport);
211 writer->appendBool("Aniso Support", fAnisoSupport);
212 writer->appendBool("Reuse Scratch Textures", fReuseScratchTextures);
213 writer->appendBool("Reuse Scratch Buffers", fReuseScratchBuffers);
214 writer->appendBool("Gpu Tracing Support", fGpuTracingSupport);
215 writer->appendBool("Oversized Stencil Support", fOversizedStencilSupport);
216 writer->appendBool("Texture Barrier Support", fTextureBarrierSupport);
217 writer->appendBool("Sample Locations Support", fSampleLocationsSupport);
218 writer->appendBool("Draw Instanced Support", fDrawInstancedSupport);
219 writer->appendBool("Native Draw Indirect Support", fNativeDrawIndirectSupport);
220 writer->appendBool("Use client side indirect buffers", fUseClientSideIndirectBuffers);
221 writer->appendBool("Conservative Raster Support", fConservativeRasterSupport);
222 writer->appendBool("Wireframe Support", fWireframeSupport);
223 writer->appendBool("MSAA Resolves Automatically", fMSAAResolvesAutomatically);
224 writer->appendBool("Use primitive restart", fUsePrimitiveRestart);
225 writer->appendBool("Prefer client-side dynamic buffers", fPreferClientSideDynamicBuffers);
226 writer->appendBool("Prefer fullscreen clears (and stencil discard)", fPreferFullscreenClears);
227 writer->appendBool("Two-sided Stencil Refs And Masks Must Match",
228 fTwoSidedStencilRefsAndMasksMustMatch);
229 writer->appendBool("Must clear buffer memory", fMustClearUploadedBufferData);
230 writer->appendBool("Should initialize textures", fShouldInitializeTextures);
231 writer->appendBool("Buffers are initially zero", fBuffersAreInitiallyZero);
232 writer->appendBool("Supports importing AHardwareBuffers", fSupportsAHardwareBufferImages);
233 writer->appendBool("Fence sync support", fFenceSyncSupport);
234 writer->appendBool("Semaphore support", fSemaphoreSupport);
235 writer->appendBool("Cross context texture support", fCrossContextTextureSupport);
236 writer->appendBool("Half float vertex attribute support", fHalfFloatVertexAttributeSupport);
237 writer->appendBool("Specify GeometryProcessor textures as a dynamic state array",
238 fDynamicStateArrayGeometryProcessorTextureSupport);
239 writer->appendBool("Use draws for partial clears", fPerformPartialClearsAsDraws);
240 writer->appendBool("Use draws for color clears", fPerformColorClearsAsDraws);
241 writer->appendBool("Avoid Large IndexBuffer Draws", fAvoidLargeIndexBufferDraws);
242 writer->appendBool("Use draws for stencil clip clears", fPerformStencilClearsAsDraws);
243 writer->appendBool("Supports transfers from buffers to textures",
244 fTransferFromBufferToTextureSupport);
245 writer->appendBool("Supports transfers from textures to buffers",
246 fTransferFromSurfaceToBufferSupport);
247 writer->appendBool("Write pixels row bytes support", fWritePixelsRowBytesSupport);
248 writer->appendBool("Transfer pixels to row bytes support", fTransferPixelsToRowBytesSupport);
249 writer->appendBool("Read pixels row bytes support", fReadPixelsRowBytesSupport);
250 writer->appendBool("Disable TessellationPathRenderer current driver [workaround]",
251 fDisableTessellationPathRenderer);
252 writer->appendBool("Clamp-to-border", fClampToBorderSupport);
253
254 writer->appendBool("Prefer VRAM Use over flushes [workaround]", fPreferVRAMUseOverFlushes);
255 writer->appendBool("Avoid stencil buffers [workaround]", fAvoidStencilBuffers);
256 writer->appendBool("Avoid writePixels fast path [workaround]", fAvoidWritePixelsFastPath);
257 writer->appendBool("Native draw indexed indirect is broken [workaround]",
258 fNativeDrawIndexedIndirectIsBroken);
259 writer->appendBool("Avoid DAG reordering [workaround]", fAvoidReorderingRenderTasks);
260 writer->appendBool("Avoid Dithering [workaround]", fAvoidDithering);
261 writer->appendBool("Disable perspective SDF Text [workaround]", fDisablePerspectiveSDFText);
262
263 if (this->advancedBlendEquationSupport()) {
264 writer->appendHexU32("Advanced Blend Equation Disable Flags", fAdvBlendEqDisableFlags);
265 }
266
267 writer->appendS32("Max Vertex Attributes", fMaxVertexAttributes);
268 writer->appendS32("Max Texture Size", fMaxTextureSize);
269 writer->appendS32("Max Render Target Size", fMaxRenderTargetSize);
270 writer->appendS32("Max Preferred Render Target Size", fMaxPreferredRenderTargetSize);
271 writer->appendS32("Max Window Rectangles", fMaxWindowRectangles);
272 writer->appendS32("Sample Count for Internal MSAA", fInternalMultisampleCount);
273
274 static const char* kBlendEquationSupportNames[] = {
275 "Basic",
276 "Advanced",
277 "Advanced Coherent",
278 };
279 static_assert(0 == kBasic_BlendEquationSupport);
280 static_assert(1 == kAdvanced_BlendEquationSupport);
281 static_assert(2 == kAdvancedCoherent_BlendEquationSupport);
282 static_assert(std::size(kBlendEquationSupportNames) == kLast_BlendEquationSupport + 1);
283
284 writer->appendCString("Blend Equation Support",
285 kBlendEquationSupportNames[fBlendEquationSupport]);
286 writer->appendString("Map Buffer Support", map_flags_to_string(fMapBufferFlags));
287
288 this->onDumpJSON(writer);
289
290 writer->appendName("shaderCaps");
291 this->shaderCaps()->dumpJSON(writer);
292
293 writer->endObject();
294 }
295 #else
dumpJSON(SkJSONWriter * writer) const296 void GrCaps::dumpJSON(SkJSONWriter* writer) const { }
297 #endif
298
surfaceSupportsWritePixels(const GrSurface * surface) const299 bool GrCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
300 return surface->readOnly() ? false : this->onSurfaceSupportsWritePixels(surface);
301 }
302
canCopySurface(const GrSurfaceProxy * dst,const SkIRect & dstRect,const GrSurfaceProxy * src,const SkIRect & srcRect) const303 bool GrCaps::canCopySurface(const GrSurfaceProxy* dst, const SkIRect& dstRect,
304 const GrSurfaceProxy* src, const SkIRect& srcRect) const {
305 if (dst->readOnly()) {
306 return false;
307 }
308
309 if (dst->backendFormat() != src->backendFormat()) {
310 return false;
311 }
312 // For simplicity, all GrGpu::copySurface() calls can assume that srcRect and dstRect
313 // are already contained within their respective surfaces.
314 if (!SkIRect::MakeSize(dst->dimensions()).contains(dstRect) ||
315 !SkIRect::MakeSize(src->dimensions()).contains(srcRect)) {
316 return false;
317 }
318 return this->onCanCopySurface(dst, dstRect, src, srcRect);
319 }
320
validateSurfaceParams(const SkISize & dimensions,const GrBackendFormat & format,GrRenderable renderable,int renderTargetSampleCnt,skgpu::Mipmapped mipped,GrTextureType textureType) const321 bool GrCaps::validateSurfaceParams(const SkISize& dimensions, const GrBackendFormat& format,
322 GrRenderable renderable, int renderTargetSampleCnt,
323 skgpu::Mipmapped mipped, GrTextureType textureType) const {
324 if (textureType != GrTextureType::kNone) {
325 if (!this->isFormatTexturable(format, textureType)) {
326 return false;
327 }
328 }
329
330 if (skgpu::Mipmapped::kYes == mipped && !this->mipmapSupport()) {
331 return false;
332 }
333
334 if (dimensions.width() < 1 || dimensions.height() < 1) {
335 return false;
336 }
337
338 if (renderable == GrRenderable::kYes) {
339 if (!this->isFormatRenderable(format, renderTargetSampleCnt)) {
340 return false;
341 }
342 int maxRTSize = this->maxRenderTargetSize();
343 if (dimensions.width() > maxRTSize || dimensions.height() > maxRTSize) {
344 return false;
345 }
346 } else {
347 // We currently do not support multisampled textures
348 if (renderTargetSampleCnt != 1) {
349 return false;
350 }
351 int maxSize = this->maxTextureSize();
352 if (dimensions.width() > maxSize || dimensions.height() > maxSize) {
353 return false;
354 }
355 }
356
357 return true;
358 }
359
supportedReadPixelsColorType(GrColorType srcColorType,const GrBackendFormat & srcFormat,GrColorType dstColorType) const360 GrCaps::SupportedRead GrCaps::supportedReadPixelsColorType(GrColorType srcColorType,
361 const GrBackendFormat& srcFormat,
362 GrColorType dstColorType) const {
363 SupportedRead read = this->onSupportedReadPixelsColorType(srcColorType, srcFormat,
364 dstColorType);
365
366 // There are known problems with 24 vs 32 bit BPP with this color type. Just fail for now if
367 // using a transfer buffer.
368 if (GrColorType::kRGB_888x == read.fColorType) {
369 read.fOffsetAlignmentForTransferBuffer = 0;
370 }
371 // It's very convenient to access 1 byte-per-channel 32 bit color types as uint32_t on the CPU.
372 // Make those aligned reads out of the buffer even if the underlying API doesn't require it.
373 auto channelFlags = GrColorTypeChannelFlags(read.fColorType);
374 if ((channelFlags == kRGBA_SkColorChannelFlags || channelFlags == kRGB_SkColorChannelFlags ||
375 channelFlags == kAlpha_SkColorChannelFlag || channelFlags == kGray_SkColorChannelFlag) &&
376 GrColorTypeBytesPerPixel(read.fColorType) == 4) {
377 switch (read.fOffsetAlignmentForTransferBuffer & 0b11) {
378 // offset alignment already a multiple of 4
379 case 0:
380 break;
381 // offset alignment is a multiple of 2 but not 4.
382 case 2:
383 read.fOffsetAlignmentForTransferBuffer *= 2;
384 break;
385 // offset alignment is not a multiple of 2.
386 default:
387 read.fOffsetAlignmentForTransferBuffer *= 4;
388 break;
389 }
390 }
391 return read;
392 }
393
getDefaultBackendFormat(GrColorType colorType,GrRenderable renderable) const394 GrBackendFormat GrCaps::getDefaultBackendFormat(GrColorType colorType,
395 GrRenderable renderable) const {
396 // Unknown color types are always an invalid format, so early out before calling virtual.
397 if (colorType == GrColorType::kUnknown) {
398 return {};
399 }
400
401 auto format = this->onGetDefaultBackendFormat(colorType);
402 if (!this->isFormatTexturable(format, GrTextureType::k2D)) {
403 return {};
404 }
405 if (!this->areColorTypeAndFormatCompatible(colorType, format)) {
406 return {};
407 }
408 // Currently we require that it be possible to write pixels into the "default" format. Perhaps,
409 // that could be a separate requirement from the caller. It seems less necessary if
410 // renderability was requested.
411 if (this->supportedWritePixelsColorType(colorType, format, colorType).fColorType ==
412 GrColorType::kUnknown) {
413 return {};
414 }
415 if (renderable == GrRenderable::kYes &&
416 !this->isFormatAsColorTypeRenderable(colorType, format)) {
417 return {};
418 }
419 return format;
420 }
421
areColorTypeAndFormatCompatible(GrColorType grCT,const GrBackendFormat & format) const422 bool GrCaps::areColorTypeAndFormatCompatible(GrColorType grCT,
423 const GrBackendFormat& format) const {
424 if (GrColorType::kUnknown == grCT) {
425 return false;
426 }
427
428 SkImage::CompressionType compression = GrBackendFormatToCompressionType(format);
429 if (compression != SkImage::CompressionType::kNone) {
430 return grCT == (SkCompressionTypeIsOpaque(compression) ? GrColorType::kRGB_888x
431 : GrColorType::kRGBA_8888);
432 }
433
434 return this->onAreColorTypeAndFormatCompatible(grCT, format);
435 }
436
getReadSwizzle(const GrBackendFormat & format,GrColorType colorType) const437 skgpu::Swizzle GrCaps::getReadSwizzle(const GrBackendFormat& format, GrColorType colorType) const {
438 SkImage::CompressionType compression = GrBackendFormatToCompressionType(format);
439 if (compression != SkImage::CompressionType::kNone) {
440 if (colorType == GrColorType::kRGB_888x || colorType == GrColorType::kRGBA_8888) {
441 return skgpu::Swizzle::RGBA();
442 }
443 SkDEBUGFAILF("Illegal color type (%d) and compressed format (%d) combination.",
444 (int)colorType, (int)compression);
445 return {};
446 }
447
448 return this->onGetReadSwizzle(format, colorType);
449 }
450
isFormatCompressed(const GrBackendFormat & format) const451 bool GrCaps::isFormatCompressed(const GrBackendFormat& format) const {
452 return GrBackendFormatToCompressionType(format) != SkImage::CompressionType::kNone;
453 }
454
getDstSampleFlagsForProxy(const GrRenderTargetProxy * rt,bool drawUsesMSAA) const455 GrDstSampleFlags GrCaps::getDstSampleFlagsForProxy(const GrRenderTargetProxy* rt,
456 bool drawUsesMSAA) const {
457 SkASSERT(rt);
458 if (this->textureBarrierSupport() && (!drawUsesMSAA || this->msaaResolvesAutomatically())) {
459 return this->onGetDstSampleFlagsForProxy(rt);
460 }
461 return GrDstSampleFlags::kNone;
462 }
463
supportsDynamicMSAA(const GrRenderTargetProxy * rtProxy) const464 bool GrCaps::supportsDynamicMSAA(const GrRenderTargetProxy* rtProxy) const {
465 return rtProxy->numSamples() == 1 &&
466 this->internalMultisampleCount(rtProxy->backendFormat()) > 1 &&
467 this->onSupportsDynamicMSAA(rtProxy);
468 }
469
color_type_fallback(GrColorType ct)470 static inline GrColorType color_type_fallback(GrColorType ct) {
471 switch (ct) {
472 // kRGBA_8888 is our default fallback for many color types that may not have renderable
473 // backend formats.
474 case GrColorType::kAlpha_8:
475 case GrColorType::kBGR_565:
476 case GrColorType::kABGR_4444:
477 case GrColorType::kBGRA_8888:
478 case GrColorType::kRGBA_1010102:
479 case GrColorType::kBGRA_1010102:
480 case GrColorType::kRGBA_F16:
481 case GrColorType::kRGBA_F16_Clamped:
482 return GrColorType::kRGBA_8888;
483 case GrColorType::kAlpha_F16:
484 return GrColorType::kRGBA_F16;
485 case GrColorType::kGray_8:
486 return GrColorType::kRGB_888x;
487 default:
488 return GrColorType::kUnknown;
489 }
490 }
491
getFallbackColorTypeAndFormat(GrColorType ct,int sampleCnt) const492 std::tuple<GrColorType, GrBackendFormat> GrCaps::getFallbackColorTypeAndFormat(
493 GrColorType ct,
494 int sampleCnt) const {
495 do {
496 auto format = this->getDefaultBackendFormat(ct, GrRenderable::kYes);
497 // We continue to the fallback color type if there no default renderable format or we
498 // requested msaa and the format doesn't support msaa.
499 if (format.isValid() && this->isFormatRenderable(format, sampleCnt)) {
500 return {ct, format};
501 }
502 ct = color_type_fallback(ct);
503 } while (ct != GrColorType::kUnknown);
504 return {GrColorType::kUnknown, {}};
505 }
506