Hash :
2fb58a95
Author :
Date :
2022-02-15T15:40:23
Re-land: "Vulkan: GBM platform" Add support for GBM platform by implementing a Display with no WSI extension. Re-land fixes build script, including GBM Vulkan backend whenever ozone platform GBM is enabled. Bug: angleproject:7217 Change-Id: Icbf2d034b700e22ab4c351e479f472d65d832ebe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3637562 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build_overrides/angle.gni")
declare_args() {
is_ggp = false
# Extract native libs in ANGLE apk. Useful for flamegraph generation.
angle_extract_native_libs = false
# Display mode for ANGLE vulkan display, could be 'simple' or 'headless', default is 'simple'.
angle_vulkan_display_mode = "simple"
# Defaults to capture building to $root_out_dir/angle_libs/with_capture.
# Switch on to build capture to $root_out_dir.
angle_with_capture_by_default = false
# Enables OpenCL support, off by default.
angle_enable_cl = false
}
if (angle_has_build) {
import("//build/config/dcheck_always_on.gni")
import("//build/config/ozone.gni") # import the ozone_platform_x11 variable
import("//build/config/sanitizers/sanitizers.gni")
import("//build_overrides/build.gni")
import("//testing/test.gni")
if (is_android) {
import("//build/config/android/config.gni")
}
if (is_win) {
import("//build/config/win/visual_studio_version.gni")
}
if (is_chromecast || ozone_platform_headless) {
angle_vulkan_display_mode = "headless"
}
declare_args() {
angle_use_gbm = ozone_platform_gbm
angle_use_x11 = ozone_platform_x11 && !is_ggp && is_linux && !is_chromecast
angle_use_wayland =
ozone_platform_wayland && !is_ggp && is_linux && !is_chromecast
angle_use_vulkan_display = (is_linux || is_chromeos) && !is_ggp
}
} else {
declare_args() {
is_ubsan = false
is_tsan = false
is_asan = false
is_lsan = false
build_with_chromium = false
dcheck_always_on = false
angle_use_x11 = (is_linux || is_chromeos) && !is_ggp
angle_use_wayland = is_linux && !is_ggp
use_ozone = false
ozone_platform_gbm = false
ozone_platform_wayland = false
ozone_platform_headless = false
use_fuzzing_engine = false
is_apple = is_mac || is_ios
}
declare_args() {
angle_use_vulkan_display = (is_linux || is_chromeos) && !is_ggp
}
}
# Subdirectory to place data files (e.g. layer JSON files).
angle_data_dir = "angledata"
declare_args() {
angle_assert_always_on = dcheck_always_on
if (current_cpu == "arm64" || current_cpu == "x64" ||
current_cpu == "mips64el" || current_cpu == "s390x" ||
current_cpu == "ppc64" || current_cpu == "loong64") {
angle_64bit_current_cpu = true
} else if (current_cpu == "arm" || current_cpu == "x86" ||
current_cpu == "mipsel" || current_cpu == "s390" ||
current_cpu == "ppc" || current_cpu == "loong32") {
angle_64bit_current_cpu = false
} else {
assert(false, "Unknown current CPU: $current_cpu")
}
# Indicate if the rapidJSON library is available to build with in third_party/.
angle_has_rapidjson = angle_has_build
}
declare_args() {
# By default we enable debug layers when asserts are turned on.
angle_debug_layers_enabled = is_debug || angle_assert_always_on
if (!is_android) {
ndk_api_level_at_least_26 = false
} else {
ndk_api_level_at_least_26 =
(!angle_64bit_current_cpu && android32_ndk_api_level >= 26) ||
(angle_64bit_current_cpu && android64_ndk_api_level >= 26)
}
# Vulkan loader is statically linked on Mac. http://anglebug.com/4477
angle_shared_libvulkan = !is_mac
# There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves
angle_is_winuwp = is_win && target_os == "winuwp"
# Default to using "_angle" suffix on Android
if (is_android) {
angle_libs_suffix = "_angle"
} else {
angle_libs_suffix = ""
}
# Currently Windows on Arm doesn't support OpenGL or Vulkan.
is_win_arm64 = is_win && target_cpu == "arm64"
# Frame capture code is enabled by default if rapidjson is available.
angle_has_frame_capture = angle_has_rapidjson
# By default, include the SPIR-V based MSL translator (in addition to the direct translator)
angle_enable_msl_through_spirv = is_mac
}
declare_args() {
# By default, ANGLE is using a thread pool for parallel compilation.
# Activating the delegate worker results in posting the tasks using the
# embedder API. In Chromium code base, it results in sending tasks to the
# worker thread pool.
angle_delegate_workers = build_with_chromium
# True if we are building inside an ANGLE checkout.
angle_standalone = !build_with_chromium
angle_enable_d3d9 = is_win && !angle_is_winuwp
angle_enable_d3d11 = is_win
angle_enable_gl =
(ozone_platform_gbm || ozone_platform_wayland || !is_linux ||
((angle_use_x11 && !is_chromeos) || angle_use_wayland)) && !is_fuchsia &&
!angle_is_winuwp && !is_ggp && !is_win_arm64
angle_enable_vulkan =
angle_has_build &&
!(is_android && build_with_chromium && is_official_build) &&
((is_win && !angle_is_winuwp) ||
((is_linux || is_chromeos) &&
(angle_use_x11 || angle_use_wayland || angle_use_vulkan_display)) ||
is_android || is_fuchsia || is_ggp || angle_enable_msl_through_spirv)
# When set to true, ANGLE will not use VK_KHR_surface and VK_KHR_swapchain
# extensions. Content can be rendered only off-screen.
angle_use_vulkan_null_display = build_with_chromium && is_fuchsia
# Disable null backend to save space for official build.
angle_enable_null = !is_official_build
angle_enable_gl_desktop = !is_android && !is_ios
# http://anglebug.com/2634
angle_enable_metal = is_mac
# Enables the OpenCL pass-through back end
angle_enable_cl_passthrough = angle_enable_cl
# Use glslang to generate SPIR-V
angle_use_spirv_gen_through_glslang = false
}
# OpenCL is not supported on Windows UWP, because the CL headers include DX9, which is not
# supported by UWP. A workaround might be possible if CL support on UWP is required.
assert(!angle_is_winuwp || !angle_enable_cl,
"OpenCL is not supported on Windows UWP")
if (!angle_enable_cl) {
angle_enable_cl_passthrough = false
}
declare_args() {
# Currently SwiftShader's Vulkan front-end doesn't build on Android.
# Disabled by default on MSVC because of compiler warnings/errors.
angle_enable_swiftshader =
angle_enable_vulkan && !is_android && !is_ggp && is_clang
# Translator frontend support:
angle_enable_desktop_glsl = angle_enable_gl_desktop
# Translator backend support:
angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11
angle_enable_essl = angle_enable_gl || use_ozone
angle_enable_glsl = angle_enable_gl || use_ozone
angle_enable_trace = false
angle_enable_trace_android_logcat = false
angle_enable_trace_events = false
# Disable the layers in ubsan builds because of really slow builds.
# Vulkan Validation Layers require Android NDK API level 26, i.e. Oreo, due to
# Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714.
angle_enable_vulkan_validation_layers =
angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan &&
angle_debug_layers_enabled && (!is_android || ndk_api_level_at_least_26)
# Support using glslang to generate SPIR-V for the time being for the purpose of debugging
# the SPIR-V generation path, but leave it disabled on release. It's still used by the metal
# backend nevertheless.
angle_enable_spirv_gen_through_glslang =
is_debug || angle_assert_always_on || angle_enable_msl_through_spirv ||
angle_use_spirv_gen_through_glslang
# ISpriteVisual windows cannot be validated and can lead to crashes if an invalid window is
# provided to ANGLE. Disable them for non-standalone ANGLE builds. crbug.com/1176118
angle_enable_d3d11_compositor_native_window =
angle_enable_d3d11 && angle_standalone
# Disable performance counter output by default
angle_enable_perf_counter_output = false
# We should use EAGL (ES) on iOS except on Mac Catalyst on Intel CPUs, which uses CGL (desktop GL).
angle_enable_eagl = angle_enable_gl && is_ios &&
!(target_environment == "catalyst" &&
(target_cpu == "x86" || target_cpu == "x64"))
# Directory where to find wayland source files
angle_wayland_dir = "$angle_root/third_party/wayland"
angle_vulkan_headers_dir =
"$angle_root/third_party/vulkan-deps/vulkan-headers/src"
angle_vulkan_loader_dir =
"$angle_root/third_party/vulkan-deps/vulkan-loader/src"
angle_vulkan_tools_dir =
"$angle_root/third_party/vulkan-deps/vulkan-tools/src"
angle_vulkan_validation_layers_dir =
"$angle_root/third_party/vulkan-deps/vulkan-validation-layers/src"
angle_build_vulkan_system_info = angle_has_build && !angle_is_winuwp
# Enable overlay by default when debug layers are enabled. This is currently only implemented on
# Vulkan.
angle_enable_overlay = angle_enable_vulkan && angle_debug_layers_enabled
}
declare_args() {
# TODO(jdarpinian): Support enabling CGL and EAGL at the same time using the soft linking code. Also support disabling both for Metal-only builds.
angle_enable_cgl = angle_enable_gl && !angle_enable_eagl && is_apple
angle_enable_apple_translator_workarounds =
is_apple &&
(angle_enable_glsl || angle_enable_metal || use_fuzzing_engine)
angle_has_histograms = angle_has_build
}
declare_args() {
angle_enable_renderdoc = angle_enable_vulkan_validation_layers
}
if (!defined(angle_zlib_compression_utils_dir)) {
angle_zlib_compression_utils_dir = "//third_party/zlib/google"
}
angle_common_configs = [
angle_root + ":angle_asserts_config",
angle_root + ":constructor_and_destructor_warnings",
angle_root + ":extra_warnings",
angle_root + ":internal_config",
angle_root + ":angle_uwp_env",
]
angle_remove_configs = []
if (angle_has_build) {
angle_remove_configs += [ "//build/config/compiler:default_include_dirs" ]
}
if (angle_has_build && is_clang) {
angle_remove_configs += [ "//build/config/clang:find_bad_constructs" ]
}
set_defaults("angle_executable") {
configs = angle_common_configs
public_configs = []
suppressed_configs = angle_remove_configs
data_deps = []
}
set_defaults("angle_shared_library") {
configs = angle_common_configs
public_configs = []
suppressed_configs = angle_remove_configs
}
set_defaults("angle_source_set") {
configs = angle_common_configs
public_configs = []
suppressed_configs = angle_remove_configs
}
set_defaults("angle_static_library") {
configs = angle_common_configs
public_configs = []
suppressed_configs = angle_remove_configs
}
set_defaults("angle_test") {
# Gtest itself can't pass all the strict warning filters.
configs = angle_common_configs - [
"$angle_root:constructor_and_destructor_warnings",
"$angle_root:extra_warnings",
] + [ "$angle_root/src/tests:angle_maybe_has_histograms" ] +
[ "$angle_root/src/tests:angle_enable_renderdoc" ]
public_configs = []
public_deps = []
sources = []
data = []
defines = []
deps = []
data_deps = []
suppressed_configs = angle_remove_configs
}
template("angle_executable") {
executable(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= invoker.suppressed_configs
if (angle_has_build && is_win) {
data_deps += [ "//build/win:runtime_libs" ]
}
if (is_ios) {
check_includes = false
}
}
}
template("angle_shared_library") {
# On ios, define an ios_framework_bundle instead of a shared library.
# ios_framework_bundle doesn't automatically link, so we have to create
# a group that links and bundles the framework as well.
target_type = "shared_library"
internal_target_name = target_name
if (is_ios) {
target_type = "ios_framework_bundle"
internal_target_name = target_name + "_framework"
}
target(target_type, internal_target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= invoker.suppressed_configs
public_configs += [ angle_root + ":shared_library_public_config" ]
if (is_android) {
configs += [ angle_root + ":build_id_config" ]
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
}
if (is_ios) {
info_plist = "$angle_root/util/ios/Info.plist"
# shared libraries are hidden inside ios_framework_bundle, but we include headers from them
# Specifically, libGLESv1_CM includes headers from libGLESv2
check_includes = false
}
}
if (is_ios) {
group(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
public_deps = [
":${internal_target_name}+bundle",
":${internal_target_name}+link",
]
}
}
}
template("angle_source_set") {
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= invoker.suppressed_configs
}
}
template("angle_static_library") {
static_library(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"suppressed_configs",
"visibility",
])
# Needed because visibility is global.
forward_variables_from(invoker, [ "visibility" ])
configs += invoker.configs
configs -= invoker.suppressed_configs
}
}
if (angle_standalone || build_with_chromium) {
template("angle_test") {
test(target_name) {
forward_variables_from(invoker,
"*",
[
"configs",
"data",
"public_deps",
])
configs += invoker.configs
configs -= invoker.suppressed_configs
if (is_ios) {
# shared libraries are hidden inside ios_framework_bundle, but we include headers from them
check_includes = false
}
public_deps = invoker.public_deps + [
"$angle_root:angle_common",
"$angle_root:includes",
"$angle_root/src/tests:angle_test_expectations",
"$angle_root/third_party/rapidjson:rapidjson",
"$angle_root/util:angle_test_utils",
"//testing/gmock",
"//testing/gtest",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
data = invoker.data + [
"$angle_root/scripts/run_gtest_angle_test.py",
"$angle_root/src/tests/py_utils/angle_path_util.py",
"$angle_root/src/tests/py_utils/angle_test_util.py",
"//testing/scripts/common.py",
"//testing/xvfb.py",
]
sources += [
"$angle_root/src/tests/test_utils/runner/HistogramWriter.h",
"$angle_root/src/tests/test_utils/runner/TestSuite.cpp",
"$angle_root/src/tests/test_utils/runner/TestSuite.h",
]
if (angle_has_histograms) {
sources +=
[ "$angle_root/src/tests/test_utils/runner/HistogramWriter.cpp" ]
deps += [
"//third_party/catapult/tracing/tracing:histogram",
"//third_party/catapult/tracing/tracing:reserved_infos",
]
}
if (is_mac) {
if (angle_enable_metal) {
# On macOS, compiling Metal shader sometimes takes very long time due to internal caching
# mechanism. This hooking library is a way to bypass this caching mechanism.
data_deps += [ "$angle_root/src/libANGLE/renderer/metal/file_hooking:metal_shader_cache_file_hooking" ]
}
if (angle_enable_cgl) {
configs += [ "$angle_root:supports_automatic_graphics_switching" ]
}
}
if ((is_linux && !is_chromeos) ||
(build_with_chromium && is_chromeos_lacros && !is_chromeos_device)) {
use_xvfb = true
}
if ((is_linux || is_chromeos) && !is_component_build) {
# Set rpath to find shared libs in a non-component build.
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
if (is_android) {
public_configs += [ "$angle_root:build_id_config" ]
configs -= [ "//build/config/android:hide_all_but_jni" ]
use_default_launcher = false
generate_final_jni = false
android_manifest_template = "$angle_root/src/tests/test_utils/runner/android/java/AndroidManifest.xml.jinja2"
deps += [
"$angle_root/src/tests:native_test_java",
"$angle_root/src/tests:native_test_support_android",
]
}
if (is_ios) {
# We use a special main function on iOS to initialize UIKit before the normal main runs.
ldflags = [
"-e",
"_ios_main",
]
sources += [ "$angle_root/util/ios/ios_main.mm" ]
}
if (angle_has_build && is_win) {
data_deps += [ "//build/win:runtime_libs" ]
}
}
}
}
# Used by a few targets that compile traces.
template("angle_trace_fixture") {
_config_name = target_name + "_config"
config(_config_name) {
include_dirs = [ "$angle_root/src/libANGLE/capture" ]
}
angle_source_set(target_name) {
testonly = true
defines = [ "ANGLE_REPLAY_IMPLEMENTATION" ]
suppressed_configs += [ "$angle_root:constructor_and_destructor_warnings" ]
sources = [
"$angle_root/src/libANGLE/capture/trace_fixture.cpp",
"$angle_root/src/libANGLE/capture/trace_fixture.h",
invoker.gl_header,
]
public_deps = [ "$angle_root:includes" ]
if (defined(invoker.public_deps)) {
public_deps += invoker.public_deps
}
include_dirs = [ "." ]
public_configs = [ ":${_config_name}" ]
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
if (is_ios) {
# shared libraries are hidden inside ios_framework_bundle, but we include headers from them
check_includes = false
}
}
}
template("angle_trace") {
angle_shared_library(target_name) {
testonly = true
# Similar to capture replay sample, use the file index for sources
sources = invoker.sources
data = invoker.data
defines = [ "ANGLE_REPLAY_IMPLEMENTATION" ]
suppressed_configs += [ "$angle_root:constructor_and_destructor_warnings" ]
deps = [
"$angle_root:includes",
invoker.fixture,
]
if (is_android) {
libs = [ "log" ]
}
# Disable optimization in the trace perf tests to avoid optimizing huge files.
if (!is_debug && !is_ubsan) {
suppressed_configs += [
"//build/config/compiler:afdo",
"//build/config/compiler:afdo_optimize_size",
"//build/config/compiler:default_optimization",
"//build/config/compiler/pgo:default_pgo_flags",
]
configs += [ "//build/config/compiler:no_optimize" ]
}
include_dirs = [ "." ]
if (defined(invoker.output_name)) {
output_name = invoker.output_name
}
}
}
set_defaults("angle_trace_library") {
# Uses a short name to work around file path limits on Windows.
short_names = false
}
template("angle_trace_library") {
_trace_json = read_file(invoker.json_path, "json")
_trace_targets = []
if (invoker.short_names) {
_trace_counter = 1
}
foreach(_trace_and_version, _trace_json.traces) {
_trace_and_version_arr = []
_trace_and_version_arr = string_split(_trace_and_version)
_trace = _trace_and_version_arr[0]
if (defined(invoker.trace_dir)) {
_trace_dir = invoker.trace_dir
} else {
_trace_dir = _trace
}
_trace_json_path = "$_trace_dir/$_trace.json"
_trace_data = []
_trace_data = read_file(_trace_json_path, "json")
if (invoker.short_names) {
_target = "cr_trace_${_trace_counter}"
_trace_counter += 1
} else {
_target = "${target_name}_$_trace"
}
angle_trace(_target) {
sources = rebase_path(_trace_data.TraceFiles, ".", _trace_dir)
data = [
"$_trace_dir/$_trace.json",
"$_trace_dir/$_trace.angledata.gz",
]
fixture = invoker.trace_fixture
if (invoker.short_names) {
output_name = _trace
}
}
_trace_targets += [ ":$_target" ]
}
group(target_name) {
testonly = true
data = [ invoker.json_path ]
data_deps = _trace_targets
}
}