1// 2// Copyright (C) 2018 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17package { 18 // http://go/android-license-faq 19 // A large-scale-change added 'default_applicable_licenses' to import 20 // the below license kinds from "external_swiftshader_license": 21 // SPDX-license-identifier-Apache-2.0 22 // SPDX-license-identifier-BSD 23 default_applicable_licenses: ["external_swiftshader_license"], 24} 25 26cc_defaults { 27 name: "libswiftshadervk_llvm_defaults", 28 29 host_supported: true, 30 31 header_libs: [ 32 "swiftshader_platform_headers", 33 ], 34 35 srcs: [ 36 "Reactor/Assert.cpp", 37 "Reactor/CPUID.cpp", 38 "Reactor/Debug.cpp", 39 "Reactor/ExecutableMemory.cpp", 40 "Reactor/LLVMJIT.cpp", 41 "Reactor/LLVMReactor.cpp", 42 "Reactor/Pragma.cpp", 43 "Reactor/Reactor.cpp", 44 "Reactor/SIMD.cpp", 45 ], 46 47 cflags: [ 48 "-DREACTOR_ANONYMOUS_MMAP_NAME=swiftshader_jit", 49 "-Wno-unused-parameter", 50 "-Wno-implicit-fallthrough", 51 ], 52 53 static_libs: [ 54 "libLLVM16_swiftshader", 55 ], 56 57 shared_libs: [ 58 "libcutils", 59 "liblog", 60 ], 61} 62 63cc_library_static { 64 name: "libswiftshadervk_llvm", 65 vendor: true, 66 defaults: [ "libswiftshadervk_llvm_defaults" ], 67} 68 69cc_library_static { 70 name: "libswiftshadervk_llvm_debug", 71 vendor: true, 72 defaults: [ "libswiftshadervk_llvm_defaults" ], 73 cflags: [ 74 "-UNDEBUG", 75 ], 76} 77 78genrule { 79 name: "commit_header", 80 out: ["commit.h"], 81 tool_files: ["commit_id.py"], 82 cmd: "$(location commit_id.py) gen $(genDir)/commit.h", 83} 84 85cc_defaults { 86 name: "libvk_swiftshader_defaults", 87 host_supported: true, 88 vendor: true, 89 90 defaults: [ "swiftshader_common" ], 91 92 cflags: [ 93 "-D_GNU_SOURCE", 94 "-D__STDC_LIMIT_MACROS", 95 "-D__STDC_CONSTANT_MACROS", 96 "-D__STDC_FORMAT_MACROS", 97 "-Wno-implicit-fallthrough", 98 "-Wno-unused-parameter", 99 "-Wno-unused-local-typedef", 100 "-Wno-missing-field-initializers", 101 // Enable to output commit hash when SwiftShader is initialized 102 //"-DENABLE_BUILD_VERSION_OUTPUT", 103 ], 104 105 cppflags: [ 106 "-Wno-sign-promo", 107 "-Wno-non-virtual-dtor", 108 ], 109 110 ldflags: [ 111 // -Bsymbolic binds symbol references to their global definitions within 112 // a shared object, thereby preventing symbol preemption. 113 "-Wl,-Bsymbolic", 114 ], 115 116 local_include_dirs: [ "Vulkan" ], 117 118 generated_headers: [ "commit_header" ], 119 120 target: { 121 android: { 122 relative_install_path: "hw", 123 header_libs: [ 124 "swiftshader_platform_headers", 125 "vulkan_headers", 126 "hwvulkan_headers", 127 ], 128 shared_libs: [ 129 "libnativewindow", 130 "libhardware", 131 "libsync", 132 "liblog", 133 ], 134 static_libs: [ 135 "libarect", 136 ], 137 version_script: "Vulkan/android_vk_swiftshader.lds", 138 }, 139 host: { 140 version_script: "Vulkan/android_host_vk_swiftshader.lds", 141 }, 142 }, 143} 144 145cc_library_static { 146 name: "swiftshader_debug", 147 148 host_supported: true, 149 150 vendor_available: true, 151 152 cflags: [ 153 "-DLOG_TAG=\"swiftshader\"", 154 ], 155 156 srcs: [ 157 "System/Debug.cpp", 158 ], 159 160 export_include_dirs: [ 161 ".", 162 ], 163 164 shared_libs: [ 165 "liblog", 166 ], 167} 168 169cc_defaults { 170 name: "libvk_swiftshader_common_defaults", 171 172 cflags: [ 173 "-DLOG_TAG=\"swiftshader\"", 174 "-DSWIFTSHADER_ENABLE_ASTC", // TODO(b/150130101) 175 "-DSWIFTSHADER_DEVICE_MEMORY_REPORT", 176 ], 177 178 srcs: [ 179 "System/Build.cpp", 180 "System/Configurator.cpp", 181 "System/CPUID.cpp", 182 "System/Half.cpp", 183 "System/Linux/MemFd.cpp", 184 "System/Math.cpp", 185 "System/Memory.cpp", 186 "System/Socket.cpp", 187 "System/SwiftConfig.cpp", 188 "System/Timer.cpp", 189 "Device/*.cpp", 190 "Pipeline/*.cpp", 191 "Vulkan/libVulkan.cpp", 192 "Vulkan/main.cpp", 193 "Vulkan/VkBuffer.cpp", 194 "Vulkan/VkBufferView.cpp", 195 "Vulkan/VkCommandBuffer.cpp", 196 "Vulkan/VkCommandPool.cpp", 197 "Vulkan/VkDebugUtilsMessenger.cpp", 198 "Vulkan/VkDescriptorPool.cpp", 199 "Vulkan/VkDescriptorSet.cpp", 200 "Vulkan/VkDescriptorSetLayout.cpp", 201 "Vulkan/VkDescriptorUpdateTemplate.cpp", 202 "Vulkan/VkDevice.cpp", 203 "Vulkan/VkDeviceMemory.cpp", 204 "Vulkan/VkDeviceMemoryExternalHost.cpp", 205 "Vulkan/VkFormat.cpp", 206 "Vulkan/VkFramebuffer.cpp", 207 "Vulkan/VkGetProcAddress.cpp", 208 "Vulkan/VkImage.cpp", 209 "Vulkan/VkImageView.cpp", 210 "Vulkan/VkInstance.cpp", 211 "Vulkan/VkMemory.cpp", 212 "Vulkan/VkPhysicalDevice.cpp", 213 "Vulkan/VkPipelineCache.cpp", 214 "Vulkan/VkPipeline.cpp", 215 "Vulkan/VkPipelineLayout.cpp", 216 "Vulkan/VkPromotedExtensions.cpp", 217 "Vulkan/VkQueryPool.cpp", 218 "Vulkan/VkQueue.cpp", 219 "Vulkan/VkRenderPass.cpp", 220 "Vulkan/VkSampler.cpp", 221 "Vulkan/VkSemaphore.cpp", 222 "Vulkan/VkShaderModule.cpp", 223 "Vulkan/VkSpecializationInfo.cpp", 224 "Vulkan/VkStringify.cpp", 225 "Vulkan/VkTimelineSemaphore.cpp", 226 "WSI/HeadlessSurfaceKHR.cpp", 227 "WSI/VkSurfaceKHR.cpp", 228 ], 229 230 static_libs: [ 231 "swiftshader_astc", 232 "swiftshader_debug", 233 "swiftshader_marl", 234 "swiftshader_spirv-tools", 235 ], 236 237 include_dirs: [ 238 "external/swiftshader/third_party/SPIRV-Headers/include", 239 "external/swiftshader/include", 240 ], 241 242 target: { 243 android: { 244 srcs: [ 245 "Vulkan/VkDeviceMemoryExternalAndroid.cpp", 246 ], 247 cflags: [ 248 "-DSWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER", 249 ], 250 }, 251 host: { 252 srcs: [ 253 "WSI/VkSwapchainKHR.cpp", 254 ], 255 cflags: [ 256 "-DSWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD", 257 // Allocations which may be mapped into a KVM based virtual 258 // machine must be page aligned. 259 "-DSWIFTSHADER_DEVICE_MEMORY_ALLOCATION_ALIGNMENT=4096", 260 ], 261 }, 262 }, 263} 264 265cc_library_shared { 266 name: "vulkan.pastel", 267 268 static_libs: [ 269 "libswiftshadervk_llvm", 270 "libLLVM16_swiftshader", 271 ], 272 273 target: { 274 host: { 275 strip: { 276 keep_symbols_and_debug_frame: true, 277 }, 278 }, 279 }, 280 281 defaults: [ 282 "libvk_swiftshader_common_defaults", 283 "libvk_swiftshader_defaults" 284 ], 285} 286 287cc_library_shared { 288 name: "vulkan.pastel.debug", 289 290 static_libs: [ 291 "libswiftshadervk_llvm_debug", 292 "libLLVM16_swiftshader_debug", 293 ], 294 295 cflags: [ 296 "-UNDEBUG", 297 "-g", 298 "-O0", 299 "-DDEFAULT_THREAD_COUNT=1", 300 ], 301 302 defaults: [ 303 "libvk_swiftshader_common_defaults", 304 "libvk_swiftshader_defaults", 305 ], 306} 307 308filegroup { 309 name: "swiftshader_icd_json_template", 310 srcs: [ 311 "Vulkan/vk_swiftshader_icd.json.tmpl", 312 ], 313} 314