Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | # Copyright 2018 The Dawn & Tint Authors |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 2 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions are met: |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 5 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | # 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | # list of conditions and the following disclaimer. |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 8 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | # 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 Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 27 | |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 28 | import("//build_overrides/build.gni") |
Austin Eng | c02f143 | 2023-07-05 22:38:39 +0000 | [diff] [blame] | 29 | import("dawn_overrides_with_defaults.gni") |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 30 | |
| 31 | if (build_with_chromium) { |
Maksim Sisov | 08949a3 | 2021-09-10 06:08:41 +0000 | [diff] [blame] | 32 | import("//build/config/ozone.gni") |
Loko Kung | 349062f | 2021-11-29 18:18:58 +0000 | [diff] [blame] | 33 | import("//build/config/sanitizers/sanitizers.gni") |
Corentin Wallez | a727845 | 2020-10-15 14:30:23 +0000 | [diff] [blame] | 34 | |
Maksim Sisov | 08949a3 | 2021-09-10 06:08:41 +0000 | [diff] [blame] | 35 | dawn_use_x11 = ozone_platform_x11 |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 36 | dawn_use_wayland = false |
Corentin Wallez | a727845 | 2020-10-15 14:30:23 +0000 | [diff] [blame] | 37 | } else { |
| 38 | declare_args() { |
| 39 | # Whether Dawn should enable X11 support. |
| 40 | dawn_use_x11 = is_linux && !is_chromeos |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 41 | dawn_use_wayland = false |
Corentin Wallez | a727845 | 2020-10-15 14:30:23 +0000 | [diff] [blame] | 42 | } |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 43 | } |
| 44 | |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 45 | # Enable the compilation for UWP |
| 46 | dawn_is_winuwp = is_win && target_os == "winuwp" |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 47 | dawn_use_windows_ui = is_win |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 48 | |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 49 | declare_args() { |
Stephen White | 90d59b4 | 2023-11-29 17:02:31 +0000 | [diff] [blame] | 50 | dawn_tests_use_angle = true |
Stephen White | 77fcdf7 | 2021-01-11 15:52:12 +0000 | [diff] [blame] | 51 | |
Austin Eng | 017f9cc | 2022-01-19 17:32:56 +0000 | [diff] [blame] | 52 | # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir |
| 53 | # to be set to take effect. |
Brandon Jones | 8f3d771 | 2022-09-06 22:40:13 +0000 | [diff] [blame] | 54 | # TODO(dawn:1536): Enable SwiftShader for Android. |
Ian Vollick | 8509fcc | 2023-06-30 19:26:43 +0000 | [diff] [blame] | 55 | dawn_use_swiftshader = !is_android && !is_ios |
Austin Eng | c02f143 | 2023-07-05 22:38:39 +0000 | [diff] [blame] | 56 | |
| 57 | # Whether we allow building DXC. |
Antonio Maiorano | 9d7d7de | 2023-09-12 16:20:00 +0000 | [diff] [blame] | 58 | # DXC requires SM6.0+ which is blocklisted on x86, |
| 59 | # and arm64 support is not implemented yet. |
Austin Eng | c02f143 | 2023-07-05 22:38:39 +0000 | [diff] [blame] | 60 | # See crbug.com/tint/1753. |
Antonio Maiorano | 9d7d7de | 2023-09-12 16:20:00 +0000 | [diff] [blame] | 61 | dawn_use_built_dxc = is_win && target_cpu != "x86" && target_cpu != "arm64" |
Austin Eng | eb1ca45 | 2020-01-25 02:14:39 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | declare_args() { |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 65 | # Enable Dawn's ASSERTs even in release builds |
| 66 | dawn_always_assert = false |
| 67 | |
Corentin Wallez | 03f6429 | 2019-01-12 17:26:49 +0000 | [diff] [blame] | 68 | # 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 Huang | ebfd505 | 2023-04-03 21:33:54 +0000 | [diff] [blame] | 73 | # Enables the compilation of Dawn's D3D11 backend |
Peng Huang | 9cc2930 | 2023-05-03 23:42:25 +0000 | [diff] [blame] | 74 | dawn_enable_d3d11 = is_win |
Peng Huang | ebfd505 | 2023-04-03 21:33:54 +0000 | [diff] [blame] | 75 | |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 76 | # 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 Vollick | 8509fcc | 2023-06-30 19:26:43 +0000 | [diff] [blame] | 80 | dawn_enable_metal = is_mac || is_ios |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 81 | |
| 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 White | 7c0afdf | 2022-02-15 22:16:29 +0000 | [diff] [blame] | 88 | dawn_enable_desktop_gl = is_linux && !is_chromeos |
Stephen White | 21ce5d2 | 2021-05-17 18:04:48 +0000 | [diff] [blame] | 89 | |
| 90 | # Enables the compilation of Dawn's OpenGLES backend |
| 91 | # (WebGPU/Compat subset) |
陈俊嘉 | 16201e6 | 2021-05-31 08:46:21 +0000 | [diff] [blame] | 92 | # Disables OpenGLES when compiling for UWP, since UWP only supports d3d |
Stephen White | 7c0afdf | 2022-02-15 22:16:29 +0000 | [diff] [blame] | 93 | dawn_enable_opengles = |
Stephen White | 20a67ef | 2024-04-06 10:54:12 +0000 | [diff] [blame] | 94 | (is_linux && !is_chromeos) || (is_win && !dawn_is_winuwp) || is_android |
Corentin Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 95 | |
| 96 | # Enables the compilation of Dawn's Vulkan backend |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 97 | # Disables vulkan when compiling for UWP, since UWP only supports d3d |
Ian Vollick | c118734 | 2023-07-05 17:39:02 +0000 | [diff] [blame] | 98 | dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) || |
| 99 | is_fuchsia || is_android || dawn_use_swiftshader |
Ryan Harrison | d561448 | 2019-10-07 15:47:27 +0000 | [diff] [blame] | 100 | |
Austin Eng | 6ea362c | 2019-12-17 00:47:40 +0000 | [diff] [blame] | 101 | # 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 Wallez | f5f7ab1 | 2018-08-13 08:31:17 +0200 | [diff] [blame] | 104 | } |
Li, Hao | 0e1bef3 | 2019-11-07 12:13:27 +0000 | [diff] [blame] | 105 | |
| 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 Wallez | 74cebd6 | 2019-11-26 18:21:51 +0000 | [diff] [blame] | 109 | declare_args() { |
Corentin Wallez | 0925720 | 2020-04-17 08:22:25 +0000 | [diff] [blame] | 110 | # Uses our built version of the Vulkan validation layers |
Corentin Wallez | 74cebd6 | 2019-11-26 18:21:51 +0000 | [diff] [blame] | 111 | dawn_enable_vulkan_validation_layers = |
Corentin Wallez | 0925720 | 2020-04-17 08:22:25 +0000 | [diff] [blame] | 112 | 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 Kung | 349062f | 2021-11-29 18:18:58 +0000 | [diff] [blame] | 116 | dawn_enable_vulkan_loader = |
| 117 | dawn_enable_vulkan && (is_mac || (is_linux && !is_android)) |
Brandon Jones | 61d2cf2 | 2023-01-19 21:17:42 +0000 | [diff] [blame] | 118 | |
| 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, Hao | 0e1bef3 | 2019-11-07 12:13:27 +0000 | [diff] [blame] | 122 | } |
Corentin Wallez | b31015b | 2020-04-10 08:20:10 +0000 | [diff] [blame] | 123 | |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 124 | # UWP only supports CoreWindow for windowing |
Corentin Wallez | b31015b | 2020-04-10 08:20:10 +0000 | [diff] [blame] | 125 | dawn_supports_glfw_for_windowing = |
陈俊嘉 | 02336e6 | 2021-04-23 02:16:12 +0000 | [diff] [blame] | 126 | (is_win && !dawn_is_winuwp) || (is_linux && !is_chromeos) || is_mac |
Stephen White | 21ce5d2 | 2021-05-17 18:04:48 +0000 | [diff] [blame] | 127 | |
Stephen White | 5d17ed6 | 2021-08-10 18:30:55 +0000 | [diff] [blame] | 128 | # 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] | 129 | dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl |