BUILD.gn 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. # Copyright 2016 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/buildflag_header.gni")
  5. import("//build/config/dcheck_always_on.gni")
  6. import("//build/config/ozone.gni")
  7. import("//build/config/ui.gni")
  8. import("//build_overrides/wayland.gni")
  9. import("//testing/test.gni")
  10. import("features.gni")
  11. # Generate a buildflag header for compile-time checking of Vulkan support.
  12. buildflag_header("buildflags") {
  13. header = "buildflags.h"
  14. flags = [ "ENABLE_VULKAN=$enable_vulkan" ]
  15. }
  16. if (enable_vulkan) {
  17. use_vulkan_xcb = ozone_platform_x11
  18. config("vulkan_config") {
  19. defines = [ "VK_NO_PROTOTYPES" ]
  20. if (use_vulkan_xcb) {
  21. defines += [ "USE_VULKAN_XCB" ]
  22. }
  23. if (ozone_platform_wayland && !use_system_libwayland) {
  24. configs = [ "//third_party/wayland:wayland_config" ]
  25. }
  26. }
  27. source_set("vulkan_function_pointers") {
  28. visibility = [
  29. ":vma_wrapper",
  30. ":vulkan",
  31. ]
  32. sources = [
  33. "vulkan_function_pointers.cc",
  34. "vulkan_function_pointers.h",
  35. ]
  36. public_configs = [ ":vulkan_config" ]
  37. defines = [ "IS_VULKAN_IMPL" ]
  38. deps = [
  39. "//base",
  40. "//ui/gfx",
  41. ]
  42. public_deps =
  43. [ "//third_party/vulkan-deps/vulkan-headers/src:vulkan_headers" ]
  44. if (is_fuchsia) {
  45. sources += [ "fuchsia/vulkan_fuchsia_ext.h" ]
  46. }
  47. }
  48. source_set("vma_wrapper") {
  49. visibility = [ ":vulkan" ]
  50. sources = [
  51. "vma_wrapper.cc",
  52. "vma_wrapper.h",
  53. ]
  54. defines = [ "IS_VULKAN_IMPL" ]
  55. deps = [
  56. ":vulkan_function_pointers",
  57. "//base",
  58. "//third_party/vulkan_memory_allocator",
  59. ]
  60. }
  61. component("vulkan") {
  62. output_name = "vulkan_wrapper"
  63. sources = [
  64. "semaphore_handle.cc",
  65. "semaphore_handle.h",
  66. "vulkan_command_buffer.cc",
  67. "vulkan_command_buffer.h",
  68. "vulkan_command_pool.cc",
  69. "vulkan_command_pool.h",
  70. "vulkan_crash_keys.cc",
  71. "vulkan_crash_keys.h",
  72. "vulkan_cxx.h",
  73. "vulkan_device_queue.cc",
  74. "vulkan_device_queue.h",
  75. "vulkan_fence_helper.cc",
  76. "vulkan_fence_helper.h",
  77. "vulkan_image.cc",
  78. "vulkan_image.h",
  79. "vulkan_implementation.cc",
  80. "vulkan_implementation.h",
  81. "vulkan_instance.cc",
  82. "vulkan_instance.h",
  83. "vulkan_surface.cc",
  84. "vulkan_surface.h",
  85. "vulkan_swap_chain.cc",
  86. "vulkan_swap_chain.h",
  87. "vulkan_util.cc",
  88. "vulkan_util.h",
  89. ]
  90. defines = [ "IS_VULKAN_IMPL" ]
  91. if (ozone_platform == "x11") {
  92. defines += [ "OZONE_PLATFORM_IS_X11" ]
  93. }
  94. deps = [
  95. ":buildflags",
  96. "//base",
  97. "//build:chromeos_buildflags",
  98. "//components/crash/core/common:crash_key",
  99. "//gpu/ipc/common:vulkan_ycbcr_info",
  100. "//ui/gfx",
  101. "//ui/gl",
  102. ]
  103. public_deps = [
  104. ":vma_wrapper",
  105. ":vulkan_function_pointers",
  106. "//gpu/config:vulkan_info",
  107. ]
  108. data_deps = []
  109. if (is_posix) {
  110. sources += [ "vulkan_util_posix.cc" ]
  111. if (is_linux || is_chromeos) {
  112. sources += [ "vulkan_image_linux.cc" ]
  113. }
  114. }
  115. if (is_android) {
  116. sources += [ "vulkan_image_android.cc" ]
  117. }
  118. if (is_fuchsia) {
  119. sources += [ "vulkan_util_fuchsia.cc" ]
  120. }
  121. if (is_win) {
  122. sources += [
  123. "vulkan_image_win.cc",
  124. "vulkan_util_win32.cc",
  125. ]
  126. }
  127. if (is_fuchsia) {
  128. sources += [ "vulkan_image_fuchsia.cc" ]
  129. public_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/zx" ]
  130. data_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/vulkan" ]
  131. # VulkanInstance enables validation layer in Debug builds and when DCHECKs
  132. # are enabled in Release builds. In these cases the validation layer
  133. # libraries and configs need to be included in the generated Fuchsia
  134. # package.
  135. if (is_debug || dcheck_always_on) {
  136. data_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/vulkan_layers:VkLayer_khronos_validation" ]
  137. }
  138. }
  139. if (is_apple) {
  140. sources += [ "vulkan_image_mac.cc" ]
  141. }
  142. }
  143. static_library("test_support") {
  144. testonly = true
  145. sources = [ "tests/native_window.h" ]
  146. deps = [
  147. "//ui/base:features",
  148. "//ui/gfx",
  149. "//ui/gfx:native_widget_types",
  150. ]
  151. if (use_ozone) {
  152. sources += [ "tests/native_window.cc" ]
  153. deps += [
  154. "//ui/ozone",
  155. "//ui/platform_window",
  156. ]
  157. }
  158. if (is_win) {
  159. sources += [ "tests/native_window_win.cc" ]
  160. }
  161. if (is_android) {
  162. sources += [ "tests/native_window_android.cc" ]
  163. deps += [
  164. "//ui/android:ui_java",
  165. "//ui/gl",
  166. ]
  167. }
  168. }
  169. # TODO(penghuang): support more platforms
  170. # https://crbug.com/1065499
  171. if (is_android || is_win || use_ozone) {
  172. test("vulkan_tests") {
  173. use_xvfb = use_xvfb_in_this_config
  174. sources = [
  175. "tests/basic_vulkan_test.cc",
  176. "tests/basic_vulkan_test.h",
  177. "tests/vulkan_test.cc",
  178. "tests/vulkan_tests_main.cc",
  179. # TODO(crbug.com/1234132): fix compile problem with the latest vulkan
  180. # headers.
  181. # "vulkan_cxx_unittest.cc",
  182. "vulkan_fence_helper_unittest.cc",
  183. "vulkan_image_unittest.cc",
  184. ]
  185. deps = [
  186. ":test_support",
  187. "//base:base",
  188. "//base/test:test_support",
  189. "//components/viz/common:vulkan_context_provider",
  190. "//gpu/ipc/service",
  191. "//gpu/vulkan/init",
  192. "//testing/gmock",
  193. "//testing/gtest",
  194. "//ui/events/platform",
  195. "//ui/gfx",
  196. "//ui/gfx:native_widget_types",
  197. "//ui/gfx:test_support",
  198. "//ui/gfx/geometry",
  199. ]
  200. if (is_android) {
  201. deps += [ "//ui/android:ui_java_test_support" ]
  202. }
  203. if (use_ozone) {
  204. deps += [ "//ui/ozone" ]
  205. }
  206. }
  207. }
  208. }