• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2SkOpts is built differently than the rest of our source files. See //src/core/SkOpts.h for
3a bit more background about what SkOpts is for and how it works.
4
5Instead of bubbling all the headers and sources up to the top level where they are compiled in
6one large library, we only bubble up the headers, so the default implementations in those files
7can be built against the minimum version of Skia (which the whole library is compiled with).
8
9We create several libraries that contain a single source file and may need to access any of
10Skia's headers. These libraries are each compiled with a different set of compiler flags
11(e.g. architecture options) and linked into the final library or binary.
12"""
13
14load("@skia_user_config//:copts.bzl", "DEFAULT_COPTS")
15load("//:defines.bzl", "DEFAULT_DEFINES", "DEFAULT_LOCAL_DEFINES")
16load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_cc_deps", "skia_cc_library", "skia_filegroup")
17load("//bazel:flags.bzl", "selects")
18
19package(
20    features = [
21        # While the OPTS_HDRS are already pulled in as textual_headers,
22        # any implicit dependency on the system headers also needs to be textual.
23        "-use_header_modules",
24    ],
25)
26
27licenses(["notice"])
28
29exports_files_legacy()
30
31skia_filegroup(
32    name = "private_hdrs",
33    srcs = [
34        "SkBitmapProcState_opts.h",
35        "SkBlitMask_opts.h",
36        "SkBlitRow_opts.h",
37        "SkChecksum_opts.h",
38        "SkRasterPipeline_opts.h",
39        "SkSwizzler_opts.h",
40        "SkUtils_opts.h",
41        "SkVM_opts.h",
42        "SkXfermode_opts.h",
43    ],
44    visibility = ["//src:__pkg__"],
45)
46
47OPTS_HDRS = [
48    "//src:private_hdrs",
49    "//include:private_hdrs",
50    "//include:public_hdrs",
51]
52
53skia_cc_library(
54    name = "crc32",  # https://developer.arm.com/documentation/dui0801/g/A32-and-T32-Instructions/CRC32
55    srcs = ["SkOpts_crc32.cpp"],
56    copts = DEFAULT_COPTS + ["-march=armv8-a+crc"],
57    local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES,
58    textual_hdrs = OPTS_HDRS,
59    deps = ["@skia_user_config//:user_config"],
60)
61
62skia_cc_library(
63    name = "ssse3",  # https://en.wikipedia.org/wiki/SSSE3
64    srcs = ["SkOpts_ssse3.cpp"],
65    copts = DEFAULT_COPTS + ["-mssse3"],
66    local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES,
67    textual_hdrs = OPTS_HDRS,
68    deps = ["@skia_user_config//:user_config"],
69)
70
71skia_cc_library(
72    name = "sse42",  # https://en.wikipedia.org/wiki/SSE4#SSE4.2
73    srcs = ["SkOpts_sse42.cpp"],
74    copts = DEFAULT_COPTS + ["-msse4.2"],
75    local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES,
76    textual_hdrs = OPTS_HDRS,
77    deps = ["@skia_user_config//:user_config"],
78)
79
80skia_cc_library(
81    name = "avx",  # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions
82    srcs = ["SkOpts_avx.cpp"],
83    copts = DEFAULT_COPTS + ["-mavx"],
84    local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES,
85    textual_hdrs = OPTS_HDRS,
86    deps = ["@skia_user_config//:user_config"],
87)
88
89skia_cc_library(
90    name = "hsw",  # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#Advanced_Vector_Extensions_2
91    srcs = ["SkOpts_hsw.cpp"],
92    copts = DEFAULT_COPTS + ["-march=haswell"],
93    local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES,
94    textual_hdrs = OPTS_HDRS,
95    deps = [
96        "//modules/skcms",  # Needed to implement SkRasterPipeline_opts.h
97        "@skia_user_config//:user_config",
98    ],
99)
100
101skia_cc_library(
102    name = "skx",  # https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#AVX-512
103    srcs = ["SkOpts_skx.cpp"],
104    copts = DEFAULT_COPTS + ["-march=skylake-avx512"],
105    local_defines = DEFAULT_DEFINES + DEFAULT_LOCAL_DEFINES,
106    textual_hdrs = OPTS_HDRS,
107    deps = ["@skia_user_config//:user_config"],
108)
109
110skia_cc_deps(
111    name = "deps",
112    visibility = ["//src:__pkg__"],
113    deps = selects.with_or({
114        ("@platforms//cpu:x86_64", "@platforms//cpu:x86_32"): [
115            ":avx",
116            ":hsw",
117            ":skx",
118            ":sse42",
119            ":ssse3",
120        ],
121        "@platforms//cpu:arm64": [
122            ":crc32",
123        ],
124        # None of these opts work on WASM, so do not even bother compiling them.
125        "//bazel/common_config_settings:cpu_wasm": [],
126        "//conditions:default": [],
127    }),
128)
129