Skip to content

Commit 50e42f9

Browse files
Ben WagnerSkCQ
Ben Wagner
authored and
SkCQ
committed
Use implementation_deps to hide vulkan headers
Skia has its own set of vulkan headers which it compiles against internally, but the user may specify a different set of vulkan headers when compiling against Skia. Ensure that the internal vulkan headers do not leak by using implementation_deps. Pre-Fix: https://chromium-review.googlesource.com/c/chromium/src/+/5854646 Pre-Fix: https://chromium-review.googlesource.com/c/chromium/src/+/5854994 Pre-Fix: flutter/engine#55126 Pre-Fix: flutter/engine#55143 Change-Id: Ic11c0920c20e4aeb537c607ec5879a93144276a5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/898139 Reviewed-by: Kaylee Lubick <[email protected]> Commit-Queue: Ben Wagner <[email protected]>
1 parent 266c3c5 commit 50e42f9

File tree

9 files changed

+30
-9
lines changed

9 files changed

+30
-9
lines changed

BUILD.gn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ group("compile_all_sksl_tests") {
855855
optional("gpu_shared") {
856856
enabled = skia_enable_ganesh || skia_enable_graphite
857857

858+
configs = []
858859
deps = []
859860
libs = []
860861
public_defines = []
@@ -901,6 +902,7 @@ optional("gpu_shared") {
901902
if (skia_use_vulkan) {
902903
public_defines += [ "SK_VULKAN" ]
903904
sources += skia_shared_vk_sources
905+
configs += [ ":our_vulkan_headers" ]
904906
if (skia_enable_vulkan_debug_layers) {
905907
public_defines += [ "SK_ENABLE_VK_LAYERS" ]
906908
}
@@ -930,6 +932,7 @@ optional("gpu") {
930932
if (skia_generate_workarounds) {
931933
deps += [ ":workaround_list" ]
932934
}
935+
configs = []
933936
public_defines = []
934937
public_configs = []
935938
public_deps = []
@@ -1003,6 +1006,7 @@ optional("gpu") {
10031006
if (skia_use_vulkan) {
10041007
public += skia_gpu_vk_public
10051008
sources += skia_gpu_vk_private
1009+
configs += [ ":our_vulkan_headers" ]
10061010
if (is_fuchsia) {
10071011
if (using_fuchsia_sdk) {
10081012
public_deps += [ "$fuchsia_sdk_root/pkg:vulkan" ]
@@ -1147,6 +1151,7 @@ optional("ndk_images") {
11471151
}
11481152

11491153
optional("graphite") {
1154+
configs = []
11501155
libs = []
11511156
frameworks = []
11521157
public_defines = []
@@ -1188,6 +1193,7 @@ optional("graphite") {
11881193
if (skia_use_vulkan) {
11891194
public += skia_graphite_vk_public
11901195
sources += skia_graphite_vk_sources
1196+
configs += [ ":our_vulkan_headers" ]
11911197
}
11921198
if (skia_enable_precompile) {
11931199
public += skia_graphite_precompile_public
@@ -1707,6 +1713,7 @@ group("modules") {
17071713

17081714
config("our_vulkan_headers") {
17091715
include_dirs = [ "include/third_party/vulkan" ]
1716+
defines = [ "SK_USE_INTERNAL_VULKAN_HEADERS" ]
17101717
}
17111718

17121719
config("vulkan_memory_allocator") {

bazel/external/vulkan_headers/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ cc_library(
1919
hdrs = [
2020
"include/vulkan/vk_platform.h",
2121
"include/vulkan/vulkan.h",
22+
"include/vulkan/vulkan_android.h",
2223
"include/vulkan/vulkan_core.h",
24+
"include/vulkan/vulkan_xcb.h",
2325
],
2426
includes = ["include"],
2527
visibility = ["//visibility:public"],

example/external_client/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ cc_binary(
237237
deps = [
238238
"@skia//:core",
239239
"@skia//:graphite_native_vulkan",
240+
"@vulkan_headers",
240241
],
241242
)
242243

include/private/gpu/vk/SkiaVulkan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// IWYU pragma: begin_exports
1414

15-
#if (SKIA_IMPLEMENTATION || !defined(SK_VULKAN)) && !defined(SK_USE_EXTERNAL_VULKAN_HEADERS)
15+
#if defined(SK_USE_INTERNAL_VULKAN_HEADERS) && !defined(SK_BUILD_FOR_GOOGLE3)
1616
#include "include/third_party/vulkan/vulkan/vulkan_core.h"
1717
#else
1818
// For google3 builds we don't set SKIA_IMPLEMENTATION so we need to make sure that the vulkan
@@ -22,7 +22,7 @@
2222

2323
#ifdef SK_BUILD_FOR_ANDROID
2424
// This is needed to get android extensions for external memory
25-
#if (SKIA_IMPLEMENTATION || !defined(SK_VULKAN)) && !defined(SK_USE_EXTERNAL_VULKAN_HEADERS)
25+
#if defined(SK_USE_INTERNAL_VULKAN_HEADERS) && !defined(SK_BUILD_FOR_GOOGLE3)
2626
#include "include/third_party/vulkan/vulkan/vulkan_android.h"
2727
#else
2828
// For google3 builds we don't set SKIA_IMPLEMENTATION so we need to make sure that the vulkan

src/gpu/ganesh/vk/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ skia_cc_library(
145145
features = ["layering_check"],
146146
local_defines = [
147147
"GPU_TEST_UTILS",
148-
"SK_USE_EXTERNAL_VULKAN_HEADERS",
149148
],
150149
visibility = ["//tools:__subpackages__"],
151150
deps = [

src/gpu/graphite/vk/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ skia_cc_library(
6363
"//include/gpu/graphite/vk:public_hdrs",
6464
],
6565
defines = ["SK_VULKAN"],
66+
implementation_deps = [
67+
"//include/third_party/vulkan",
68+
],
69+
local_defines = ["SK_USE_INTERNAL_VULKAN_HEADERS"],
6670
visibility = ["//:__pkg__"],
6771
deps = [
6872
"//:core",
@@ -90,6 +94,10 @@ skia_cc_library(
9094
"SK_VULKAN",
9195
"GPU_TEST_UTILS",
9296
],
97+
implementation_deps = [
98+
"//include/third_party/vulkan",
99+
],
100+
local_defines = ["SK_USE_INTERNAL_VULKAN_HEADERS"],
93101
visibility = ["//tools:__pkg__"],
94102
deps = [
95103
"//:core",

src/gpu/vk/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ skia_cc_library(
4040
":_vk_hdrs",
4141
"//include/gpu/vk:shared_public_hdrs",
4242
],
43-
defines = [
44-
"SK_USE_EXTERNAL_VULKAN_HEADERS",
45-
],
4643
features = ["layering_check"],
44+
implementation_deps = [
45+
"//include/third_party/vulkan",
46+
],
47+
local_defines = ["SK_USE_INTERNAL_VULKAN_HEADERS"],
4748
visibility = [
4849
"//src/gpu/ganesh/vk:__pkg__",
4950
"//src/gpu/graphite/vk:__pkg__",
5051
"//src/gpu/vk/vulkanmemoryallocator:__pkg__",
5152
],
5253
deps = [
5354
"//:core",
54-
"//include/third_party/vulkan",
5555
"//src/base",
5656
"//src/gpu",
5757
"//src/sksl/codegen:spirv",

src/gpu/vk/vulkanmemoryallocator/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ skia_cc_library(
3535
# https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/issues/299
3636
"-Wno-implicit-fallthrough",
3737
],
38+
implementation_deps = [
39+
"//include/third_party/vulkan",
40+
],
41+
local_defines = ["SK_USE_INTERNAL_VULKAN_HEADERS"],
3842
textual_hdrs = [
3943
"VulkanMemoryAllocatorWrapper.h",
4044
],
@@ -46,7 +50,6 @@ skia_cc_library(
4650
],
4751
deps = [
4852
"//:core",
49-
"//include/third_party/vulkan",
5053
"//src/base",
5154
"//src/gpu/vk",
5255
"@vulkanmemoryallocator//:hdrs",

src/gpu/vk/vulkanmemoryallocator/BUILD.gn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ source_set("vulkanmemoryallocator") {
1919
"../../../../include/third_party/vulkan",
2020
"../../../../",
2121
]
22+
defines = [ "SK_USE_INTERNAL_VULKAN_HEADERS" ]
2223

2324
if (skia_disable_vma_stl_shared_mutex) {
24-
defines = [ "VMA_USE_STL_SHARED_MUTEX=0" ]
25+
defines += [ "VMA_USE_STL_SHARED_MUTEX=0" ]
2526
}
2627

2728
sources = [

0 commit comments

Comments
 (0)