Skip to content

Commit

Permalink
[skia] Fix vulkan feature (#32740)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Jul 27, 2023
1 parent 91bb3e4 commit f204b54
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 11 deletions.
20 changes: 13 additions & 7 deletions ports/skia/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ declare_external_from_git(tint
REF "200492e32b94f042d9942154fb4fa7f93bb8289a"
LICENSE_FILE LICENSE
)
declare_external_from_git(vulkan-headers
URL "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers"
REF "c896e2f920273bfee852da9cca2a356bc1c2031e"
LICENSE_FILE LICENSE.txt
)
declare_external_from_git(vulkan-tools
URL "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools"
REF "d55c7aaf041af331bee8c22fb448a6ff4c797f73"
Expand All @@ -98,6 +93,8 @@ declare_external_from_pkgconfig(libpng)
declare_external_from_pkgconfig(libwebp MODULES libwebpdecoder libwebpdemux libwebpmux libwebp)
declare_external_from_pkgconfig(zlib)

declare_external_from_vcpkg(vulkan_headers PATH third_party/externals/vulkan-headers)

set(known_cpus x86 x64 arm arm64 wasm)
if(NOT VCPKG_TARGET_ARCHITECTURE IN_LIST known_cpus)
message(WARNING "Unknown target cpu '${VCPKG_TARGET_ARCHITECTURE}'.")
Expand Down Expand Up @@ -178,8 +175,17 @@ if("metal" IN_LIST FEATURES)
endif()

if("vulkan" IN_LIST FEATURES)
list(APPEND required_externals
vulkan_headers
vulkan-tools
)
string(APPEND OPTIONS " skia_use_vulkan=true")
file(COPY "${CURRENT_INSTALLED_DIR}/include/vk_mem_alloc.h" DESTINATION "${SOURCE_PATH}/third_party/vulkanmemoryallocator")
file(COPY "${CURRENT_INSTALLED_DIR}/include/vk_mem_alloc.h" DESTINATION "${SOURCE_PATH}/third_party/externals/vulkanmemoryallocator/include")
# Cf. third_party/vulkanmemoryallocator/GrVulkanMemoryAllocator.h:25
vcpkg_replace_string("${SOURCE_PATH}/third_party/externals/vulkanmemoryallocator/include/vk_mem_alloc.h"
"#include <vulkan/vulkan.h>"
"#ifndef VULKAN_H_\n #include <vulkan/vulkan.h>\n#endif"
)
endif()

if("direct3d" IN_LIST FEATURES)
Expand Down Expand Up @@ -214,8 +220,8 @@ They can be installed on Debian based systems via
tint
jinja2
markupsafe
vulkan_headers
## Remove
vulkan-headers
vulkan-tools
abseil-cpp
## REMOVE ^
Expand Down
39 changes: 39 additions & 0 deletions ports/skia/skia-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function(declare_external_from_pkgconfig name)
set(skia_external_pkgconfig_${name} "${ARGN}" PARENT_SCOPE)
endfunction()

# Declare a named external dependencies to be resolved via vcpkg installed tree.
function(declare_external_from_vcpkg name)
set(skia_external_vcpkg_${name} "${ARGN}" PARENT_SCOPE)
endfunction()

# Download and integrate named external dependencies.
# Downlods must be handled before vcpkg in order to support --only-downloads mode.
function(get_externals)
Expand All @@ -32,11 +37,14 @@ function(get_externals)
list(REMOVE_DUPLICATES ARGN)
set(from_git "")
set(from_pkgconfig "")
set(from_vcpkg "")
foreach(name IN LISTS ARGN)
if(DEFINED "skia_external_git_${name}")
list(APPEND from_git "${name}")
elseif(DEFINED "skia_external_pkgconfig_${name}")
list(APPEND from_pkgconfig "${name}")
elseif(DEFINED "skia_external_vcpkg_${name}")
list(APPEND from_vcpkg "${name}")
else()
message(FATAL_ERROR "Unknown external dependency '${name}'")
endif()
Expand All @@ -62,6 +70,9 @@ function(get_externals)
foreach(name IN LISTS from_pkgconfig)
third_party_from_pkgconfig("${name}" ${skia_external_pkgconfig_${name}})
endforeach()
foreach(name IN LISTS from_vcpkg)
third_party_from_vcpkg("${name}" ${skia_external_vcpkg_${name}})
endforeach()
endfunction()

# Setup a third-party dependency from pkg-config data
Expand Down Expand Up @@ -109,6 +120,34 @@ function(third_party_from_pkgconfig gn_group)
configure_file("${CMAKE_CURRENT_LIST_DIR}/third-party.gn.in" "${SOURCE_PATH}/${arg_PATH}/BUILD.gn" @ONLY)
endfunction()

# Setup a third-party dependency from vcpkg installed tree
function(third_party_from_vcpkg gn_group)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "PATH" "")
if(NOT arg_PATH)
set(arg_PATH "third_party/${gn_group}")
endif()
if(arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unparsed arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
set(defines "")
set(include_dirs "${CURRENT_INSTALLED_DIR}/include")
set(libdirs_RELEASE "${CURRENT_INSTALLED_DIR}/lib")
set(libdirs_DEBUG "${CURRENT_INSTALLED_DIR}/lib/debug")
set(ldflags "")
foreach(config IN ITEMS DEBUG RELEASE)
set(lib_dirs "${libdirs_${config}}")
set(GN_OUT_${config} "")
foreach(item IN ITEMS defines include_dirs lib_dirs ldflags)
set("gn_${item}_${config}" "")
if(NOT "${${item}}" STREQUAL "")
list(JOIN ${item} [[", "]] list)
set("gn_${item}_${config}" "\"${list}\"")
endif()
endforeach()
endforeach()
configure_file("${CMAKE_CURRENT_LIST_DIR}/third-party.gn.in" "${SOURCE_PATH}/${arg_PATH}/BUILD.gn" @ONLY)
endfunction()

# Turn a space separated string into a gn list:
# "a b c" -> ["a","b","c"]
function(string_to_gn_list out_var input)
Expand Down
9 changes: 6 additions & 3 deletions ports/skia/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "skia",
"version": "0.36.0",
"port-version": 7,
"port-version": 8,
"description": [
"Skia is an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms.",
"It serves as the graphics engine for Google Chrome and Chrome OS, Android, Mozilla Firefox and Firefox OS, and many other products.",
Expand Down Expand Up @@ -43,7 +43,10 @@
],
"features": {
"dawn": {
"description": "dawn support for skia"
"description": "dawn support for skia",
"dependencies": [
"vulkan-headers"
]
},
"default-features": {
"description": "Default feature configuration",
Expand Down Expand Up @@ -136,7 +139,7 @@
"vulkan": {
"description": "Vulkan support for skia",
"dependencies": [
"vulkan",
"vulkan-headers",
"vulkan-memory-allocator"
]
}
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7590,7 +7590,7 @@
},
"skia": {
"baseline": "0.36.0",
"port-version": 7
"port-version": 8
},
"skyr-url": {
"baseline": "1.13.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/s-/skia.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "59bcc7110298012cf8f0d6e68ec8d04a4cb01e8b",
"version": "0.36.0",
"port-version": 8
},
{
"git-tree": "508710af38e0b50675532741bf899ec4c3f20c3b",
"version": "0.36.0",
Expand Down

0 comments on commit f204b54

Please sign in to comment.