diff --git a/src/gpu/GrDirectContextPriv.cpp b/src/gpu/GrDirectContextPriv.cpp
index dc770f9..b00a1a2 100644
--- a/src/gpu/GrDirectContextPriv.cpp
+++ b/src/gpu/GrDirectContextPriv.cpp
@@ -9,7 +9,6 @@
 
 #include "include/gpu/GrContextThreadSafeProxy.h"
 #include "include/gpu/GrDirectContext.h"
-#include "src/core/SkRuntimeEffectPriv.h"
 #include "src/gpu/GrAuditTrail.h"
 #include "src/gpu/GrContextThreadSafeProxyPriv.h"
 #include "src/gpu/GrDrawingManager.h"
@@ -22,6 +21,7 @@
 #include "src/gpu/GrThreadSafePipelineBuilder.h"
 #include "src/gpu/SkGr.h"
 #include "src/gpu/effects/GrSkSLFP.h"
+#include "src/gpu/effects/generated/GrConfigConversionEffect.h"
 #include "src/gpu/text/GrAtlasManager.h"
 #include "src/gpu/text/GrTextBlobCache.h"
 #include "src/image/SkImage_Base.h"
@@ -192,129 +192,12 @@
 }
 #endif
 
-// Both of these effects aggressively round to the nearest exact (N / 255) floating point values.
-// This lets us find a round-trip preserving pair on some GPUs that do odd byte to float conversion.
-static std::unique_ptr<GrFragmentProcessor> make_premul_effect(
-        std::unique_ptr<GrFragmentProcessor> fp) {
-    if (!fp) {
-        return nullptr;
-    }
-
-    static auto effect = SkMakeRuntimeEffect(SkRuntimeEffect::MakeForColorFilter, R"(
-        half4 main(half4 color) {
-            color = floor(color * 255 + 0.5) / 255;
-            color.rgb = floor(color.rgb * color.a * 255 + 0.5) / 255;
-            return color;
-        }
-    )");
-
-    fp = GrSkSLFP::Make(effect, "ToPremul", std::move(fp), GrSkSLFP::OptFlags::kNone);
-    return GrFragmentProcessor::HighPrecision(std::move(fp));
-}
-
-static std::unique_ptr<GrFragmentProcessor> make_unpremul_effect(
-        std::unique_ptr<GrFragmentProcessor> fp) {
-    if (!fp) {
-        return nullptr;
-    }
-
-    static auto effect = SkMakeRuntimeEffect(SkRuntimeEffect::MakeForColorFilter, R"(
-        half4 main(half4 color) {
-            color = floor(color * 255 + 0.5) / 255;
-            color.rgb = color.a <= 0 ? half3(0) : floor(color.rgb / color.a * 255 + 0.5) / 255;
-            return color;
-        }
-    )");
-
-    fp = GrSkSLFP::Make(effect, "ToUnpremul", std::move(fp), GrSkSLFP::OptFlags::kNone);
-    return GrFragmentProcessor::HighPrecision(std::move(fp));
-}
-
-static bool test_for_preserving_PM_conversions(GrDirectContext* dContext) {
-    static constexpr int kSize = 256;
-    SkAutoTMalloc<uint32_t> data(kSize * kSize * 3);
-    uint32_t* srcData = data.get();
-
-    // Fill with every possible premultiplied A, color channel value. There will be 256-y duplicate
-    // values in row y. We set r, g, and b to the same value since they are handled identically.
-    for (int y = 0; y < kSize; ++y) {
-        for (int x = 0; x < kSize; ++x) {
-            uint8_t* color = reinterpret_cast<uint8_t*>(&srcData[kSize*y + x]);
-            color[3] = y;
-            color[2] = std::min(x, y);
-            color[1] = std::min(x, y);
-            color[0] = std::min(x, y);
-        }
-    }
-
-    const SkImageInfo pmII =
-            SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
-    const SkImageInfo upmII = pmII.makeAlphaType(kUnpremul_SkAlphaType);
-
-    auto readSFC = GrSurfaceFillContext::Make(dContext, upmII, SkBackingFit::kExact);
-    auto tempSFC = GrSurfaceFillContext::Make(dContext,  pmII, SkBackingFit::kExact);
-    if (!readSFC || !tempSFC) {
-        return false;
-    }
-
-    // This function is only ever called if we are in a GrDirectContext since we are calling read
-    // pixels here. Thus the pixel data will be uploaded immediately and we don't need to keep the
-    // pixel data alive in the proxy. Therefore the ReleaseProc is nullptr.
-    SkBitmap bitmap;
-    bitmap.installPixels(pmII, srcData, 4 * kSize);
-    bitmap.setImmutable();
-
-    auto dataView = std::get<0>(GrMakeUncachedBitmapProxyView(dContext, bitmap));
-    if (!dataView) {
-        return false;
-    }
-
-    uint32_t* firstRead  = data.get() +   kSize*kSize;
-    uint32_t* secondRead = data.get() + 2*kSize*kSize;
-    std::fill_n( firstRead, kSize*kSize, 0);
-    std::fill_n(secondRead, kSize*kSize, 0);
-
-    GrPixmap firstReadPM( upmII,  firstRead, kSize*sizeof(uint32_t));
-    GrPixmap secondReadPM(upmII, secondRead, kSize*sizeof(uint32_t));
-
-    // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw
-    // from readTex to tempTex followed by a PM->UPM draw to readTex and finally read the data.
-    // We then verify that two reads produced the same values.
-
-    auto fp1 = make_unpremul_effect(GrTextureEffect::Make(std::move(dataView), bitmap.alphaType()));
-    readSFC->fillRectWithFP(SkIRect::MakeWH(kSize, kSize), std::move(fp1));
-    if (!readSFC->readPixels(dContext, firstReadPM, {0, 0})) {
-        return false;
-    }
-
-    auto fp2 = make_premul_effect(
-            GrTextureEffect::Make(readSFC->readSurfaceView(), readSFC->colorInfo().alphaType()));
-    tempSFC->fillRectWithFP(SkIRect::MakeWH(kSize, kSize), std::move(fp2));
-
-    auto fp3 = make_unpremul_effect(
-            GrTextureEffect::Make(tempSFC->readSurfaceView(), tempSFC->colorInfo().alphaType()));
-    readSFC->fillRectWithFP(SkIRect::MakeWH(kSize, kSize), std::move(fp3));
-
-    if (!readSFC->readPixels(dContext, secondReadPM, {0, 0})) {
-        return false;
-    }
-
-    for (int y = 0; y < kSize; ++y) {
-        for (int x = 0; x <= y; ++x) {
-            if (firstRead[kSize*y + x] != secondRead[kSize*y + x]) {
-                return false;
-            }
-        }
-    }
-
-    return true;
-}
-
 bool GrDirectContextPriv::validPMUPMConversionExists() {
     ASSERT_SINGLE_OWNER
 
     if (!fContext->fDidTestPMConversions) {
-        fContext->fPMUPMConversionsRoundTrip = test_for_preserving_PM_conversions(fContext);
+        fContext->fPMUPMConversionsRoundTrip =
+                GrConfigConversionEffect::TestForPreservingPMConversions(fContext);
         fContext->fDidTestPMConversions = true;
     }
 
@@ -330,7 +213,7 @@
     // ...and it should have succeeded
     SkASSERT(this->validPMUPMConversionExists());
 
-    return make_unpremul_effect(std::move(fp));
+    return GrConfigConversionEffect::Make(std::move(fp), PMConversion::kToUnpremul);
 }
 
 std::unique_ptr<GrFragmentProcessor> GrDirectContextPriv::createUPMToPMEffect(
@@ -341,7 +224,7 @@
     // ...and it should have succeeded
     SkASSERT(this->validPMUPMConversionExists());
 
-    return make_premul_effect(std::move(fp));
+    return GrConfigConversionEffect::Make(std::move(fp), PMConversion::kToPremul);
 }
 
 sk_sp<SkBaseGpuDevice> GrDirectContextPriv::createDevice(GrColorType colorType,
