Skip to content

Commit

Permalink
[Impeller] turned on validations for all debug builds (#45350)
Browse files Browse the repository at this point in the history
fixes flutter/flutter#133794

This adds the following shared libraries to the flutter.jar for debug builds on arm64:
```
lib/arm64-v8a/libVkLayer_khronos_validation.so
lib/arm64-v8a/libc++_shared.so
```

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
gaaclarke authored Sep 1, 2023
1 parent e6b2573 commit b6224e2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '6b0243e97d94836767ea8b94a477d7d15ee3bb91',
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'b615dd6af4c2e95a388060151c7fd1e429e34d61',

# Fuchsia compatibility
#
Expand Down
11 changes: 7 additions & 4 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,15 @@ action("android_jar") {

if (enable_vulkan_validation_layers) {
assert(impeller_enable_vulkan)
deps += [ "//third_party/vulkan_validation_layers" ]
apilevel26_toolchain = "//build/toolchain/android:clang_arm64_apilevel26"
validation_layer_target =
"//third_party/vulkan_validation_layers($apilevel26_toolchain)"
validation_layer_out_dir =
get_label_info(validation_layer_target, "root_out_dir")
deps += [ validation_layer_target ]
args += [
"--native_lib",
rebase_path("libVkLayer_khronos_validation.so",
root_build_dir,
root_build_dir),
rebase_path("$validation_layer_out_dir/libVkLayer_khronos_validation.so"),
]
if (current_cpu == "arm64") {
args += [
Expand Down
7 changes: 6 additions & 1 deletion shell/platform/android/android_context_vulkan_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ static std::shared_ptr<impeller::Context> CreateImpellerContext(
settings.cache_directory = fml::paths::GetCachesDirectory();
settings.enable_validation = enable_vulkan_validation;

FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan).";
if (settings.enable_validation) {
FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan with "
"Validation Layers).";
} else {
FML_LOG(ERROR) << "Using the Impeller rendering backend (Vulkan).";
}

return impeller::ContextVK::Create(std::move(settings));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ public InitResult call() {
}
}

private static boolean areValidationLayersOnByDefault() {
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return Build.SUPPORTED_ABIS[0].equals("arm64-v8a");
}
return false;
}

/**
* Blocks until initialization of the native system has completed.
*
Expand Down Expand Up @@ -324,7 +331,8 @@ public void ensureInitializationComplete(
if (metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
shellArgs.add("--enable-impeller");
}
if (metaData.getBoolean(ENABLE_VULKAN_VALIDATION_META_DATA_KEY, false)) {
if (metaData.getBoolean(
ENABLE_VULKAN_VALIDATION_META_DATA_KEY, areValidationLayersOnByDefault())) {
shellArgs.add("--enable-vulkan-validation");
}
String backend = metaData.getString(IMPELLER_BACKEND_META_DATA_KEY);
Expand Down
4 changes: 3 additions & 1 deletion tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ def to_gn_args(args):
if args.unoptimized and args.target_os == 'android' and args.android_cpu == 'arm64':
enable_vulkan_validation = True

if enable_vulkan_validation:
if enable_vulkan_validation or (args.enable_impeller_vulkan and
runtime_mode == 'debug' and
gn_args['target_cpu'] == 'arm64'):
gn_args['enable_vulkan_validation_layers'] = True
if args.target_os == 'android':
gn_args['android_api_level'] = 26
Expand Down

0 comments on commit b6224e2

Please sign in to comment.