14abec45f0
sk_app has existing support for Dawn on top of Vulkan, and this adds support to build //example:hello_world_dawn and get this to run on Linux. Dawn depends on Tint and abseil-cpp. Tint further depends on spirv_tools and spirv_headers (for writing to the SPIR-V format). Dawn and Tint only have GN and CMake support, so we need to make our Bazel rules for them (see //third_party/BUILD.bazel). abseil-cpp and the SPIR-V libraries have Bazel support, so we can just include them (see //WORKSPACE.bazel). It is important that @spirv_headers be called that exactly because @spirv_tools depends on it by that name. The hand-crafted cc_library rules for Dawn and Tint were produced by reading the appropriate GN files and using the parts necessary for a supporting Vulkan+Linux. If we use Dawn for other backends (e.g. WebGPU), we will need to expand the Bazel rules. One day, we might contribute the Bazel rules to Dawn and Tint so they can support them and avoid breaking us if new files are added. Suggested Review Order - bazel/common_config_settings/BUILD.bazel to see introduction of new select-able option "has_gpu_backend" which cleans up some of our code that is enabled for any GPU backend. - src/*/BUILD.bazel to see has_gpu_backend rolled out. - WORKSPACE.bazel to see DEPS declared there (using the files in third_party/externals, which are brought in via tools/git-sync-deps). - third_party/BUILD.bazel which adds Dawn and Tint rules. It may be helpful to look in third_party/externals for the Dawn [1] and Tint [2] GN files. Especially interesting are the Python scripts [3] Dawn uses to generate some header and source files. - All other files. [1] https://dawn.googlesource.com/dawn/+/d9f22ce0346b222759d5510be3d1cd93caa5ab86/src/dawn/native/BUILD.gn#183 [2] https://dawn.googlesource.com/tint/+/453d5ae84ec30ab51ac592c13d472412ae8b5fc9/src/tint/BUILD.gn#174 [3] https://dawn.googlesource.com/dawn/+/d9f22ce0346b222759d5510be3d1cd93caa5ab86/generator/dawn_json_generator.py#774 Change-Id: Ied5b162045d8e841b9666457f0158457e2b078d4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/516996 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
127 lines
3.4 KiB
Python
127 lines
3.4 KiB
Python
load("//bazel:macros.bzl", "generated_cc_atom")
|
|
load("//bazel:cc_binary_with_flags.bzl", "cc_binary_with_flags")
|
|
|
|
cc_binary_with_flags(
|
|
name = "hello_world_gl",
|
|
srcs = [
|
|
"//example:HelloWorld_src",
|
|
],
|
|
linkopts = [
|
|
"-lX11",
|
|
"-lxcb",
|
|
"-lXau",
|
|
"-lXdmcp",
|
|
"-lGL",
|
|
],
|
|
# These flags are defined in //bazel/common_config_settings/BUILD.bazel
|
|
set_flags = {
|
|
# Use the GL backend with the normal GL standard (as opposed to WebGL or GLES)
|
|
"gpu_backend": [
|
|
"gl_backend",
|
|
],
|
|
"with_gl_standard": [
|
|
"gl_standard",
|
|
],
|
|
# Load fonts from the standard system directory (e.g. "/usr/share/fonts/")
|
|
# as defined in //src/ports/SkFontMgr_custom_directory_factory.cpp
|
|
"fontmgr_factory": [
|
|
"custom_directory_fontmgr_factory",
|
|
],
|
|
},
|
|
deps = [
|
|
"//:skia_core",
|
|
"//src/utils:json_srcs",
|
|
"//tools/sk_app",
|
|
],
|
|
)
|
|
|
|
cc_binary_with_flags(
|
|
name = "hello_world_vulkan",
|
|
srcs = [
|
|
"//example:HelloWorld_src",
|
|
],
|
|
linkopts = [
|
|
"-lX11",
|
|
"-lxcb",
|
|
"-lXau",
|
|
"-lXdmcp",
|
|
"-lX11-xcb",
|
|
],
|
|
# These flags are defined in //bazel/common_config_settings/BUILD.bazel
|
|
set_flags = {
|
|
"gpu_backend": [
|
|
"vulkan_backend",
|
|
],
|
|
# Load fonts from the standard system directory (e.g. "/usr/share/fonts/")
|
|
# as defined in //src/ports/SkFontMgr_custom_directory_factory.cpp
|
|
"fontmgr_factory": [
|
|
"custom_directory_fontmgr_factory",
|
|
],
|
|
},
|
|
deps = [
|
|
"//:skia_core",
|
|
"//src/utils:json_srcs",
|
|
"//third_party:vulkanmemoryallocator",
|
|
"//tools/sk_app",
|
|
],
|
|
)
|
|
|
|
cc_binary_with_flags(
|
|
name = "hello_world_dawn",
|
|
srcs = [
|
|
"//example:HelloWorld_src",
|
|
],
|
|
linkopts = [
|
|
"-lX11",
|
|
"-lxcb",
|
|
"-lXau",
|
|
"-lXdmcp",
|
|
"-lX11-xcb",
|
|
],
|
|
# These flags are defined in //bazel/common_config_settings/BUILD.bazel
|
|
set_flags = {
|
|
"gpu_backend": [
|
|
"dawn_backend",
|
|
],
|
|
# Load fonts from the standard system directory (e.g. "/usr/share/fonts/")
|
|
# as defined in //src/ports/SkFontMgr_custom_directory_factory.cpp
|
|
"fontmgr_factory": [
|
|
"custom_directory_fontmgr_factory",
|
|
],
|
|
},
|
|
deps = [
|
|
"//:skia_core",
|
|
"//src/utils:json_srcs",
|
|
"//tools/sk_app",
|
|
],
|
|
)
|
|
|
|
# Everything below this line is autogenerated by gazelle using the C++ plugin built here:
|
|
# https://github.com/google/skia-buildbot/tree/main/bazel/gazelle/cpp
|
|
# These can be regenerated (if needed) by navigating to //bazel and running `make generate`
|
|
# =========================================================================================
|
|
|
|
generated_cc_atom(
|
|
name = "HelloWorld_hdr",
|
|
hdrs = ["HelloWorld.h"],
|
|
visibility = ["//:__subpackages__"],
|
|
deps = [
|
|
"//tools/sk_app:Application_hdr",
|
|
"//tools/sk_app:Window_hdr",
|
|
],
|
|
)
|
|
|
|
generated_cc_atom(
|
|
name = "HelloWorld_src",
|
|
srcs = ["HelloWorld.cpp"],
|
|
visibility = ["//:__subpackages__"],
|
|
deps = [
|
|
":HelloWorld_hdr",
|
|
"//include/core:SkCanvas_hdr",
|
|
"//include/core:SkFont_hdr",
|
|
"//include/core:SkGraphics_hdr",
|
|
"//include/core:SkSurface_hdr",
|
|
"//include/effects:SkGradientShader_hdr",
|
|
],
|
|
)
|