-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addpkg(main/mesa-vulkan-icd-wrapper): Android Vulkan wrapper
- Loading branch information
Showing
5 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/mesa-vulkan-icd-wrapper/0001-fix-for-anon-file.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Fallback to `@TERMUX_PREFIX@/tmp` if env `XDG_RUNTIME_DIR` is not set. | ||
|
||
--- a/src/util/anon_file.c | ||
+++ b/src/util/anon_file.c | ||
@@ -136,6 +136,11 @@ | ||
char *name; | ||
|
||
path = getenv("XDG_RUNTIME_DIR"); | ||
+#ifdef __TERMUX__ | ||
+ if (!path) { | ||
+ path = "@TERMUX_PREFIX@/tmp"; | ||
+ } | ||
+#endif | ||
if (!path) { | ||
errno = ENOENT; | ||
return -1; |
88 changes: 88 additions & 0 deletions
88
packages/mesa-vulkan-icd-wrapper/0002-wsi-no-pthread_cancel.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c | ||
index c91633e9bc4..4ce516d6276 100644 | ||
--- a/src/vulkan/wsi/wsi_common_display.c | ||
+++ b/src/vulkan/wsi/wsi_common_display.c | ||
@@ -176,6 +176,12 @@ struct wsi_display_sync { | ||
|
||
static uint64_t fence_sequence; | ||
|
||
+#ifdef __TERMUX__ | ||
+static void thread_signal_handler (int signum) { | ||
+ pthread_exit (0); | ||
+} | ||
+#endif | ||
+ | ||
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_mode, VkDisplayModeKHR) | ||
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_connector, VkDisplayKHR) | ||
|
||
@@ -1341,7 +1347,9 @@ wsi_display_wait_thread(void *data) | ||
.events = POLLIN | ||
}; | ||
|
||
+#ifndef __TERMUX__ | ||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); | ||
+#endif | ||
for (;;) { | ||
int ret = poll(&pollfd, 1, -1); | ||
if (ret > 0) { | ||
@@ -1369,9 +1377,22 @@ wsi_display_start_wait_thread(struct wsi_display *wsi) | ||
static void | ||
wsi_display_stop_wait_thread(struct wsi_display *wsi) | ||
{ | ||
+#ifdef __TERMUX__ | ||
+ struct sigaction actions; | ||
+ memset (&actions, 0, sizeof (actions)); | ||
+ sigemptyset (&actions.sa_mask); | ||
+ actions.sa_flags = 0; | ||
+ actions.sa_handler = thread_signal_handler; | ||
+ sigaction (SIGUSR2, &actions, NULL); | ||
+#endif | ||
+ | ||
mtx_lock(&wsi->wait_mutex); | ||
if (wsi->wait_thread) { | ||
+#ifndef __TERMUX__ | ||
pthread_cancel(wsi->wait_thread); | ||
+#else | ||
+ pthread_kill(wsi->wait_thread, SIGUSR2); | ||
+#endif | ||
pthread_join(wsi->wait_thread, NULL); | ||
wsi->wait_thread = 0; | ||
} | ||
@@ -2215,7 +2236,9 @@ udev_event_listener_thread(void *data) | ||
|
||
int udev_fd = udev_monitor_get_fd(mon); | ||
|
||
+#ifndef __TERMUX__ | ||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); | ||
+#endif | ||
|
||
for (;;) { | ||
nfds_t nfds = 1; | ||
@@ -2340,6 +2363,15 @@ wsi_display_finish_wsi(struct wsi_device *wsi_device, | ||
struct wsi_display *wsi = | ||
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY]; | ||
|
||
+#ifdef __TERMUX__ | ||
+ struct sigaction actions; | ||
+ memset (&actions, 0, sizeof (actions)); | ||
+ sigemptyset (&actions.sa_mask); | ||
+ actions.sa_flags = 0; | ||
+ actions.sa_handler = thread_signal_handler; | ||
+ sigaction (SIGUSR2, &actions, NULL); | ||
+#endif | ||
+ | ||
if (wsi) { | ||
wsi_for_each_connector(connector, wsi) { | ||
wsi_for_each_display_mode(mode, connector) { | ||
@@ -2351,7 +2383,11 @@ wsi_display_finish_wsi(struct wsi_device *wsi_device, | ||
wsi_display_stop_wait_thread(wsi); | ||
|
||
if (wsi->hotplug_thread) { | ||
+#ifndef __TERMUX__ | ||
pthread_cancel(wsi->hotplug_thread); | ||
+#else | ||
+ pthread_kill(wsi->hotplug_thread, SIGUSR2); | ||
+#endif | ||
pthread_join(wsi->hotplug_thread, NULL); | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
packages/mesa-vulkan-icd-wrapper/0003-vulkan-x11-disable-immediate-mode.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c | ||
index 22ac573cca2..9e0eb25f45f 100644 | ||
--- a/src/vulkan/wsi/wsi_common_x11.c | ||
+++ b/src/vulkan/wsi/wsi_common_x11.c | ||
@@ -462,7 +462,9 @@ static const VkFormat formats[] = { | ||
}; | ||
|
||
static const VkPresentModeKHR present_modes[] = { | ||
+#ifndef __TERMUX__ | ||
VK_PRESENT_MODE_IMMEDIATE_KHR, | ||
+#endif | ||
VK_PRESENT_MODE_MAILBOX_KHR, | ||
VK_PRESENT_MODE_FIFO_KHR, | ||
VK_PRESENT_MODE_FIFO_RELAXED_KHR, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
TERMUX_PKG_HOMEPAGE=https://www.mesa3d.org | ||
TERMUX_PKG_DESCRIPTION="Android Vulkan wrapper" | ||
TERMUX_PKG_LICENSE="MIT" | ||
TERMUX_PKG_LICENSE_FILE="docs/license.rst" | ||
TERMUX_PKG_MAINTAINER="xMeM <[email protected]>" | ||
TERMUX_PKG_VERSION="24.3.1" | ||
TERMUX_PKG_REVISION=4 | ||
TERMUX_PKG_SRCURL=git+https://github.com/xMeM/mesa | ||
TERMUX_PKG_GIT_BRANCH=wrapper | ||
_COMMIT=578ceaf21b23233f90d1b31add7a0dfdfb31b860 | ||
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++, libdrm, libx11, libxcb, libxshmfence, libwayland, vulkan-loader-generic, zlib, zstd" | ||
TERMUX_PKG_BUILD_DEPENDS="libwayland-protocols, libxrandr, xorgproto" | ||
TERMUX_PKG_API_LEVEL=26 | ||
|
||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" | ||
--cmake-prefix-path $TERMUX_PREFIX | ||
-Dcpp_rtti=false | ||
-Dgbm=disabled | ||
-Dopengl=false | ||
-Dllvm=disabled | ||
-Dshared-llvm=disabled | ||
-Dplatforms=x11,wayland | ||
-Dgallium-drivers= | ||
-Dxmlconfig=disabled | ||
-Dvulkan-drivers=wrapper | ||
" | ||
|
||
termux_step_post_get_source() { | ||
git fetch --unshallow | ||
git checkout $_COMMIT | ||
# Do not use meson wrap projects | ||
rm -rf subprojects | ||
} | ||
|
||
termux_step_pre_configure() { | ||
termux_setup_cmake | ||
|
||
CPPFLAGS+=" -D__USE_GNU" | ||
CPPFLAGS+=" -U__ANDROID__" | ||
LDFLAGS+=" -landroid-shmem" | ||
|
||
_WRAPPER_BIN=$TERMUX_PKG_BUILDDIR/_wrapper/bin | ||
mkdir -p $_WRAPPER_BIN | ||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then | ||
sed 's|@CMAKE@|'"$(command -v cmake)"'|g' \ | ||
$TERMUX_PKG_BUILDER_DIR/cmake-wrapper.in \ | ||
> $_WRAPPER_BIN/cmake | ||
chmod 0700 $_WRAPPER_BIN/cmake | ||
termux_setup_wayland_cross_pkg_config_wrapper | ||
fi | ||
export PATH=$_WRAPPER_BIN:$PATH | ||
} | ||
|
||
termux_step_post_configure() { | ||
rm -f $_WRAPPER_BIN/cmake | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
if [ -e CMakeLists.txt ]; then | ||
sed -i '1s|^|project(foo LANGUAGES C CXX)\n|' CMakeLists.txt | ||
fi | ||
|
||
for f in "$@"; do | ||
case "${f}" in | ||
-DCMAKE_TOOLCHAIN_FILE=* ) | ||
sed -i "${f#-DCMAKE_TOOLCHAIN_FILE=}" \ | ||
-e 's|\(set(CMAKE_SYSTEM_NAME\) "Android")|\1 "Linux")|g' | ||
;; | ||
esac | ||
done | ||
|
||
exec @CMAKE@ "$@" |