Merge remote-tracking branch 'upstream/sdk-1.1.121' into HEAD

Change-Id: Id5770cc6ec38b511ed57fa04f3a2f1c8fbd54dd9
diff --git a/BUILD.gn b/BUILD.gn
index 46bb075..87eb4b6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -13,12 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import("//build_overrides/build.gni")
 import("//build_overrides/vulkan_tools.gni")
 
-# Vulkan-tools isn't ported to Fuchsia yet.
-# TODO(spang): Port mock ICD to Fuchsia.
-assert(!is_fuchsia)
-
 vulkan_undefine_configs = []
 if (is_win) {
   vulkan_undefine_configs += [
@@ -64,8 +61,10 @@
     if (is_win) {
       sources += [ "icd/VkICD_mock_icd.def" ]
     }
-    configs -= [ "//build/config/compiler:chromium_code" ]
-    configs += [ "//build/config/compiler:no_chromium_code" ]
+    if (build_with_chromium) {
+      configs -= [ "//build/config/compiler:chromium_code" ]
+      configs += [ "//build/config/compiler:no_chromium_code" ]
+    }
   }
 
   action("vulkan_gen_icd_json_file") {
@@ -82,6 +81,10 @@
       sources += [ "icd/linux/VkICD_mock_icd.json" ]
       args += [ "$raw_vulkan_icd_dir/linux" ]
     }
+    if (is_fuchsia) {
+      sources += [ "icd/linux/VkICD_mock_icd.json" ]
+      args += [ "$raw_vulkan_icd_dir/fuchsia" ]
+    }
 
     # The layer JSON files are part of the necessary data deps.
     outputs = [
@@ -90,4 +93,17 @@
     data = outputs
     args += [ raw_vulkan_data_dir ] + rebase_path(sources, root_build_dir)
   }
+
+  executable("vulkaninfo") {
+    sources = [
+      "vulkaninfo/vulkaninfo.c",
+    ]
+
+    cflags_c = [ "-Wno-missing-field-initializers" ]
+
+    deps = [
+      "$vulkan_headers_dir:vulkan_headers",
+      "//third_party/Vulkan-Loader:libvulkan",
+    ]
+  }
 }
diff --git a/README.fuchsia b/README.fuchsia
new file mode 100644
index 0000000..bb4f0be
--- /dev/null
+++ b/README.fuchsia
@@ -0,0 +1,8 @@
+Name: Vulkan-Tools
+License: Apache 2.0
+License File: LICENSE.txt
+Upstream Git: https://github.com/KhronosGroup/Vulkan-Tools
+Description:
+
+Provides Khronos official Vulkan Tools and Utilities.
+
diff --git a/vulkaninfo/vulkaninfo.c b/vulkaninfo/vulkaninfo.c
index 1ff6425..7afb3b9 100644
--- a/vulkaninfo/vulkaninfo.c
+++ b/vulkaninfo/vulkaninfo.c
@@ -587,7 +587,7 @@
 }
 
 #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \
-    defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR)
+    defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_FUCHSIA)
 static const char *VkPresentModeString(VkPresentModeKHR mode) {
     switch (mode) {
 #define STR(r)                \
@@ -1105,8 +1105,12 @@
 
     vkGetPhysicalDeviceFeatures(gpu->obj, &gpu->features);
 
+    AppGetPhysicalDeviceLayerExtensions(gpu, NULL, &gpu->device_extension_count, &gpu->device_extensions);
+
     if (CheckExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, gpu->inst->inst_extensions,
-                              gpu->inst->inst_extensions_count)) {
+                              gpu->inst->inst_extensions_count) &&
+        CheckPhysicalDeviceExtensionIncluded(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME, gpu->device_extensions,
+                                             gpu->device_extension_count)) {
         struct pNextChainBuildingBlockInfo mem_prop_chain_info[] = {
             {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT,
              .mem_size = sizeof(VkPhysicalDeviceMemoryBudgetPropertiesEXT)}};
@@ -1172,8 +1176,6 @@
         inst->vkGetPhysicalDeviceFeatures2KHR(gpu->obj, &gpu->features2);
     }
 
-    AppGetPhysicalDeviceLayerExtensions(gpu, NULL, &gpu->device_extension_count, &gpu->device_extensions);
-
     const float queue_priority = 1.0f;
     const VkDeviceQueueCreateInfo q_ci = {.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
                                           .queueFamilyIndex = 0,  // just pick the first one and hope for the best
@@ -1389,8 +1391,9 @@
 #endif  // VK_USE_PLATFORM_WIN32_KHR
 //-----------------------------------------------------------
 
-#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \
-    defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_ANDROID_KHR)
+#if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) ||        \
+    defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_ANDROID_KHR) || \
+    defined(VK_USE_PLATFORM_FUCHSIA)
 static void AppDestroySurface(struct AppInstance *inst, VkSurfaceKHR surface) {  // same for all platforms
     vkDestroySurfaceKHR(inst->instance, surface, NULL);
 }
@@ -1570,7 +1573,7 @@
 #endif  // VK_USE_PLATFORM_WAYLAND_KHR
 
 #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) || \
-    defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR)
+    defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || defined(VK_USE_PLATFORM_FUCHSIA)
 static int AppDumpSurfaceFormats(struct AppInstance *inst, struct AppGpu *gpu, VkSurfaceKHR surface, FILE *out) {
     // Get the list of VkFormat's that are supported
     VkResult err;