Revert "Remove GrCaps::SupportedRead::fSwizzle and supporting code"

This reverts commit 1cec69ae5cdc2c183f6a2115d60ebdf796a89a92.

Reason for revert: Causing Valgrind failures

Original change's description:
> Remove GrCaps::SupportedRead::fSwizzle and supporting code
> 
> Add weird color types that handle the swizzling.
> 
> Change-Id: Ie37a00eb877fe5e519f7498bf749e02a2f1dc204
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230135
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,bsalomon@google.com

Change-Id: I710e1952f2cef1a1e6e7ccf408b8a71ce721c002
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/231262
Reviewed-by: Ben Wagner aka dogben <benjaminwagner@google.com>
Commit-Queue: Ben Wagner aka dogben <benjaminwagner@google.com>
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 85be494..fd08219 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -1150,14 +1150,6 @@
     kRGBA_F16_Clamped,
     kRGBA_F32,
 
-    // Unusual formats that come up after reading back in cases where we are reassigning the meaning
-    // of a texture format's channels to use for a particular color format but have to read back the
-    // data to a full RGBA quadruple. (e.g. using a R8 texture format as A8 color type but the API
-    // only supports reading to RGBA8.) None of these have SkColorType equivalents.
-    kAlpha_8xxx,
-    kAlpha_F32xxx,
-    kGray_8xxx,
-
     kR_16,          // Not in SkColorType
     kRG_1616,       // Not in SkColorType
 
@@ -1188,9 +1180,6 @@
         case GrColorType::kRGBA_F16:         return kRGBA_F16_SkColorType;
         case GrColorType::kRGBA_F16_Clamped: return kRGBA_F16Norm_SkColorType;
         case GrColorType::kRGBA_F32:         return kRGBA_F32_SkColorType;
-        case GrColorType::kAlpha_8xxx:       return kUnknown_SkColorType;
-        case GrColorType::kAlpha_F32xxx:     return kUnknown_SkColorType;
-        case GrColorType::kGray_8xxx:        return kUnknown_SkColorType;
         case GrColorType::kR_16:             return kUnknown_SkColorType;
         case GrColorType::kRG_1616:          return kUnknown_SkColorType;
         // Experimental (for Y416 and mutant P016/P010)
@@ -1243,9 +1232,6 @@
         case GrColorType::kRGBA_F16:         return kRGBA_SkColorTypeComponentFlags;
         case GrColorType::kRGBA_F16_Clamped: return kRGBA_SkColorTypeComponentFlags;
         case GrColorType::kRGBA_F32:         return kRGBA_SkColorTypeComponentFlags;
-        case GrColorType::kAlpha_8xxx:       return kAlpha_SkColorTypeComponentFlag;
-        case GrColorType::kAlpha_F32xxx:     return kAlpha_SkColorTypeComponentFlag;
-        case GrColorType::kGray_8xxx:        return kGray_SkColorTypeComponentFlag;
         case GrColorType::kR_16:             return kRed_SkColorTypeComponentFlag;
         case GrColorType::kRG_1616:          return kRed_SkColorTypeComponentFlag |
                                                     kGreen_SkColorTypeComponentFlag;
@@ -1378,12 +1364,6 @@
             return GrColorTypeDesc::MakeRGBA(16, GrColorTypeEncoding::kFloat);
         case GrColorType::kRGBA_F32:
             return GrColorTypeDesc::MakeRGBA(32, GrColorTypeEncoding::kFloat);
-        case GrColorType::kAlpha_8xxx:
-            return GrColorTypeDesc::MakeAlpha(8, GrColorTypeEncoding::kUnorm);
-        case GrColorType::kAlpha_F32xxx:
-            return GrColorTypeDesc::MakeAlpha(32, GrColorTypeEncoding::kFloat);
-        case GrColorType::kGray_8xxx:
-            return GrColorTypeDesc::MakeGray(8, GrColorTypeEncoding::kUnorm);
         case GrColorType::kR_16:
             return GrColorTypeDesc::MakeR(16, GrColorTypeEncoding::kUnorm);
         case GrColorType::kRG_1616:
@@ -1441,9 +1421,6 @@
         case GrColorType::kRGBA_F16:         return 8;
         case GrColorType::kRGBA_F16_Clamped: return 8;
         case GrColorType::kRGBA_F32:         return 16;
-        case GrColorType::kAlpha_8xxx:       return 4;
-        case GrColorType::kAlpha_F32xxx:     return 16;
-        case GrColorType::kGray_8xxx:        return 4;
         case GrColorType::kR_16:             return 2;
         case GrColorType::kRG_1616:          return 4;
         // Experimental (for Y416 and mutant P016/P010)
@@ -1541,9 +1518,6 @@
         case GrColorType::kAlpha_F16:        return kAlpha_half_GrPixelConfig;
         case GrColorType::kRGBA_F16:         return kRGBA_half_GrPixelConfig;
         case GrColorType::kRGBA_F16_Clamped: return kRGBA_half_Clamped_GrPixelConfig;
-        case GrColorType::kAlpha_8xxx:       return kUnknown_GrPixelConfig;
-        case GrColorType::kAlpha_F32xxx:     return kUnknown_GrPixelConfig;
-        case GrColorType::kGray_8xxx:        return kUnknown_GrPixelConfig;
         case GrColorType::kR_16:             return kR_16_GrPixelConfig;
         case GrColorType::kRG_1616:          return kRG_1616_GrPixelConfig;
 
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index a66b391..32714b8 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -361,13 +361,11 @@
     if (GrColorType::kRGB_888x == read.fColorType) {
         read.fOffsetAlignmentForTransferBuffer = 0;
     }
-    // It's very convenient to access 1 byte-per-channel 32 bit color types as uint32_t on the CPU.
+    // It's very convenient to access 1 byte-per-channel 32 bitvRGB/RGBA color types as uint32_t.
     // Make those aligned reads out of the buffer even if the underlying API doesn't require it.
     auto componentFlags = GrColorTypeComponentFlags(read.fColorType);
     if ((componentFlags == kRGBA_SkColorTypeComponentFlags ||
-         componentFlags == kRGB_SkColorTypeComponentFlags  ||
-         componentFlags == kAlpha_SkColorTypeComponentFlag ||
-         componentFlags == kGray_SkColorTypeComponentFlag) &&
+         componentFlags == kRGB_SkColorTypeComponentFlags) &&
         GrColorTypeBytesPerPixel(read.fColorType) == 4) {
         switch (read.fOffsetAlignmentForTransferBuffer & 0b11) {
             // offset alignment already a multiple of 4
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 19a993e..61df9db 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -237,6 +237,7 @@
                                                          GrColorType srcColorType) const = 0;
 
     struct SupportedRead {
+        GrSwizzle fSwizzle;
         GrColorType fColorType;
         // If the read is occurring using GrGpu::transferPixelsFrom then this provides the
         // minimum alignment of the offset into the transfer buffer.
diff --git a/src/gpu/GrDataUtils.cpp b/src/gpu/GrDataUtils.cpp
index 45d2ff8..a36a271 100644
--- a/src/gpu/GrDataUtils.cpp
+++ b/src/gpu/GrDataUtils.cpp
@@ -390,15 +390,6 @@
         case GrColorType::kRGBA_F32:         *load = SkRasterPipeline::load_f32;
                                              *isNormalized = false;
                                              break;
-        case GrColorType::kAlpha_8xxx:       *load = SkRasterPipeline::load_8888;
-                                             swizzle = GrSwizzle("000r");
-                                             break;
-        case GrColorType::kAlpha_F32xxx:     *load = SkRasterPipeline::load_f32;
-                                             swizzle = GrSwizzle("000r");
-                                             break;
-        case GrColorType::kGray_8xxx:       *load = SkRasterPipeline::load_8888;
-                                             swizzle = GrSwizzle("rrr1");
-                                             break;
         case GrColorType::kR_16:             *load = SkRasterPipeline::load_a16;
                                              swizzle = GrSwizzle("a001");
                                              break;
@@ -449,12 +440,6 @@
         case GrColorType::kRGBA_F32:         *store = SkRasterPipeline::store_f32;
                                              *isNormalized = false;
                                              break;
-        case GrColorType::kAlpha_8xxx:       *store = SkRasterPipeline::store_8888;
-                                             swizzle = GrSwizzle("a000");
-                                             break;
-        case GrColorType::kAlpha_F32xxx:     *store = SkRasterPipeline::store_f32;
-                                             swizzle = GrSwizzle("a000");
-                                             break;
         case GrColorType::kR_16:             swizzle = GrSwizzle("000r");
                                              *store = SkRasterPipeline::store_a16;
                                              break;
@@ -466,7 +451,6 @@
                                              break;
 
         case GrColorType::kGray_8:  // not currently supported as output
-        case GrColorType::kGray_8xxx:  // not currently supported as output
         case GrColorType::kUnknown:
             SK_ABORT("unexpected CT");
     }
@@ -482,7 +466,7 @@
 
 bool GrConvertPixels(const GrPixelInfo& dstInfo,       void* dst, size_t dstRB,
                      const GrPixelInfo& srcInfo, const void* src, size_t srcRB,
-                     bool flipY) {
+                     bool flipY, GrSwizzle swizzle) {
     TRACE_EVENT0("skia.gpu", TRACE_FUNC);
     if (!srcInfo.isValid() || !dstInfo.isValid()) {
         return false;
@@ -513,6 +497,7 @@
     bool srcIsSRGB;
     auto loadSwizzle = get_load_and_get_swizzle(srcInfo.colorType(), &load, &srcIsNormalized,
                                                 &srcIsSRGB);
+    loadSwizzle = GrSwizzle::Concat(loadSwizzle, swizzle);
 
     SkRasterPipeline::StockStage store;
     bool dstIsNormalized;
@@ -598,6 +583,7 @@
     return true;
 }
 
+
 GrColorType SkColorTypeAndFormatToGrColorType(const GrCaps* caps,
                                               SkColorType skCT,
                                               const GrBackendFormat& format) {
diff --git a/src/gpu/GrDataUtils.h b/src/gpu/GrDataUtils.h
index c72feb7..5417ac9 100644
--- a/src/gpu/GrDataUtils.h
+++ b/src/gpu/GrDataUtils.h
@@ -107,6 +107,6 @@
 // Swizzle param is applied after loading and before converting from srcInfo to dstInfo.
 bool GrConvertPixels(const GrPixelInfo& dstInfo,       void* dst, size_t dstRB,
                      const GrPixelInfo& srcInfo, const void* src, size_t srcRB,
-                     bool flipY = false);
+                     bool flipY = false, GrSwizzle swizzle = GrSwizzle{});
 
 #endif
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 630fea3..15dad7a 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -180,7 +180,8 @@
     bool makeTight = !caps->readPixelsRowBytesSupport() && tightRowBytes != rowBytes;
 
     bool convert = unpremul || premul || needColorConversion || flip || makeTight ||
-                   (dstInfo.colorType() != supportedRead.fColorType);
+                   (dstInfo.colorType() != supportedRead.fColorType) ||
+                   supportedRead.fSwizzle != GrSwizzle::RGBA();
 
     std::unique_ptr<char[]> tmpPixels;
     GrPixelInfo tmpInfo;
@@ -208,7 +209,8 @@
     }
 
     if (convert) {
-        return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, readDst, readRB, flip);
+        return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, readDst, readRB, flip,
+                               supportedRead.fSwizzle);
     }
     return true;
 }
@@ -627,14 +629,14 @@
     PixelTransferResult result;
     result.fTransferBuffer = std::move(buffer);
     auto at = this->colorSpaceInfo().alphaType();
-    if (supportedRead.fColorType != dstCT || flip) {
+    if (supportedRead.fColorType != dstCT || supportedRead.fSwizzle != GrSwizzle("rgba") || flip) {
         result.fPixelConverter = [w = rect.width(), h = rect.height(), dstCT, supportedRead, at](
                 void* dst, const void* src) {
               GrPixelInfo srcInfo(supportedRead.fColorType, at, nullptr, w, h);
               GrPixelInfo dstInfo(dstCT,                    at, nullptr, w, h);
               GrConvertPixels(dstInfo, dst, dstInfo.minRowBytes(),
                               srcInfo, src, srcInfo.minRowBytes(),
-                              /* flipY = */ false);
+                              /* flipY = */ false, supportedRead.fSwizzle);
         };
     }
     return result;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 668448b..09a93a2 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -308,9 +308,6 @@
         case GrColorType::kRGBA_F16:
         case GrColorType::kRGBA_F16_Clamped:
         case GrColorType::kAlpha_8:
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
             return -1;
     }
     SkUNREACHABLE;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 20320be..529e5a4 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -1590,13 +1590,14 @@
                     ioFormat.fExternalReadFormat = 0;
                 }
 
-                // Format: R8, Surface: kAlpha_8, Data: kAlpha_8xxx
+                // Format: R8, Surface: kAlpha_8, Data: kRGBA_8888
                 {
                     auto& ioFormat = ctInfo.fExternalIOFormats[ioIdx++];
-                    ioFormat.fColorType = GrColorType::kAlpha_8xxx;
+                    ioFormat.fColorType = GrColorType::kRGBA_8888;
                     ioFormat.fExternalType = GR_GL_UNSIGNED_BYTE;
                     ioFormat.fExternalTexImageFormat = 0;
                     ioFormat.fExternalReadFormat = GR_GL_RGBA;
+                    ioFormat.fReadSwizzle = GrSwizzle("000r");
                 }
             }
 
@@ -1621,13 +1622,14 @@
                     ioFormat.fExternalReadFormat = 0;
                 }
 
-                // Format: R8, Surface: kGray_8, Data: kGray_8xxx
+                // Format: R8, Surface: kGray_8, Data: kRGBA_8888
                 {
                     auto& ioFormat = ctInfo.fExternalIOFormats[ioIdx++];
-                    ioFormat.fColorType = GrColorType::kGray_8xxx;
+                    ioFormat.fColorType = GrColorType::kRGBA_8888;
                     ioFormat.fExternalType = GR_GL_UNSIGNED_BYTE;
                     ioFormat.fExternalTexImageFormat = 0;
                     ioFormat.fExternalReadFormat = GR_GL_RGBA;
+                    ioFormat.fReadSwizzle = GrSwizzle("rrr1");
                 }
             }
         }
@@ -1702,6 +1704,7 @@
                         ioFormat.fExternalType = GR_GL_UNSIGNED_BYTE;
                         ioFormat.fExternalTexImageFormat = 0;
                         ioFormat.fExternalReadFormat = GR_GL_RGBA;
+                        ioFormat.fReadSwizzle = GrSwizzle("000a");
                     }
                 }
             }
@@ -2100,13 +2103,14 @@
                     ioFormat.fExternalReadFormat = 0;
                 }
 
-                // Format: R16F, Surface: kAlpha_F16, Data: kAlpha_F32xxx
+                // Format: R16F, Surface: kAlpha_F16, Data: kRGBA_F32
                 {
                     auto& ioFormat = ctInfo.fExternalIOFormats[ioIdx++];
-                    ioFormat.fColorType = GrColorType::kAlpha_F32xxx;
+                    ioFormat.fColorType = GrColorType::kRGBA_F32;
                     ioFormat.fExternalType = GR_GL_FLOAT;
                     ioFormat.fExternalTexImageFormat = 0;
                     ioFormat.fExternalReadFormat = GR_GL_RGBA;
+                    ioFormat.fReadSwizzle = GrSwizzle("000r");
                 }
             }
         }
@@ -3684,12 +3688,12 @@
     // this as makes sense to increase performance and correctness.
     GrGLFormat srcFormat = GrGLBackendFormatToGLFormat(srcBackendFormat);
     if (srcFormat == GrGLFormat::kUnknown) {
-        return {GrColorType::kUnknown, 0};
+        return {GrSwizzle{}, GrColorType::kUnknown, 0};
     }
 
     // We first try to find a supported read pixels GrColorType that matches the requested
     // dstColorType. If that doesn't exists we will use any valid read pixels GrColorType.
-    GrCaps::SupportedRead fallbackRead = {GrColorType::kUnknown, 0};
+    GrCaps::SupportedRead fallbackRead = {GrSwizzle{}, GrColorType::kUnknown, 0};
     const auto& formatInfo = this->getFormatInfo(srcFormat);
     bool foundSrcCT = false;
     for (int i = 0; !foundSrcCT && i < formatInfo.fColorTypeInfoCount; ++i) {
@@ -3702,12 +3706,13 @@
                     GrGLenum transferOffsetAlignment =
                             offset_alignment_for_transfer_buffer(ioInfo.fExternalType);
                     if (ioInfo.fColorType == dstColorType) {
-                        return {dstColorType, transferOffsetAlignment};
+                        return {ioInfo.fReadSwizzle, dstColorType, transferOffsetAlignment};
                     }
                     // Currently we just pick the first supported format that we find as our
                     // fallback.
                     if (fallbackRead.fColorType == GrColorType::kUnknown) {
-                        fallbackRead = {ioInfo.fColorType, transferOffsetAlignment};
+                        fallbackRead = {ioInfo.fReadSwizzle, ioInfo.fColorType,
+                                        transferOffsetAlignment};
                     }
                 }
             }
@@ -3996,12 +4001,6 @@
                 return kRG_half_GrPixelConfig;
             }
             break;
-
-        // These have no equivalent config:
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
-            break;
     }
 
     SkDebugf("Unknown pixel config 0x%x\n", format);
@@ -4075,7 +4074,7 @@
 bool GrGLCaps::canClearTextureOnCreation() const { return fClearTextureSupport; }
 
 #ifdef SK_DEBUG
-static constexpr bool format_color_type_valid_pair(GrGLenum format, GrColorType colorType) {
+static bool format_color_type_valid_pair(GrGLenum format, GrColorType colorType) {
     switch (colorType) {
         case GrColorType::kUnknown:
             return false;
@@ -4120,13 +4119,9 @@
         case GrColorType::kRG_F16:
             return GR_GL_RG16F == format;
 
-        // These have no equivalent config:
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
-            return false;
     }
-    SkUNREACHABLE;
+    SK_ABORT("Unknown color type");
+    return false;
 }
 #endif
 
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 64be61a..57bd50e 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -611,6 +611,10 @@
             GrGLenum fExternalType = 0;
             GrGLenum fExternalTexImageFormat = 0;
             GrGLenum fExternalReadFormat = 0;
+
+            // This is the swizzle to apply to the data after it is read back using the
+            // fExternalReadFormat so that the data is in the form expected by fColorType.
+            GrSwizzle fReadSwizzle = GrSwizzle::RGBA();
         };
 
         GrGLenum externalFormat(GrColorType externalColorType, ExternalFormatUsage usage) const {
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index 23a47a4..3f4e5a0 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -184,7 +184,7 @@
 
     SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType, const GrBackendFormat&,
                                                  GrColorType) const override {
-        return SupportedRead{srcColorType, 1};
+        return SupportedRead{GrSwizzle::RGBA(), srcColorType, 1};
     }
 
     static const int kMaxSampleCnt = 16;
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 1b7e30d..56ad7e8 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -599,7 +599,7 @@
 }
 
 // A near clone of format_color_type_valid_pair
-static constexpr GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat, GrColorType ct) {
+GrPixelConfig validate_sized_format(GrMTLPixelFormat grFormat, GrColorType ct) {
     MTLPixelFormat format = static_cast<MTLPixelFormat>(grFormat);
     switch (ct) {
         case GrColorType::kUnknown:
@@ -615,6 +615,7 @@
         case GrColorType::kBGR_565:
         case GrColorType::kABGR_4444:
             return kUnknown_GrPixelConfig;
+            break;
 #else
         case GrColorType::kBGR_565:
             if (MTLPixelFormatB5G6R5Unorm == format) {
@@ -702,12 +703,9 @@
                 return kRG_half_GrPixelConfig;
             }
             break;
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
-            return kUnknown_GrPixelConfig;
     }
-    SkUNREACHABLE;
+
+    return kUnknown_GrPixelConfig;
 }
 
 bool GrMtlCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
@@ -784,7 +782,7 @@
 }
 
 #ifdef SK_DEBUG
-static constexpr bool format_color_type_valid_pair(MTLPixelFormat format, GrColorType colorType) {
+static bool format_color_type_valid_pair(MTLPixelFormat format, GrColorType colorType) {
     switch (colorType) {
         case GrColorType::kUnknown:
             return false;
@@ -839,12 +837,9 @@
             return MTLPixelFormatRGBA16Unorm == format;
         case GrColorType::kRG_F16:
             return MTLPixelFormatRG16Float == format;
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
-            return false;
     }
-    SkUNREACHABLE;
+    SK_ABORT("Unknown color type");
+    return false;
 }
 #endif
 
@@ -907,7 +902,7 @@
         GrColorType dstColorType) const {
     const GrMTLPixelFormat* grMtlFormat = srcBackendFormat.getMtlFormat();
     if (!grMtlFormat) {
-        return {GrColorType::kUnknown, 0};
+        return {GrSwizzle(), GrColorType::kUnknown, 0};
     }
 
     GrColorType readCT = GrColorType::kUnknown;
@@ -979,6 +974,6 @@
     }
     // Metal requires the destination offset for copyFromTexture to be a multiple of the textures
     // pixels size.
-    return {readCT, GrColorTypeBytesPerPixel(readCT)};
+    return {GrSwizzle::RGBA(), readCT, GrColorTypeBytesPerPixel(readCT)};
 }
 
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 259a5ad..563fb65 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1065,11 +1065,6 @@
                 return kRG_half_GrPixelConfig;
             }
             break;
-        // These have no equivalent:
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
-            break;
     }
 
     return kUnknown_GrPixelConfig;
@@ -1147,7 +1142,7 @@
 bool GrVkCaps::canClearTextureOnCreation() const { return true; }
 
 #ifdef SK_DEBUG
-static constexpr bool format_color_type_valid_pair(VkFormat vkFormat, GrColorType colorType) {
+static bool format_color_type_valid_pair(VkFormat vkFormat, GrColorType colorType) {
     switch (colorType) {
         case GrColorType::kUnknown:
             return false;
@@ -1192,12 +1187,9 @@
             return VK_FORMAT_R16G16B16A16_UNORM == vkFormat;
         case GrColorType::kRG_F16:
             return VK_FORMAT_R16G16_SFLOAT == vkFormat;
-        case GrColorType::kAlpha_8xxx:
-        case GrColorType::kAlpha_F32xxx:
-        case GrColorType::kGray_8xxx:
-            return false;
     }
-    SkUNREACHABLE;
+    SK_ABORT("Unknown color type");
+    return false;
 }
 #endif
 
@@ -1248,7 +1240,7 @@
         GrColorType dstColorType) const {
     const VkFormat* vkFormat = srcBackendFormat.getVkFormat();
     if (!vkFormat) {
-        return {GrColorType::kUnknown, 0};
+        return {GrSwizzle(), GrColorType::kUnknown, 0};
     }
 
     // The VkBufferImageCopy bufferOffset field must be both a multiple of 4 and of a single texel.
@@ -1256,53 +1248,53 @@
 
     switch (*vkFormat) {
         case VK_FORMAT_R8G8B8A8_UNORM:
-            return {GrColorType::kRGBA_8888, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRGBA_8888, offsetAlignment};
         case VK_FORMAT_R8_UNORM:
             if (srcColorType == GrColorType::kAlpha_8) {
-                return {GrColorType::kAlpha_8, offsetAlignment};
+                return {GrSwizzle::RGBA(), GrColorType::kAlpha_8, offsetAlignment};
             } else if (srcColorType == GrColorType::kGray_8) {
-                return {GrColorType::kGray_8, offsetAlignment};
+                return {GrSwizzle::RGBA(), GrColorType::kGray_8, offsetAlignment};
             } else {
-                return {GrColorType::kUnknown, 0};
+                return {GrSwizzle(), GrColorType::kUnknown, 0};
             }
         case VK_FORMAT_B8G8R8A8_UNORM:
-            return {GrColorType::kBGRA_8888, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kBGRA_8888, offsetAlignment};
         case VK_FORMAT_R5G6B5_UNORM_PACK16:
-            return {GrColorType::kBGR_565, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kBGR_565, offsetAlignment};
         case VK_FORMAT_R16G16B16A16_SFLOAT:
             if (srcColorType == GrColorType::kRGBA_F16) {
-                return {GrColorType::kRGBA_F16, offsetAlignment};
+                return {GrSwizzle::RGBA(), GrColorType::kRGBA_F16, offsetAlignment};
             } else if (srcColorType == GrColorType::kRGBA_F16_Clamped) {
-                return {GrColorType::kRGBA_F16_Clamped, offsetAlignment};
+                return {GrSwizzle::RGBA(), GrColorType::kRGBA_F16_Clamped, offsetAlignment};
             } else {
-                return {GrColorType::kUnknown, 0};
+                return {GrSwizzle(), GrColorType::kUnknown, 0};
             }
         case VK_FORMAT_R16_SFLOAT:
-            return {GrColorType::kAlpha_F16, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kAlpha_F16, offsetAlignment};
         case VK_FORMAT_R8G8B8_UNORM:
-            return {GrColorType::kRGB_888x, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRGB_888x, offsetAlignment};
         case VK_FORMAT_R8G8_UNORM:
-            return {GrColorType::kRG_88, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRG_88, offsetAlignment};
         case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
-            return {GrColorType::kRGBA_1010102, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRGBA_1010102, offsetAlignment};
         case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
-            return {GrColorType::kABGR_4444, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kABGR_4444, offsetAlignment};
         case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
-            return {GrColorType::kABGR_4444, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kABGR_4444, offsetAlignment};
         case VK_FORMAT_R32G32B32A32_SFLOAT:
-            return {GrColorType::kRGBA_F32, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRGBA_F32, offsetAlignment};
         case VK_FORMAT_R8G8B8A8_SRGB:
-            return {GrColorType::kRGBA_8888_SRGB, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRGBA_8888_SRGB, offsetAlignment};
         case VK_FORMAT_R16_UNORM:
-            return {GrColorType::kR_16, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kR_16, offsetAlignment};
         case VK_FORMAT_R16G16_UNORM:
-            return {GrColorType::kRG_1616, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRG_1616, offsetAlignment};
         // Experimental (for Y416 and mutant P016/P010)
         case VK_FORMAT_R16G16B16A16_UNORM:
-            return {GrColorType::kRGBA_16161616, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRGBA_16161616, offsetAlignment};
         case VK_FORMAT_R16G16_SFLOAT:
-            return {GrColorType::kRG_F16, offsetAlignment};
+            return {GrSwizzle::RGBA(), GrColorType::kRG_F16, offsetAlignment};
         default:
-            return {GrColorType::kUnknown, 0};
+            return {GrSwizzle(), GrColorType::kUnknown, 0};
     }
 }
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp
index c331381..cf0ac31 100644
--- a/tests/GrTestingBackendTextureUploadTest.cpp
+++ b/tests/GrTestingBackendTextureUploadTest.cpp
@@ -58,7 +58,7 @@
     // skbug.com/9165
     auto supportedRead =
             caps->supportedReadPixelsColorType(grCT, backendTex.getBackendFormat(), grCT);
-    if (supportedRead.fColorType != grCT) {
+    if (supportedRead.fColorType != grCT || supportedRead.fSwizzle != GrSwizzle("rgba")) {
         return;
     }
 
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index 1b459d2..d4c4aab 100644
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -78,7 +78,7 @@
     GrCaps::SupportedRead supportedRead = caps->supportedReadPixelsColorType(
             srcCT, texture->backendFormat(), dstColorType);
     std::fill_n(tolerances, 4, 0);
-    if (supportedRead.fColorType != dstColorType) {
+    if (supportedRead.fColorType != dstColorType || supportedRead.fSwizzle != GrSwizzle("rgba")) {
         size_t tmpRowBytes = GrColorTypeBytesPerPixel(supportedRead.fColorType) * w;
         std::unique_ptr<char[]> tmpPixels(new char[tmpRowBytes * h]);
         if (!gpu->readPixels(texture, 0, 0, w, h,
@@ -88,8 +88,8 @@
         GrPixelInfo tmpInfo(supportedRead.fColorType, kUnpremul_SkAlphaType, nullptr, w, h);
         GrPixelInfo dstInfo(dstColorType,             kUnpremul_SkAlphaType, nullptr, w, h);
         determine_tolerances(tmpInfo.colorType(), dstInfo.colorType(), tolerances);
-        return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, tmpPixels.get(), tmpRowBytes,
-                               false);
+        return GrConvertPixels(dstInfo, dst, rowBytes, tmpInfo, tmpPixels.get(), tmpRowBytes, false,
+                               supportedRead.fSwizzle);
     }
     return gpu->readPixels(texture, 0, 0, w, h, supportedRead.fColorType, dst, rowBytes);
 }
@@ -364,6 +364,11 @@
 
     GrPixelInfo transferInfo(allowedRead.fColorType, kUnpremul_SkAlphaType, nullptr, kTextureWidth,
                              kTextureHeight);
+    // Caps may indicate that we should swizzle this data before we compare it.
+    if (allowedRead.fSwizzle != GrSwizzle("rgba")) {
+        GrConvertPixels(transferInfo, transferData.get(), fullBufferRowBytes, transferInfo,
+                        transferData.get(), fullBufferRowBytes, false, allowedRead.fSwizzle);
+    }
 
     float tol[4];
     determine_tolerances(allowedRead.fColorType, colorType, tol);
@@ -405,6 +410,11 @@
     buffer->unmap();
 
     transferInfo = transferInfo.makeWH(kPartialWidth, kPartialHeight);
+    if (allowedRead.fSwizzle != GrSwizzle("rgba")) {
+        GrConvertPixels(transferInfo, transferData.get(), partialBufferRowBytes, transferInfo,
+                        transferData.get(), partialBufferRowBytes, false, allowedRead.fSwizzle);
+    }
+
     const char* textureDataStart =
             textureData.get() + textureDataRowBytes * kPartialTop + textureDataBpp * kPartialLeft;
     textureDataInfo = textureDataInfo.makeWH(kPartialWidth, kPartialHeight);