Add the Vulkan loader as an optional dependency and use it on Mac

On macOS we can't rely on having the Vulkan loader installed in the
system. So we add the Vulkan loader as an optional dependency of Dawn
and use it on macOS when building Dawn in standalone with Vulkan
support.

Usage of building our own loader might broaden if the loader gains
features that are useful on other OSes. For example the ability to pass
in the "root ICD" entrypoint to the loader so we can have both
Swiftshader and the system driver at the same time.

Bug: dawn:388

Change-Id: I7ade4961cce0463c66846ad17aebf95224f1afcc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19723
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2020-04-17 08:22:25 +00:00
committed by Commit Bot service account
parent 53f694b34a
commit 0925720ecb
8 changed files with 55 additions and 23 deletions

View File

@@ -28,22 +28,28 @@ if (is_mac) {
}
}
# The VVLs are an optional dependency, only use it if the path has been set.
enable_vulkan_validation_layers = dawn_enable_vulkan_validation_layers &&
dawn_vulkan_validation_layers_dir != ""
if (enable_vulkan_validation_layers) {
import("//build_overrides/vulkan_validation_layers.gni")
}
# Swiftshader is an optional dependency of Dawn so we only use it if the path
# to it has been set.
# 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) {
assert(dawn_enable_vulkan,
"dawn_use_swiftshader requires dawn_enable_vulkan=true")
import("${dawn_swiftshader_dir}/src/Vulkan/vulkan.gni")
}
# The Vulkan loader is an optional dependency, only use it if the path has been
# set.
if (dawn_enable_vulkan) {
enable_vulkan_loader =
dawn_enable_vulkan_loader && dawn_vulkan_loader_dir != ""
}
config("dawn_native_internal") {
configs = [ "${dawn_root}/src/common:dawn_internal" ]
@@ -102,9 +108,7 @@ if (dawn_enable_opengl) {
# Public dawn_native headers so they can be publicly visible for
# dependencies of dawn_native
source_set("dawn_native_headers") {
public_deps = [
"${dawn_root}/src/dawn:dawncpp_headers",
]
public_deps = [ "${dawn_root}/src/dawn:dawncpp_headers" ]
all_dependent_configs = [ "${dawn_root}/src/common:dawn_public_include_dirs" ]
sources = [
"${dawn_root}/src/include/dawn_native/DawnNative.h",
@@ -554,7 +558,9 @@ source_set("dawn_native_sources") {
"DAWN_VK_DATA_DIR=\"$vulkan_data_subdir\"",
]
}
if (enable_vulkan_loader) {
data_deps += [ "${dawn_vulkan_loader_dir}:libvulkan" ]
}
if (use_swiftshader) {
data_deps += [
"${dawn_swiftshader_dir}/src/Vulkan:icd_file",
@@ -575,17 +581,13 @@ dawn_component("dawn_native") {
DEFINE_PREFIX = "DAWN_NATIVE"
#Make headers publically visible
public_deps = [
":dawn_native_headers",
]
public_deps = [ ":dawn_native_headers" ]
deps = [
":dawn_native_sources",
"${dawn_root}/src/common",
]
sources = [
"DawnNative.cpp",
]
sources = [ "DawnNative.cpp" ]
configs = [ ":dawn_native_internal" ]
public_configs = [ ":dawn_native_weak_framework" ]
@@ -605,9 +607,8 @@ dawn_component("dawn_native") {
sources += [ "vulkan/VulkanBackend.cpp" ]
if (enable_vulkan_validation_layers) {
data_deps = [
"${dawn_vulkan_validation_layers_dir}:vulkan_validation_layers",
]
data_deps =
[ "${dawn_vulkan_validation_layers_dir}:vulkan_validation_layers" ]
if (!is_android) {
data_deps +=
[ "${dawn_vulkan_validation_layers_dir}:vulkan_gen_json_files" ]

View File

@@ -42,10 +42,10 @@ constexpr char kVulkanLibName[] = "libvulkan.so.1";
# endif
#elif defined(DAWN_PLATFORM_WINDOWS)
constexpr char kVulkanLibName[] = "vulkan-1.dll";
#elif defined(DAWN_PLATFORM_MACOS)
constexpr char kVulkanLibName[] = "libvulkan.dylib";
#elif defined(DAWN_PLATFORM_FUCHSIA)
constexpr char kVulkanLibName[] = "libvulkan.so";
#elif defined(DAWN_ENABLE_SWIFTSHADER)
const char* kVulkanLibName = kSwiftshaderLibName;
#else
# error "Unimplemented Vulkan backend platform"
#endif