blob: 323c0a9cda82c10446ee0635b68439f10a4cd598 [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001# Copyright 2018 The Dawn & Tint Authors
Corentin Wallezf5f7ab12018-08-13 08:31:17 +02002#
Austin Engcc2516a2023-10-17 20:57:54 +00003# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are met:
Corentin Wallezf5f7ab12018-08-13 08:31:17 +02005#
Austin Engcc2516a2023-10-17 20:57:54 +00006# 1. Redistributions of source code must retain the above copyright notice, this
7# list of conditions and the following disclaimer.
Corentin Wallezf5f7ab12018-08-13 08:31:17 +02008#
Austin Engcc2516a2023-10-17 20:57:54 +00009# 2. Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12#
13# 3. Neither the name of the copyright holder nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020027
Austin Eng6ea362c2019-12-17 00:47:40 +000028import("//build_overrides/build.gni")
Austin Engc02f1432023-07-05 22:38:39 +000029import("dawn_overrides_with_defaults.gni")
Austin Eng6ea362c2019-12-17 00:47:40 +000030
31if (build_with_chromium) {
Maksim Sisov08949a32021-09-10 06:08:41 +000032 import("//build/config/ozone.gni")
Loko Kung349062f2021-11-29 18:18:58 +000033 import("//build/config/sanitizers/sanitizers.gni")
Corentin Walleza7278452020-10-15 14:30:23 +000034
Maksim Sisov08949a32021-09-10 06:08:41 +000035 dawn_use_x11 = ozone_platform_x11
Corentin Wallez2e22d922022-06-01 09:30:50 +000036 dawn_use_wayland = false
Corentin Walleza7278452020-10-15 14:30:23 +000037} else {
38 declare_args() {
39 # Whether Dawn should enable X11 support.
40 dawn_use_x11 = is_linux && !is_chromeos
Corentin Wallez2e22d922022-06-01 09:30:50 +000041 dawn_use_wayland = false
Corentin Walleza7278452020-10-15 14:30:23 +000042 }
Austin Eng6ea362c2019-12-17 00:47:40 +000043}
44
陈俊嘉02336e62021-04-23 02:16:12 +000045# Enable the compilation for UWP
46dawn_is_winuwp = is_win && target_os == "winuwp"
Stephen Gutekanst55623702023-07-01 11:43:55 +000047dawn_use_windows_ui = is_win
陈俊嘉02336e62021-04-23 02:16:12 +000048
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020049declare_args() {
Stephen White90d59b42023-11-29 17:02:31 +000050 dawn_tests_use_angle = true
Stephen White77fcdf72021-01-11 15:52:12 +000051
Austin Eng017f9cc2022-01-19 17:32:56 +000052 # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir
53 # to be set to take effect.
Brandon Jones8f3d7712022-09-06 22:40:13 +000054 # TODO(dawn:1536): Enable SwiftShader for Android.
Ian Vollick8509fcc2023-06-30 19:26:43 +000055 dawn_use_swiftshader = !is_android && !is_ios
Austin Engc02f1432023-07-05 22:38:39 +000056
57 # Whether we allow building DXC.
Antonio Maiorano9d7d7de2023-09-12 16:20:00 +000058 # DXC requires SM6.0+ which is blocklisted on x86,
59 # and arm64 support is not implemented yet.
Austin Engc02f1432023-07-05 22:38:39 +000060 # See crbug.com/tint/1753.
Antonio Maiorano9d7d7de2023-09-12 16:20:00 +000061 dawn_use_built_dxc = is_win && target_cpu != "x86" && target_cpu != "arm64"
Austin Engeb1ca452020-01-25 02:14:39 +000062}
63
64declare_args() {
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020065 # Enable Dawn's ASSERTs even in release builds
66 dawn_always_assert = false
67
Corentin Wallez03f64292019-01-12 17:26:49 +000068 # Should the Dawn static libraries be fully linked vs. GN's default of
69 # treating them as source sets. This is useful for people using Dawn
70 # standalone to produce static libraries to use in their projects.
71 dawn_complete_static_libs = false
72
Peng Huangebfd5052023-04-03 21:33:54 +000073 # Enables the compilation of Dawn's D3D11 backend
Peng Huang9cc29302023-05-03 23:42:25 +000074 dawn_enable_d3d11 = is_win
Peng Huangebfd5052023-04-03 21:33:54 +000075
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020076 # Enables the compilation of Dawn's D3D12 backend
77 dawn_enable_d3d12 = is_win
78
79 # Enables the compilation of Dawn's Metal backend
Ian Vollick8509fcc2023-06-30 19:26:43 +000080 dawn_enable_metal = is_mac || is_ios
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020081
82 # Enables the compilation of Dawn's Null backend
83 # (required for unittests, obviously non-conformant)
84 dawn_enable_null = true
85
86 # Enables the compilation of Dawn's OpenGL backend
87 # (best effort, non-conformant)
Stephen White7c0afdf2022-02-15 22:16:29 +000088 dawn_enable_desktop_gl = is_linux && !is_chromeos
Stephen White21ce5d22021-05-17 18:04:48 +000089
90 # Enables the compilation of Dawn's OpenGLES backend
91 # (WebGPU/Compat subset)
陈俊嘉16201e62021-05-31 08:46:21 +000092 # Disables OpenGLES when compiling for UWP, since UWP only supports d3d
Stephen White7c0afdf2022-02-15 22:16:29 +000093 dawn_enable_opengles =
Stephen White20a67ef2024-04-06 10:54:12 +000094 (is_linux && !is_chromeos) || (is_win && !dawn_is_winuwp) || is_android
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020095
96 # Enables the compilation of Dawn's Vulkan backend
陈俊嘉02336e62021-04-23 02:16:12 +000097 # Disables vulkan when compiling for UWP, since UWP only supports d3d
Ian Vollickc1187342023-07-05 17:39:02 +000098 dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) ||
99 is_fuchsia || is_android || dawn_use_swiftshader
Ryan Harrisond5614482019-10-07 15:47:27 +0000100
Austin Eng6ea362c2019-12-17 00:47:40 +0000101 # Enables error injection for faking failures to native API calls
102 dawn_enable_error_injection =
103 is_debug || (build_with_chromium && use_fuzzing_engine)
Corentin Wallezf5f7ab12018-08-13 08:31:17 +0200104}
Li, Hao0e1bef32019-11-07 12:13:27 +0000105
106# GN does not allow reading a variable defined in the same declare_args().
107# Put them in two separate declare_args() when setting the value of one
108# argument based on another.
Corentin Wallez74cebd62019-11-26 18:21:51 +0000109declare_args() {
Corentin Wallez09257202020-04-17 08:22:25 +0000110 # Uses our built version of the Vulkan validation layers
Corentin Wallez74cebd62019-11-26 18:21:51 +0000111 dawn_enable_vulkan_validation_layers =
Corentin Wallez09257202020-04-17 08:22:25 +0000112 dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win || is_mac)
113
114 # Uses our built version of the Vulkan loader on platforms where we can't
115 # assume to have one present at the system level.
Loko Kung349062f2021-11-29 18:18:58 +0000116 dawn_enable_vulkan_loader =
117 dawn_enable_vulkan && (is_mac || (is_linux && !is_android))
Brandon Jones61d2cf22023-01-19 21:17:42 +0000118
119 # Disable SPIR-V validation on Android because it adds a significant amount
120 # to the binary size, and Tint's output should be well-formed.
121 dawn_enable_spirv_validation = dawn_enable_vulkan && !is_android
Li, Hao0e1bef32019-11-07 12:13:27 +0000122}
Corentin Wallezb31015b2020-04-10 08:20:10 +0000123
陈俊嘉02336e62021-04-23 02:16:12 +0000124# UWP only supports CoreWindow for windowing
Corentin Wallezb31015b2020-04-10 08:20:10 +0000125dawn_supports_glfw_for_windowing =
陈俊嘉02336e62021-04-23 02:16:12 +0000126 (is_win && !dawn_is_winuwp) || (is_linux && !is_chromeos) || is_mac
Stephen White21ce5d22021-05-17 18:04:48 +0000127
Stephen White5d17ed62021-08-10 18:30:55 +0000128# Much of the GL backend code is shared, so define a convenience var.
Stephen White21ce5d22021-05-17 18:04:48 +0000129dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl