| """ | |
| SkOpts is built differently than the rest of our source files. See //src/core/SkOpts.h for | |
| a bit more background about what SkOpts is for and how it works. | |
| Instead of bubbling all the headers and sources up to the top level where they are compiled in | |
| one large library, we only bubble up the headers, so the default implementations in those files | |
| can be built against the minimum version of Skia (which the whole library is compiled with). | |
| We create several libraries that contain a single source file and may need to access any of | |
| Skia's headers. These libraries are each compiled with a different set of compiler flags | |
| (e.g. architecture options) and linked into the final library or binary. | |
| """ | |
| load("//:defines.bzl", "DEFAULT_DEFINES", "DEFAULT_LOCAL_DEFINES") | |
| load("//bazel:copts.bzl", "DEFAULT_COPTS") | |
| load("//bazel:macros.bzl", "exports_files_legacy", "selects", "skia_cc_deps", "skia_cc_library", "skia_filegroup") | |
| package( | |
| features = [ | |
| # While the OPTS_HDRS are already pulled in as textual_headers, | |
| # any implicit dependency on the system headers also needs to be textual. | |
| "-use_header_modules", | |
| ], | |
| ) | |
| licenses(["notice"]) | |
| exports_files_legacy() | |
| skia_filegroup( | |
| name = "private_hdrs", | |
| srcs = [ | |
| "SkBitmapProcState_opts.h", | |
| "SkBlitMask_opts.h", | |
| "SkBlitRow_opts.h", | |
| "SkChecksum_opts.h", | |
| "SkRasterPipeline_opts.h", | |
| "SkSwizzler_opts.h", | |
| "SkUtils_opts.h", | |
| "SkVM_opts.h", | |
| "SkXfermode_opts.h", | |
| ], | |
| visibility = ["//src:__pkg__"], | |
| ) | |
| OPTS_HDRS = [ | |
| "//src:private_hdrs", | |
| "//include:private_hdrs", | |
| "//include:public_hdrs", | |
| ] | |
| skia_cc_library( | |
| name = "crc32", # https://developer.arm.com/documentation/dui0801/g/A32-and-T32-Instructions/CRC32 | |
| srcs = ["SkOpts_crc32.cpp"], | |
| copts = DEFAULT_COPTS + ["-march=armv8-a+crc"], | |
| local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES, | |
| textual_hdrs = OPTS_HDRS, | |
| ) | |
| skia_cc_library( | |
| name = "ssse3", # https://en.wikipedia.org/wiki/SSSE3 | |
| srcs = ["SkOpts_ssse3.cpp"], | |
| copts = DEFAULT_COPTS + ["-mssse3"], | |
| local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES, | |
| textual_hdrs = OPTS_HDRS, | |
| ) | |
| skia_cc_library( | |
| name = "sse42", # https://en.wikipedia.org/wiki/SSE4#SSE4.2 | |
| srcs = ["SkOpts_sse42.cpp"], | |
| copts = DEFAULT_COPTS + ["-msse4.2"], | |
| local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES, | |
| textual_hdrs = OPTS_HDRS, | |
| ) | |
| skia_cc_library( | |
| name = "avx", # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions | |
| srcs = ["SkOpts_avx.cpp"], | |
| copts = DEFAULT_COPTS + ["-mavx"], | |
| local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES, | |
| textual_hdrs = OPTS_HDRS, | |
| ) | |
| skia_cc_library( | |
| name = "hsw", # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#Advanced_Vector_Extensions_2 | |
| srcs = ["SkOpts_hsw.cpp"], | |
| copts = DEFAULT_COPTS + ["-march=haswell"], | |
| local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES, | |
| textual_hdrs = OPTS_HDRS, | |
| deps = [ | |
| "//modules/skcms", # Needed to implement SkRasterPipeline_opts.h | |
| ], | |
| ) | |
| skia_cc_library( | |
| name = "skx", # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#AVX-512 | |
| srcs = ["SkOpts_skx.cpp"], | |
| copts = DEFAULT_COPTS + ["-march=skylake-avx512"], | |
| local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES, | |
| textual_hdrs = OPTS_HDRS, | |
| ) | |
| skia_cc_deps( | |
| name = "deps", | |
| visibility = ["//src:__pkg__"], | |
| deps = selects.with_or({ | |
| ("@platforms//cpu:x86_64", "@platforms//cpu:x86_32"): [ | |
| ":avx", | |
| ":hsw", | |
| ":skx", | |
| ":sse42", | |
| ":ssse3", | |
| ], | |
| "@platforms//cpu:arm64": [ | |
| ":crc32", | |
| ], | |
| # None of these opts work on WASM, so do not even bother compiling them. | |
| "//bazel/common_config_settings:cpu_wasm": [], | |
| "//conditions:default": [], | |
| }), | |
| ) |