| # Copyright 2019 The Fuchsia 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/sdk/sdk_atom.gni") |
| import("//build/testing/host_test_data.gni") |
| import("//src/lib/vulkan/build/config.gni") |
| import("//src/lib/vulkan/image_pipe_swapchain.gni") |
| import("//src/lib/vulkan/layers.gni") |
| |
| # Centralizing the GN points of entry into Vulkan ecosystem repositories here is helpful |
| # for grasping the full scope. Note, there are also entry points in //sdk/BUILD.gn. |
| |
| # Provides the Vulkan headers and entry points via the Vulkan loader. |
| group("vulkan") { |
| public_configs = [ ":vulkan_hpp" ] |
| |
| # Targets always use in-tree Vulkan implementation. |
| if (!is_host) { |
| public_deps = [ |
| ":headers", |
| "//third_party/Vulkan-Loader:libvulkan", |
| ] |
| } |
| |
| # Host target with "null" Vulkan should use Vulkan headers and |
| # link the null Vulkan implementation statically. |
| if (is_host && use_null_vulkan_on_host) { |
| public_deps = [ |
| ":headers", |
| "//src/lib/vulkan/third_party/null_vulkan", |
| ] |
| } |
| |
| # Host target with non-null Vulkan should link against prebuilt |
| # Vulkan SDK. |
| if (is_host && !use_null_vulkan_on_host) { |
| public_configs += [ ":vulkan_host_config" ] |
| public_deps = [ ":copy_vulkan_runtime" ] |
| } |
| } |
| |
| group("vulkan_headers_and_loader") { |
| public_deps = [ |
| ":headers", |
| "//third_party/Vulkan-Loader:libvulkan", |
| ] |
| } |
| |
| # Provides only the Vulkan headers without the loader. |
| group("headers") { |
| public_deps = [ "//third_party/Vulkan-Headers:vulkan_headers" ] |
| } |
| |
| # Support code for building layers without bloat. |
| group("micro_layer_common") { |
| public_deps = [ "//third_party/Vulkan-ValidationLayers:micro_layer_common" ] |
| } |
| |
| # Tests for the Vulkan loader and validation layers. |
| group("loader_and_validation_tests") { |
| testonly = true |
| public_deps = [ |
| "//third_party/Vulkan-Loader:tests", |
| "//third_party/Vulkan-ValidationLayers:tests", |
| ] |
| } |
| |
| # The vulkaninfo application. |
| group("vulkaninfo") { |
| public_deps = [ "//third_party/Vulkan-Tools:vulkaninfo" ] |
| } |
| |
| config("vulkan_hpp") { |
| defines = [ |
| "VULKAN_HPP_ASSERT(expr)=do {} while(0)", |
| "VULKAN_HPP_NO_EXCEPTIONS", |
| ] |
| } |
| |
| sdk_atom("vulkan_layers") { |
| id = "sdk://pkg/vulkan_layers" |
| |
| category = "partner" |
| |
| files = [] |
| |
| resources = |
| vulkan_validation_layers.resources + image_pipe_swapchain.resources |
| |
| loadable_modules = vulkan_validation_layers.loadable_modules + |
| image_pipe_swapchain.loadable_modules |
| non_sdk_deps = |
| vulkan_validation_layers.public_deps + image_pipe_swapchain.public_deps |
| |
| sdk_resources = [] |
| foreach(resource, resources) { |
| destination = "pkg/vulkan_layers/data/" + resource.dest |
| files += [ |
| { |
| source = resource.path |
| dest = destination |
| }, |
| ] |
| sdk_resources += [ destination ] |
| } |
| |
| sdk_binaries = [] |
| foreach(loadable_module, loadable_modules) { |
| destination = "arch/$target_cpu/dist/" + loadable_module.name |
| files += [ |
| { |
| source = "$root_out_dir/" + loadable_module.name |
| dest = destination |
| }, |
| ] |
| sdk_binaries += [ destination ] |
| } |
| |
| meta = { |
| dest = "pkg/vulkan_layers/meta.json" |
| schema = "loadable_module" |
| value = { |
| type = "loadable_module" |
| name = "vulkan_layers" |
| root = "pkg/vulkan_layers" |
| resources = [] |
| resources = sdk_resources |
| binaries = { |
| } |
| if (target_cpu == "arm64") { |
| binaries.arm64 = sdk_binaries |
| } else if (target_cpu == "x64") { |
| binaries.x64 = sdk_binaries |
| } else { |
| assert(false, "Unknown CPU type: %target_cpu") |
| } |
| } |
| } |
| } |
| |
| # |
| # Copy Vulkan runtime (loader, validation layers library and layers descriptor) |
| # to test_data directory. |
| # |
| if (is_host) { |
| copy("copy_vulkan_libs") { |
| assert(is_linux, "Vulkan is only supported on Linux host.") |
| _lib_dir = vulkan_host_runtime_sub_dirs.lib |
| sources = [ |
| "$vulkan_host_runtime_dir/$_lib_dir/libVkLayer_khronos_validation.so", |
| "$vulkan_host_runtime_dir/$_lib_dir/libvulkan.so.1", |
| ] |
| if (use_swiftshader_vulkan_icd_on_host) { |
| sources += [ |
| "$vulkan_host_runtime_dir/$_lib_dir/libvk_swiftshader.so", |
| "$vulkan_host_runtime_dir/$_lib_dir/vk_swiftshader_icd.json", |
| ] |
| } |
| outputs = [ "${root_out_dir}/${vulkan_host_runtime_out_root}/${_lib_dir}/{{source_file_part}}" ] |
| } |
| |
| # libvulkan.so is a symbolic link to libvulkan.so.1. For symbolic links, ninja |
| # records the modification time of the linked file into its log, so we need to |
| # ensure that the original library file is copied before the symbolic link. We |
| # do this by adding "copy_vulkan_libs" as its dependency. |
| copy("copy_vulkan_lib_links") { |
| assert(is_linux, "Vulkan is only supported on Linux host.") |
| _lib_dir = vulkan_host_runtime_sub_dirs.lib |
| sources = [ "$vulkan_host_runtime_dir/$_lib_dir/libvulkan.so" ] |
| outputs = [ "${root_out_dir}/${vulkan_host_runtime_out_root}/${_lib_dir}/{{source_file_part}}" ] |
| deps = [ ":copy_vulkan_libs" ] |
| } |
| |
| copy("copy_vulkan_etc") { |
| assert(is_linux, "Vulkan is only supported on Linux host.") |
| _layers_dir = vulkan_host_runtime_sub_dirs.layers |
| sources = [ |
| "$vulkan_host_runtime_dir/$_layers_dir/VkLayer_khronos_validation.json", |
| "$vulkan_host_runtime_dir/$_layers_dir/VkLayer_standard_validation.json", |
| ] |
| outputs = [ "${root_out_dir}/${vulkan_host_runtime_out_root}/${_layers_dir}/{{source_file_part}}" ] |
| } |
| |
| host_test_data("vulkan_test_data") { |
| _lib_dir = vulkan_host_runtime_sub_dirs.lib |
| _layers_dir = vulkan_host_runtime_sub_dirs.layers |
| _data_dir = "${root_out_dir}/${vulkan_host_runtime_out_root}" |
| sources = [ |
| "${_data_dir}/${_layers_dir}", |
| "${_data_dir}/${_lib_dir}", |
| ] |
| deps = [ |
| ":copy_vulkan_etc", |
| ":copy_vulkan_libs", |
| ] |
| } |
| |
| group("copy_vulkan_runtime") { |
| assert(is_linux, "Vulkan is only supported on Linux host.") |
| deps = [ |
| ":copy_vulkan_etc", |
| ":copy_vulkan_lib_links", |
| ":copy_vulkan_libs", |
| ] |
| } |
| } |
| |
| # |
| # Vulkan dependencies required for Vulkan executables / tests / source sets. |
| # This includes headers, loader linkage, and copying of runtime files for host |
| # executables. |
| # |
| config("vulkan_host_config") { |
| if (is_host && is_linux) { |
| include_dirs = [ "$vulkan_host_sdk_dir/include" ] |
| lib_dirs = |
| [ "$vulkan_host_runtime_dir/${vulkan_host_runtime_sub_dirs.lib}" ] |
| |
| # Link Vulkan loader to host executables. |
| libs = [ "vulkan" ] |
| } |
| } |