Add ANGLE to Dawn build.

Bug: dawn:447, dawn:580
Change-Id: I77726651ca00d64768bddc0bb476fd920e11851f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35081
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/.gn b/.gn
index c212766..b506763 100644
--- a/.gn
+++ b/.gn
@@ -23,6 +23,21 @@
   # Chromium is still on 10.10).
   mac_deployment_target = "10.11.0"
   mac_min_system_version = "10.11.0"
+
+  angle_enable_abseil = false
+
+  angle_standalone = false
+
+  angle_build_all = false
+
+  angle_vulkan_headers_dir = "//third_party/vulkan-deps/vulkan-headers/src"
+
+  angle_vulkan_loader_dir = "//third_party/vulkan-deps/vulkan-loader/src"
+
+  angle_vulkan_tools_dir = "//third_party/vulkan-deps/vulkan-tools/src"
+
+  angle_vulkan_validation_layers_dir =
+      "//third_party/vulkan-deps/vulkan-validation-layers/src"
 }
 
 check_targets = [
diff --git a/DEPS b/DEPS
index 5d18477..f4e8b6d 100644
--- a/DEPS
+++ b/DEPS
@@ -80,6 +80,16 @@
     'condition': 'dawn_standalone',
   },
 
+  'third_party/vulkan_memory_allocator': {
+    'url': '{chromium_git}/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator@065e739079d9d58bef28ccd793cbf512261f09ed',
+    'condition': 'dawn_standalone',
+  },
+
+  'third_party/angle': {
+    'url': '{chromium_git}/angle/angle@f4cd17472aca1939277b145ef0f72b0946b83716',
+    'condition': 'dawn_standalone',
+  },
+
   'third_party/swiftshader': {
     'url': '{swiftshader_git}/SwiftShader@df17a76102dfabb3f1bd6e51449cece9f77b45e3',
     'condition': 'dawn_standalone',
@@ -87,6 +97,10 @@
 
   'third_party/vulkan-deps': {
     'url': '{chromium_git}/vulkan-deps@c493c61120215a00f54cc59f067f7419dabad066',
+  },
+
+  'third_party/zlib': {
+    'url': '{chromium_git}/chromium/src/third_party/zlib@c29ee8c9c3824ca013479bf8115035527967fe02',
     'condition': 'dawn_standalone',
   },
 }
diff --git a/build_overrides/angle.gni b/build_overrides/angle.gni
new file mode 100644
index 0000000..85d4d95
--- /dev/null
+++ b/build_overrides/angle.gni
@@ -0,0 +1,26 @@
+# Copyright 2020 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Override for angle_root
+angle_root = "//third_party/angle"
+
+# True if ANGLE can access build/, testing/ and other Chrome folders.
+angle_has_build = true
+
+# Paths to ANGLE dependencies in Dawn
+angle_glslang_dir = "//third_party/vulkan-deps/glslang/src"
+angle_spirv_cross_dir = "//third_party/vulkan-deps/spirv-cross/src"
+angle_spirv_headers_dir = "//third_party/vulkan-deps/spirv-headers/src"
+angle_spirv_tools_dir = "//third_party/vulkan-deps/spirv-tools/src"
+angle_vulkan_memory_allocator_dir = "//third_party/vulkan_memory_allocator"
diff --git a/build_overrides/dawn.gni b/build_overrides/dawn.gni
index 3b913dd..6fac7d4 100644
--- a/build_overrides/dawn.gni
+++ b/build_overrides/dawn.gni
@@ -27,6 +27,7 @@
 # users of Dawn don't have to set dirs if they happen to use the same as Dawn.
 
 # The paths to Dawn's dependencies
+dawn_angle_dir = "//third_party/angle"
 dawn_jinja2_dir = "//third_party/jinja2"
 dawn_glfw_dir = "//third_party/glfw"
 dawn_glm_dir = "//third_party/glm"
diff --git a/build_overrides/vulkan_tools.gni b/build_overrides/vulkan_tools.gni
new file mode 100644
index 0000000..cd89fc9
--- /dev/null
+++ b/build_overrides/vulkan_tools.gni
@@ -0,0 +1,8 @@
+# Copyright 2019 The ANGLE Project Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+vulkan_headers_dir = "//third_party/vulkan-deps/vulkan-headers/src"
+
+vulkan_data_subdir = "vulkandata"
+vulkan_gen_subdir = "angle/vulkan"
diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni
index 09db849..cc2899a 100644
--- a/scripts/dawn_features.gni
+++ b/scripts/dawn_features.gni
@@ -27,6 +27,8 @@
 }
 
 declare_args() {
+  dawn_use_angle = true
+
   # Enables usage of swiftshader on the Vulkan backend.
   # Note that this will only work in standalone and in projects that set the
   # dawn_swiftshader_dir variable in build_overrides/dawn.gni
diff --git a/src/dawn_native/BUILD.gn b/src/dawn_native/BUILD.gn
index e57c7e1..f396433 100644
--- a/src/dawn_native/BUILD.gn
+++ b/src/dawn_native/BUILD.gn
@@ -35,6 +35,9 @@
   import("//build_overrides/vulkan_validation_layers.gni")
 }
 
+# ANGLE is an optional dependency; only use it if the path has been set.
+use_angle = dawn_use_angle && defined(dawn_angle_dir)
+
 # Swiftshader is an optional dependency, only use it if the path has been set.
 use_swiftshader = dawn_use_swiftshader && dawn_swiftshader_dir != ""
 if (use_swiftshader) {
@@ -603,6 +606,13 @@
     }
   }
 
+  if (use_angle) {
+    data_deps += [
+      "${dawn_angle_dir}:libEGL",
+      "${dawn_angle_dir}:libGLESv2",
+    ]
+  }
+
   if (dawn_enable_wgsl) {
     deps += [ "${dawn_tint_dir}:libtint" ]
   }