Skip to content

Commit

Permalink
Enable Vulkan validation layers for shell_test
Browse files Browse the repository at this point in the history
  • Loading branch information
George Wright committed Apr 13, 2020
1 parent b241ec1 commit 6d9909d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
7 changes: 7 additions & 0 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import("//flutter/common/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/testing/testing.gni")
import("//flutter/vulkan/config.gni")


if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
Expand Down Expand Up @@ -267,6 +269,11 @@ if (enable_unittests) {
dest = "assets/shelltest_screenshot.png"
},
]

if (test_enable_vulkan) {
libraries = vulkan_validation_libs
resources += vulkan_icds
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion shell/common/shell_test_platform_view_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "flutter/shell/common/shell_test_platform_view_vulkan.h"
#include "flutter/vulkan/vulkan_utilities.h"

namespace flutter {
namespace testing {
Expand All @@ -18,7 +19,9 @@ ShellTestPlatformViewVulkan::ShellTestPlatformViewVulkan(
create_vsync_waiter_(std::move(create_vsync_waiter)),
vsync_clock_(vsync_clock),
proc_table_(fml::MakeRefCounted<vulkan::VulkanProcTable>()),
shell_test_external_view_embedder_(shell_test_external_view_embedder) {}
shell_test_external_view_embedder_(shell_test_external_view_embedder) {
vulkan::SetValidationLayersEnabled(true);
}

ShellTestPlatformViewVulkan::~ShellTestPlatformViewVulkan() = default;

Expand Down
16 changes: 0 additions & 16 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ flutter_runner("jit") {
extra_defines += [ "FLUTTER_PROFILE" ]
}

if (enable_vulkan_validation_layers) {
extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
}

extra_deps = [
"//third_party/dart/runtime:libdart_jit",
"//third_party/dart/runtime/platform:libdart_platform_jit",
Expand All @@ -50,10 +46,6 @@ flutter_runner("jit_product") {

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 @@ -69,10 +61,6 @@ flutter_runner("aot") {
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 @@ -85,10 +73,6 @@ flutter_runner("aot_product") {

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
4 changes: 4 additions & 0 deletions tools/fuchsia/fuchsia_archive.gni
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ template("fuchsia_test_archive") {
resources = invoker.resources
}

if (defined(invoker.libraries)) {
libraries += invoker.libraries
}

meta_dir = "//flutter/testing/fuchsia/meta"
cmx_file = "$meta_dir/fuchsia_test.cmx"
}
Expand Down
16 changes: 12 additions & 4 deletions vulkan/vulkan_utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@

namespace vulkan {

static bool sValidationLayersEnabled = false;

bool IsDebuggingEnabled() {
#ifndef NDEBUG
return true;
#elif defined(VULKAN_VALIDATION_LAYERS_ENABLED)
return true;
#else
return false;
return ValidationLayersEnabled();
#endif
}

void SetValidationLayersEnabled(bool enabled) {
sValidationLayersEnabled = enabled;
}

bool ValidationLayersEnabled() {
return sValidationLayersEnabled;
}

// Whether to show Vulkan validation layer info messages in addition
// to the error messages.
bool ValidationLayerInfoMessagesEnabled() {
Expand All @@ -36,7 +44,7 @@ bool ValidationErrorsFatal() {
static std::vector<std::string> InstanceOrDeviceLayersToEnable(
const VulkanProcTable& vk,
VkPhysicalDevice physical_device) {
if (!IsDebuggingEnabled()) {
if (!ValidationLayersEnabled()) {
return {};
}

Expand Down
2 changes: 2 additions & 0 deletions vulkan/vulkan_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
namespace vulkan {

bool IsDebuggingEnabled();
void SetValidationLayersEnabled(bool enabled);
bool ValidationLayersEnabled();
bool ValidationLayerInfoMessagesEnabled();
bool ValidationErrorsFatal();

Expand Down

0 comments on commit 6d9909d

Please sign in to comment.