Add first Dawn dependencies.

Add Dawn repo to DEPS.
Add skia_use_dawn flag to BUILD.gn (default false).
Add Metal.framework for Mac when building for Dawn/Metal.
Add d3d12, dxgi, d3dcompiler libs when building for Dawn/D3D12.
Disable SPIRV validation when building for Dawn.
Add BUILD.gn for dawn and dawn/third_party libraries.

(Note that I had to split the declare_args() section of BUILD.gn
into two, so that I could refer to skia_use_dawn in skia_enable_spirv_validation.
If there's a better way to do this, I'm open to suggestions.)

Change-Id: I9bdaf990694f6b8bcce6b77c1a8b1620a7396e34
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225137
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 3bbc66b..8e2ec15 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -36,16 +36,19 @@
   skia_use_wuffs = false
   skia_use_zlib = true
   skia_use_metal = false
+  skia_use_dawn = false
   skia_use_libheif = is_skia_dev_build
   skia_use_x11 = is_linux
   skia_use_xps = true
+}
 
+declare_args() {
   skia_android_serial = ""
   skia_enable_ccpr = true
   skia_enable_nvpr = !skia_enable_flutter_defines
   skia_enable_discrete_gpu = true
   skia_enable_pdf = true
-  skia_enable_spirv_validation = is_skia_dev_build && is_debug
+  skia_enable_spirv_validation = is_skia_dev_build && is_debug && !skia_use_dawn
   skia_enable_skpicture = true
   skia_enable_sksl_interpreter = is_skia_dev_build
   skia_enable_skvm_jit = is_skia_dev_build && target_cpu == "x64" && is_linux
@@ -63,6 +66,11 @@
   skia_tools_require_resources = false
   skia_include_multiframe_procs = false
 }
+
+if (skia_use_dawn) {
+  import("third_party/externals/dawn/scripts/dawn_features.gni")
+}
+
 declare_args() {
   skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
   skia_use_sfntly = skia_use_icu
@@ -637,6 +645,24 @@
     }
   }
 
+  if (skia_use_dawn) {
+    public_defines += [ "SK_DAWN" ]
+    public_deps += [
+      "//third_party/dawn:dawn_headers",
+      "//third_party/dawn:libdawn",
+      "//third_party/dawn:libdawn_native_sources",
+    ]
+    if (dawn_enable_d3d12) {
+      libs += [
+        "d3d12.lib",
+        "dxgi.lib",
+        "d3dcompiler.lib",
+      ]
+    } else if (dawn_enable_metal) {
+      libs += [ "Metal.framework" ]
+    }
+  }
+
   cflags_objcc = []
   if (skia_use_metal) {
     public_defines += [ "SK_METAL" ]
@@ -1252,6 +1278,10 @@
       "modules/skottie",
       "modules/skshaper",
     ]
+
+    if (skia_use_dawn) {
+      deps += [ "//third_party/dawn:dawn_headers" ]
+    }
   }
 
   template("test_lib") {