Skip to content

Commit

Permalink
[vulkan] Bundle vulkan validation layer so files (flutter#13930)
Browse files Browse the repository at this point in the history
Enable vulkan validation for Fuchsia in debug mode as well.
  • Loading branch information
iskakaushik authored Nov 26, 2019
1 parent 9f64013 commit 201cfae
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 8 deletions.
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/dart_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
53 changes: 48 additions & 5 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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 = [
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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 = [
{
Expand Down
2 changes: 1 addition & 1 deletion tools/fuchsia/fuchsia_archive.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
63 changes: 63 additions & 0 deletions tools/fuchsia/common_libs.gni → tools/fuchsia/fuchsia_libs.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
]
7 changes: 7 additions & 0 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions vulkan/config.gni
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 3 additions & 1 deletion vulkan/vulkan_utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -12,6 +13,8 @@ namespace vulkan {
bool IsDebuggingEnabled() {
#ifndef NDEBUG
return true;
#elif defined(VULKAN_VALIDATION_LAYERS_ENABLED)
return true;
#else
return false;
#endif
Expand All @@ -27,7 +30,6 @@ bool ValidationErrorsFatal() {
#if OS_FUCHSIA
return false;
#endif

return true;
}

Expand Down

0 comments on commit 201cfae

Please sign in to comment.