mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[vulkan] Bundle vulkan validation layer so files (flutter/engine#13930)
Enable vulkan validation for Fuchsia in debug mode as well.
This commit is contained in:
parent
dee0c26a36
commit
d6b2b657eb
@ -6,9 +6,9 @@ assert(is_fuchsia)
|
||||
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
import("$flutter_root/common/fuchsia_config.gni")
|
||||
import("$flutter_root/tools/fuchsia/common_libs.gni")
|
||||
import("$flutter_root/tools/fuchsia/dart.gni")
|
||||
import("$flutter_root/tools/fuchsia/fuchsia_archive.gni")
|
||||
import("$flutter_root/tools/fuchsia/fuchsia_libs.gni")
|
||||
|
||||
template("runner") {
|
||||
assert(defined(invoker.product), "The parameter 'product' must be defined")
|
||||
|
||||
@ -8,9 +8,10 @@ import("//build/fuchsia/sdk.gni")
|
||||
import("$flutter_root/common/config.gni")
|
||||
import("$flutter_root/shell/gpu/gpu.gni")
|
||||
import("$flutter_root/testing/testing.gni")
|
||||
import("$flutter_root/tools/fuchsia/common_libs.gni")
|
||||
import("$flutter_root/tools/fuchsia/dart.gni")
|
||||
import("$flutter_root/tools/fuchsia/fuchsia_archive.gni")
|
||||
import("$flutter_root/tools/fuchsia/fuchsia_libs.gni")
|
||||
import("$flutter_root/vulkan/config.gni")
|
||||
import("engine_flutter_runner.gni")
|
||||
|
||||
shell_gpu_configuration("fuchsia_gpu_configuration") {
|
||||
@ -38,8 +39,14 @@ if (!using_fuchsia_sdk) {
|
||||
flutter_runner("jit") {
|
||||
output_name = "flutter_jit_runner"
|
||||
product = false
|
||||
|
||||
extra_defines = []
|
||||
if (flutter_runtime_mode == "profile") {
|
||||
extra_defines = [ "FLUTTER_PROFILE" ]
|
||||
extra_defines += [ "FLUTTER_PROFILE" ]
|
||||
}
|
||||
|
||||
if (enable_vulkan_validation_layers) {
|
||||
extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
|
||||
}
|
||||
|
||||
extra_deps = [
|
||||
@ -51,8 +58,13 @@ flutter_runner("jit") {
|
||||
flutter_runner("jit_product") {
|
||||
output_name = "flutter_jit_product_runner"
|
||||
product = true
|
||||
|
||||
extra_defines = [ "DART_PRODUCT" ]
|
||||
|
||||
if (enable_vulkan_validation_layers) {
|
||||
extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
|
||||
}
|
||||
|
||||
extra_deps = [
|
||||
"//third_party/dart/runtime:libdart_jit_product",
|
||||
"//third_party/dart/runtime/platform:libdart_platform_jit_product",
|
||||
@ -62,9 +74,16 @@ flutter_runner("jit_product") {
|
||||
flutter_runner("aot") {
|
||||
output_name = "flutter_aot_runner"
|
||||
product = false
|
||||
|
||||
extra_defines = []
|
||||
if (flutter_runtime_mode == "profile") {
|
||||
extra_defines = [ "FLUTTER_PROFILE" ]
|
||||
extra_defines += [ "FLUTTER_PROFILE" ]
|
||||
}
|
||||
|
||||
if (enable_vulkan_validation_layers) {
|
||||
extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
|
||||
}
|
||||
|
||||
extra_deps = [
|
||||
"//third_party/dart/runtime:libdart_precompiled_runtime",
|
||||
"//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime",
|
||||
@ -74,7 +93,13 @@ flutter_runner("aot") {
|
||||
flutter_runner("aot_product") {
|
||||
output_name = "flutter_aot_product_runner"
|
||||
product = true
|
||||
|
||||
extra_defines = [ "DART_PRODUCT" ]
|
||||
|
||||
if (enable_vulkan_validation_layers) {
|
||||
extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
|
||||
}
|
||||
|
||||
extra_deps = [
|
||||
"//third_party/dart/runtime:libdart_precompiled_runtime_product",
|
||||
"//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime_product",
|
||||
@ -157,7 +182,16 @@ template("jit_runner") {
|
||||
},
|
||||
]
|
||||
|
||||
libraries = common_libs
|
||||
_vulkan_icds = []
|
||||
_libs = common_libs
|
||||
if (enable_vulkan_validation_layers) {
|
||||
_libs += vulkan_validation_libs
|
||||
_vulkan_icds += vulkan_icds
|
||||
}
|
||||
|
||||
resources += _vulkan_icds
|
||||
|
||||
libraries = _libs
|
||||
|
||||
meta = [
|
||||
{
|
||||
@ -215,7 +249,16 @@ template("aot_runner") {
|
||||
]
|
||||
}
|
||||
|
||||
libraries = common_libs
|
||||
_vulkan_icds = []
|
||||
_libs = common_libs
|
||||
if (enable_vulkan_validation_layers) {
|
||||
_libs += vulkan_validation_libs
|
||||
_vulkan_icds += vulkan_icds
|
||||
}
|
||||
|
||||
resources += _vulkan_icds
|
||||
|
||||
libraries = _libs
|
||||
|
||||
meta = [
|
||||
{
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("$flutter_root/tools/fuchsia/common_libs.gni")
|
||||
import("$flutter_root/tools/fuchsia/fuchsia_debug_symbols.gni")
|
||||
import("$flutter_root/tools/fuchsia/fuchsia_libs.gni")
|
||||
|
||||
# Creates a Fuchsia archive (.far) file using PM from the Fuchsia SDK.
|
||||
template("fuchsia_archive") {
|
||||
|
||||
@ -69,3 +69,66 @@ common_libs = [
|
||||
"$clang_base/${clang_manifest_json.md5_beb70f40d525448b39ea87d9f5811e56}")
|
||||
},
|
||||
]
|
||||
|
||||
vulkan_dist = "$fuchsia_sdk_base/dist"
|
||||
|
||||
vulkan_validation_libs = [
|
||||
{
|
||||
name = "VkLayer_core_validation.so"
|
||||
path = rebase_path("$vulkan_dist")
|
||||
},
|
||||
{
|
||||
name = "VkLayer_khronos_validation.so"
|
||||
path = rebase_path("$vulkan_dist")
|
||||
},
|
||||
{
|
||||
name = "VkLayer_object_lifetimes.so"
|
||||
path = rebase_path("$vulkan_dist")
|
||||
},
|
||||
{
|
||||
name = "VkLayer_stateless_validation.so"
|
||||
path = rebase_path("$vulkan_dist")
|
||||
},
|
||||
{
|
||||
name = "VkLayer_thread_safety.so"
|
||||
path = rebase_path("$vulkan_dist")
|
||||
},
|
||||
{
|
||||
name = "VkLayer_unique_objects.so"
|
||||
path = rebase_path("$vulkan_dist")
|
||||
},
|
||||
]
|
||||
|
||||
vulkan_data_dir =
|
||||
"//fuchsia/sdk/linux/pkg/vulkan_layers/data/vulkan/explicit_layer.d"
|
||||
|
||||
vulkan_icds = [
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_core_validation.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_core_validation.json"
|
||||
},
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_object_lifetimes.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_object_lifetimes.json"
|
||||
},
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_thread_safety.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_thread_safety.json"
|
||||
},
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_stateless_validation.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_stateless_validation.json"
|
||||
},
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_unique_objects.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_unique_objects.json"
|
||||
},
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_khronos_validation.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_khronos_validation.json"
|
||||
},
|
||||
{
|
||||
path = rebase_path("$vulkan_data_dir/VkLayer_standard_validation.json")
|
||||
dest = "vulkan/explicit_layer.d/VkLayer_standard_validation.json"
|
||||
},
|
||||
]
|
||||
@ -268,6 +268,12 @@ def to_gn_args(args):
|
||||
if args.ubsan:
|
||||
gn_args['is_ubsan'] = True
|
||||
|
||||
if args.enable_vulkan_validation_layers:
|
||||
if args.target_os is not 'fuchsia':
|
||||
print('Vulkan validation layers are currently only supported on Fuchsia targets.')
|
||||
sys.exit(1)
|
||||
gn_args['enable_vulkan_validation_layers'] = True
|
||||
|
||||
return gn_args
|
||||
|
||||
def parse_args(args):
|
||||
@ -316,6 +322,7 @@ def parse_args(args):
|
||||
|
||||
parser.add_argument('--enable-fontconfig', action='store_true', default=False)
|
||||
parser.add_argument('--enable-skshaper', action='store_true', default=False)
|
||||
parser.add_argument('--enable-vulkan-validation-layers', action='store_true', default=False)
|
||||
|
||||
parser.add_argument('--embedder-for-target', dest='embedder_for_target', action='store_true', default=False)
|
||||
|
||||
|
||||
12
engine/src/flutter/vulkan/config.gni
Normal file
12
engine/src/flutter/vulkan/config.gni
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
declare_args() {
|
||||
# Whether to include vulkan validation layers, if available.
|
||||
#
|
||||
# Currently these are only supported on Fuchsia, where by default they are
|
||||
# disabled, to enable them pass `--enable-vulkan-validation-layers` to your
|
||||
# gn args.
|
||||
enable_vulkan_validation_layers = false
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/vulkan/vulkan_utilities.h"
|
||||
#include "flutter/fml/build_config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <unordered_set>
|
||||
@ -12,6 +13,8 @@ namespace vulkan {
|
||||
bool IsDebuggingEnabled() {
|
||||
#ifndef NDEBUG
|
||||
return true;
|
||||
#elif defined(VULKAN_VALIDATION_LAYERS_ENABLED)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@ -27,7 +30,6 @@ bool ValidationErrorsFatal() {
|
||||
#if OS_FUCHSIA
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user