Skip to content

Commit d3c42fc

Browse files
committed
addpkg(main/vulkan-wrapper-android): 25.0.0
1 parent ca65584 commit d3c42fc

6 files changed

Lines changed: 200 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/util/detect_os.h b/src/util/detect_os.h
2+
index 86286dfbe70..f589104f6a7 100644
3+
--- a/src/util/detect_os.h
4+
+++ b/src/util/detect_os.h
5+
@@ -24,7 +24,7 @@
6+
* Android defines __linux__, so DETECT_OS_LINUX and DETECT_OS_POSIX will
7+
* also be defined.
8+
*/
9+
-#if defined(__ANDROID__)
10+
+#if 0
11+
#define DETECT_OS_ANDROID 1
12+
#endif
13+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Fallback to `@TERMUX_PREFIX@/tmp` if env `XDG_RUNTIME_DIR` is not set.
2+
3+
--- a/src/util/anon_file.c
4+
+++ b/src/util/anon_file.c
5+
@@ -136,6 +136,11 @@
6+
char *name;
7+
8+
path = getenv("XDG_RUNTIME_DIR");
9+
+#ifdef __TERMUX__
10+
+ if (!path) {
11+
+ path = "@TERMUX_PREFIX@/tmp";
12+
+ }
13+
+#endif
14+
if (!path) {
15+
errno = ENOENT;
16+
return -1;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
+++ ./src/vulkan/wsi/wsi_common_display.c
2+
@@ -176,6 +176,12 @@
3+
4+
static uint64_t fence_sequence;
5+
6+
+#ifdef __ANDROID__
7+
+static void thread_signal_handler (int signum) {
8+
+ pthread_exit (0);
9+
+}
10+
+#endif
11+
+
12+
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_mode, VkDisplayModeKHR)
13+
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_connector, VkDisplayKHR)
14+
15+
@@ -1341,7 +1347,9 @@
16+
.events = POLLIN
17+
};
18+
19+
+#ifndef __ANDROID__
20+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
21+
+#endif
22+
for (;;) {
23+
int ret = poll(&pollfd, 1, -1);
24+
if (ret > 0) {
25+
@@ -1369,9 +1377,22 @@
26+
static void
27+
wsi_display_stop_wait_thread(struct wsi_display *wsi)
28+
{
29+
+#ifdef __ANDROID__
30+
+ struct sigaction actions;
31+
+ memset (&actions, 0, sizeof (actions));
32+
+ sigemptyset (&actions.sa_mask);
33+
+ actions.sa_flags = 0;
34+
+ actions.sa_handler = thread_signal_handler;
35+
+ sigaction (SIGUSR2, &actions, NULL);
36+
+#endif
37+
+
38+
mtx_lock(&wsi->wait_mutex);
39+
if (wsi->wait_thread) {
40+
+#ifndef __ANDROID__
41+
pthread_cancel(wsi->wait_thread);
42+
+#else
43+
+ pthread_kill(wsi->wait_thread, SIGUSR2);
44+
+#endif
45+
pthread_join(wsi->wait_thread, NULL);
46+
wsi->wait_thread = 0;
47+
}
48+
@@ -2215,7 +2236,9 @@
49+
50+
int udev_fd = udev_monitor_get_fd(mon);
51+
52+
+#ifndef __ANDROID__
53+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
54+
+#endif
55+
56+
for (;;) {
57+
nfds_t nfds = 1;
58+
@@ -2340,6 +2363,15 @@
59+
struct wsi_display *wsi =
60+
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
61+
62+
+#ifdef __ANDROID__
63+
+ struct sigaction actions;
64+
+ memset (&actions, 0, sizeof (actions));
65+
+ sigemptyset (&actions.sa_mask);
66+
+ actions.sa_flags = 0;
67+
+ actions.sa_handler = thread_signal_handler;
68+
+ sigaction (SIGUSR2, &actions, NULL);
69+
+#endif
70+
+
71+
if (wsi) {
72+
wsi_for_each_connector(connector, wsi) {
73+
wsi_for_each_display_mode(mode, connector) {
74+
@@ -2351,7 +2383,11 @@
75+
wsi_display_stop_wait_thread(wsi);
76+
77+
if (wsi->hotplug_thread) {
78+
+#ifndef __ANDROID__
79+
pthread_cancel(wsi->hotplug_thread);
80+
+#else
81+
+ pthread_kill(wsi->hotplug_thread, SIGUSR2);
82+
+#endif
83+
pthread_join(wsi->hotplug_thread, NULL);
84+
}
85+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
2+
index 22ac573cca2..9e0eb25f45f 100644
3+
--- a/src/vulkan/wsi/wsi_common_x11.c
4+
+++ b/src/vulkan/wsi/wsi_common_x11.c
5+
@@ -462,7 +462,9 @@ static const VkFormat formats[] = {
6+
};
7+
8+
static const VkPresentModeKHR present_modes[] = {
9+
+#ifndef __TERMUX__
10+
VK_PRESENT_MODE_IMMEDIATE_KHR,
11+
+#endif
12+
VK_PRESENT_MODE_MAILBOX_KHR,
13+
VK_PRESENT_MODE_FIFO_KHR,
14+
VK_PRESENT_MODE_FIFO_RELAXED_KHR,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
TERMUX_PKG_HOMEPAGE=https://www.mesa3d.org
2+
TERMUX_PKG_DESCRIPTION="Android Vulkan ICD"
3+
TERMUX_PKG_LICENSE="MIT"
4+
TERMUX_PKG_LICENSE_FILE="docs/license.rst"
5+
TERMUX_PKG_MAINTAINER="xMeM <haooy@outlook.com>"
6+
TERMUX_PKG_VERSION="25.0.0"
7+
TERMUX_PKG_REVISION=2
8+
TERMUX_PKG_SRCURL=git+https://github.com/xMeM/mesa
9+
TERMUX_PKG_GIT_BRANCH=wrapper
10+
_COMMIT=e65c7eb6ee2f9903c3256f2677beb1d98464103f
11+
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++, libdrm, libx11, libxcb, libxshmfence, libwayland, vulkan-loader-generic, zlib, zstd"
12+
TERMUX_PKG_BUILD_DEPENDS="libwayland-protocols, libxrandr, xorgproto"
13+
TERMUX_PKG_API_LEVEL=26
14+
15+
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
16+
--cmake-prefix-path $TERMUX_PREFIX
17+
-Dcpp_rtti=false
18+
-Dgbm=disabled
19+
-Dopengl=false
20+
-Dllvm=disabled
21+
-Dshared-llvm=disabled
22+
-Dplatforms=x11,wayland
23+
-Dgallium-drivers=
24+
-Dxmlconfig=disabled
25+
-Dvulkan-drivers=wrapper
26+
-Db_ndebug=true
27+
"
28+
29+
termux_step_post_get_source() {
30+
git fetch --unshallow
31+
git checkout $_COMMIT
32+
# Do not use meson wrap projects
33+
rm -rf subprojects
34+
}
35+
36+
termux_step_pre_configure() {
37+
termux_setup_cmake
38+
39+
CPPFLAGS+=" -D__USE_GNU"
40+
LDFLAGS+=" -landroid-shmem"
41+
42+
_WRAPPER_BIN=$TERMUX_PKG_BUILDDIR/_wrapper/bin
43+
mkdir -p $_WRAPPER_BIN
44+
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
45+
sed 's|@CMAKE@|'"$(command -v cmake)"'|g' \
46+
$TERMUX_PKG_BUILDER_DIR/cmake-wrapper.in \
47+
> $_WRAPPER_BIN/cmake
48+
chmod 0700 $_WRAPPER_BIN/cmake
49+
termux_setup_wayland_cross_pkg_config_wrapper
50+
fi
51+
export PATH=$_WRAPPER_BIN:$PATH
52+
}
53+
54+
termux_step_post_configure() {
55+
rm -f $_WRAPPER_BIN/cmake
56+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
if [ -e CMakeLists.txt ]; then
4+
sed -i '1s|^|project(foo LANGUAGES C CXX)\n|' CMakeLists.txt
5+
fi
6+
7+
for f in "$@"; do
8+
case "${f}" in
9+
-DCMAKE_TOOLCHAIN_FILE=* )
10+
sed -i "${f#-DCMAKE_TOOLCHAIN_FILE=}" \
11+
-e 's|\(set(CMAKE_SYSTEM_NAME\) "Android")|\1 "Linux")|g'
12+
;;
13+
esac
14+
done
15+
16+
exec @CMAKE@ "$@"

0 commit comments

Comments
 (0)