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:
parent
53f694b34a
commit
0925720ecb
|
@ -23,6 +23,7 @@ third_party/swiftshader/
|
|||
third_party/spirv-cross/
|
||||
third_party/spirv-headers/
|
||||
third_party/vulkan-headers/
|
||||
third_party/vulkan-loader/
|
||||
third_party/vulkan-validation-layers/
|
||||
tools
|
||||
out
|
||||
|
|
8
DEPS
8
DEPS
|
@ -101,17 +101,19 @@ deps = {
|
|||
'condition': 'dawn_standalone and checkout_linux',
|
||||
},
|
||||
|
||||
# Khronos Vulkan-Headers
|
||||
# Khronos Vulkan headers, validation layers and loader.
|
||||
'third_party/vulkan-headers': {
|
||||
'url': '{chromium_git}/external/github.com/KhronosGroup/Vulkan-Headers@e01f13e1f777cf592ebd1a5f4836d4cd10ed85f6',
|
||||
'condition': 'dawn_standalone',
|
||||
},
|
||||
|
||||
# Khronos Vulkan-ValidationLayers
|
||||
'third_party/vulkan-validation-layers': {
|
||||
'url': '{chromium_git}/external/github.com/KhronosGroup/Vulkan-ValidationLayers@1533266eac486fae0c34bffe4868c4bc91dbe078',
|
||||
'condition': 'dawn_standalone',
|
||||
},
|
||||
'third_party/vulkan-loader': {
|
||||
'url': '{chromium_git}/external/github.com/KhronosGroup/Vulkan-Loader@3f7e3cbf33a732e945b3780212aad853ca0add29',
|
||||
'condition': 'dawn_standalone',
|
||||
},
|
||||
|
||||
'third_party/swiftshader': {
|
||||
'url': '{swiftshader_git}/SwiftShader@63ed0e445fa525ee01637350ea92fbdaa2226c73',
|
||||
|
|
|
@ -35,4 +35,5 @@ dawn_shaderc_dir = "//third_party/shaderc"
|
|||
dawn_spirv_tools_dir = "//third_party/SPIRV-Tools"
|
||||
dawn_spirv_cross_dir = "//third_party/spirv-cross"
|
||||
dawn_swiftshader_dir = "//third_party/swiftshader"
|
||||
dawn_vulkan_loader_dir = "//third_party/vulkan-loader"
|
||||
dawn_vulkan_validation_layers_dir = "//third_party/vulkan-validation-layers"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# 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.
|
||||
|
||||
vulkan_headers_dir = "//third_party/vulkan-headers"
|
||||
|
||||
vulkan_gen_subdir = "vulkan_loader"
|
||||
vulkan_loader_shared = true
|
|
@ -74,9 +74,13 @@ declare_args() {
|
|||
# Put them in two separate declare_args() when setting the value of one
|
||||
# argument based on another.
|
||||
declare_args() {
|
||||
# Uses our built version of Vulkan validation layers
|
||||
# Uses our built version of the Vulkan validation layers
|
||||
dawn_enable_vulkan_validation_layers =
|
||||
dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win)
|
||||
dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win || is_mac)
|
||||
|
||||
# Uses our built version of the Vulkan loader on platforms where we can't
|
||||
# assume to have one present at the system level.
|
||||
dawn_enable_vulkan_loader = dawn_enable_vulkan && is_mac
|
||||
}
|
||||
|
||||
dawn_supports_glfw_for_windowing =
|
||||
|
|
|
@ -62,6 +62,11 @@ if (!defined(dawn_swiftshader_dir)) {
|
|||
dawn_swiftshader_dir = ""
|
||||
}
|
||||
|
||||
if (!defined(dawn_vulkan_loader_dir)) {
|
||||
# Default to the Vulkan loader not being available.
|
||||
dawn_vulkan_loader_dir = ""
|
||||
}
|
||||
|
||||
if (!defined(dawn_vulkan_validation_layers_dir)) {
|
||||
# Default to VVLs not being available.
|
||||
dawn_vulkan_validation_layers_dir = ""
|
||||
|
|
|
@ -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" ]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue