Add support for building with MoltenVK

Bug: skia:
Change-Id: If55785d7fcc6e2c92c961ac390700add874c8d6d
Reviewed-on: https://skia-review.googlesource.com/125601
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Chris Dalton 2018-05-03 09:30:29 -06:00 committed by Skia Commit-Bot
parent 9afad68453
commit 3a67b8e46b
2 changed files with 46 additions and 5 deletions

View File

@ -44,6 +44,7 @@ declare_args() {
skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
skia_vulkan_header = ""
skia_vulkan_sdk = getenv("VULKAN_SDK")
skia_moltenvk_path = ""
skia_qt_path = getenv("QT_PATH")
skia_compile_processors = false
skia_generate_workarounds = false
@ -69,7 +70,7 @@ declare_args() {
} else if (is_fuchsia) {
skia_use_vulkan = fuchsia_use_vulkan
} else {
skia_use_vulkan = skia_vulkan_sdk != ""
skia_use_vulkan = skia_vulkan_sdk != "" || skia_moltenvk_path != ""
}
if (is_ios) {
@ -223,6 +224,32 @@ config("skia_library") {
defines = [ "SKIA_IMPLEMENTATION=1" ]
}
config("moltenvk") {
if (is_ios) {
moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/iOS"
} else {
moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/macOS"
}
cflags = [
"-F$moltenvk_framework_path",
"-isystem$skia_moltenvk_path/MoltenVK/include", # for <vulkan/vulkan.h>
]
ldflags = [ "-F$moltenvk_framework_path" ]
libs = [
"MoltenVK.framework",
"Metal.framework",
"IOSurface.framework",
"QuartzCore.framework",
"Foundation.framework",
]
if (is_ios) {
libs += [ "UIKit.framework" ]
} else {
libs += [ "IOKit.framework" ]
}
defines = [ "SK_MOLTENVK" ]
}
skia_library_configs = [
":skia_public",
":skia_private",
@ -350,6 +377,9 @@ template("optional") {
if (defined(invoker.public_defines)) {
defines = invoker.public_defines
}
if (defined(invoker.public_configs)) {
configs = invoker.public_configs
}
}
source_set(target_name) {
forward_variables_from(invoker,
@ -591,6 +621,7 @@ optional("gpu") {
deps += [ ":workaround_list" ]
}
public_defines = []
public_configs = []
sources = skia_gpu_sources + skia_sksl_sources + skia_gpu_processor_outputs
@ -633,10 +664,13 @@ optional("gpu") {
}
if (skia_vulkan_header != "") {
public_defines += [ "SK_VULKAN_HEADER=\"$skia_vulkan_header\"" ]
} else {
if (is_skia_dev_build) {
public_defines += [ "SK_VULKAN_HEADER=\"GrVulkanDefines.h\"" ]
}
} else if (skia_moltenvk_path != "") {
public_defines += [ "SK_VULKAN_HEADER=<MoltenVK/mvk_vulkan.h>" ]
} else if (is_skia_dev_build) {
public_defines += [ "SK_VULKAN_HEADER=\"GrVulkanDefines.h\"" ]
}
if (skia_moltenvk_path != "") {
public_configs += [ ":moltenvk" ]
}
}
if (skia_use_legacy_gpu_pixel_ops) {

View File

@ -15,6 +15,12 @@ namespace sk_gpu_test {
bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc,
PFN_vkGetDeviceProcAddr* devProc) {
#ifdef SK_MOLTENVK
// MoltenVK is a statically linked framework, so there is no Vulkan library to load.
*instProc = &vkGetInstanceProcAddr;
*devProc = &vkGetDeviceProcAddr;
return true;
#else
static void* vkLib = nullptr;
static PFN_vkGetInstanceProcAddr localInstProc = nullptr;
static PFN_vkGetDeviceProcAddr localDevProc = nullptr;
@ -38,6 +44,7 @@ bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc,
*instProc = localInstProc;
*devProc = localDevProc;
return true;
#endif
}
}