Add some swizzle checks to vulkan backend
authorGreg Daniel <egdaniel@google.com>
Thu, 11 May 2017 13:20:59 +0000 (09:20 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 11 May 2017 13:43:12 +0000 (13:43 +0000)
Bug: skia:
Change-Id: I9f5a5c1fda9cf26fc6479e1cd6d0e981e6991c8e
Reviewed-on: https://skia-review.googlesource.com/16426
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>

src/gpu/vk/GrVkCopyManager.cpp
src/gpu/vk/GrVkPipeline.cpp

index 6f5acb46c43dc9489d700ed5c0e7d0d4def42287..d0edb2365d5e3434d797ed037104b52cc20f1cb3 100644 (file)
@@ -144,6 +144,13 @@ bool GrVkCopyManager::copySurfaceAsDraw(GrVkGpu* gpu,
                                         GrSurface* src,
                                         const SkIRect& srcRect,
                                         const SkIPoint& dstPoint) {
+    // None of our copy methods can handle a swizzle. TODO: Make copySurfaceAsDraw handle the
+    // swizzle.
+    if (gpu->caps()->shaderCaps()->configOutputSwizzle(src->config()) !=
+        gpu->caps()->shaderCaps()->configOutputSwizzle(dst->config())) {
+        return false;
+    }
+
     if (!gpu->vkCaps().supportsCopiesAsDraws()) {
         return false;
     }
index 809333f7ef24bb4c2f1a8ef2ca48a35ea896e9b5..47acb94266608d331e28e60f624d3c6e009912da 100644 (file)
@@ -526,7 +526,11 @@ static void set_dynamic_blend_constant_state(GrVkGpu* gpu,
     GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
     float floatColors[4];
     if (blend_coeff_refs_constant(srcCoeff) || blend_coeff_refs_constant(dstCoeff)) {
-        GrColorToRGBAFloat(blendInfo.fBlendConstant, floatColors);
+        // Swizzle the blend to match what the shader will output.
+        const GrSwizzle& swizzle = gpu->caps()->shaderCaps()->configOutputSwizzle(
+                pipeline.getRenderTarget()->config());
+        GrColor blendConst = swizzle.applyTo(blendInfo.fBlendConstant);
+        GrColorToRGBAFloat(blendConst, floatColors);
     } else {
         memset(floatColors, 0, 4 * sizeof(float));
     }