Skip to content

Commit

Permalink
Reland "Vulkan: Use VK repos' internal BUILD.gn files"
Browse files Browse the repository at this point in the history
This is a reland of 552f5fc
There was a missing build dependence causing a build no-op
issue which has now been fixed in the upstream Vulkan Validation
Layer repo.

Primary workaround that need to be re-visted and fixed are:
1. Disabled validation layers on 32-bit Windows
2. Disabled validation layers on 32-bit Android
3. Disabled DebugUtils on Android, using DebugReport instead
4. Using custom VK Loader branch to avoid WDK dependence

Original change's description:
> Vulkan: Use VK repos' internal BUILD.gn files
>
> This retires custom BUILD.gn files for the Vulkan Headers, Tools,
> Validation-Layers, and Loader repos. They now have integrated BUILD.gn
> files so switched ANGLE to use those by default.
> Also Validation Layer, Loader, and Tools repos no longer uses codegen
> so this speeds up the build overall.
> Switched over from old VK_LAYER_LUNARG_standard_validation meta-layer
> to VK_LAYER_KHRONOS_validation unified layer.
>
> This changes includes a temporary workaround to the Vulkan-Loader repo
> to remove its Window's build dependence on WDK. There are plans to
> remove that depenedence in Loader master, but until then we can use
> our custom branch workaround.
> It also includes a custom branch for validation layers that includes
> some build fixes for ANGLE.
> Finally, the layers were crashing on Android when attempting to use
> DebugUtils extension so forcing DebugReport on Android for now.
>
> Bug: angleproject:2449
> Bug: angleproject:3320
> Bug: angleproject:3852
> Bug: angleproject:3924
> Bug: angleproject:3925
> Bug: angleproject:3946
> Bug: chromium:997009
> Bug: chromium:997016
> Change-Id: I48b36acefcc7f2bc930eb72d6fdbc87bca24f833
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1610438
> Reviewed-by: Shahbaz Youssefi <[email protected]>
> Reviewed-by: Jamie Madill <[email protected]>
> Commit-Queue: Tobin Ehlis <[email protected]>

Bug: angleproject:2449, angleproject:3320, angleproject:3852
Change-Id: I373ada091a1329db5e304874079428d01ba21d52
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1778302
Reviewed-by: Tobin Ehlis <[email protected]>
Commit-Queue: Tobin Ehlis <[email protected]>
  • Loading branch information
tobine authored and Commit Bot committed Oct 1, 2019
1 parent 377b167 commit f22f16d
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 812 deletions.
23 changes: 14 additions & 9 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ if (angle_enable_vulkan) {
if (is_android) {
libs = [ "vulkan" ]
}
if (angle_enable_vulkan_validation_layers) {
defines += [ "ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT" ]
}
}

if (angle_swiftshader) {
Expand Down Expand Up @@ -611,16 +614,16 @@ if (angle_enable_vulkan) {
# Use this target to include everything ANGLE needs for Vulkan.
group("angle_vulkan") {
public_deps = [
"$angle_root/third_party/vulkan-headers:vulkan_headers",
"$angle_root/third_party/vulkan-headers/src:vulkan_headers",
]
public_configs = [ ":vulkan_config" ]
deps = []
data_deps = []
if (!is_android && !is_fuchsia) {
deps += [ "$angle_root/third_party/vulkan-loader:libvulkan" ]
data_deps += [ "$angle_root/third_party/vulkan-tools:VkICD_mock_icd" ]
deps += [ "$angle_root/third_party/vulkan-loader/src:libvulkan" ]
data_deps += [ "$angle_root/third_party/vulkan-tools/src:VkICD_mock_icd" ]
public_configs +=
[ "$angle_root/third_party/vulkan-loader:vulkan_loader_config" ]
[ "$angle_root/third_party/vulkan-loader/src:vulkan_loader_config" ]
}
if (is_fuchsia) {
public_deps += [
Expand All @@ -634,9 +637,9 @@ if (angle_enable_vulkan) {
if (is_fuchsia) {
deps += [ "//third_party/fuchsia-sdk:vulkan_validation" ]
} else {
data_deps += [ "$angle_root/third_party/vulkan-validation-layers:vulkan_validation_layers" ]
data_deps += [ "$angle_root/third_party/vulkan-validation-layers/src:vulkan_validation_layers" ]
if (!is_android) {
data_deps += [ "$angle_root/third_party/vulkan-validation-layers:vulkan_gen_json_files" ]
data_deps += [ "$angle_root/third_party/vulkan-validation-layers/src:vulkan_gen_json_files" ]
}
}
}
Expand Down Expand Up @@ -770,7 +773,8 @@ angle_source_set("libANGLE_base") {
"${angle_glslang_dir}:glslang_sources",
"${angle_spirv_tools_dir}:spvtools_val",
]
public_deps += [ "$angle_root/third_party/vulkan-headers:vulkan_headers" ]
public_deps +=
[ "$angle_root/third_party/vulkan-headers/src:vulkan_headers" ]

# Include generated shaders.
import("src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.gni")
Expand Down Expand Up @@ -1302,8 +1306,9 @@ if (!is_component_build && is_android && symbol_level != 0) {

if (angle_enable_vulkan_validation_layers) {
foreach(_layer, vulkan_validation_layers) {
deps +=
[ "${angle_root}/third_party/vulkan-validation-layers:${_layer}" ]
deps += [
"${angle_root}/third_party/vulkan-validation-layers/src:${_layer}",
]
}
}

Expand Down
8 changes: 4 additions & 4 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ vars = {
'spirv_tools_revision': '85c67b5e08eea1818767f174515612464740a53c',

# Current revision of Khronos Vulkan-Headers.
'vulkan_headers_revision': '982f0f84dccf6f281b48318c77261a9028000126',
'vulkan_headers_revision': '5b44df19e040fca0048ab30c553a8c2d2cb9623e',

# Current revision of Khronos Vulkan-Loader.
'vulkan_loader_revision': '2f0abfcf9eb04018e6e92125a70bc28665aa17fe',
'vulkan_loader_revision': 'b5a0995324fa9fb2a6152197b442400e7d7be5b6',

# Current revision of Khronos Vulkan-Tools.
'vulkan_tools_revision': 'f392e71b994036c92b896c2a62cc63d042b7f9b1',
'vulkan_tools_revision': '40cd2166a44647a4283517e31af4589410c654eb',

# Current revision of Khronos Vulkan-ValidationLayers.
'vulkan_validation_revision': 'ff80a937c8a505abbdddb95d8ffaa446820c8391',
'vulkan_validation_revision': '9fba37afae13a11bd49ae942bf82e5bf1098e381',
}

deps = {
Expand Down
8 changes: 1 addition & 7 deletions android/angle_apk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
import("//build/config/android/rules.gni")
import("//third_party/angle/gni/angle.gni")

vulkan_validation_layers = [
"VkLayer_core_validation",
"VkLayer_object_lifetimes",
"VkLayer_stateless_validation",
"VkLayer_thread_safety",
"VkLayer_unique_objects",
]
vulkan_validation_layers = [ "VkLayer_khronos_validation" ]

angle_libraries = [
"libEGL",
Expand Down
10 changes: 10 additions & 0 deletions build_overrides/vulkan_loader.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//gni/angle.gni")

vulkan_headers_dir = "//third_party/vulkan-headers/src"

vulkan_gen_subdir = "angle/vulkan"
vulkan_loader_shared = angle_shared_libvulkan
10 changes: 10 additions & 0 deletions build_overrides/vulkan_tools.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//gni/angle.gni")

vulkan_headers_dir = "//third_party/vulkan-headers/src"

vulkan_data_subdir = angle_data_dir
vulkan_gen_subdir = "angle/vulkan"
12 changes: 12 additions & 0 deletions build_overrides/vulkan_validation_layers.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//gni/angle.gni")

vulkan_headers_dir = "//third_party/vulkan-headers/src"
vvl_spirv_tools_dir = "//third_party/spirv-tools/src"
vvl_glslang_dir = "//third_party/glslang/src"

vulkan_data_subdir = angle_data_dir
vulkan_gen_subdir = "angle/vulkan"
9 changes: 5 additions & 4 deletions dotfile_settings.gni
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
angle_dotfile_settings = {
exec_script_whitelist = [
get_path_info("BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-headers/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-loader/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-tools/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-validation-layers/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-headers/src/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-loader/src/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-tools/src/BUILD.gn", "abspath"),
get_path_info("third_party/vulkan-validation-layers/src/BUILD.gn",
"abspath"),
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"src/libANGLE/renderer/vulkan/vk_mandatory_format_support_table_autogen.cpp":
"d20e549634ef32d6ad4e9f0b28e52acf",
"third_party/vulkan-headers/src/registry/vk.xml":
"8af0f992bd45c2d9500eb5ed60c256d6"
"db16f42dab8a7a1ee88c42a90f0c02c2"
}
6 changes: 3 additions & 3 deletions src/libANGLE/renderer/renderer_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ bool ShouldUseDebugLayers(const egl::AttributeMap &attribs)
EGLAttrib debugSetting =
attribs.get(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE, EGL_DONT_CARE);

// Prefer to enable debug layers if compiling in Debug, and disabled in Release.
#if defined(ANGLE_ENABLE_ASSERTS)
// Prefer to enable debug layers when available.
#if defined(ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT)
return (debugSetting != EGL_FALSE);
#else
return (debugSetting == EGL_TRUE);
#endif // defined(ANGLE_ENABLE_ASSERTS)
#endif // defined(ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT)
}

bool ShouldUseVirtualizedContexts(const egl::AttributeMap &attribs, bool defaultValue)
Expand Down
32 changes: 30 additions & 2 deletions src/libANGLE/renderer/vulkan/RendererVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ constexpr const char *kSkippedMessages[] = {
"UNASSIGNED-CoreValidation-Shader-PointSizeMissing",
// http://anglebug.com/3832
"VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00428",
// http://anglebug.com/3450
"VUID-vkDestroySemaphore-semaphore-parameter",
// http://anglebug.com/3924
"UNASSIGNED-Threading-Info",
// http://anglebug.com/3925
"VUID-vkDestroyDescriptorPool-descriptorPool-parameter",
"VUID-vkDestroyBuffer-buffer-parameter",
"VUID-vkDestroyImage-image-parameter",
};

// Suppress validation errors that are known
Expand Down Expand Up @@ -603,7 +611,13 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
const egl::AttributeMap &attribs = mDisplay->getAttributeMap();
ScopedVkLoaderEnvironment scopedEnvironment(ShouldUseDebugLayers(attribs),
ChooseICDFromAttribs(attribs));
#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(_WIN64)
// TODO: Re-enable validation layers on 32bit Windows
// http://anglebug.com/3946, http://anglebug.com/3924
mEnableValidationLayers = false;
#else
mEnableValidationLayers = scopedEnvironment.canEnableValidationLayers();
#endif
mEnabledICD = scopedEnvironment.getEnabledICD();

// Gather global layer properties.
Expand Down Expand Up @@ -671,10 +685,15 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
ExtensionNameList enabledInstanceExtensions;
enabledInstanceExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
enabledInstanceExtensions.push_back(wsiExtension);

#if defined(ANGLE_PLATFORM_ANDROID)
// TODO: Enable DebugUtils on Android
// http://anglebug.com/3852
bool enableDebugUtils = false;
#else
bool enableDebugUtils =
mEnableValidationLayers &&
ExtensionFound(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, instanceExtensionNames);
#endif
bool enableDebugReport =
mEnableValidationLayers && !enableDebugUtils &&
ExtensionFound(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, instanceExtensionNames);
Expand Down Expand Up @@ -740,7 +759,16 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
enabledInstanceExtensions.empty() ? nullptr : enabledInstanceExtensions.data();
instanceInfo.enabledLayerCount = static_cast<uint32_t>(enabledInstanceLayerNames.size());
instanceInfo.ppEnabledLayerNames = enabledInstanceLayerNames.data();

#if defined(ANGLE_PLATFORM_ANDROID) && !defined(ANGLE_IS_64_BIT_CPU)
// TODO: Re-enable validation layers on 32-bit Android
// http://anglebug.com/3924
VkValidationFeatureDisableEXT vkValFeaturesDisable = VK_VALIDATION_FEATURE_DISABLE_ALL_EXT;
VkValidationFeaturesEXT validationFeatures = {};
validationFeatures.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT;
validationFeatures.disabledValidationFeatureCount = 1;
validationFeatures.pDisabledValidationFeatures = &vkValFeaturesDisable;
instanceInfo.pNext = &validationFeatures;
#endif
ANGLE_VK_TRY(displayVk, vkCreateInstance(&instanceInfo, nullptr, &mInstance));

if (enableDebugUtils)
Expand Down
23 changes: 17 additions & 6 deletions src/libANGLE/renderer/vulkan/vk_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ egl::Error ToEGL(Result result, rx::DisplayVk *displayVk, EGLint errorCode)

namespace rx
{
// Mirrors std_validation_str in loader.c
const char *g_VkStdValidationLayerName = "VK_LAYER_LUNARG_standard_validation";
const char *g_VkValidationLayerNames[] = {
// Unified layer that includes full validation layer stack
const char *g_VkKhronosValidationLayerName = "VK_LAYER_KHRONOS_validation";
const char *g_VkStandardValidationLayerName = "VK_LAYER_LUNARG_standard_validation";
const char *g_VkValidationLayerNames[] = {
"VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation",
"VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_core_validation",
"VK_LAYER_GOOGLE_unique_objects"};
Expand All @@ -72,9 +73,14 @@ bool HasValidationLayer(const std::vector<VkLayerProperties> &layerProps, const
return false;
}

bool HasKhronosValidationLayer(const std::vector<VkLayerProperties> &layerProps)
{
return HasValidationLayer(layerProps, g_VkKhronosValidationLayerName);
}

bool HasStandardValidationLayer(const std::vector<VkLayerProperties> &layerProps)
{
return HasValidationLayer(layerProps, g_VkStdValidationLayerName);
return HasValidationLayer(layerProps, g_VkStandardValidationLayerName);
}

bool HasValidationLayers(const std::vector<VkLayerProperties> &layerProps)
Expand Down Expand Up @@ -215,9 +221,14 @@ bool GetAvailableValidationLayers(const std::vector<VkLayerProperties> &layerPro
bool mustHaveLayers,
VulkanLayerVector *enabledLayerNames)
{
if (HasStandardValidationLayer(layerProps))
// Favor unified Khronos layer, but fallback to standard validation
if (HasKhronosValidationLayer(layerProps))
{
enabledLayerNames->push_back(g_VkKhronosValidationLayerName);
}
else if (HasStandardValidationLayer(layerProps))
{
enabledLayerNames->push_back(g_VkStdValidationLayerName);
enabledLayerNames->push_back(g_VkStandardValidationLayerName);
}
else if (HasValidationLayers(layerProps))
{
Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_utils/angle_test_configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ EGLint PlatformParameters::getRenderer() const

void PlatformParameters::initDefaultParameters()
{
#if defined(ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT)
// Default debug layers to enabled in tests.
eglParameters.debugLayersEnabled = EGL_TRUE;
#else
eglParameters.debugLayersEnabled = EGL_FALSE;
#endif // defined(ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT)
}

bool operator<(const PlatformParameters &a, const PlatformParameters &b)
Expand Down
40 changes: 0 additions & 40 deletions third_party/vulkan-headers/BUILD.gn

This file was deleted.

13 changes: 0 additions & 13 deletions third_party/vulkan-headers/vulkan_headers_script_deps.gni

This file was deleted.

Loading

0 comments on commit f22f16d

Please sign in to comment.