Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 1 | # Copyright 2019 The SwiftShader Authors. All Rights Reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import("//build_overrides/build.gni") |
| 16 | import("../swiftshader.gni") |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 17 | import("vulkan.gni") |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 18 | |
| 19 | # Need a separate config to ensure the warnings are added to the end. |
| 20 | config("swiftshader_libvulkan_private_config") { |
Hidehiko Abe | fe878de | 2020-09-11 16:12:25 +0900 | [diff] [blame] | 21 | if (is_linux || is_chromeos) { |
Alexis Hetu | 110f60e | 2019-06-04 10:02:09 -0400 | [diff] [blame] | 22 | defines = [ |
| 23 | "VK_USE_PLATFORM_XLIB_KHR", |
Jamie Madill | cebb963 | 2019-09-09 11:28:19 -0400 | [diff] [blame] | 24 | "VK_USE_PLATFORM_XCB_KHR", |
Alexis Hetu | 110f60e | 2019-06-04 10:02:09 -0400 | [diff] [blame] | 25 | "VK_EXPORT=__attribute__((visibility(\"default\")))", |
| 26 | ] |
David 'Digit' Turner | 58c34f5 | 2019-08-12 14:11:58 +0200 | [diff] [blame] | 27 | } else if (is_fuchsia) { |
| 28 | defines = [ |
| 29 | "VK_USE_PLATFORM_FUCHSIA=1", |
| 30 | "VK_EXPORT=__attribute__((visibility(\"default\")))", |
| 31 | ] |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 32 | } else if (is_win) { |
| 33 | defines = [ |
| 34 | "VK_USE_PLATFORM_WIN32_KHR=1", |
| 35 | "VK_EXPORT=", |
| 36 | ] |
Jonah Ryan-Davis | 6623ca1 | 2019-10-25 10:44:05 -0600 | [diff] [blame] | 37 | } else if (is_mac) { |
| 38 | defines = [ |
| 39 | "VK_USE_PLATFORM_MACOS_MVK=1", |
Jonah Ryan-Davis | 215bc79 | 2019-10-31 17:23:49 -0400 | [diff] [blame] | 40 | "VK_USE_PLATFORM_METAL_EXT=1", |
Jonah Ryan-Davis | 6623ca1 | 2019-10-25 10:44:05 -0600 | [diff] [blame] | 41 | "VK_EXPORT=__attribute__((visibility(\"default\")))", |
| 42 | ] |
Alexis Hetu | 110f60e | 2019-06-04 10:02:09 -0400 | [diff] [blame] | 43 | } else { |
| 44 | defines = [ "VK_EXPORT=" ] |
| 45 | } |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 46 | |
Jamie Madill | 9746f8b | 2019-09-05 13:17:09 -0400 | [diff] [blame] | 47 | if (is_clang) { |
| 48 | cflags = [ |
| 49 | "-Wno-unused-private-field", |
| 50 | "-Wno-switch", |
| 51 | ] |
| 52 | } |
Nicolas Capens | a4347a9 | 2020-03-01 08:29:25 -0500 | [diff] [blame] | 53 | |
| 54 | defines += [ |
| 55 | "SWIFTSHADER_ENABLE_ASTC", # TODO(b/150130101) |
| 56 | ] |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 57 | } |
| 58 | |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 59 | swiftshader_source_set("swiftshader_libvulkan_headers") { |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 60 | sources = [ |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 61 | "Version.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 62 | "VkBuffer.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 63 | "VkBufferView.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 64 | "VkCommandBuffer.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 65 | "VkCommandPool.hpp", |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 66 | "VkConfig.hpp", |
Alexis Hetu | 74f6c65 | 2020-07-22 21:57:05 -0400 | [diff] [blame] | 67 | "VkDebugUtilsMessenger.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 68 | "VkDescriptorPool.hpp", |
| 69 | "VkDescriptorSet.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 70 | "VkDescriptorSetLayout.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 71 | "VkDescriptorUpdateTemplate.hpp", |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 72 | "VkDestroy.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 73 | "VkDevice.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 74 | "VkDeviceMemory.hpp", |
Alexis Hetu | a1594b9 | 2021-10-07 15:48:06 -0400 | [diff] [blame] | 75 | "VkDeviceMemoryExternalHost.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 76 | "VkEvent.hpp", |
| 77 | "VkFence.hpp", |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 78 | "VkFormat.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 79 | "VkFramebuffer.hpp", |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 80 | "VkGetProcAddress.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 81 | "VkImage.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 82 | "VkImageView.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 83 | "VkInstance.hpp", |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 84 | "VkMemory.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 85 | "VkObject.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 86 | "VkPhysicalDevice.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 87 | "VkPipeline.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 88 | "VkPipelineCache.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 89 | "VkPipelineLayout.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 90 | "VkQueryPool.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 91 | "VkQueue.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 92 | "VkRenderPass.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 93 | "VkSampler.hpp", |
| 94 | "VkSemaphore.hpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 95 | "VkShaderModule.hpp", |
Ben Clayton | 4d23aa3 | 2020-04-14 20:33:52 +0100 | [diff] [blame] | 96 | "VkSpecializationInfo.hpp", |
Ben Clayton | 597db18 | 2019-11-24 22:40:40 +0000 | [diff] [blame] | 97 | "VkStringify.hpp", |
Sean Risser | 6846389 | 2020-12-14 16:35:57 -0500 | [diff] [blame] | 98 | "VkTimelineSemaphore.hpp", |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 99 | "VulkanPlatform.hpp", |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 100 | ] |
Hidehiko Abe | fe878de | 2020-09-11 16:12:25 +0900 | [diff] [blame] | 101 | if (is_linux || is_chromeos || is_android) { |
David 'Digit' Turner | 7c4d0a0 | 2019-09-03 17:00:02 +0200 | [diff] [blame] | 102 | sources += [ |
David 'Digit' Turner | 359bc80 | 2019-08-14 17:46:07 +0200 | [diff] [blame] | 103 | "VkDeviceMemoryExternalLinux.hpp", |
David 'Digit' Turner | 7c4d0a0 | 2019-09-03 17:00:02 +0200 | [diff] [blame] | 104 | "VkSemaphoreExternalLinux.hpp", |
| 105 | ] |
David 'Digit' Turner | 89fd148 | 2020-02-20 13:12:08 +0100 | [diff] [blame] | 106 | } else if (is_mac) { |
| 107 | sources += [ |
| 108 | "VkDeviceMemoryExternalMac.hpp", |
| 109 | ] |
David 'Digit' Turner | fda994c | 2019-09-04 16:36:36 +0200 | [diff] [blame] | 110 | } else if (is_fuchsia) { |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 111 | sources += [ "VkSemaphoreExternalFuchsia.hpp" ] |
David 'Digit' Turner | 7c4d0a0 | 2019-09-03 17:00:02 +0200 | [diff] [blame] | 112 | } |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | swiftshader_shared_library("swiftshader_libvulkan") { |
| 116 | sources = [ |
| 117 | "VkBuffer.cpp", |
| 118 | "VkBufferView.cpp", |
| 119 | "VkCommandBuffer.cpp", |
| 120 | "VkCommandPool.cpp", |
Alexis Hetu | 74f6c65 | 2020-07-22 21:57:05 -0400 | [diff] [blame] | 121 | "VkDebugUtilsMessenger.cpp", |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 122 | "VkDescriptorPool.cpp", |
Alexis Hetu | 4f438a5 | 2020-06-15 16:13:51 -0400 | [diff] [blame] | 123 | "VkDescriptorSet.cpp", |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 124 | "VkDescriptorSetLayout.cpp", |
| 125 | "VkDescriptorUpdateTemplate.cpp", |
| 126 | "VkDevice.cpp", |
| 127 | "VkDeviceMemory.cpp", |
Alexis Hetu | a1594b9 | 2021-10-07 15:48:06 -0400 | [diff] [blame] | 128 | "VkDeviceMemoryExternalHost.cpp", |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 129 | "VkFormat.cpp", |
| 130 | "VkFramebuffer.cpp", |
| 131 | "VkGetProcAddress.cpp", |
| 132 | "VkImage.cpp", |
| 133 | "VkImageView.cpp", |
| 134 | "VkInstance.cpp", |
| 135 | "VkMemory.cpp", |
| 136 | "VkPhysicalDevice.cpp", |
| 137 | "VkPipeline.cpp", |
| 138 | "VkPipelineCache.cpp", |
| 139 | "VkPipelineLayout.cpp", |
| 140 | "VkPromotedExtensions.cpp", |
| 141 | "VkQueryPool.cpp", |
| 142 | "VkQueue.cpp", |
| 143 | "VkRenderPass.cpp", |
| 144 | "VkSampler.cpp", |
David 'Digit' Turner | 99938ea | 2019-09-03 15:11:17 +0200 | [diff] [blame] | 145 | "VkSemaphore.cpp", |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 146 | "VkShaderModule.cpp", |
Ben Clayton | 4d23aa3 | 2020-04-14 20:33:52 +0100 | [diff] [blame] | 147 | "VkSpecializationInfo.cpp", |
Ben Clayton | d44d615 | 2019-11-24 22:40:40 +0000 | [diff] [blame] | 148 | "VkStringify.cpp", |
Sean Risser | 6846389 | 2020-12-14 16:35:57 -0500 | [diff] [blame] | 149 | "VkTimelineSemaphore.cpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 150 | "libVulkan.cpp", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 151 | "main.cpp", |
| 152 | "resource.h", |
| 153 | ] |
| 154 | |
| 155 | configs = [ ":swiftshader_libvulkan_private_config" ] |
| 156 | |
Jamie Madill | 9746f8b | 2019-09-05 13:17:09 -0400 | [diff] [blame] | 157 | # TODO(capn): Use the same ICD name on both Windows and non-Windows. |
| 158 | if (is_win) { |
| 159 | output_name = "vk_swiftshader" |
| 160 | } else { |
| 161 | output_name = "libvk_swiftshader" |
| 162 | } |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 163 | |
Sylvain Defresne | b94db86 | 2020-09-24 11:47:25 +0200 | [diff] [blame] | 164 | if (is_win) { |
| 165 | sources += [ |
| 166 | "Vulkan.rc", |
| 167 | "vk_swiftshader.def", |
| 168 | ] |
| 169 | } |
| 170 | |
Alexis Hetu | ec63fbe | 2019-07-15 14:33:11 -0400 | [diff] [blame] | 171 | if (is_mac) { |
| 172 | ldflags = [ |
| 173 | "-Wl,-install_name,@rpath/libvk_swiftshader.dylib", |
| 174 | "-Wl,-exported_symbols_list," + |
Nicolas Capens | f003332 | 2019-08-30 12:51:12 -0400 | [diff] [blame] | 175 | rebase_path("vk_swiftshader.exports", root_build_dir), |
Alexis Hetu | ec63fbe | 2019-07-15 14:33:11 -0400 | [diff] [blame] | 176 | ] |
Hidehiko Abe | fe878de | 2020-09-11 16:12:25 +0900 | [diff] [blame] | 177 | } else if (is_linux || is_chromeos || is_fuchsia) { |
Tom Anderson | 42d6461 | 2019-06-12 11:05:21 -0700 | [diff] [blame] | 178 | inputs = [ |
Nicolas Capens | f003332 | 2019-08-30 12:51:12 -0400 | [diff] [blame] | 179 | "vk_swiftshader.lds", |
Tom Anderson | 42d6461 | 2019-06-12 11:05:21 -0700 | [diff] [blame] | 180 | ] |
Nicolas Capens | e3621dc | 2020-02-25 22:45:42 -0500 | [diff] [blame] | 181 | ldflags = [ |
| 182 | # -Bsymbolic binds symbol references to their global definitions within |
| 183 | # a shared object, thereby preventing symbol preemption. |
| 184 | "-Wl,-Bsymbolic", |
| 185 | "-Wl,--version-script=" + |
| 186 | rebase_path("vk_swiftshader.lds", root_build_dir) ] |
Alexis Hetu | f9e9cf6 | 2019-06-05 17:18:40 -0400 | [diff] [blame] | 187 | } |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 188 | |
| 189 | deps = [ |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 190 | "${swiftshader_spirv_tools_dir}:SPIRV-Tools", |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 191 | "../../third_party/marl:Marl", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 192 | "../Device", |
| 193 | "../Pipeline", |
Alexis Hetu | f6e439f | 2020-03-10 16:44:26 -0400 | [diff] [blame] | 194 | "../Reactor:swiftshader_reactor", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 195 | "../System", |
| 196 | "../WSI", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 197 | ] |
| 198 | |
| 199 | include_dirs = [ |
| 200 | "..", |
| 201 | "../../include", |
Jamie Madill | bbd8c42 | 2019-08-28 17:08:17 -0400 | [diff] [blame] | 202 | "$swiftshader_spirv_tools_dir/include", |
| 203 | "$spirv_tools_spirv_headers_dir/include", |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 204 | ] |
Jamie Madill | fe23c66 | 2019-08-30 17:38:24 -0400 | [diff] [blame] | 205 | |
| 206 | public_deps = [ |
| 207 | ":swiftshader_libvulkan_headers", |
| 208 | ] |
Saman Sami | f4d2a44 | 2019-05-21 15:04:41 -0400 | [diff] [blame] | 209 | } |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 210 | |
| 211 | # Generates an ICD JSON file that can be used by all targets in this GN build |
| 212 | # (ANGLE, Dawn, Chromium). |
| 213 | action("icd_file") { |
Jamie Madill | 2613cb5 | 2019-11-27 08:34:49 -0500 | [diff] [blame] | 214 | output_icd_file = "${root_out_dir}/${swiftshader_icd_file_name}" |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 215 | input_file = swiftshader_icd_file_name |
| 216 | |
| 217 | if (is_win) { |
| 218 | library_path = ".\\vk_swiftshader.dll" |
| 219 | } else if (is_mac) { |
| 220 | library_path = "./libvk_swiftshader.dylib" |
| 221 | } else { |
| 222 | library_path = "./libvk_swiftshader.so" |
| 223 | } |
| 224 | |
| 225 | script = "write_icd_json.py" |
| 226 | args = [ |
| 227 | "--input", |
Jamie Madill | 389749a | 2019-11-28 10:35:58 -0500 | [diff] [blame] | 228 | rebase_path(input_file, root_build_dir), |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 229 | "--output", |
Jamie Madill | 389749a | 2019-11-28 10:35:58 -0500 | [diff] [blame] | 230 | rebase_path(output_icd_file, root_build_dir), |
Corentin Wallez | e7ce4e5 | 2019-11-22 16:13:50 +0100 | [diff] [blame] | 231 | "--library_path", |
| 232 | library_path, |
| 233 | ] |
| 234 | |
| 235 | inputs = [ |
| 236 | input_file, |
| 237 | ] |
| 238 | outputs = [ |
| 239 | output_icd_file, |
| 240 | ] |
| 241 | |
| 242 | deps = [ |
| 243 | ":swiftshader_libvulkan", |
| 244 | ] |
| 245 | } |