mirror of https://github.com/microsoft/vcpkg.git
[dawn] New port (#47027)
Co-authored-by: ayeteadoe <ayeteadoe@gmail.com>
This commit is contained in:
parent
c78ed12e24
commit
2e6fcc4457
|
|
@ -0,0 +1,19 @@
|
|||
diff --git a/emdawnwebgpu.port.py b/emdawnwebgpu.port.py
|
||||
index 4b90064..1956d0b 100644
|
||||
--- a/emdawnwebgpu.port.py
|
||||
+++ b/emdawnwebgpu.port.py
|
||||
@@ -70,10 +70,10 @@ def _walk(path):
|
||||
yield os.path.join(dirpath, filename)
|
||||
|
||||
|
||||
-_pkg_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
-_c_include_dir = os.path.join(_pkg_dir, 'webgpu', 'include')
|
||||
-_cpp_include_dir = os.path.join(_pkg_dir, 'webgpu_cpp', 'include')
|
||||
-_src_dir = os.path.join(_pkg_dir, 'webgpu', 'src')
|
||||
+_pkg_dir = os.path.dirname(os.path.realpath(os.path.join(__file__, '..', '..')))
|
||||
+_c_include_dir = os.path.join(_pkg_dir, 'include')
|
||||
+_cpp_include_dir = os.path.join(_pkg_dir, 'include')
|
||||
+_src_dir = os.path.join(_pkg_dir, 'share', 'dawn', 'src')
|
||||
_srcs = [
|
||||
os.path.join(_src_dir, 'webgpu.cpp'),
|
||||
]
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
diff --git a/src/cmake/DawnLibrary.cmake b/src/cmake/DawnLibrary.cmake
|
||||
index a5352433f0..d8aa1788d2 100644
|
||||
--- a/src/cmake/DawnLibrary.cmake
|
||||
+++ b/src/cmake/DawnLibrary.cmake
|
||||
@@ -180,12 +180,12 @@ function(dawn_install_target name)
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
# When building in debug mode with MSVC, install PDB files together with binaries
|
||||
- if (MSVC)
|
||||
- get_target_property(target_type "${name}" TYPE)
|
||||
- if ((target_type STREQUAL "STATIC_LIBRARY") OR (target_type STREQUAL "SHARED_LIBRARY") OR (target_type STREQUAL "EXECUTABLE"))
|
||||
- install(FILES $<TARGET_PDB_FILE:${name}> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
||||
- endif()
|
||||
- endif (MSVC)
|
||||
+ # if (MSVC)
|
||||
+ # get_target_property(target_type "${name}" TYPE)
|
||||
+ # if ((target_type STREQUAL "STATIC_LIBRARY") OR (target_type STREQUAL "SHARED_LIBRARY") OR (target_type STREQUAL "EXECUTABLE"))
|
||||
+ # install(FILES $<TARGET_PDB_FILE:${name}> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
||||
+ # endif()
|
||||
+ # endif (MSVC)
|
||||
|
||||
# Automatically determine where each header should go based on its subdirectory in the include dir.
|
||||
foreach(header IN LISTS arg_HEADERS)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
diff --git a/src/dawn/native/d3d/PlatformFunctions.cpp b/src/dawn/native/d3d/PlatformFunctions.cpp
|
||||
index 12d65e0db5..d3abb05fb5 100644
|
||||
--- a/src/dawn/native/d3d/PlatformFunctions.cpp
|
||||
+++ b/src/dawn/native/d3d/PlatformFunctions.cpp
|
||||
@@ -121,10 +121,14 @@ MaybeError PlatformFunctions::EnsureFXC(std::span<const std::string> searchPaths
|
||||
}
|
||||
|
||||
void PlatformFunctions::InitWindowsVersion() {
|
||||
+#if DAWN_PLATFORM_IS(WINUWP)
|
||||
+ return;
|
||||
+#else
|
||||
// Currently we only care about the build number of Windows 10 and Windows 11.
|
||||
if (!IsWindows10OrGreater()) {
|
||||
return;
|
||||
}
|
||||
+#endif
|
||||
|
||||
// Referenced from base/win/windows_version.cc in Chromium
|
||||
constexpr wchar_t kRegKeyWindowsNTCurrentVersion[] =
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 5826595d6f..9521fcf6a7 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -214,6 +214,12 @@ else()
|
||||
set(TINT_DEFAULT_GLSL OFF)
|
||||
endif()
|
||||
|
||||
+if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12)
|
||||
+ set(TINT_DEFAULT_HLSL ON)
|
||||
+else()
|
||||
+ set(TINT_DEFAULT_HLSL OFF)
|
||||
+endif()
|
||||
+
|
||||
option(TINT_ENABLE_INSTALL "Enable install step for Tint libraries" OFF)
|
||||
option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" ON)
|
||||
|
||||
@@ -227,7 +233,7 @@ option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKA
|
||||
option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
|
||||
option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL})
|
||||
option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" ON)
|
||||
-option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12})
|
||||
+option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${TINT_DEFAULT_HLSL})
|
||||
option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL})
|
||||
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN})
|
||||
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 9521fcf6a7..9c38142ec2 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -460,6 +460,11 @@ set(TINT_SPIRV_TOOLS_DIR ${DAWN_SPIRV_TOOLS_DIR})
|
||||
################################################################################
|
||||
# Run on all subdirectories
|
||||
################################################################################
|
||||
+find_package(absl CONFIG REQUIRED)
|
||||
+if (DAWN_ENABLE_VULKAN)
|
||||
+ find_package(VulkanHeaders CONFIG REQUIRED)
|
||||
+ find_package(VulkanUtilityLibraries CONFIG REQUIRED)
|
||||
+endif()
|
||||
add_subdirectory(third_party)
|
||||
|
||||
# TODO(crbug.com/tint/455): Tint does not currently build with CMake when
|
||||
diff --git a/src/cmake/BundleLibraries.cmake b/src/cmake/BundleLibraries.cmake
|
||||
index 682a73924c..1ec358c54c 100644
|
||||
--- a/src/cmake/BundleLibraries.cmake
|
||||
+++ b/src/cmake/BundleLibraries.cmake
|
||||
@@ -92,7 +92,18 @@ function(bundle_libraries output_target library_type)
|
||||
|
||||
# Collect $<TARGET_OBJECTS:...> from STATIC and OBJECT library dependencies
|
||||
set(all_objects "")
|
||||
+ set(all_libraries "")
|
||||
+ message(STATUS "all_dependencies: ${all_dependencies}")
|
||||
foreach(dependency IN LISTS all_dependencies)
|
||||
+ if("${dependency}" MATCHES "^absl::")
|
||||
+ list(APPEND all_libraries ${dependency})
|
||||
+ continue()
|
||||
+ endif()
|
||||
+ if("${dependency}" MATCHES "^Vulkan-Headers" OR "${dependency}" MATCHES "^VulkanUtility")
|
||||
+ list(APPEND all_libraries ${dependency})
|
||||
+ continue()
|
||||
+ endif()
|
||||
+
|
||||
get_target_property(type ${dependency} TYPE)
|
||||
|
||||
# We only want object files from static or object libraries.
|
||||
@@ -112,6 +123,7 @@ function(bundle_libraries output_target library_type)
|
||||
# Create the output library using the validated type and collected objects
|
||||
# If all_objects is empty, add_library will still create an empty library of the specified type.
|
||||
add_library(${output_target} ${library_type} ${all_objects})
|
||||
+ target_link_libraries(${output_target} PRIVATE ${all_libraries})
|
||||
|
||||
# Add dependencies to ensure input targets are built before the bundled library.
|
||||
# This handles the build order correctly.
|
||||
diff --git a/src/cmake/DawnConfig.cmake.in b/src/cmake/DawnConfig.cmake.in
|
||||
index 8bfeda55bc..a0f9858530 100644
|
||||
--- a/src/cmake/DawnConfig.cmake.in
|
||||
+++ b/src/cmake/DawnConfig.cmake.in
|
||||
@@ -31,4 +31,9 @@
|
||||
# 2. https://cmake.org/cmake/help/latest/guide/tutorial/Adding%20Export%20Configuration.html
|
||||
|
||||
@PACKAGE_INIT@
|
||||
+
|
||||
+include(CMakeFindDependencyMacro)
|
||||
+
|
||||
+find_dependency(absl CONFIG)
|
||||
+
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/DawnTargets.cmake")
|
||||
diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt
|
||||
index 21ef415451..7f4867fee6 100644
|
||||
--- a/src/dawn/native/CMakeLists.txt
|
||||
+++ b/src/dawn/native/CMakeLists.txt
|
||||
@@ -636,11 +636,17 @@ if ((DAWN_ENABLE_OPENGL OR DAWN_ENABLE_VULKAN) AND DAWN_ENABLE_SPIRV_VALIDATION)
|
||||
endif()
|
||||
|
||||
if (DAWN_ENABLE_OPENGL)
|
||||
+ find_path(OPENGL_REGISTRY_INCLUDE_DIRS "GL/glcorearb.h")
|
||||
+ find_file(
|
||||
+ OPENGL_XML_FILE
|
||||
+ NAMES "opengl/gl.xml"
|
||||
+ PATHS "${OPENGL_REGISTRY_INCLUDE_DIRS}/../share"
|
||||
+ )
|
||||
DawnGenerator(
|
||||
SCRIPT "${Dawn_SOURCE_DIR}/generator/opengl_loader_generator.py"
|
||||
PRINT_NAME "OpenGL function loader"
|
||||
EXTRA_PARAMETERS "--gl-xml"
|
||||
- "${Dawn_SOURCE_DIR}/third_party/khronos/OpenGL-Registry/xml/gl.xml"
|
||||
+ "${OPENGL_XML_FILE}"
|
||||
"--supported-extensions"
|
||||
"${Dawn_SOURCE_DIR}/src/dawn/native/opengl/supported_extensions.json"
|
||||
OUTPUT_HEADERS DAWN_NATIVE_OPENGL_AUTOGEN_HEADERS
|
||||
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
|
||||
index b423c43d27..068a784b3d 100644
|
||||
--- a/third_party/CMakeLists.txt
|
||||
+++ b/third_party/CMakeLists.txt
|
||||
@@ -41,6 +41,7 @@ if (DAWN_FETCH_DEPENDENCIES)
|
||||
)
|
||||
endif ()
|
||||
|
||||
+if(0)
|
||||
set(ABSL_ROOT_DIR ${DAWN_ABSEIL_DIR})
|
||||
if (NOT TARGET absl::strings)
|
||||
# Recommended setting for compatibility with future abseil releases.
|
||||
@@ -62,6 +63,7 @@ if (NOT TARGET absl::strings)
|
||||
|
||||
add_subdirectory(${DAWN_ABSEIL_DIR} "${CMAKE_CURRENT_BINARY_DIR}/abseil")
|
||||
endif()
|
||||
+endif()
|
||||
|
||||
if (DAWN_BUILD_PROTOBUF AND EXISTS "${DAWN_PROTOBUF_DIR}/cmake")
|
||||
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND WIN32)
|
||||
@@ -175,10 +177,12 @@ endif()
|
||||
if (DAWN_ENABLE_DESKTOP_GL OR DAWN_ENABLE_OPENGLES)
|
||||
# Header-only library for khrplatform.h
|
||||
add_library(dawn_khronos_platform INTERFACE)
|
||||
- target_sources(dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos/EGL-Registry/api/KHR/khrplatform.h")
|
||||
- target_include_directories(dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos/EGL-Registry/api")
|
||||
+ find_path(EGL_REGISTRY_INCLUDE_DIRS "EGL/egl.h")
|
||||
+ target_sources(dawn_khronos_platform INTERFACE "${EGL_REGISTRY_INCLUDE_DIRS}/KHR/khrplatform.h")
|
||||
+ target_include_directories(dawn_khronos_platform INTERFACE "${EGL_REGISTRY_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
+if (0)
|
||||
if (NOT TARGET Vulkan::Headers AND DAWN_ENABLE_VULKAN)
|
||||
message(STATUS "Dawn: using Vulkan::Headers at ${DAWN_VULKAN_HEADERS_DIR}")
|
||||
|
||||
@@ -190,6 +194,7 @@ if (NOT TARGET Vulkan::UtilityHeaders AND DAWN_ENABLE_VULKAN)
|
||||
message(STATUS "Dawn: using VulkanUtilityLibraries at ${DAWN_VULKAN_UTILITY_LIBRARIES_DIR}")
|
||||
add_subdirectory(${DAWN_VULKAN_UTILITY_LIBRARIES_DIR} "${CMAKE_CURRENT_BINARY_DIR}/vulkan-utility-libraries/src")
|
||||
endif()
|
||||
+endif()
|
||||
|
||||
if (DAWN_ENABLE_SWIFTSHADER AND NOT TARGET vk_swiftshader)
|
||||
set(SWIFTSHADER_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
if (NOT TARGET dawn::webgpu_dawn)
|
||||
add_library(dawn::webgpu_dawn INTERFACE IMPORTED)
|
||||
set_target_properties(dawn::webgpu_dawn PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "--use-port=${CMAKE_CURRENT_LIST_DIR}/emdawnwebgpu.port.py"
|
||||
INTERFACE_LINK_OPTIONS "--use-port=${CMAKE_CURRENT_LIST_DIR}/emdawnwebgpu.port.py"
|
||||
)
|
||||
endif()
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
if (VCPKG_TARGET_IS_EMSCRIPTEN)
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://github.com/google/dawn/releases/download/v${VERSION}/emdawnwebgpu_pkg-v${VERSION}.zip"
|
||||
FILENAME "emdawnwebgpu_pkg-v${VERSION}.zip"
|
||||
SHA512 a0544b3bf2d81abee91fb43901d384b021005d4158b43fec996977607f08852b211940a3ca71d37ac8bda52821c361bbaa93d0e4e63f72ff186863ef48a6a3d0
|
||||
)
|
||||
vcpkg_extract_source_archive(
|
||||
SOURCE_PATH
|
||||
ARCHIVE ${ARCHIVE}
|
||||
PATCHES
|
||||
000-fix-emdawnwebgpu.patch
|
||||
)
|
||||
set(VCPKG_BUILD_TYPE release)
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/DawnConfig.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
file(INSTALL "${SOURCE_PATH}/webgpu/include" DESTINATION "${CURRENT_PACKAGES_DIR}")
|
||||
file(INSTALL "${SOURCE_PATH}/webgpu_cpp/include" DESTINATION "${CURRENT_PACKAGES_DIR}")
|
||||
file(INSTALL "${SOURCE_PATH}/webgpu/src" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" PATTERN "LICENSE" EXCLUDE)
|
||||
file(INSTALL "${SOURCE_PATH}/emdawnwebgpu.port.py" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
set(DAWN_PKGCONFIG_CFLAGS "--use-port=\${prefix}/share/${PORT}/emdawnwebgpu.port.py")
|
||||
set(DAWN_PKGCONFIG_LIBS "--use-port=\${prefix}/share/${PORT}/emdawnwebgpu.port.py")
|
||||
set(DAWN_PKGCONFIG_REQUIRES "")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial_webgpu_dawn.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/unofficial_webgpu_dawn.pc" @ONLY)
|
||||
vcpkg_fixup_pkgconfig()
|
||||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/webgpu/src/LICENSE" "${SOURCE_PATH}/webgpu_cpp/LICENSE")
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO google/dawn
|
||||
REF "v${VERSION}"
|
||||
SHA512 6962d1526ac88d4e00d236b4ae86bd885d67f493d6b7342117e3b658fa6f37bf6d6b8617af4d74ef0bf9e3e95cf91aed567fb0f90bf836ad132dff4a304525f8
|
||||
HEAD_REF master
|
||||
PATCHES
|
||||
001-fix-windows-build.patch
|
||||
002-fix-uwp.patch
|
||||
003-fix-d3d11.patch
|
||||
004-deps.patch
|
||||
)
|
||||
|
||||
# vcpkg_find_acquire_program(PYTHON3)
|
||||
# vcpkg_execute_in_download_mode(
|
||||
# COMMAND "${PYTHON3}" tools/fetch_dawn_dependencies.py
|
||||
# WORKING_DIRECTORY "${SOURCE_PATH}"
|
||||
# )
|
||||
#
|
||||
# get_dawn_deps_commit() { curl -s "https://dawn.googlesource.com/dawn/+/refs/heads/chromium/7371/$1" | htmlq .gitlink-detail --text; }
|
||||
#
|
||||
|
||||
function(checkout_in_path PATH URL REF)
|
||||
if(EXISTS "${PATH}")
|
||||
file(GLOB_RECURSE subdirectory_children "${CURRENT_PACKAGES_DIR}/include/${directory_child}/*")
|
||||
if(NOT "${subdirectory_children}" STREQUAL "")
|
||||
return()
|
||||
else()
|
||||
file(REMOVE_RECURSE "${PATH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
vcpkg_from_git(
|
||||
OUT_SOURCE_PATH DEP_SOURCE_PATH
|
||||
URL "${URL}"
|
||||
REF "${REF}"
|
||||
)
|
||||
file(RENAME "${DEP_SOURCE_PATH}" "${PATH}")
|
||||
file(REMOVE_RECURSE "${DEP_SOURCE_PATH}")
|
||||
endfunction()
|
||||
|
||||
checkout_in_path(
|
||||
"${SOURCE_PATH}/third_party/jinja2"
|
||||
"https://chromium.googlesource.com/chromium/src/third_party/jinja2"
|
||||
"e2d024354e11cc6b041b0cff032d73f0c7e43a07"
|
||||
)
|
||||
|
||||
checkout_in_path(
|
||||
"${SOURCE_PATH}/third_party/markupsafe"
|
||||
"https://chromium.googlesource.com/chromium/src/third_party/markupsafe"
|
||||
"0bad08bb207bbfc1d6f3bbc82b9242b0c50e5794"
|
||||
)
|
||||
|
||||
checkout_in_path(
|
||||
"${SOURCE_PATH}/third_party/spirv-headers/src"
|
||||
"https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers"
|
||||
"a8637796c28386c3cf3b4e8107020fbb52c46f3f"
|
||||
)
|
||||
|
||||
checkout_in_path(
|
||||
"${SOURCE_PATH}/third_party/spirv-tools/src"
|
||||
"https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools"
|
||||
"f386417185be0601894b20d9ad000aceb73d898b"
|
||||
)
|
||||
|
||||
vcpkg_find_acquire_program(PYTHON3)
|
||||
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
set(DAWN_BUILD_MONOLITHIC_LIBRARY "STATIC")
|
||||
else()
|
||||
set(DAWN_BUILD_MONOLITHIC_LIBRARY "SHARED")
|
||||
endif()
|
||||
|
||||
# DAWN_BUILD_MONOLITHIC_LIBRARY SHARED/STATIC requires BUILD_SHARED_LIBS=OFF
|
||||
set(VCPKG_LIBRARY_LINKAGE_BACKUP ${VCPKG_LIBRARY_LINKAGE})
|
||||
set(VCPKG_LIBRARY_LINKAGE static)
|
||||
|
||||
set(DAWN_ENABLE_NULL ON)
|
||||
set(DAWN_ENABLE_D3D11 OFF)
|
||||
if("d3d11" IN_LIST FEATURES)
|
||||
set(DAWN_ENABLE_D3D11 ON)
|
||||
endif()
|
||||
set(DAWN_ENABLE_D3D12 OFF)
|
||||
if("d3d12" IN_LIST FEATURES)
|
||||
set(DAWN_ENABLE_D3D12 ON)
|
||||
endif()
|
||||
set(DAWN_ENABLE_DESKTOP_GL OFF)
|
||||
if("gl" IN_LIST FEATURES)
|
||||
set(DAWN_ENABLE_DESKTOP_GL ON)
|
||||
endif()
|
||||
set(DAWN_ENABLE_OPENGLES OFF)
|
||||
if("gles" IN_LIST FEATURES)
|
||||
set(DAWN_ENABLE_OPENGLES ON)
|
||||
endif()
|
||||
set(DAWN_ENABLE_METAL OFF)
|
||||
if("metal" IN_LIST FEATURES)
|
||||
set(DAWN_ENABLE_METAL ON)
|
||||
endif()
|
||||
set(DAWN_ENABLE_VULKAN OFF)
|
||||
if("vulkan" IN_LIST FEATURES)
|
||||
set(DAWN_ENABLE_VULKAN ON)
|
||||
endif()
|
||||
set(DAWN_USE_WAYLAND OFF)
|
||||
if("wayland" IN_LIST FEATURES)
|
||||
set(DAWN_USE_WAYLAND ON)
|
||||
endif()
|
||||
set(DAWN_USE_X11 OFF)
|
||||
if("x11" IN_LIST FEATURES)
|
||||
set(DAWN_USE_X11 ON)
|
||||
endif()
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
OPTIONS
|
||||
-DPython3_EXECUTABLE="${PYTHON3}"
|
||||
-DDAWN_BUILD_MONOLITHIC_LIBRARY=${DAWN_BUILD_MONOLITHIC_LIBRARY}
|
||||
-DDAWN_ENABLE_INSTALL=ON
|
||||
-DDAWN_USE_GLFW=OFF
|
||||
-DDAWN_BUILD_PROTOBUF=OFF
|
||||
-DDAWN_BUILD_SAMPLES=OFF
|
||||
-DDAWN_BUILD_TESTS=OFF
|
||||
-DTINT_BUILD_TESTS=OFF
|
||||
-DTINT_ENABLE_INSTALL=OFF
|
||||
-DTINT_BUILD_CMD_TOOLS=OFF
|
||||
-DDAWN_ENABLE_NULL=${DAWN_ENABLE_NULL}
|
||||
-DDAWN_ENABLE_D3D11=${DAWN_ENABLE_D3D11}
|
||||
-DDAWN_ENABLE_D3D12=${DAWN_ENABLE_D3D12}
|
||||
-DDAWN_ENABLE_DESKTOP_GL=${DAWN_ENABLE_DESKTOP_GL}
|
||||
-DDAWN_ENABLE_OPENGLES=${DAWN_ENABLE_OPENGLES}
|
||||
-DDAWN_ENABLE_METAL=${DAWN_ENABLE_METAL}
|
||||
-DDAWN_ENABLE_VULKAN=${DAWN_ENABLE_VULKAN}
|
||||
-DDAWN_USE_WAYLAND=${DAWN_USE_WAYLAND}
|
||||
-DDAWN_USE_X11=${DAWN_USE_X11}
|
||||
)
|
||||
|
||||
vcpkg_cmake_install()
|
||||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/Dawn)
|
||||
|
||||
list(APPEND DAWN_ABSL_REQUIRES
|
||||
absl_flat_hash_set
|
||||
absl_flat_hash_map
|
||||
absl_inlined_vector
|
||||
absl_no_destructor
|
||||
absl_overload
|
||||
absl_str_format_internal
|
||||
absl_strings
|
||||
absl_span
|
||||
absl_string_view
|
||||
)
|
||||
list(JOIN DAWN_ABSL_REQUIRES ", " DAWN_ABSL_REQUIRES)
|
||||
|
||||
set(DAWN_PKGCONFIG_CFLAGS "")
|
||||
set(DAWN_PKGCONFIG_REQUIRES "${DAWN_ABSL_REQUIRES}")
|
||||
set(DAWN_PKGCONFIG_LIBS "-lwebgpu_dawn")
|
||||
|
||||
if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW AND NOT VCPKG_TARGET_IS_UWP)
|
||||
set(DAWN_PKGCONFIG_LIBS "${DAWN_PKGCONFIG_LIBS} -lonecore -luser32 -ldelayimp")
|
||||
endif()
|
||||
if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12)
|
||||
set(DAWN_PKGCONFIG_LIBS "${DAWN_PKGCONFIG_LIBS} -ldxguid")
|
||||
endif()
|
||||
if (DAWN_ENABLE_METAL)
|
||||
set(DAWN_PKGCONFIG_LIBS "${DAWN_PKGCONFIG_LIBS} -framework IOSurface -framework Metal -framework QuartzCore")
|
||||
if (VCPKG_TARGET_IS_OSX)
|
||||
set(DAWN_PKGCONFIG_LIBS "${DAWN_PKGCONFIG_LIBS} -framework Cocoa -framework IOKit")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial_webgpu_dawn.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/unofficial_webgpu_dawn.pc" @ONLY)
|
||||
endif()
|
||||
if (EXISTS "${CURRENT_PACKAGES_DIR}/lib")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial_webgpu_dawn.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/unofficial_webgpu_dawn.pc" @ONLY)
|
||||
endif()
|
||||
vcpkg_fixup_pkgconfig()
|
||||
|
||||
# Restore the original library linkage
|
||||
set(VCPKG_LIBRARY_LINKAGE ${VCPKG_LIBRARY_LINKAGE_BACKUP})
|
||||
|
||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
|
||||
|
||||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
prefix=${pcfiledir}/../..
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: unofficial_webgpu_dawn
|
||||
Description: Dawn WebGPU library
|
||||
Version: @VERSION@
|
||||
URL: https://dawn.googlesource.com/dawn
|
||||
|
||||
Libs: -L${libdir} @DAWN_PKGCONFIG_LIBS@
|
||||
Requires.private: @DAWN_PKGCONFIG_REQUIRES@
|
||||
Cflags: -I${includedir} @DAWN_PKGCONFIG_CFLAGS@
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
dawn provides CMake targets:
|
||||
|
||||
find_package(Dawn CONFIG REQUIRED)
|
||||
target_link_libraries(main PRIVATE dawn::webgpu_dawn)
|
||||
|
||||
dawn provides pkg-config modules:
|
||||
|
||||
unofficial_webgpu_dawn
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
"name": "dawn",
|
||||
"version": "20250922.223923",
|
||||
"description": "Dawn is an open-source and cross-platform implementation of the WebGPU standard.",
|
||||
"homepage": "https://dawn.googlesource.com/dawn",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "abseil",
|
||||
"platform": "!emscripten"
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-get-python-packages",
|
||||
"host": true
|
||||
}
|
||||
],
|
||||
"default-features": [
|
||||
{
|
||||
"name": "d3d11",
|
||||
"platform": "windows"
|
||||
},
|
||||
{
|
||||
"name": "d3d12",
|
||||
"platform": "windows"
|
||||
},
|
||||
{
|
||||
"name": "gl",
|
||||
"platform": "linux | freebsd | openbsd"
|
||||
},
|
||||
{
|
||||
"name": "gles",
|
||||
"platform": "android | linux | freebsd | openbsd"
|
||||
},
|
||||
{
|
||||
"name": "metal",
|
||||
"platform": "osx | ios"
|
||||
},
|
||||
{
|
||||
"name": "vulkan",
|
||||
"platform": "(windows & !uwp) | android | linux | freebsd | openbsd"
|
||||
},
|
||||
{
|
||||
"name": "x11",
|
||||
"platform": "linux | freebsd | openbsd"
|
||||
}
|
||||
],
|
||||
"features": {
|
||||
"d3d11": {
|
||||
"description": "Direct3D 11 backend support",
|
||||
"supports": "windows"
|
||||
},
|
||||
"d3d12": {
|
||||
"description": "Direct3D 12 backend support",
|
||||
"supports": "windows"
|
||||
},
|
||||
"gl": {
|
||||
"description": "Desktop OpenGL backend support",
|
||||
"supports": "linux | freebsd | openbsd",
|
||||
"dependencies": [
|
||||
"egl-registry",
|
||||
"opengl-registry"
|
||||
]
|
||||
},
|
||||
"gles": {
|
||||
"description": "OpenGL ES backend support",
|
||||
"supports": "android | linux | freebsd | openbsd",
|
||||
"dependencies": [
|
||||
"egl-registry",
|
||||
"opengl-registry"
|
||||
]
|
||||
},
|
||||
"metal": {
|
||||
"description": "Metal backend support",
|
||||
"supports": "osx | ios"
|
||||
},
|
||||
"vulkan": {
|
||||
"description": "Vulkan backend support",
|
||||
"supports": "(windows & !uwp) | android | linux | freebsd | openbsd",
|
||||
"dependencies": [
|
||||
"vulkan-headers",
|
||||
"vulkan-utility-libraries"
|
||||
]
|
||||
},
|
||||
"wayland": {
|
||||
"description": "Wayland support",
|
||||
"supports": "linux | freebsd | openbsd"
|
||||
},
|
||||
"x11": {
|
||||
"description": "X11 support",
|
||||
"supports": "linux | freebsd | openbsd"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
diff --git a/BUILD.gn b/BUILD.gn
|
||||
index 2698abd9bd..c1ea6741e6 100644
|
||||
--- a/BUILD.gn
|
||||
+++ b/BUILD.gn
|
||||
@@ -9,10 +9,6 @@ import("gn/shared_sources.gni")
|
||||
import("gn/skia.gni")
|
||||
import("gn/toolchain/wasm.gni")
|
||||
|
||||
-if (skia_use_dawn) {
|
||||
- import("//third_party/externals/dawn/scripts/dawn_features.gni")
|
||||
-}
|
||||
-
|
||||
if (defined(skia_settings)) {
|
||||
import(skia_settings)
|
||||
}
|
||||
@@ -885,30 +881,7 @@ optional("gpu_shared") {
|
||||
|
||||
if (skia_use_dawn) {
|
||||
public_defines += [ "SK_DAWN" ]
|
||||
-
|
||||
- # When building for WASM, the WebGPU headers are provided by Emscripten. For native builds we
|
||||
- # have to depend on Dawn directly.
|
||||
- if (!skia_use_webgpu) {
|
||||
- public_deps += [
|
||||
- "//third_party/externals/dawn/include/dawn:cpp_headers",
|
||||
- "//third_party/externals/dawn/src/dawn:cpp",
|
||||
- "//third_party/externals/dawn/src/dawn:proc",
|
||||
- ]
|
||||
-
|
||||
- if (dawn_enable_d3d12 || dawn_enable_d3d11 || dawn_enable_desktop_gl ||
|
||||
- dawn_enable_metal || dawn_enable_opengles || dawn_enable_vulkan) {
|
||||
- public_deps += [ "//third_party/externals/dawn/src/dawn/native" ]
|
||||
- }
|
||||
- if (dawn_enable_d3d12) {
|
||||
- libs += [
|
||||
- "d3d12.lib",
|
||||
- "dxgi.lib",
|
||||
- "d3dcompiler.lib",
|
||||
- ]
|
||||
- } else if (dawn_enable_metal) {
|
||||
- frameworks += [ "Metal.framework" ]
|
||||
- }
|
||||
- }
|
||||
+ deps += [ "//third_party/dawn" ]
|
||||
}
|
||||
|
||||
if (skia_use_direct3d) {
|
||||
@@ -1958,10 +1931,6 @@ skia_source_set("public_headers_warnings_check") {
|
||||
"modules/skottie",
|
||||
"modules/skshaper",
|
||||
]
|
||||
-
|
||||
- if (skia_use_dawn) {
|
||||
- deps += [ "//third_party/externals/dawn/include/dawn:headers" ]
|
||||
- }
|
||||
}
|
||||
|
||||
# TODO: have each optional provide a target with examples and depend on those.
|
||||
@@ -2229,7 +2198,6 @@ if (skia_enable_tools) {
|
||||
sources += [ "tools/gpu/d3d/D3DTestUtils.cpp" ]
|
||||
}
|
||||
if (skia_use_dawn) {
|
||||
- public_deps += [ "//third_party/externals/dawn/include/dawn:headers" ]
|
||||
if (is_clang) {
|
||||
cflags_cc = [ "-Wno-microsoft-cast" ]
|
||||
}
|
||||
diff --git a/tools/window/BUILD.gn b/tools/window/BUILD.gn
|
||||
index 4a30186dbd..c001232b44 100644
|
||||
--- a/tools/window/BUILD.gn
|
||||
+++ b/tools/window/BUILD.gn
|
||||
@@ -5,10 +5,6 @@
|
||||
|
||||
import("../../gn/skia.gni")
|
||||
|
||||
-if (skia_use_dawn) {
|
||||
- import("//third_party/externals/dawn/scripts/dawn_features.gni")
|
||||
-}
|
||||
-
|
||||
config("public_config") {
|
||||
defines = []
|
||||
include_dirs = [ "." ]
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
diff --git a/include/gpu/graphite/Recorder.h b/include/gpu/graphite/Recorder.h
|
||||
index 24f1483f46..2a6d93e4c4 100644
|
||||
index 63c7bc55d5..a7adc83271 100644
|
||||
--- a/include/gpu/graphite/Recorder.h
|
||||
+++ b/include/gpu/graphite/Recorder.h
|
||||
@@ -11,6 +11,7 @@
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "include/core/SkRecorder.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/core/SkSize.h"
|
||||
#include "include/gpu/graphite/GraphiteTypes.h"
|
||||
+#include "include/gpu/graphite/ImageProvider.h"
|
||||
#include "include/gpu/graphite/Recording.h"
|
||||
#include "include/private/base/SingleOwner.h"
|
||||
#include "include/private/base/SkTArray.h"
|
||||
#include "include/private/base/SkAPI.h"
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ include("${CMAKE_CURRENT_LIST_DIR}/skia-functions.cmake")
|
|||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO google/skia
|
||||
REF "aefbd9403c1b3032ad4cd0281ef312ed262c7125"
|
||||
SHA512 8d1af006d4974c919c5760f4e461331db5dcf8ad4c4ee91c12433a88b15ea186a8932b7cd241ce47b012eb0fa5ed28f5d5d9ad187abb2bfd45a6ece8edb48d19
|
||||
REF "66a9fa68df253ee59200364436267a46545aee9e"
|
||||
SHA512 5248b09ca2025caba48f1419277d104e332f1fb6d570fb530b9bb803133cdb79795cccbbe42981397be0c268edb113f26ffd9766ccea0ffab8275633966f6c96
|
||||
PATCHES
|
||||
disable-msvc-env-setup.patch
|
||||
# disable-dev-test.patch
|
||||
skia-include-string.patch
|
||||
bentleyottmann-build.patch
|
||||
|
|
@ -14,6 +13,7 @@ vcpkg_from_github(
|
|||
vulkan-headers.patch
|
||||
pdfsubsetfont-uwp.diff
|
||||
skparagraph-dllexport.patch
|
||||
dawn.patch
|
||||
)
|
||||
|
||||
# De-vendor
|
||||
|
|
@ -22,8 +22,8 @@ file(REMOVE_RECURSE "${SOURCE_PATH}/include/third_party/vulkan")
|
|||
# these following aren't available in vcpkg
|
||||
# to update, visit the DEPS file in Skia's root directory
|
||||
declare_external_from_git(abseil-cpp
|
||||
URL "https://github.com/abseil/abseil-cpp.git"
|
||||
REF "65a55c2ba891f6d2492477707f4a2e327a0b40dc"
|
||||
URL "https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git"
|
||||
REF "cae4b6a3990e1431caa09c7b2ed1c76d0dfeab17"
|
||||
LICENSE_FILE LICENSE
|
||||
)
|
||||
declare_external_from_git(d3d12allocator
|
||||
|
|
@ -31,14 +31,9 @@ declare_external_from_git(d3d12allocator
|
|||
REF "169895d529dfce00390a20e69c2f516066fe7a3b"
|
||||
LICENSE_FILE LICENSE.txt
|
||||
)
|
||||
declare_external_from_git(dawn
|
||||
URL "https://dawn.googlesource.com/dawn.git"
|
||||
REF "acd89d9f169a9d09b9ada09d1bd80350376b8544"
|
||||
LICENSE_FILE LICENSE
|
||||
)
|
||||
declare_external_from_git(dng_sdk
|
||||
URL "https://android.googlesource.com/platform/external/dng_sdk.git"
|
||||
REF "c8d0c9b1d16bfda56f15165d39e0ffa360a11123"
|
||||
REF "dbe0a676450d9b8c71bf00688bb306409b779e90"
|
||||
LICENSE_FILE LICENSE
|
||||
)
|
||||
declare_external_from_git(jinja2
|
||||
|
|
@ -68,12 +63,12 @@ declare_external_from_git(spirv-cross
|
|||
)
|
||||
declare_external_from_git(spirv-headers
|
||||
URL "https://github.com/KhronosGroup/SPIRV-Headers.git"
|
||||
REF "e7294a8ebed84f8c5bd3686c68dbe12a4e65b644"
|
||||
REF "97e96f9e9defeb4bba3cfbd034dec516671dd7a3"
|
||||
LICENSE_FILE LICENSE
|
||||
)
|
||||
declare_external_from_git(spirv-tools
|
||||
URL "https://github.com/KhronosGroup/SPIRV-Tools.git"
|
||||
REF "ce37fd67f83cd1e8793b988d2e4126bbf72b19dd"
|
||||
REF "3aeaaa088d37b86cff036eee1a9bf452abad7d9d"
|
||||
LICENSE_FILE LICENSE
|
||||
)
|
||||
declare_external_from_git(wuffs
|
||||
|
|
@ -209,50 +204,12 @@ if("graphite" IN_LIST FEATURES)
|
|||
endif()
|
||||
|
||||
if("dawn" IN_LIST FEATURES)
|
||||
if (VCPKG_TARGET_IS_LINUX)
|
||||
message(WARNING
|
||||
[[
|
||||
dawn support requires the following libraries from the system package manager:
|
||||
|
||||
libx11-xcb-dev mesa-common-dev
|
||||
|
||||
They can be installed on Debian based systems via
|
||||
|
||||
apt-get install libx11-xcb-dev mesa-common-dev
|
||||
]]
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND required_externals
|
||||
spirv-cross
|
||||
spirv-headers
|
||||
spirv-tools
|
||||
jinja2
|
||||
markupsafe
|
||||
vulkan_headers
|
||||
## Remove
|
||||
abseil-cpp
|
||||
## REMOVE ^
|
||||
partition_alloc
|
||||
dawn
|
||||
)
|
||||
file(REMOVE_RECURSE "${SOURCE_PATH}/third_party/externals/opengl-registry")
|
||||
file(INSTALL "${CURRENT_INSTALLED_DIR}/share/opengl/" DESTINATION "${SOURCE_PATH}/third_party/externals/opengl-registry/xml")
|
||||
# cf. external dawn/src/dawn/native/BUILD.gn
|
||||
string(APPEND OPTIONS " skia_use_dawn=true dawn_use_swiftshader=false")
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
string(APPEND OPTIONS " dawn_complete_static_libs=true")
|
||||
endif()
|
||||
string(APPEND OPTIONS " skia_use_dawn=true")
|
||||
declare_external_from_pkgconfig(dawn PATH "third_party/dawn" MODULES unofficial_webgpu_dawn)
|
||||
list(APPEND required_externals dawn)
|
||||
endif()
|
||||
|
||||
get_externals(${required_externals})
|
||||
if(EXISTS "${SOURCE_PATH}/third_party/externals/dawn")
|
||||
vcpkg_find_acquire_program(GIT)
|
||||
vcpkg_replace_string("${SOURCE_PATH}/third_party/externals/dawn/generator/dawn_version_generator.py"
|
||||
"get_git(),"
|
||||
"\"${GIT}\","
|
||||
)
|
||||
endif()
|
||||
if("icu" IN_LIST FEATURES)
|
||||
vcpkg_replace_string("${SOURCE_PATH}/third_party/icu/BUILD.gn"
|
||||
[[config("vcpkg_icu") {]]
|
||||
|
|
@ -294,6 +251,8 @@ if(VCPKG_TARGET_IS_UWP)
|
|||
string(APPEND OPTIONS " extra_ldflags=${SKIA_LD_FLAGS}")
|
||||
endif()
|
||||
|
||||
string(APPEND OPTIONS " skia_use_cpp20=true")
|
||||
|
||||
vcpkg_gn_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
OPTIONS "${OPTIONS}"
|
||||
|
|
|
|||
|
|
@ -117,7 +117,14 @@ function(third_party_from_pkgconfig gn_group)
|
|||
# At least icu must be newer than in Windows SDK
|
||||
foreach(name IN LISTS ldflags)
|
||||
set(filepath NOTFOUND)
|
||||
find_file(filepath NAMES "${name}" PATHS ${lib_dirs} NO_DEFAULT_PATH NO_CACHE)
|
||||
|
||||
set(possible_names "${name}")
|
||||
string(REGEX REPLACE "\\.lib$" ".dll.lib" dll_lib_name "${name}")
|
||||
if(NOT dll_lib_name STREQUAL name)
|
||||
list(APPEND possible_names "${dll_lib_name}")
|
||||
endif()
|
||||
|
||||
find_file(filepath NAMES ${possible_names} PATHS ${lib_dirs} NO_DEFAULT_PATH NO_CACHE)
|
||||
if(filepath)
|
||||
list(APPEND libs_with_path "${filepath}")
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"name": "skia",
|
||||
"version": "134",
|
||||
"port-version": 2,
|
||||
"version": "140",
|
||||
"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.",
|
||||
|
|
@ -71,18 +70,27 @@
|
|||
"features": {
|
||||
"dawn": {
|
||||
"description": "dawn support for skia",
|
||||
"supports": "!android & !uwp",
|
||||
"dependencies": [
|
||||
"egl-registry",
|
||||
"opengl-registry",
|
||||
{
|
||||
"name": "dawn",
|
||||
"default-features": false,
|
||||
"features": [
|
||||
"x11"
|
||||
],
|
||||
"platform": "linux"
|
||||
},
|
||||
{
|
||||
"name": "dawn",
|
||||
"platform": "osx | windows"
|
||||
},
|
||||
{
|
||||
"name": "skia",
|
||||
"default-features": false,
|
||||
"features": [
|
||||
"graphite",
|
||||
"vulkan"
|
||||
"graphite"
|
||||
]
|
||||
},
|
||||
"vulkan-utility-libraries"
|
||||
}
|
||||
]
|
||||
},
|
||||
"direct3d": {
|
||||
|
|
|
|||
|
|
@ -1932,8 +1932,6 @@ shiva-sfml:arm64-windows = cascade
|
|||
shiva-sfml:x64-uwp = cascade
|
||||
shiva-sfml:x64-windows-static = cascade
|
||||
shiva-sfml:x64-windows-static-md = cascade
|
||||
skia[dawn,fontconfig,harfbuzz,icu,vulkan]:arm64-uwp = cascade
|
||||
skia[dawn,fontconfig,harfbuzz,icu,vulkan]:x64-uwp = cascade
|
||||
skia[default-features]:arm64-windows = cascade
|
||||
skia[freetype]:x64-uwp = cascade
|
||||
sleepy-discord[websocketpp]:arm64-uwp = cascade
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
||||
|
||||
vcpkg_find_acquire_program(PKGCONFIG)
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
|
||||
OPTIONS
|
||||
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
|
||||
)
|
||||
vcpkg_cmake_build()
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
project(vcpkg_ci_dawn)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
find_package(glfw3 CONFIG REQUIRED)
|
||||
|
||||
################################################################################
|
||||
# Use cmake config #
|
||||
################################################################################
|
||||
find_package(Dawn CONFIG REQUIRED)
|
||||
add_executable(vcpkg_ci_dawn main.cpp webgpu_glfw3.cpp)
|
||||
target_link_libraries(vcpkg_ci_dawn PRIVATE glfw dawn::webgpu_dawn)
|
||||
if (EMSCRIPTEN)
|
||||
target_link_options(vcpkg_ci_dawn PRIVATE -sASYNCIFY)
|
||||
set(TARGET_NAME "vcpkg_ci_dawn")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/main.html" "${CMAKE_BINARY_DIR}/${TARGET_NAME}.html" @ONLY)
|
||||
endif ()
|
||||
|
||||
################################################################################
|
||||
# Use pkg-config #
|
||||
################################################################################
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(webgpu_dawn REQUIRED IMPORTED_TARGET unofficial_webgpu_dawn)
|
||||
add_executable(vcpkg_ci_dawn_pc main.cpp webgpu_glfw3.cpp)
|
||||
target_link_libraries(vcpkg_ci_dawn_pc PRIVATE glfw PkgConfig::webgpu_dawn)
|
||||
if (EMSCRIPTEN)
|
||||
target_link_options(vcpkg_ci_dawn_pc PRIVATE -sASYNCIFY)
|
||||
set(TARGET_NAME "vcpkg_ci_dawn_pc")
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/main.html" "${CMAKE_BINARY_DIR}/${TARGET_NAME}.html" @ONLY)
|
||||
endif ()
|
||||
|
|
@ -0,0 +1,391 @@
|
|||
//
|
||||
// Copyright (c) 2024 xiaozhuai
|
||||
//
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "webgpu/webgpu_cpp.h"
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include "emscripten/emscripten.h"
|
||||
#endif
|
||||
|
||||
#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
#if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__)
|
||||
#define MY_PRETTY_FUNCTION __FUNCSIG__
|
||||
#else
|
||||
#define MY_PRETTY_FUNCTION __PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
#define ASSERT(expr, fmt, ...) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
LOG("Assertion failed: %s:%d, func: \"%s\", expr: \"%s\", message: " /**/ \
|
||||
fmt, /**/ \
|
||||
__FILE__, __LINE__, MY_PRETTY_FUNCTION, #expr, /**/ \
|
||||
##__VA_ARGS__); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
wgpu::Instance create_instance() {
|
||||
wgpu::InstanceDescriptor instance_desc;
|
||||
std::vector<wgpu::InstanceFeatureName> required_features = {
|
||||
wgpu::InstanceFeatureName::TimedWaitAny,
|
||||
};
|
||||
instance_desc.requiredFeatureCount = required_features.size();
|
||||
instance_desc.requiredFeatures = required_features.data();
|
||||
return wgpu::CreateInstance(&instance_desc);
|
||||
}
|
||||
|
||||
wgpu::Surface create_surface(const wgpu::Instance &instance, GLFWwindow *window);
|
||||
|
||||
wgpu::Adapter request_adapter(const wgpu::Instance &instance, const wgpu::Surface &surface) {
|
||||
wgpu::RequestAdapterOptions adapter_options;
|
||||
adapter_options.compatibleSurface = surface;
|
||||
adapter_options.powerPreference = wgpu::PowerPreference::HighPerformance;
|
||||
|
||||
wgpu::Adapter adapter;
|
||||
auto adapter_future = instance.RequestAdapter(
|
||||
&adapter_options, wgpu::CallbackMode::WaitAnyOnly,
|
||||
[&adapter](wgpu::RequestAdapterStatus status, wgpu::Adapter adapter_ret, wgpu::StringView message) {
|
||||
ASSERT(status == wgpu::RequestAdapterStatus::Success && adapter_ret != nullptr, "Failed to get adapter: %s",
|
||||
message.data);
|
||||
adapter = std::move(adapter_ret);
|
||||
});
|
||||
ASSERT(instance.WaitAny(adapter_future, wgpu::kLimitU64Undefined) == wgpu::WaitStatus::Success,
|
||||
"Failed to wait for adapter request");
|
||||
|
||||
return adapter;
|
||||
}
|
||||
|
||||
void device_lost_callback(const wgpu::Device &, wgpu::DeviceLostReason, wgpu::StringView message) {
|
||||
LOG("Device lost: %s", message.data);
|
||||
}
|
||||
|
||||
void device_uncaptured_error_callback(const wgpu::Device &, wgpu::ErrorType type, wgpu::StringView message) {
|
||||
const char *error_type;
|
||||
switch (type) {
|
||||
case wgpu::ErrorType::Validation:
|
||||
error_type = "Validation";
|
||||
break;
|
||||
case wgpu::ErrorType::OutOfMemory:
|
||||
error_type = "Out of memory";
|
||||
break;
|
||||
case wgpu::ErrorType::Internal:
|
||||
error_type = "Internal";
|
||||
break;
|
||||
case wgpu::ErrorType::Unknown:
|
||||
error_type = "Unknown";
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, "Unknown ErrorType");
|
||||
}
|
||||
LOG("Uncaptured Error %s: %s", error_type, message.data);
|
||||
}
|
||||
|
||||
wgpu::Device request_device(const wgpu::Instance &instance, const wgpu::Adapter &adapter) {
|
||||
wgpu::DeviceDescriptor device_desc;
|
||||
|
||||
device_desc.SetDeviceLostCallback(wgpu::CallbackMode::AllowSpontaneous, device_lost_callback);
|
||||
device_desc.SetUncapturedErrorCallback(device_uncaptured_error_callback);
|
||||
|
||||
wgpu::Device device;
|
||||
auto device_future = adapter.RequestDevice(
|
||||
&device_desc, wgpu::CallbackMode::WaitAnyOnly,
|
||||
[&device](wgpu::RequestDeviceStatus status, wgpu::Device device_ret, wgpu::StringView message) {
|
||||
ASSERT(status == wgpu::RequestDeviceStatus::Success && device_ret != nullptr, "Failed to get device: %s",
|
||||
message.data);
|
||||
device = std::move(device_ret);
|
||||
});
|
||||
ASSERT(instance.WaitAny(device_future, wgpu::kLimitU64Undefined) == wgpu::WaitStatus::Success,
|
||||
"Failed to wait for device request");
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
wgpu::ShaderModule create_shader(const wgpu::Device &device, const std::string &shader_code) {
|
||||
wgpu::ShaderSourceWGSL shader_code_desc;
|
||||
shader_code_desc.sType = wgpu::SType::ShaderSourceWGSL;
|
||||
shader_code_desc.code = shader_code.c_str();
|
||||
wgpu::ShaderModuleDescriptor shader_desc;
|
||||
shader_desc.nextInChain = &shader_code_desc;
|
||||
return device.CreateShaderModule(&shader_desc);
|
||||
}
|
||||
|
||||
struct alignas(16) Uniforms {
|
||||
struct {
|
||||
float width = 0.0f;
|
||||
float height = 0.0f;
|
||||
} resolution;
|
||||
float time = 0.0f;
|
||||
};
|
||||
|
||||
void glfw_error_callback(int error, const char *description) { LOG("GLFW error, %d, %s", error, description); }
|
||||
|
||||
struct AppState {
|
||||
wgpu::Instance instance;
|
||||
wgpu::Surface surface;
|
||||
wgpu::Adapter adapter;
|
||||
wgpu::Device device;
|
||||
wgpu::Queue queue;
|
||||
wgpu::SurfaceConfiguration surface_config;
|
||||
int surface_width = 0;
|
||||
int surface_height = 0;
|
||||
};
|
||||
|
||||
int main() {
|
||||
glfwSetErrorCallback(glfw_error_callback);
|
||||
ASSERT(glfwInit(), "GLFW init failed");
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
auto *window = glfwCreateWindow(1024, 1024, "vcpkg-ci-dawn", nullptr, nullptr);
|
||||
|
||||
AppState state;
|
||||
state.instance = create_instance();
|
||||
state.surface = create_surface(state.instance, window);
|
||||
state.adapter = request_adapter(state.instance, state.surface);
|
||||
state.device = request_device(state.instance, state.adapter);
|
||||
state.queue = state.device.GetQueue();
|
||||
|
||||
wgpu::SurfaceCapabilities surface_capabilities;
|
||||
state.surface.GetCapabilities(state.adapter, &surface_capabilities);
|
||||
glfwGetFramebufferSize(window, &state.surface_width, &state.surface_height);
|
||||
|
||||
state.surface_config.device = state.device;
|
||||
state.surface_config.usage = wgpu::TextureUsage::RenderAttachment;
|
||||
state.surface_config.format = surface_capabilities.formats[0];
|
||||
state.surface_config.presentMode = surface_capabilities.presentModes[0];
|
||||
state.surface_config.alphaMode = surface_capabilities.alphaModes[0];
|
||||
state.surface_config.width = state.surface_width;
|
||||
state.surface_config.height = state.surface_height;
|
||||
state.surface.Configure(&state.surface_config);
|
||||
|
||||
glfwSetWindowUserPointer(window, &state);
|
||||
|
||||
glfwSetKeyCallback(window, [](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
|
||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||
}
|
||||
});
|
||||
glfwSetFramebufferSizeCallback(window, [](GLFWwindow *window, int width, int height) {
|
||||
auto &state = *static_cast<AppState *>(glfwGetWindowUserPointer(window));
|
||||
state.surface_width = width;
|
||||
state.surface_height = height;
|
||||
state.surface_config.width = width;
|
||||
state.surface_config.height = height;
|
||||
state.surface.Configure(&state.surface_config);
|
||||
});
|
||||
|
||||
std::string shader_source = R"(
|
||||
struct Uniforms {
|
||||
resolution: vec2f,
|
||||
time: f32,
|
||||
};
|
||||
|
||||
@group(0)
|
||||
@binding(0)
|
||||
var<uniform> uniforms: Uniforms;
|
||||
|
||||
struct VertexInput {
|
||||
@location(0)
|
||||
pos: vec2f,
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position)
|
||||
pos: vec4f,
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_main(input: VertexInput) -> VertexOutput {
|
||||
var output: VertexOutput;
|
||||
output.pos = vec4f(input.pos, 0.0, 1.0);
|
||||
return output;
|
||||
}
|
||||
|
||||
struct FragmentInput {
|
||||
@builtin(position)
|
||||
coord: vec4f,
|
||||
};
|
||||
|
||||
struct FragmentOutput {
|
||||
@location(0)
|
||||
color: vec4f,
|
||||
};
|
||||
|
||||
fn palette(t: f32) -> vec3f{
|
||||
let a = vec3f(0.5, 0.5, 0.5);
|
||||
let b = vec3f(0.5, 0.5, 0.5);
|
||||
let c = vec3f(1.0, 1.0, 1.0);
|
||||
let d = vec3f(0.263, 0.416, 0.557);
|
||||
return a + b * cos(6.28318 * (c * t + d));
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(input: FragmentInput) -> FragmentOutput {
|
||||
var uv = (input.coord.xy * 2.0 - uniforms.resolution) / min(uniforms.resolution.x, uniforms.resolution.y);
|
||||
let uv0 = uv;
|
||||
var color = vec3f(0.0);
|
||||
for (var i: f32 = 0.0; i < 4.0; i += 1.0) {
|
||||
uv = fract(uv * 1.5) - 0.5;
|
||||
var d = length(uv) * exp(-length(uv0));
|
||||
let col = palette(length(uv0) + i * 0.4 + uniforms.time * 0.4);
|
||||
d = sin(d * 8.0 + uniforms.time) / 8.0;
|
||||
d = abs(d);
|
||||
d = pow(0.01 / d, 1.2);
|
||||
color += col * d;
|
||||
}
|
||||
var output: FragmentOutput;
|
||||
output.color = vec4f(color, 1.0);
|
||||
return output;
|
||||
}
|
||||
)";
|
||||
auto shader_module = create_shader(state.device, shader_source);
|
||||
|
||||
constexpr float vertices[12] = {-1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0};
|
||||
constexpr int vertex_count = std::size(vertices) / 2;
|
||||
wgpu::BufferDescriptor vertex_buffer_desc;
|
||||
vertex_buffer_desc.size = sizeof(vertices);
|
||||
vertex_buffer_desc.usage = wgpu::BufferUsage::Vertex | wgpu::BufferUsage::CopyDst;
|
||||
wgpu::Buffer vertex_buffer = state.device.CreateBuffer(&vertex_buffer_desc);
|
||||
state.queue.WriteBuffer(vertex_buffer, 0, vertices, sizeof(vertices));
|
||||
|
||||
Uniforms uniforms;
|
||||
wgpu::BufferDescriptor uniform_buffer_desc;
|
||||
uniform_buffer_desc.size = sizeof(uniforms);
|
||||
uniform_buffer_desc.usage = wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopyDst;
|
||||
wgpu::Buffer uniform_buffer = state.device.CreateBuffer(&uniform_buffer_desc);
|
||||
state.queue.WriteBuffer(uniform_buffer, 0, &uniforms, sizeof(uniforms));
|
||||
|
||||
wgpu::RenderPipelineDescriptor pipeline_desc;
|
||||
|
||||
std::vector<wgpu::VertexAttribute> vertex_attributes(1);
|
||||
vertex_attributes[0].format = wgpu::VertexFormat::Float32x2;
|
||||
vertex_attributes[0].offset = 0;
|
||||
vertex_attributes[0].shaderLocation = 0;
|
||||
std::vector<wgpu::VertexBufferLayout> vertex_layouts(1);
|
||||
vertex_layouts[0].arrayStride = 2 * sizeof(float);
|
||||
vertex_layouts[0].attributeCount = vertex_attributes.size();
|
||||
vertex_layouts[0].attributes = vertex_attributes.data();
|
||||
vertex_layouts[0].stepMode = wgpu::VertexStepMode::Vertex;
|
||||
|
||||
pipeline_desc.vertex.bufferCount = vertex_layouts.size();
|
||||
pipeline_desc.vertex.buffers = vertex_layouts.data();
|
||||
|
||||
pipeline_desc.vertex.module = shader_module;
|
||||
pipeline_desc.vertex.entryPoint = "vs_main";
|
||||
pipeline_desc.vertex.constantCount = 0;
|
||||
pipeline_desc.vertex.constants = nullptr;
|
||||
|
||||
pipeline_desc.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
|
||||
pipeline_desc.primitive.stripIndexFormat = wgpu::IndexFormat::Undefined;
|
||||
pipeline_desc.primitive.frontFace = wgpu::FrontFace::CCW;
|
||||
pipeline_desc.primitive.cullMode = wgpu::CullMode::None;
|
||||
|
||||
wgpu::FragmentState fragment_state;
|
||||
fragment_state.module = shader_module;
|
||||
fragment_state.entryPoint = "fs_main";
|
||||
fragment_state.constantCount = 0;
|
||||
fragment_state.constants = nullptr;
|
||||
|
||||
wgpu::BlendState blend_state;
|
||||
blend_state.color.srcFactor = wgpu::BlendFactor::SrcAlpha;
|
||||
blend_state.color.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;
|
||||
blend_state.color.operation = wgpu::BlendOperation::Add;
|
||||
blend_state.alpha.srcFactor = wgpu::BlendFactor::Zero;
|
||||
blend_state.alpha.dstFactor = wgpu::BlendFactor::One;
|
||||
blend_state.alpha.operation = wgpu::BlendOperation::Add;
|
||||
|
||||
wgpu::ColorTargetState color_target;
|
||||
color_target.format = state.surface_config.format;
|
||||
color_target.blend = &blend_state;
|
||||
color_target.writeMask = wgpu::ColorWriteMask::All;
|
||||
|
||||
fragment_state.targetCount = 1;
|
||||
fragment_state.targets = &color_target;
|
||||
pipeline_desc.fragment = &fragment_state;
|
||||
|
||||
pipeline_desc.depthStencil = nullptr;
|
||||
pipeline_desc.multisample.count = 1;
|
||||
pipeline_desc.multisample.mask = ~0u;
|
||||
|
||||
pipeline_desc.multisample.alphaToCoverageEnabled = false;
|
||||
pipeline_desc.layout = nullptr;
|
||||
|
||||
wgpu::RenderPipeline pipeline = state.device.CreateRenderPipeline(&pipeline_desc);
|
||||
|
||||
std::vector<wgpu::BindGroupEntry> bind_group_entries(1);
|
||||
bind_group_entries[0].binding = 0;
|
||||
bind_group_entries[0].buffer = uniform_buffer;
|
||||
bind_group_entries[0].size = uniform_buffer.GetSize();
|
||||
|
||||
wgpu::BindGroupDescriptor bind_group_desc;
|
||||
bind_group_desc.layout = pipeline.GetBindGroupLayout(0);
|
||||
bind_group_desc.entryCount = bind_group_entries.size();
|
||||
bind_group_desc.entries = bind_group_entries.data();
|
||||
wgpu::BindGroup bind_group = state.device.CreateBindGroup(&bind_group_desc);
|
||||
|
||||
const double start_time = glfwGetTime();
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glfwPollEvents();
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
emscripten_sleep(0);
|
||||
#endif
|
||||
|
||||
const double time = glfwGetTime() - start_time;
|
||||
|
||||
wgpu::SurfaceTexture surface_texture;
|
||||
state.surface.GetCurrentTexture(&surface_texture);
|
||||
ASSERT(surface_texture.status == wgpu::SurfaceGetCurrentTextureStatus::SuccessOptimal ||
|
||||
surface_texture.status == wgpu::SurfaceGetCurrentTextureStatus::SuccessSuboptimal,
|
||||
"Failed to get current texture");
|
||||
if (surface_texture.status == wgpu::SurfaceGetCurrentTextureStatus::SuccessSuboptimal) {
|
||||
LOG("Surface texture is suboptimal");
|
||||
}
|
||||
|
||||
wgpu::Texture texture = surface_texture.texture;
|
||||
wgpu::TextureView frame = texture.CreateView();
|
||||
|
||||
uniforms.resolution.width = static_cast<float>(texture.GetWidth());
|
||||
uniforms.resolution.height = static_cast<float>(texture.GetHeight());
|
||||
uniforms.time = static_cast<float>(time);
|
||||
state.queue.WriteBuffer(uniform_buffer, 0, &uniforms, sizeof(uniforms));
|
||||
|
||||
auto encoder = state.device.CreateCommandEncoder();
|
||||
|
||||
wgpu::RenderPassColorAttachment color_attachment;
|
||||
color_attachment.view = frame;
|
||||
color_attachment.loadOp = wgpu::LoadOp::Clear;
|
||||
color_attachment.storeOp = wgpu::StoreOp::Store;
|
||||
color_attachment.clearValue = {0.1f, 0.2f, 0.3f, 1.0f};
|
||||
wgpu::RenderPassDescriptor pass_desc;
|
||||
pass_desc.colorAttachmentCount = 1;
|
||||
pass_desc.colorAttachments = &color_attachment;
|
||||
pass_desc.depthStencilAttachment = nullptr;
|
||||
|
||||
auto pass = encoder.BeginRenderPass(&pass_desc);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetVertexBuffer(0, vertex_buffer, 0, vertex_buffer.GetSize());
|
||||
pass.SetBindGroup(0, bind_group, 0, nullptr);
|
||||
pass.Draw(vertex_count);
|
||||
pass.End();
|
||||
|
||||
wgpu::CommandBuffer command_buffer = encoder.Finish();
|
||||
state.queue.Submit(1, &command_buffer);
|
||||
|
||||
#if !defined(__EMSCRIPTEN__)
|
||||
ASSERT(state.surface.Present(), "Failed to present the surface");
|
||||
state.device.Tick();
|
||||
#endif
|
||||
}
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>@TARGET_NAME@</title>
|
||||
<style>
|
||||
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
|
||||
.canvas-container { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
|
||||
#canvas { max-width: 100%; max-height: 100%; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="canvas-container">
|
||||
<canvas id="canvas" width="1024" height="1024"></canvas>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">var Module = {canvas: document.getElementById('canvas')};</script>
|
||||
<script type="text/javascript" src="@TARGET_NAME@.js"></script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
//
|
||||
// Copyright (c) 2025 xiaozhuai
|
||||
//
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "webgpu/webgpu_cpp.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#define DAWN_USE_X11
|
||||
#endif
|
||||
|
||||
#if defined(DAWN_USE_X11)
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
#endif
|
||||
|
||||
#if defined(DAWN_USE_WAYLAND)
|
||||
#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||
#endif
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include "emscripten/emscripten.h"
|
||||
#else
|
||||
#include "GLFW/glfw3native.h"
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <objc/message.h>
|
||||
#include <objc/objc.h>
|
||||
#include <objc/runtime.h>
|
||||
template <typename T, typename... Args>
|
||||
T objc_call(id obj, const char *sel, Args... args) {
|
||||
using FuncPtr = T (*)(id, SEL, Args...);
|
||||
return reinterpret_cast<FuncPtr>(objc_msgSend)(obj, sel_registerName(sel), args...);
|
||||
}
|
||||
template <typename T, typename... Args>
|
||||
T objc_call(const char *clazz, const char *sel, Args... args) {
|
||||
return objc_call<T>(reinterpret_cast<id>(objc_getClass(clazz)), sel, args...);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::unique_ptr<wgpu::ChainedStruct> setup_window_and_get_surface_descriptor(GLFWwindow *window) {
|
||||
if (glfwGetWindowAttrib(window, GLFW_CLIENT_API) != GLFW_NO_API) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
auto desc = std::make_unique<wgpu::EmscriptenSurfaceSourceCanvasHTMLSelector>();
|
||||
desc->selector = "#canvas";
|
||||
return desc;
|
||||
#elif defined(_WIN32)
|
||||
auto desc = std::make_unique<wgpu::SurfaceSourceWindowsHWND>();
|
||||
desc->hwnd = glfwGetWin32Window(window);
|
||||
desc->hinstance = GetModuleHandle(nullptr);
|
||||
return desc;
|
||||
#elif defined(__APPLE__)
|
||||
// NSWindow *ns_window = glfwGetCocoaWindow(window);
|
||||
// NSView *view = [ns_window contentView];
|
||||
// [view setWantsLayer:YES];
|
||||
// CAMetalLayer *layer = [CAMetalLayer layer];
|
||||
// CGFloat scale_factor = [ns_window backingScaleFactor];
|
||||
// [layer setContentsScale:scale_factor];
|
||||
// [view setLayer:layer];
|
||||
auto ns_window = glfwGetCocoaWindow(window);
|
||||
CFRetain(ns_window);
|
||||
auto view = objc_call<id>(ns_window, "contentView");
|
||||
CFRetain(view);
|
||||
objc_call<void, BOOL>(view, "setWantsLayer:", YES);
|
||||
auto layer = objc_call<id>("CAMetalLayer", "layer");
|
||||
auto scale_factor = objc_call<CGFloat>(ns_window, "backingScaleFactor");
|
||||
objc_call<void, CGFloat>(layer, "setContentsScale:", scale_factor);
|
||||
objc_call<void, id>(view, "setLayer:", layer);
|
||||
auto desc = std::make_unique<wgpu::SurfaceSourceMetalLayer>();
|
||||
desc->layer = layer;
|
||||
CFRelease(view);
|
||||
CFRelease(ns_window);
|
||||
return desc;
|
||||
#elif defined(DAWN_USE_WAYLAND) || defined(DAWN_USE_X11)
|
||||
#if defined(GLFW_PLATFORM_WAYLAND) && defined(DAWN_USE_WAYLAND)
|
||||
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) {
|
||||
auto desc = std::make_unique<wgpu::SurfaceSourceWaylandSurface>();
|
||||
desc->display = glfwGetWaylandDisplay();
|
||||
desc->surface = glfwGetWaylandWindow(window);
|
||||
return desc;
|
||||
} else // NOLINT(readability/braces)
|
||||
#endif
|
||||
#if defined(DAWN_USE_X11)
|
||||
{
|
||||
auto desc = std::make_unique<wgpu::SurfaceSourceXlibWindow>();
|
||||
desc->display = glfwGetX11Display();
|
||||
desc->window = glfwGetX11Window(window);
|
||||
return desc;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
wgpu::Surface create_surface(const wgpu::Instance &instance, GLFWwindow *window) {
|
||||
auto chainedDescriptor = setup_window_and_get_surface_descriptor(window);
|
||||
wgpu::SurfaceDescriptor descriptor;
|
||||
descriptor.nextInChain = chainedDescriptor.get();
|
||||
wgpu::Surface surface = instance.CreateSurface(&descriptor);
|
||||
return surface;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "vcpkg-ci-dawn",
|
||||
"version-date": "2025-08-23",
|
||||
"description": "Validates dawn",
|
||||
"license": null,
|
||||
"supports": "!uwp & !android & !ios",
|
||||
"dependencies": [
|
||||
"dawn",
|
||||
"glfw3",
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
"features": [
|
||||
"dawn"
|
||||
],
|
||||
"platform": "linux | (windows & !uwp)"
|
||||
"platform": "!android & !uwp"
|
||||
},
|
||||
{
|
||||
"name": "skia",
|
||||
|
|
|
|||
|
|
@ -2348,6 +2348,10 @@
|
|||
"baseline": "2.2.5",
|
||||
"port-version": 1
|
||||
},
|
||||
"dawn": {
|
||||
"baseline": "20250922.223923",
|
||||
"port-version": 0
|
||||
},
|
||||
"daxa": {
|
||||
"baseline": "3.0.3",
|
||||
"port-version": 0
|
||||
|
|
@ -8953,8 +8957,8 @@
|
|||
"port-version": 0
|
||||
},
|
||||
"skia": {
|
||||
"baseline": "134",
|
||||
"port-version": 2
|
||||
"baseline": "140",
|
||||
"port-version": 0
|
||||
},
|
||||
"skyr-url": {
|
||||
"baseline": "1.13.0",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "ab06b79e17bffaf06a5373b6750ef33388793d65",
|
||||
"version": "20250922.223923",
|
||||
"port-version": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "f51c683b289d76716471f84250e0a7831aa27797",
|
||||
"version": "140",
|
||||
"port-version": 0
|
||||
},
|
||||
{
|
||||
"git-tree": "ac9af642ebbc1ad29c7fbed2d46dd65e75e9a1cf",
|
||||
"version": "134",
|
||||
|
|
|
|||
Loading…
Reference in New Issue