dawn-cmake/src/common/BUILD.gn

115 lines
3.1 KiB
Plaintext
Raw Normal View History

# Copyright 2019 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.
import("../../scripts/dawn_overrides_with_defaults.gni")
import("//build_overrides/build.gni")
import("${dawn_root}/scripts/dawn_features.gni")
# Use Chromium's dcheck_always_on when available so that we respect it when
# running tests on the GPU builders
if (build_with_chromium) {
import("//build/config/dcheck_always_on.gni")
} else {
dcheck_always_on = false
}
###############################################################################
# Common dawn configs
###############################################################################
config("dawn_public_include_dirs") {
include_dirs = [
"${target_gen_dir}/../..",
"${dawn_root}/src/include",
]
}
config("dawn_internal") {
include_dirs = [ "${dawn_root}/src" ]
defines = []
if (dawn_always_assert || dcheck_always_on || is_debug) {
defines += [ "DAWN_ENABLE_ASSERTS" ]
}
if (dawn_enable_d3d12) {
defines += [ "DAWN_ENABLE_BACKEND_D3D12" ]
}
if (dawn_enable_metal) {
defines += [ "DAWN_ENABLE_BACKEND_METAL" ]
}
if (dawn_enable_null) {
defines += [ "DAWN_ENABLE_BACKEND_NULL" ]
}
if (dawn_enable_opengl) {
defines += [ "DAWN_ENABLE_BACKEND_OPENGL" ]
}
if (dawn_enable_vulkan) {
defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
}
if (is_linux && !is_chromeos) {
defines += [ "DAWN_USE_X11" ]
}
# Only internal Dawn targets can use this config, this means only targets in
# this BUILD.gn file.
visibility = [ ":*" ]
}
###############################################################################
# Common dawn library
###############################################################################
# This GN file is discovered by all Chromium builds, but common doesn't support
# all of Chromium's OSes so we explicitly make the target visible only on
# systems we know Dawn is able to compile on.
Enable Vulkan for Chromium Fuchsia build. Enable the Vulkan backend when building Dawn with the Chromium build system for Fuchsia. To make this work properly the following is required: - Modify VulkanInfo.cpp and BackendVk.cpp to correctly probe the Fuchsia swapchain layer and its layer extension, as well as enabling them when creating a new VkInstance. - Modify VulkanFunctions.cpp to load the Fuchsia swapchain related extension for this platform only. - Provide a small mock GLFW library for Fuchsia under src/utils/Glfw3Fuchsia.cpp, since the upstream project does not support this platform at all. Its purpose is only to allow the creation of the right VulkanBinding instance, which depends on the creation of a display surface for latter swapchain creation. - Add //third_party/fuchsia-sdk:vulkan_base and //third_party/fuchsia-sdk:vulkan_validation as data_deps of the libdawn_native_sources target in order to ensure that the Fuchsia package created by the build system will include the correct Vulkan libraries (loader and validation layers). This builds correctly, and both dawn_unittests and dawn_end2end_tests will run on a real Fuchsia device or inside the Fuchsia emulator, using either GPU virtualization or a software-based renderer. Note: dawn_unittests will also run inside QEMU, but not dawn_end2end_tests, since the latter requires proper GPU emulation which is not available in this environment. NOTE: All end2end tests pass using a device with an "Intel HD Graphics 615 (Kaby Lake GT2)" adapter. However: - For some reason, a single test takes up to 129 seconds to pass (BufferSetSubDataTests.ManySetSubData/Vulkan). - The test process crashes inside VkDestroyInstance(), apparently inside the Fuchsia-specific imagepipe layer (which implements swapchain support). This is likely a bug in the layer itself, and not Dawn. Also, may end2end tests will crash when run inside the Fuchsia emulator (which uses GPU virtualization to talk to the host GPU). The crashes happen inside libvulkan-goldfish.so, the emulator-specific Vulkan ICD on this sytem. Not a Dawn bug either. Bug=dawn:221 Change-Id: Id3598b673e8c6393f24db728b8da49fdde3cac76 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8963 Commit-Queue: David Turner <digit@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-09 10:52:08 +00:00
if (is_win || is_linux || is_mac || is_fuchsia) {
static_library("common") {
sources = [
"Assert.cpp",
"Assert.h",
"BitSetIterator.h",
"Compiler.h",
"Constants.h",
"DynamicLib.cpp",
"DynamicLib.h",
"HashUtils.h",
"Math.cpp",
"Math.h",
"Platform.h",
"Result.cpp",
"Result.h",
"Serial.h",
"SerialMap.h",
"SerialQueue.h",
"SerialStorage.h",
"SwapChainUtils.h",
"vulkan_platform.h",
"windows_with_undefs.h",
]
public_configs = [ ":dawn_internal" ]
deps = [
"${dawn_root}/src/dawn:dawn_headers",
]
if (dawn_enable_vulkan) {
public_deps = [
"../../third_party:vulkan_headers",
]
}
}
}