blob: 740c8e03f3074e779f1802cbc2e8b50ce65ddbfa [file] [log] [blame]
Corentin Wallezf5f7ab12018-08-13 08:31:17 +02001# Copyright 2018 The Dawn Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Austin Eng6ea362c2019-12-17 00:47:40 +000015import("//build_overrides/build.gni")
Austin Engc02f1432023-07-05 22:38:39 +000016import("dawn_overrides_with_defaults.gni")
Austin Eng6ea362c2019-12-17 00:47:40 +000017
18if (build_with_chromium) {
Maksim Sisov08949a32021-09-10 06:08:41 +000019 import("//build/config/ozone.gni")
Loko Kung349062f2021-11-29 18:18:58 +000020 import("//build/config/sanitizers/sanitizers.gni")
Corentin Walleza7278452020-10-15 14:30:23 +000021
Maksim Sisov08949a32021-09-10 06:08:41 +000022 dawn_use_x11 = ozone_platform_x11
Corentin Wallez2e22d922022-06-01 09:30:50 +000023 dawn_use_wayland = false
Corentin Walleza7278452020-10-15 14:30:23 +000024} else {
25 declare_args() {
26 # Whether Dawn should enable X11 support.
27 dawn_use_x11 = is_linux && !is_chromeos
Corentin Wallez2e22d922022-06-01 09:30:50 +000028 dawn_use_wayland = false
Corentin Walleza7278452020-10-15 14:30:23 +000029 }
Austin Eng6ea362c2019-12-17 00:47:40 +000030}
31
陈俊嘉02336e62021-04-23 02:16:12 +000032# Enable the compilation for UWP
33dawn_is_winuwp = is_win && target_os == "winuwp"
Stephen Gutekanst55623702023-07-01 11:43:55 +000034dawn_use_windows_ui = is_win
陈俊嘉02336e62021-04-23 02:16:12 +000035
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020036declare_args() {
Kenneth Russell417acaf2022-09-21 19:17:16 +000037 # TODO(dawn:1545): Re-enable dawn_use_angle on Android. In non-component
38 # builds, this is adding a dependency on ANGLE's libEGL.so and
39 # libGLESv2.so, apparently without regard for the use_static_angle=true
40 # GN variable. Chromium's linker on Android disallows production of more
41 # than one shared object per target (?).
Austin Engcfa10472023-09-05 18:02:47 +000042 dawn_use_angle = !is_android
Stephen White77fcdf72021-01-11 15:52:12 +000043
Austin Eng017f9cc2022-01-19 17:32:56 +000044 # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir
45 # to be set to take effect.
Brandon Jones8f3d7712022-09-06 22:40:13 +000046 # TODO(dawn:1536): Enable SwiftShader for Android.
Ian Vollick8509fcc2023-06-30 19:26:43 +000047 dawn_use_swiftshader = !is_android && !is_ios
Austin Engc02f1432023-07-05 22:38:39 +000048
49 # Whether we allow building DXC.
Antonio Maiorano9d7d7de2023-09-12 16:20:00 +000050 # DXC requires SM6.0+ which is blocklisted on x86,
51 # and arm64 support is not implemented yet.
Austin Engc02f1432023-07-05 22:38:39 +000052 # See crbug.com/tint/1753.
Antonio Maiorano9d7d7de2023-09-12 16:20:00 +000053 dawn_use_built_dxc = is_win && target_cpu != "x86" && target_cpu != "arm64"
Austin Engeb1ca452020-01-25 02:14:39 +000054}
55
56declare_args() {
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020057 # Enable Dawn's ASSERTs even in release builds
58 dawn_always_assert = false
59
Corentin Wallez03f64292019-01-12 17:26:49 +000060 # Should the Dawn static libraries be fully linked vs. GN's default of
61 # treating them as source sets. This is useful for people using Dawn
62 # standalone to produce static libraries to use in their projects.
63 dawn_complete_static_libs = false
64
Peng Huangebfd5052023-04-03 21:33:54 +000065 # Enables the compilation of Dawn's D3D11 backend
Peng Huang9cc29302023-05-03 23:42:25 +000066 dawn_enable_d3d11 = is_win
Peng Huangebfd5052023-04-03 21:33:54 +000067
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020068 # Enables the compilation of Dawn's D3D12 backend
69 dawn_enable_d3d12 = is_win
70
71 # Enables the compilation of Dawn's Metal backend
Ian Vollick8509fcc2023-06-30 19:26:43 +000072 dawn_enable_metal = is_mac || is_ios
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020073
74 # Enables the compilation of Dawn's Null backend
75 # (required for unittests, obviously non-conformant)
76 dawn_enable_null = true
77
78 # Enables the compilation of Dawn's OpenGL backend
79 # (best effort, non-conformant)
Stephen White7c0afdf2022-02-15 22:16:29 +000080 dawn_enable_desktop_gl = is_linux && !is_chromeos
Stephen White21ce5d22021-05-17 18:04:48 +000081
82 # Enables the compilation of Dawn's OpenGLES backend
83 # (WebGPU/Compat subset)
陈俊嘉16201e62021-05-31 08:46:21 +000084 # Disables OpenGLES when compiling for UWP, since UWP only supports d3d
Stephen White7c0afdf2022-02-15 22:16:29 +000085 dawn_enable_opengles =
Austin Engcfa10472023-09-05 18:02:47 +000086 (is_linux && !is_chromeos) || (is_win && !dawn_is_winuwp)
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020087
88 # Enables the compilation of Dawn's Vulkan backend
陈俊嘉02336e62021-04-23 02:16:12 +000089 # Disables vulkan when compiling for UWP, since UWP only supports d3d
Ian Vollickc1187342023-07-05 17:39:02 +000090 dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) ||
91 is_fuchsia || is_android || dawn_use_swiftshader
Ryan Harrisond5614482019-10-07 15:47:27 +000092
Austin Eng6ea362c2019-12-17 00:47:40 +000093 # Enables error injection for faking failures to native API calls
94 dawn_enable_error_injection =
95 is_debug || (build_with_chromium && use_fuzzing_engine)
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020096}
Li, Hao0e1bef32019-11-07 12:13:27 +000097
98# GN does not allow reading a variable defined in the same declare_args().
99# Put them in two separate declare_args() when setting the value of one
100# argument based on another.
Corentin Wallez74cebd62019-11-26 18:21:51 +0000101declare_args() {
Corentin Wallez09257202020-04-17 08:22:25 +0000102 # Uses our built version of the Vulkan validation layers
Corentin Wallez74cebd62019-11-26 18:21:51 +0000103 dawn_enable_vulkan_validation_layers =
Corentin Wallez09257202020-04-17 08:22:25 +0000104 dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win || is_mac)
105
106 # Uses our built version of the Vulkan loader on platforms where we can't
107 # assume to have one present at the system level.
Loko Kung349062f2021-11-29 18:18:58 +0000108 dawn_enable_vulkan_loader =
109 dawn_enable_vulkan && (is_mac || (is_linux && !is_android))
Brandon Jones61d2cf22023-01-19 21:17:42 +0000110
111 # Disable SPIR-V validation on Android because it adds a significant amount
112 # to the binary size, and Tint's output should be well-formed.
113 dawn_enable_spirv_validation = dawn_enable_vulkan && !is_android
Li, Hao0e1bef32019-11-07 12:13:27 +0000114}
Corentin Wallezb31015b2020-04-10 08:20:10 +0000115
陈俊嘉02336e62021-04-23 02:16:12 +0000116# UWP only supports CoreWindow for windowing
Corentin Wallezb31015b2020-04-10 08:20:10 +0000117dawn_supports_glfw_for_windowing =
陈俊嘉02336e62021-04-23 02:16:12 +0000118 (is_win && !dawn_is_winuwp) || (is_linux && !is_chromeos) || is_mac
Stephen White21ce5d22021-05-17 18:04:48 +0000119
Stephen White5d17ed62021-08-10 18:30:55 +0000120# Much of the GL backend code is shared, so define a convenience var.
Stephen White21ce5d22021-05-17 18:04:48 +0000121dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl