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 15import("${skia_root_dir}/build_overrides/build.gni") 16 17if (build_with_chromium) { 18 import("${skia_root_dir}/build/config/ozone.gni") 19 import("${skia_root_dir}/build/config/sanitizers/sanitizers.gni") 20 21 dawn_use_x11 = ozone_platform_x11 22} else { 23 declare_args() { 24 # Whether Dawn should enable X11 support. 25 dawn_use_x11 = is_linux && !is_chromeos 26 } 27} 28 29# Enable the compilation for UWP 30dawn_is_winuwp = is_win && target_os == "winuwp" 31 32declare_args() { 33 dawn_use_angle = true 34 35 # Enables usage of swiftshader on the Vulkan backend. 36 # Note that this will only work in standalone and in projects that set the 37 # dawn_swiftshader_dir variable in build_overrides/dawn.gni 38 # Because of how the Vulkan loader works, setting this makes Dawn only able 39 # to find the Swiftshader ICD and not the others. 40 # Enabled by default when fuzzing. 41 dawn_use_swiftshader = build_with_chromium && use_fuzzing_engine 42} 43 44declare_args() { 45 # Enable Dawn's ASSERTs even in release builds 46 dawn_always_assert = false 47 48 # Should the Dawn static libraries be fully linked vs. GN's default of 49 # treating them as source sets. This is useful for people using Dawn 50 # standalone to produce static libraries to use in their projects. 51 dawn_complete_static_libs = false 52 53 # Enables the compilation of Dawn's D3D12 backend 54 dawn_enable_d3d12 = is_win 55 56 # Enables the compilation of Dawn's Metal backend 57 dawn_enable_metal = is_mac 58 59 # Enables the compilation of Dawn's Null backend 60 # (required for unittests, obviously non-conformant) 61 dawn_enable_null = true 62 63 # Enables the compilation of Dawn's OpenGL backend 64 # (best effort, non-conformant) 65 dawn_enable_desktop_gl = !build_with_chromium && (is_linux && !is_chromeos) 66 67 # Enables the compilation of Dawn's OpenGLES backend 68 # (WebGPU/Compat subset) 69 # Disables OpenGLES when compiling for UWP, since UWP only supports d3d 70 dawn_enable_opengles = !build_with_chromium && ((is_linux && !is_chromeos) || 71 (is_win && !dawn_is_winuwp)) 72 73 # Enables the compilation of Dawn's Vulkan backend 74 # Disables vulkan when compiling for UWP, since UWP only supports d3d 75 dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) || 76 is_fuchsia || is_android || dawn_use_swiftshader 77 78 # Enable use of reflection compiler in spirv-cross. This is needed 79 # if performing reflection on systems that the platform language 80 # shader is SPIR-V, since there isn't an instance of the 81 # GLSL/HLSL/MSL compiler. This implicitly pulls in the GLSL 82 # compiler, since it is a sub-class of it. 83 dawn_enable_cross_reflection = false 84 85 # Enables error injection for faking failures to native API calls 86 dawn_enable_error_injection = 87 is_debug || (build_with_chromium && use_fuzzing_engine) 88} 89 90# GN does not allow reading a variable defined in the same declare_args(). 91# Put them in two separate declare_args() when setting the value of one 92# argument based on another. 93declare_args() { 94 # Uses our built version of the Vulkan validation layers 95 dawn_enable_vulkan_validation_layers = 96 dawn_enable_vulkan && ((is_linux && !is_chromeos) || is_win || is_mac) 97 98 # Uses our built version of the Vulkan loader on platforms where we can't 99 # assume to have one present at the system level. 100 dawn_enable_vulkan_loader = 101 dawn_enable_vulkan && (is_mac || (is_linux && !is_android)) 102} 103 104# UWP only supports CoreWindow for windowing 105dawn_supports_glfw_for_windowing = 106 (is_win && !dawn_is_winuwp) || (is_linux && !is_chromeos) || is_mac 107 108# Much of the GL backend code is shared, so define a convenience var. 109dawn_enable_opengl = dawn_enable_opengles || dawn_enable_desktop_gl 110 111# The GL backends are the last to use SPIRV-Cross, so only compile it in 112# if they are enabled. 113dawn_use_spirv_cross = dawn_enable_opengl 114