blob: 1de48654369025bc5326581ec2d6af8b76fb5bb6 [file] [log] [blame]
# Copyright 2016 The Chromium 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("//build/buildflag_header.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")
import("//testing/test.gni")
import("features.gni")
# Generate a buildflag header for compile-time checking of Vulkan support.
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "ENABLE_VULKAN=$enable_vulkan" ]
}
if (enable_vulkan) {
use_vulkan_xcb = use_x11 || ozone_platform_x11
config("vulkan_config") {
defines = [ "VK_NO_PROTOTYPES" ]
if (use_vulkan_xcb) {
defines += [ "USE_VULKAN_XCB" ]
}
}
source_set("vulkan_function_pointers") {
visibility = [
":vma_wrapper",
":vulkan",
]
sources = [
"vulkan_function_pointers.cc",
"vulkan_function_pointers.h",
]
public_configs = [ ":vulkan_config" ]
defines = [ "IS_VULKAN_IMPL" ]
deps = [
"//base",
"//ui/gfx",
]
public_deps =
[ "//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers" ]
if (is_fuchsia) {
sources += [ "fuchsia/vulkan_fuchsia_ext.h" ]
}
}
source_set("vma_wrapper") {
visibility = [ ":vulkan" ]
sources = [
"vma_wrapper.cc",
"vma_wrapper.h",
]
defines = [ "IS_VULKAN_IMPL" ]
deps = [
":vulkan_function_pointers",
"//base",
"//third_party/vulkan_memory_allocator:vulkan_memory_allocator_with_usage",
]
}
component("vulkan") {
output_name = "vulkan_wrapper"
sources = [
"semaphore_handle.cc",
"semaphore_handle.h",
"vulkan_command_buffer.cc",
"vulkan_command_buffer.h",
"vulkan_command_pool.cc",
"vulkan_command_pool.h",
"vulkan_crash_keys.cc",
"vulkan_crash_keys.h",
"vulkan_cxx.h",
"vulkan_device_queue.cc",
"vulkan_device_queue.h",
"vulkan_fence_helper.cc",
"vulkan_fence_helper.h",
"vulkan_image.cc",
"vulkan_image.h",
"vulkan_implementation.cc",
"vulkan_implementation.h",
"vulkan_instance.cc",
"vulkan_instance.h",
"vulkan_surface.cc",
"vulkan_surface.h",
"vulkan_swap_chain.cc",
"vulkan_swap_chain.h",
"vulkan_util.cc",
"vulkan_util.h",
]
defines = [ "IS_VULKAN_IMPL" ]
deps = [
":buildflags",
"//base",
"//base/util/type_safety",
"//build:chromeos_buildflags",
"//components/crash/core/common:crash_key",
"//gpu/ipc/common:vulkan_ycbcr_info",
"//ui/gfx",
]
public_deps = [
":vma_wrapper",
":vulkan_function_pointers",
"//gpu/config:vulkan_info",
]
data_deps = []
if (is_posix) {
sources += [ "vulkan_util_posix.cc" ]
if (is_linux || is_chromeos) {
sources += [ "vulkan_image_linux.cc" ]
}
}
if (is_android) {
sources += [ "vulkan_image_android.cc" ]
}
if (is_win) {
sources += [
"vulkan_image_win.cc",
"vulkan_util_win32.cc",
]
}
if (is_fuchsia) {
sources += [ "vulkan_image_fuchsia.cc" ]
public_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/zx" ]
data_deps += [ "//third_party/fuchsia-sdk:vulkan_base" ]
# VulkanInstance enables validation layer in Debug builds and when DCHECKs
# are enabled in Release builds. In these cases the validation layer
# libraries and configs need to be included in the generated Fuchsia
# package.
if (is_debug || dcheck_always_on) {
data_deps += [ "//third_party/fuchsia-sdk:vulkan_validation" ]
}
}
if (use_x11) {
deps += [ "//ui/base:features" ]
}
}
static_library("test_support") {
testonly = true
sources = [ "tests/native_window.h" ]
deps = [
"//ui/base:features",
"//ui/gfx",
"//ui/gfx:native_widget_types",
]
if (use_x11 || use_ozone) {
sources += [ "tests/native_window.cc" ]
deps += [ "//ui/platform_window" ]
if (use_x11) {
deps += [ "//ui/platform_window/x11" ]
}
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
}
if (is_win) {
sources += [ "tests/native_window_win.cc" ]
}
if (is_android) {
sources += [ "tests/native_window_android.cc" ]
deps += [
"//ui/android:ui_java",
"//ui/gl",
]
}
}
# TODO(penghuang): support more platforms
# https://crbug.com/1065499
if (is_android || use_x11 || is_win || use_ozone) {
test("vulkan_tests") {
use_xvfb = use_xvfb_in_this_config
sources = [
"tests/basic_vulkan_test.cc",
"tests/basic_vulkan_test.h",
"tests/vulkan_test.cc",
"tests/vulkan_tests_main.cc",
"vulkan_cxx_unittest.cc",
"vulkan_fence_helper_unittest.cc",
"vulkan_image_unittest.cc",
]
deps = [
":test_support",
"//base:base",
"//base/test:test_support",
"//components/viz/common:vulkan_context_provider",
"//gpu/ipc/service",
"//gpu/vulkan/init",
"//testing/gmock",
"//testing/gtest",
"//ui/events/platform",
"//ui/gfx",
"//ui/gfx:native_widget_types",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
]
if (is_android) {
deps += [ "//ui/android:ui_java_test_support" ]
}
if (use_x11) {
deps += [ "//ui/events/platform/x11" ]
}
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
}
}
}