GN: Update dcheck/assert conditions.

In preparation for a Chromium change that makes dchecks enabled
by default in Release builds, we'll keep ASSERT disabled in
Release by default. We add a new flag 'angle_assert_always_on'
for controlling ANGLE ASSERT behaviour.

Also slightly refactors the direct SPIR-V generation GN.

Chromium CL: https://crrev.com/c/2893204

Bug: chromium:1225701
Change-Id: I01a6def28d7c21e771e9800889a6b9c274972de2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3035447
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill
2021-07-19 10:30:57 -04:00
committed by Angle LUCI CQ
parent 8c1cbc5a85
commit 2b86e2d60f
10 changed files with 35 additions and 23 deletions

View File

@@ -321,9 +321,9 @@ config("debug_annotations_config") {
}
}
config("angle_release_asserts_config") {
if (dcheck_always_on) {
defines = [ "ANGLE_ENABLE_RELEASE_ASSERTS" ]
config("angle_asserts_config") {
if (angle_assert_always_on) {
defines = [ "ANGLE_ASSERT_ALWAYS_ON" ]
}
}
@@ -564,12 +564,6 @@ template("translator_lib") {
# This translator is needed by metal backend also.
sources += angle_translator_lib_vulkan_sources
# Enable direct SPIR-V generation conditionally to avoid increasing binary size of ANGLE on
# official builds until that's the only path.
if (dcheck_always_on || is_debug) {
defines += [ "ANGLE_ENABLE_DIRECT_SPIRV_GENERATION" ]
}
}
if (angle_enable_vulkan || use_fuzzing_engine) {

View File

@@ -56,10 +56,10 @@ On Windows only, ensure you **set `DEPOT_TOOLS_WIN_TOOLCHAIN=0` in your environm
GN will generate ninja files. To change the default build options run `gn args out/Debug`. Some commonly used options are:
```
target_cpu = "x86" (default is "x64")
is_clang = false (to use system default compiler instead of clang)
is_debug = true (enable debugging, true is the default)
dcheck_always_on = true (enable release asserts and debug layers)
target_cpu = "x86" (default is "x64")
is_clang = false (to use system default compiler instead of clang)
is_debug = false (for release builds. is_debug = true is the default)
angle_assert_always_on = true (enable release asserts and debug layers)
```
For a release build run `gn args out/Release` and set `is_debug = false`.

View File

@@ -19,8 +19,8 @@ target_os = "android"
target_cpu = "arm64"
is_component_build = false
is_debug = false
dcheck_always_on = true # Recommended for debugging. Turn off for performance.
use_goma = true # Googlers-only! If you're not a Googler remove this.
angle_assert_always_on = true # Recommended for debugging. Turn off for performance.
use_goma = true # Googlers-only! If you're not a Googler remove this.
```
More targeted GN arg combinations can be found [below](#android-gn-args-combinations).

View File

@@ -70,6 +70,8 @@ if (angle_has_build) {
angle_data_dir = "angledata"
declare_args() {
angle_assert_always_on = build_with_chromium && dcheck_always_on
if (current_cpu == "arm64" || current_cpu == "x64" ||
current_cpu == "mips64el" || current_cpu == "s390x" ||
current_cpu == "ppc64") {
@@ -84,6 +86,13 @@ declare_args() {
}
declare_args() {
# By default we enable debug layers when asserts are turned on.
angle_debug_layers_enabled = is_debug || angle_assert_always_on
# Enable direct SPIR-V generation conditionally to avoid increasing binary size of ANGLE on
# official builds until that's the only path.
angle_enable_direct_spirv_gen = is_debug || angle_assert_always_on
if (!is_android) {
ndk_api_level_at_least_26 = false
} else {
@@ -175,7 +184,7 @@ declare_args() {
# Vulkan Validation Layers compatibility issues, see http://crrev/c/1405714.
angle_enable_vulkan_validation_layers =
angle_enable_vulkan && !is_ubsan && !is_tsan && !is_asan &&
(is_debug || dcheck_always_on) && !is_mac &&
angle_debug_layers_enabled && !is_mac &&
(!is_android || ndk_api_level_at_least_26)
# ISpriteVisual windows cannot be validated and can lead to crashes if an invalid window is
@@ -216,7 +225,7 @@ if (!defined(angle_zlib_compression_utils_dir)) {
}
angle_common_configs = [
angle_root + ":angle_release_asserts_config",
angle_root + ":angle_asserts_config",
angle_root + ":constructor_and_destructor_warnings",
angle_root + ":extra_warnings",
angle_root + ":internal_config",

View File

@@ -338,7 +338,7 @@ const ShCompileOptions SH_ADD_VULKAN_XFB_EXTENSION_SUPPORT_CODE = UINT64_C(1) <<
const ShCompileOptions SH_INIT_FRAGMENT_OUTPUT_VARIABLES = UINT64_C(1) << 57;
// Transitory flag to select between producing SPIR-V directly vs using glslang. Ignored in
// non-dcheck-enabled builds to avoid increasing ANGLE's binary size while both generators coexist.
// non-assert-enabled builds to avoid increasing ANGLE's binary size while both generators coexist.
const ShCompileOptions SH_GENERATE_SPIRV_DIRECTLY = UINT64_C(1) << 58;
// Generate workarounds in SPIR-V for buggy code.

View File

@@ -95,7 +95,7 @@
'gn_args': 'is_debug=false symbol_level=1',
},
'release': {
'gn_args': 'is_debug=false dcheck_always_on=true symbol_level=1',
'gn_args': 'is_debug=false angle_assert_always_on=true symbol_level=1',
},
'traces': {
'gn_args': 'build_angle_trace_perf_tests=true',

View File

@@ -244,7 +244,7 @@ std::ostream &FmtHex(std::ostream &os, T value)
# define ANGLE_TRACE_ENABLED
#endif
#if !defined(NDEBUG) || defined(ANGLE_ENABLE_RELEASE_ASSERTS)
#if !defined(NDEBUG) || defined(ANGLE_ASSERT_ALWAYS_ON)
# define ANGLE_ENABLE_ASSERTS
#endif

View File

@@ -10,6 +10,12 @@ angle_source_set("angle_spirv_headers") {
deps = [ "$angle_root:angle_common" ]
}
config("angle_spirv_config") {
if (angle_enable_direct_spirv_gen) {
defines = [ "ANGLE_ENABLE_DIRECT_SPIRV_GENERATION" ]
}
}
angle_source_set("angle_spirv_base") {
sources = [ "angle_spirv_utils.cpp" ]
deps = [
@@ -18,8 +24,9 @@ angle_source_set("angle_spirv_base") {
"${angle_spirv_headers_dir}:spv_headers",
"${angle_spirv_tools_dir}:spvtools_headers",
]
public_configs = [ ":angle_spirv_config" ]
if (dcheck_always_on || is_debug) {
if (angle_debug_layers_enabled) {
deps += [ "$angle_spirv_tools_dir:spvtools_val" ]
}
}
@@ -35,6 +42,7 @@ angle_source_set("angle_spirv_builder") {
"$angle_root:angle_common",
"${angle_spirv_headers_dir}:spv_headers",
]
public_configs = [ ":angle_spirv_config" ]
}
angle_source_set("angle_spirv_parser") {
@@ -48,4 +56,5 @@ angle_source_set("angle_spirv_parser") {
"$angle_root:angle_common",
"${angle_spirv_headers_dir}:spv_headers",
]
public_configs = [ ":angle_spirv_config" ]
}

View File

@@ -263,7 +263,7 @@ class ChildProcessesManager():
if not args.debug:
gn_args.append(('is_debug', 'false'))
gn_args.append(('symbol_level', '1'))
gn_args.append(('dcheck_always_on', 'true'))
gn_args.append(('angle_assert_always_on', 'true'))
if args.goma_dir:
gn_args.append(('goma_dir', '"%s"' % args.goma_dir))
if args.asan:

View File

@@ -6,7 +6,7 @@ You can also build your own dashboards. For example, a comparison of ANGLE's bac
## Running the Tests
You can follow the usual instructions to [check out and build ANGLE](../../../doc/DevSetup.md). Build the `angle_perftests` target. Note that all test scores are higher-is-better. You should also ensure `is_debug=false` in your build. Running with `dcheck_always_on` or debug validation enabled is not recommended.
You can follow the usual instructions to [check out and build ANGLE](../../../doc/DevSetup.md). Build the `angle_perftests` target. Note that all test scores are higher-is-better. You should also ensure `is_debug=false` in your build. Running with `angle_assert_always_on` or debug validation enabled is not recommended.
Variance can be a problem when benchmarking. We have a test harness to run a single test in an infinite loop and print some statistics to help mitigate variance. See [`scripts/perf_test_runner.py`](https://chromium.googlesource.com/angle/angle/+/master/scripts/perf_test_runner.py). To use the script first compile `angle_perftests` into a folder with the word `Release` in it. Then provide the name of the test as the argument to the script. The script will automatically pick up the most current `angle_perftests` and run in an infinite loop.