blob: 234791cf0d322802cf37e0b20e5581630f78eb0f [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")
16
17if (build_with_chromium) {
Maksim Sisov08949a32021-09-10 06:08:41 +000018 import("//build/config/ozone.gni")
Loko Kung349062f2021-11-29 18:18:58 +000019 import("//build/config/sanitizers/sanitizers.gni")
Corentin Walleza7278452020-10-15 14:30:23 +000020
Maksim Sisov08949a32021-09-10 06:08:41 +000021 dawn_use_x11 = ozone_platform_x11
Corentin Walleza7278452020-10-15 14:30:23 +000022} else {
23 declare_args() {
24 # Whether Dawn should enable X11 support.
25 dawn_use_x11 = is_linux && !is_chromeos
26 }
Austin Eng6ea362c2019-12-17 00:47:40 +000027}
28
陈俊嘉02336e62021-04-23 02:16:12 +000029# Enable the compilation for UWP
30dawn_is_winuwp = is_win && target_os == "winuwp"
31
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020032declare_args() {
Stephen White77fcdf72021-01-11 15:52:12 +000033 dawn_use_angle = true
34
Austin Eng017f9cc2022-01-19 17:32:56 +000035 # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir
36 # to be set to take effect.
Austin Eng9157c782022-01-21 20:00:18 +000037 dawn_use_swiftshader = true
Austin Engeb1ca452020-01-25 02:14:39 +000038}
39
40declare_args() {
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020041 # Enable Dawn's ASSERTs even in release builds
42 dawn_always_assert = false
43
Corentin Wallez03f64292019-01-12 17:26:49 +000044 # Should the Dawn static libraries be fully linked vs. GN's default of
45 # treating them as source sets. This is useful for people using Dawn
46 # standalone to produce static libraries to use in their projects.
47 dawn_complete_static_libs = false
48
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020049 # Enables the compilation of Dawn's D3D12 backend
50 dawn_enable_d3d12 = is_win
51
52 # Enables the compilation of Dawn's Metal backend
53 dawn_enable_metal = is_mac
54
55 # Enables the compilation of Dawn's Null backend
56 # (required for unittests, obviously non-conformant)
57 dawn_enable_null = true
58
59 # Enables the compilation of Dawn's OpenGL backend
60 # (best effort, non-conformant)
Stephen White7c0afdf2022-02-15 22:16:29 +000061 dawn_enable_desktop_gl = is_linux && !is_chromeos
Stephen White21ce5d22021-05-17 18:04:48 +000062
63 # Enables the compilation of Dawn's OpenGLES backend
64 # (WebGPU/Compat subset)
陈俊嘉16201e62021-05-31 08:46:21 +000065 # Disables OpenGLES when compiling for UWP, since UWP only supports d3d
Stephen White7c0afdf2022-02-15 22:16:29 +000066 dawn_enable_opengles =
67 (is_linux && !is_chromeos) || (is_win && !dawn_is_winuwp)
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020068
69 # Enables the compilation of Dawn's Vulkan backend
陈俊嘉02336e62021-04-23 02:16:12 +000070 # Disables vulkan when compiling for UWP, since UWP only supports d3d
71 dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) ||
72 is_fuchsia || is_android || dawn_use_swiftshader
Ryan Harrisond5614482019-10-07 15:47:27 +000073
Austin Eng6ea362c2019-12-17 00:47:40 +000074 # Enables error injection for faking failures to native API calls
75 dawn_enable_error_injection =
76 is_debug || (build_with_chromium && use_fuzzing_engine)
Corentin Wallezf5f7ab12018-08-13 08:31:17 +020077}
Li, Hao0e1bef32019-11-07 12:13:27 +000078
79# GN does not allow reading a variable defined in the same declare_args().
80# Put them in two separate declare_args() when setting the value of one
81# argument based on another.
Corentin Wallez74cebd62019-11-26 18:21:51 +000082declare_args() {
Corentin Wallez09257202020-04-17 08:22:25 +000083 # Uses our built version of the Vulkan validation layers
Corentin Wallez74cebd62019-11-26 18:21:51 +000084 dawn_enable_vulkan_validation_layers =
Corentin Wallez09257202020-04-17 08:22:25 +000085 dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win || is_mac)
86
87 # Uses our built version of the Vulkan loader on platforms where we can't
88 # assume to have one present at the system level.
Loko Kung349062f2021-11-29 18:18:58 +000089 dawn_enable_vulkan_loader =
90 dawn_enable_vulkan && (is_mac || (is_linux && !is_android))
Li, Hao0e1bef32019-11-07 12:13:27 +000091}
Corentin Wallezb31015b2020-04-10 08:20:10 +000092
陈俊嘉02336e62021-04-23 02:16:12 +000093# UWP only supports CoreWindow for windowing
Corentin Wallezb31015b2020-04-10 08:20:10 +000094dawn_supports_glfw_for_windowing =
陈俊嘉02336e62021-04-23 02:16:12 +000095 (is_win && !dawn_is_winuwp) || (is_linux && !is_chromeos) || is_mac
Stephen White21ce5d22021-05-17 18:04:48 +000096
Stephen White5d17ed62021-08-10 18:30:55 +000097# Much of the GL backend code is shared, so define a convenience var.
Stephen White21ce5d22021-05-17 18:04:48 +000098dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl