Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 1 | # 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 Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 15 | import("//build_overrides/build.gni") |
Austin Eng | c02f143 | 2023-07-05 22:38:39 +0000 | [diff] [blame] | 16 | import("dawn_overrides_with_defaults.gni") |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 17 | |
| 18 | if (build_with_chromium) { |
Maksim Sisov | 08949a3 | 2021-09-10 06:08:41 +0000 | [diff] [blame] | 19 | import("//build/config/ozone.gni") |
Loko Kung | 349062f | 2021-11-29 18:18:58 +0000 | [diff] [blame] | 20 | import("//build/config/sanitizers/sanitizers.gni") |
Corentin Wallez | a727845 | 2020-10-15 14:30:23 +0000 | [diff] [blame] | 21 | |
Maksim Sisov | 08949a3 | 2021-09-10 06:08:41 +0000 | [diff] [blame] | 22 | dawn_use_x11 = ozone_platform_x11 |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 23 | dawn_use_wayland = false |
Corentin Wallez | a727845 | 2020-10-15 14:30:23 +0000 | [diff] [blame] | 24 | } else { |
| 25 | declare_args() { |
| 26 | # Whether Dawn should enable X11 support. |
| 27 | dawn_use_x11 = is_linux && !is_chromeos |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 28 | dawn_use_wayland = false |
Corentin Wallez | a727845 | 2020-10-15 14:30:23 +0000 | [diff] [blame] | 29 | } |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 30 | } |
| 31 | |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 32 | # Enable the compilation for UWP |
| 33 | dawn_is_winuwp = is_win && target_os == "winuwp" |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 34 | dawn_use_windows_ui = is_win |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 35 | |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 36 | declare_args() { |
Kenneth Russell | 417acaf | 2022-09-21 19:17:16 +0000 | [diff] [blame] | 37 | # 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 Eng | cfa1047 | 2023-09-05 18:02:47 +0000 | [diff] [blame] | 42 | dawn_use_angle = !is_android |
Stephen White | 77fcdf7 | 2021-01-11 15:52:12 +0000 | [diff] [blame] | 43 | |
Austin Eng | 017f9cc | 2022-01-19 17:32:56 +0000 | [diff] [blame] | 44 | # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir |
| 45 | # to be set to take effect. |
Brandon Jones | 8f3d771 | 2022-09-06 22:40:13 +0000 | [diff] [blame] | 46 | # TODO(dawn:1536): Enable SwiftShader for Android. |
Ian Vollick | 8509fcc | 2023-06-30 19:26:43 +0000 | [diff] [blame] | 47 | dawn_use_swiftshader = !is_android && !is_ios |
Austin Eng | c02f143 | 2023-07-05 22:38:39 +0000 | [diff] [blame] | 48 | |
| 49 | # Whether we allow building DXC. |
Antonio Maiorano | 9d7d7de | 2023-09-12 16:20:00 +0000 | [diff] [blame] | 50 | # DXC requires SM6.0+ which is blocklisted on x86, |
| 51 | # and arm64 support is not implemented yet. |
Austin Eng | c02f143 | 2023-07-05 22:38:39 +0000 | [diff] [blame] | 52 | # See crbug.com/tint/1753. |
Antonio Maiorano | 9d7d7de | 2023-09-12 16:20:00 +0000 | [diff] [blame] | 53 | dawn_use_built_dxc = is_win && target_cpu != "x86" && target_cpu != "arm64" |
Austin Eng | eb1ca45 | 2020-01-25 02:14:39 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | declare_args() { |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 57 | # Enable Dawn's ASSERTs even in release builds |
| 58 | dawn_always_assert = false |
| 59 | |
Corentin Wallez | 03f6429 | 2019-01-12 17:26:49 +0000 | [diff] [blame] | 60 | # 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 Huang | ebfd505 | 2023-04-03 21:33:54 +0000 | [diff] [blame] | 65 | # Enables the compilation of Dawn's D3D11 backend |
Peng Huang | 9cc2930 | 2023-05-03 23:42:25 +0000 | [diff] [blame] | 66 | dawn_enable_d3d11 = is_win |
Peng Huang | ebfd505 | 2023-04-03 21:33:54 +0000 | [diff] [blame] | 67 | |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 68 | # 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 Vollick | 8509fcc | 2023-06-30 19:26:43 +0000 | [diff] [blame] | 72 | dawn_enable_metal = is_mac || is_ios |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 73 | |
| 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 White | 7c0afdf | 2022-02-15 22:16:29 +0000 | [diff] [blame] | 80 | dawn_enable_desktop_gl = is_linux && !is_chromeos |
Stephen White | 21ce5d2 | 2021-05-17 18:04:48 +0000 | [diff] [blame] | 81 | |
| 82 | # Enables the compilation of Dawn's OpenGLES backend |
| 83 | # (WebGPU/Compat subset) |
陈俊嘉 | 16201e6 | 2021-05-31 08:46:21 +0000 | [diff] [blame] | 84 | # Disables OpenGLES when compiling for UWP, since UWP only supports d3d |
Stephen White | 7c0afdf | 2022-02-15 22:16:29 +0000 | [diff] [blame] | 85 | dawn_enable_opengles = |
Austin Eng | cfa1047 | 2023-09-05 18:02:47 +0000 | [diff] [blame] | 86 | (is_linux && !is_chromeos) || (is_win && !dawn_is_winuwp) |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 87 | |
| 88 | # Enables the compilation of Dawn's Vulkan backend |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 89 | # Disables vulkan when compiling for UWP, since UWP only supports d3d |
Ian Vollick | c118734 | 2023-07-05 17:39:02 +0000 | [diff] [blame] | 90 | dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) || |
| 91 | is_fuchsia || is_android || dawn_use_swiftshader |
Ryan Harrison | d561448 | 2019-10-07 15:47:27 +0000 | [diff] [blame] | 92 | |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 93 | # 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 Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 96 | } |
Li, Hao | 0e1bef3 | 2019-11-07 12:13:27 +0000 | [diff] [blame] | 97 | |
| 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 Wallez | 74cebd6 | 2019-11-26 18:21:51 +0000 | [diff] [blame] | 101 | declare_args() { |
Corentin Wallez | 0925720 | 2020-04-17 08:22:25 +0000 | [diff] [blame] | 102 | # Uses our built version of the Vulkan validation layers |
Corentin Wallez | 74cebd6 | 2019-11-26 18:21:51 +0000 | [diff] [blame] | 103 | dawn_enable_vulkan_validation_layers = |
Corentin Wallez | 0925720 | 2020-04-17 08:22:25 +0000 | [diff] [blame] | 104 | 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 Kung | 349062f | 2021-11-29 18:18:58 +0000 | [diff] [blame] | 108 | dawn_enable_vulkan_loader = |
| 109 | dawn_enable_vulkan && (is_mac || (is_linux && !is_android)) |
Brandon Jones | 61d2cf2 | 2023-01-19 21:17:42 +0000 | [diff] [blame] | 110 | |
| 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, Hao | 0e1bef3 | 2019-11-07 12:13:27 +0000 | [diff] [blame] | 114 | } |
Corentin Wallez | b31015b | 2020-04-10 08:20:10 +0000 | [diff] [blame] | 115 | |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 116 | # UWP only supports CoreWindow for windowing |
Corentin Wallez | b31015b | 2020-04-10 08:20:10 +0000 | [diff] [blame] | 117 | dawn_supports_glfw_for_windowing = |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 118 | (is_win && !dawn_is_winuwp) || (is_linux && !is_chromeos) || is_mac |
Stephen White | 21ce5d2 | 2021-05-17 18:04:48 +0000 | [diff] [blame] | 119 | |
Stephen White | 5d17ed6 | 2021-08-10 18:30:55 +0000 | [diff] [blame] | 120 | # Much of the GL backend code is shared, so define a convenience var. |
Stephen White | 21ce5d2 | 2021-05-17 18:04:48 +0000 | [diff] [blame] | 121 | dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl |