Support the Boolean form of mix() in the Metal/SPIR-V backends.

Unfortunately, it's not easily testable since SkSLTest doesn't support
non-ES2 intrinsics.

Change-Id: I5b11e2af55fdc6fc29f48725aa977471c738b55e
Bug: skia:11222
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426538
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
index f6a07fa..cc07b7b 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
@@ -759,6 +759,18 @@
             this->writeSimpleIntrinsic(c);
             return true;
         }
+        case k_mix_IntrinsicKind: {
+            SkASSERT(c.arguments().size() == 3);
+            if (arguments[2]->type().componentType().isBoolean()) {
+                // The Boolean forms of GLSL mix() use the select() intrinsic in Metal.
+                this->write("select");
+                this->writeArgumentList(c.arguments());
+                return true;
+            }
+            // The basic form of mix() is supported by Metal as-is.
+            this->writeSimpleIntrinsic(c);
+            return true;
+        }
         case k_equal_IntrinsicKind:
         case k_greaterThan_IntrinsicKind:
         case k_greaterThanEqual_IntrinsicKind: