From 09100b79d078510391f5e8c6bf7d985da0b7de09 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Fri, 1 Apr 2022 05:22:55 +0000 Subject: [PATCH] Try to use the vulkan-headers from vulkan-deps instead of third_party/khronos. Change-Id: Ic4af5ec86e4ea2ec404a6e32e49068fc5993d55a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85300 Reviewed-by: Corentin Wallez Reviewed-by: Austin Eng Commit-Queue: Loko Kung --- scripts/dawn_overrides_with_defaults.gni | 8 +++++++ src/dawn/common/vulkan_platform.h | 30 ++++++++++++++++++++---- src/dawn/native/BUILD.gn | 2 +- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/scripts/dawn_overrides_with_defaults.gni b/scripts/dawn_overrides_with_defaults.gni index 35a8baf0c6..c6676931b3 100644 --- a/scripts/dawn_overrides_with_defaults.gni +++ b/scripts/dawn_overrides_with_defaults.gni @@ -54,6 +54,14 @@ if (!defined(dawn_swiftshader_dir)) { dawn_swiftshader_dir = "" } +if (!defined(dawn_vulkan_headers_dir)) { + dawn_vulkan_headers_dir = "//third_party/vulkan-deps/vulkan-headers/src" + if (dawn_standalone) { + dawn_vulkan_headers_dir = + "${dawn_root}/third_party/vulkan-deps/vulkan-headers/src" + } +} + if (!defined(dawn_vulkan_loader_dir)) { # Default to the Vulkan loader not being available except in standalone. dawn_vulkan_loader_dir = "" diff --git a/src/dawn/common/vulkan_platform.h b/src/dawn/common/vulkan_platform.h index 57d2b130b4..868f13fcb2 100644 --- a/src/dawn/common/vulkan_platform.h +++ b/src/dawn/common/vulkan_platform.h @@ -155,26 +155,46 @@ namespace dawn::native::vulkan { // Import additional parts of Vulkan that are supported on our architecture and preemptively include // headers that vulkan.h includes that we have "undefs" for. #if defined(DAWN_PLATFORM_WINDOWS) -# define VK_USE_PLATFORM_WIN32_KHR +# ifndef VK_USE_PLATFORM_WIN32_KHR +# define VK_USE_PLATFORM_WIN32_KHR +# endif # include "dawn/common/windows_with_undefs.h" +#else +# undef VK_USE_PLATFORM_WIN32_KHR #endif // DAWN_PLATFORM_WINDOWS #if defined(DAWN_USE_X11) # define VK_USE_PLATFORM_XLIB_KHR -# define VK_USE_PLATFORM_XCB_KHR +# ifndef VK_USE_PLATFORM_XCB_KHR +# define VK_USE_PLATFORM_XCB_KHR +# endif # include "dawn/common/xlib_with_undefs.h" +#else +# undef VK_USE_PLATFORM_XCB_KHR #endif // defined(DAWN_USE_X11) #if defined(DAWN_ENABLE_BACKEND_METAL) -# define VK_USE_PLATFORM_METAL_EXT +# ifndef VK_USE_PLATFORM_METAL_EXT +# define VK_USE_PLATFORM_METAL_EXT +# endif +#else +# undef VK_USE_PLATFORM_METAL_EXT #endif // defined(DAWN_ENABLE_BACKEND_METAL) #if defined(DAWN_PLATFORM_ANDROID) -# define VK_USE_PLATFORM_ANDROID_KHR +# ifndef VK_USE_PLATFORM_ANDROID_KHR +# define VK_USE_PLATFORM_ANDROID_KHR +# endif +#else +# undef VK_USE_PLATFORM_ANDROID_KHR #endif // defined(DAWN_PLATFORM_ANDROID) #if defined(DAWN_PLATFORM_FUCHSIA) -# define VK_USE_PLATFORM_FUCHSIA +# ifndef VK_USE_PLATFORM_FUCHSIA +# define VK_USE_PLATFORM_FUCHSIA +# endif +#else +# undef VK_USE_PLATFORM_FUCHSIA #endif // defined(DAWN_PLATFORM_FUCHSIA) // The actual inclusion of vulkan.h! diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn index bc90499405..ce7d97f056 100644 --- a/src/dawn/native/BUILD.gn +++ b/src/dawn/native/BUILD.gn @@ -571,7 +571,7 @@ source_set("sources") { } if (dawn_enable_vulkan) { - public_deps += [ "${dawn_root}/third_party/khronos:vulkan_headers" ] + public_deps += [ "${dawn_vulkan_headers_dir}:vulkan_headers" ] sources += [ "vulkan/AdapterVk.cpp", "vulkan/AdapterVk.h",