Skip to content

Commit 89dbef2

Browse files
build: add android test build
Signed-off-by: DreamConnected <1487442471@qq.com>
1 parent f019de6 commit 89dbef2

12 files changed

Lines changed: 287 additions & 11 deletions

File tree

.github/workflows/android.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Android-arm64-Builds
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
ndk_version:
6+
description: 'Android NDK version'
7+
required: false
8+
default: 'r28c'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Android NDK
17+
uses: nttld/setup-ndk@v1
18+
with:
19+
ndk-version: ${{ github.event.inputs.ndk_version || 'r28c' }}
20+
21+
- name: Install dependencies
22+
run: |
23+
sudo apt-get install -y -qq build-essential pipx python3-venv pkg-config cmake docbook2x \
24+
python3-pip pipx jq
25+
sudo npm install -g conventional-changelog-cli
26+
conventional-changelog -o CHANGELOG.md -r 2
27+
pipx ensurepath
28+
pipx install meson==0.61
29+
pipx install ninja
30+
31+
- name: Download Dependencies
32+
run: |
33+
libepoxy=$(curl -s https://api.github.com/repos/DreamConnected/libepoxy-dev/releases/latest | grep browser_download_url | cut -d'"' -f4 |grep -E 'zip$')
34+
libepoxy_file=$(curl -s https://api.github.com/repos/DreamConnected/libepoxy-dev/releases/latest | grep name | cut -d'"' -f4 |grep -E 'zip$')
35+
wget -q ${libepoxy} && sudo unzip -q -o ${libepoxy_file} -d / && echo 1/1 ${libepoxy} ${libepoxy_file}
36+
37+
- name: Build virglrenderer for Android
38+
run: |
39+
sed -i "s|android-ndk-r28c|$ANDROID_NDK_HOME|g" aarch64-android-api30.txt
40+
export PKG_CONFIG_PATH=/data/share/lib/pkgconfig:/data/share/lib64/pkgconfig:$PKG_CONFIG_PATH
41+
42+
meson setup build \
43+
-Dvenus=true \
44+
-Dvulkan-dload=true \
45+
-Dplatforms=egl \
46+
-Dvideo=false \
47+
-Drender-server-worker=thread \
48+
-Ddrm-renderers= \
49+
-Dtests=false \
50+
-Dfuzzer=false \
51+
-Dvalgrind=false \
52+
-Dtracing=none \
53+
--prefix=/data/share \
54+
--cross-file=aarch64-android-api30.txt
55+
56+
meson compile -C build
57+
sudo /usr/local/bin/ninja -C build install
58+
echo "RELEASE_TAG=$(meson introspect meson.build --projectinfo | jq -r '.version')-$(git log -1 --format=%h)" >> $GITHUB_ENV
59+
60+
- name: Upload artifacts virglrenderer
61+
uses: actions/upload-artifact@v4.3.1
62+
with:
63+
name: android-${{ github.event.inputs.target_arch || 'aarch64' }}-virglrenderer
64+
path: /data/share/*
65+
66+
- name: Create a TAR file for artifact
67+
run: |
68+
tar -czvf android-${{ github.event.inputs.target_arch || 'aarch64' }}-api30-virglrenderer.tar.gz -C /data/share .
69+
70+
- name: Create Release and Upload Release Asset
71+
uses: softprops/action-gh-release@v1
72+
with:
73+
tag_name: ${{ env.RELEASE_TAG }}
74+
name: Release ${{ env.RELEASE_TAG }}
75+
body_path: CHANGELOG.md
76+
draft: false
77+
prerelease: false
78+
files: |
79+
android-${{ github.event.inputs.target_arch || 'aarch64' }}-api30-virglrenderer.tar.gz

.github/workflows/sync.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sync Fork
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 1 * *' # every first day of month 00:00
6+
workflow_dispatch: # on button click
7+
8+
jobs:
9+
sync:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Git
20+
run: |
21+
git config user.name "GitHub Actions"
22+
git config user.email "actions@github.com"
23+
24+
- name: Add upstream and fetch
25+
run: |
26+
git remote add upstream https://gitlab.freedesktop.org/virgl/virglrenderer.git 2>/dev/null || true
27+
git fetch upstream
28+
git fetch origin
29+
git checkout -b upstream upstream/main
30+
31+
- uses: tgymnich/fork-sync@v2.0.10
32+
with:
33+
owner: Container-On-Android
34+
base: main
35+
head: upstream
36+
pr_title: "Merge upstream branch 'main'"
37+
pr_message: "Merge branch 'virglrenderer:main' into main"
38+
auto_merge: false
39+
merge_method: rebase
40+
ignore_fail: true

README.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,114 @@ This project uses the meson build system:
2020
$ cd build
2121
$ ninja install
2222
23+
How to use
24+
----------
2325

26+
.. code-block:: sh
27+
28+
$ virgl_test_server --venus --no-fork --multi-clients \
29+
--use-egl-surfaceless --use-gles \
30+
--socket-path=/data/share/tmp/.virgl_test
31+
32+
Performance
33+
-----------
34+
35+
LLVM host:
36+
37+
.. code-block:: sh
38+
39+
$ glxgears -info
40+
GL_RENDERER = llvmpipe (LLVM 21.1.8, 128 bits)
41+
GL_VERSION = 4.5 (Compatibility Profile) Mesa 25.3.2
42+
GL_VENDOR = Mesa
43+
GL_EXTENSIONS = ...
44+
VisualID 979, 0x3d3
45+
958 frames in 5.0 seconds = 191.490 FPS
46+
983 frames in 5.0 seconds = 196.580 FPS
47+
48+
ZINK host:
49+
50+
.. code-block:: sh
51+
52+
$ glxgears -info
53+
GL_RENDERER = zink Vulkan 1.1(Mali-G76 (Driver Unknown))
54+
GL_VERSION = 2.1 Mesa 24.3.0-devel (git-c1567e9609)
55+
GL_VENDOR = Mesa
56+
GL_EXTENSIONS = ...
57+
VisualID 979, 0x3d3
58+
1263 frames in 5.0 seconds = 252.593 FPS
59+
1163 frames in 5.0 seconds = 232.317 FPS
60+
61+
virgl host:
62+
63+
.. code-block:: sh
64+
65+
$ glxgears -info
66+
GL_RENDERER = virgl (Mali-G76)
67+
GL_VERSION = 4.5 (Compatibility Profile) Mesa 25.3.2
68+
GL_VENDOR = Mesa
69+
GL_EXTENSIONS = ...
70+
VisualID 979, 0x3d3
71+
780 frames in 5.0 seconds = 155.832 FPS
72+
732 frames in 5.0 seconds = 146.298 FPS
73+
74+
virgl guest(lxc):
75+
76+
.. code-block:: sh
77+
78+
$ glxgears -info
79+
GL_RENDERER = virgl (Mali-G76)
80+
GL_VERSION = 3.2 (Compatibility Profile) Mesa 25.0.7-0ubuntu0.25.04.2
81+
GL_VENDOR = Mesa
82+
GL_EXTENSIONS = ...
83+
VisualID 979, 0x3d3
84+
629 frames in 5.0 seconds = 125.653 FPS
85+
604 frames in 5.0 seconds = 120.691 FPS
86+
87+
Venus
88+
-----
89+
.. code-block:: sh
90+
91+
$ vulkaninfo --summary
92+
Devices:
93+
========
94+
GPU0:
95+
apiVersion = 1.1.82
96+
driverVersion = 104857607
97+
vendorID = 0x13b5
98+
deviceID = 0x72110000
99+
deviceType = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
100+
deviceName = Virtio-GPU Venus (Mali-G76)
101+
102+
fastfetch
103+
---------
104+
105+
.. code-block:: sh
106+
107+
root@ubuntu:~# fastfetch
108+
.... root@ubuntu
109+
.',:clooo: .:looooo:. -----------
110+
.;looooooooc .oooooooooo' OS: Ubuntu 25.04 aarch64
111+
.;looooool:,''. :ooooooooooc Host: kirin980
112+
;looool;. 'oooooooooo, Kernel: Linux 4.9.148-DreamConnected-All-in-One+
113+
;clool' .cooooooc. ,, Uptime: 1 day, 16 hours, 38 mins
114+
... ...... .:oo, Packages: 2384 (dpkg)
115+
.;clol:,. .loooo' Shell: bash 5.2.37
116+
:ooooooooo, 'ooool Display (builtin): 1080x2310 @ 60 Hz
117+
'ooooooooooo. loooo. Theme: Breeze [GTK2/3]
118+
'ooooooooool coooo. Icons: breeze [GTK2/3/4]
119+
,loooooooc. .loooo. Font: Noto Sans (10pt) [GTK2/3/4]
120+
.,;;;'. ;ooooc Cursor: breeze (24px)
121+
... ,ooool. Terminal: vt220
122+
.cooooc. ..',,'. .cooo. CPU: kirin980 (8) @ 2.60 GHz
123+
;ooooo:. ;oooooooc. :l. GPU: Virtio-GPU Venus (Mali-G76) [Integrated]
124+
.coooooc,.. coooooooooo. Memory: 3.82 GiB / 5.53 GiB (69%)
125+
.:ooooooolc:. .ooooooooooo' Swap: 53.91 MiB / 6.00 GiB (1%)
126+
.':loooooo; ,oooooooooc Disk (/): 39.44 GiB / 108.22 GiB (36%) - f2fs
127+
..';::c' .;loooo:' Local IP (eth0): 10.0.3.11/24
128+
Battery: 95% [Charging, AC Connected]
129+
Locale: en_US.UTF-8
130+
24131
Support
25132
-------
26133

aarch64-android-api30.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[binaries]
2+
c = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang'
3+
cpp = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++'
4+
ar = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
5+
as = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as'
6+
ld = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ld'
7+
strip = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
8+
ranlib = 'android-ndk-r28c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib'
9+
pkgconfig = '/usr/bin/pkg-config'
10+
cmake = '/usr/bin/cmake'
11+
12+
[host_machine]
13+
system = 'linux'
14+
cpu_family = 'aarch64'
15+
cpu = 'aarch64'
16+
endian = 'little'
17+
18+
[target_machine]
19+
system = 'android'
20+
cpu_family = 'aarch64'
21+
cpu = 'aarch64'
22+
endian = 'little'

config.h.meson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#mesondefine ENABLE_VIDEO
5656
#mesondefine ENABLE_TRACING
5757
#mesondefine ENABLE_TESTS
58+
#mesondefine IS_BIONIC
5859
#mesondefine UTIL_ARCH_LITTLE_ENDIAN
5960
#mesondefine UTIL_ARCH_BIG_ENDIAN
6061
#mesondefine PIPE_ARCH_X86

meson.build

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ conf_data.set('_GNU_SOURCE', 1)
9393
# APIs. Unstable APIs may be changed or removed without a notice.
9494
conf_data.set('VIRGL_RENDERER_UNSTABLE_APIS', 1)
9595

96+
## Android
97+
have = cc.get_id().contains('clang') and cc.has_header('android/log.h')
98+
conf_data.set10('IS_BIONIC', have)
99+
96100
drm_renderers = get_option('drm-renderers')
97101

98102
with_drm_msm = drm_renderers.contains('msm')
@@ -116,7 +120,12 @@ if with_drm_renderers
116120
conf_data.set('ENABLE_DRM', 1)
117121
endif
118122

119-
libdrm_dep = dependency('libdrm', version : '>=2.4.50', required: with_drm_renderers or get_option('video'))
123+
if conf_data.get('IS_BIONIC') == true
124+
libdrm_dep = dependency('libdrm', required: false)
125+
liblog_dep = cc.find_library('log', required: true)
126+
else
127+
libdrm_dep = dependency('libdrm', version : '>=2.4.50', required: with_drm_renderers or get_option('video'))
128+
endif
120129
libdrm_amdgpu_dep = dependency('libdrm_amdgpu', version : '>=2.4.121', required: with_drm_amdgpu)
121130
conf_data.set('ENABLE_LIBDRM', libdrm_dep.found())
122131
drm_uapi_dep = declare_dependency(
@@ -172,6 +181,7 @@ endif
172181

173182
with_host_windows = host_machine.system() == 'windows'
174183
with_host_darwin = host_machine.system() == 'darwin'
184+
with_target_android = target_machine.system() == 'android'
175185

176186
if thread_dep.found() and not with_host_windows
177187
conf_data.set('HAVE_PTHREAD', 1)
@@ -279,7 +289,7 @@ have_glx = false
279289

280290
if with_egl
281291
if cc.has_header('epoxy/egl.h', dependencies: epoxy_dep) and epoxy_dep.get_variable(pkgconfig: 'epoxy_has_egl') == '1'
282-
if with_host_windows or with_host_darwin
292+
if with_host_windows or with_host_darwin or with_target_android
283293
have_egl = true
284294
else
285295
if libdrm_dep.found()

src/mesa/util/os_misc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@
5454

5555
#if DETECT_OS_ANDROID
5656
# define LOG_TAG "MESA"
57-
# include <unistd.h>
58-
# include <log/log.h>
59-
# include <cutils/properties.h>
57+
# include <android/log.h>
58+
# include <sys/system_properties.h>
59+
# define LOG_PRI(priority, tag, ...) __android_log_print(priority, tag, __VA_ARGS__)
60+
# define PROPERTY_VALUE_MAX PROP_VALUE_MAX
61+
# define PROPERTY_KEY_MAX PROP_NAME_MAX
6062
#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD
6163
# include <unistd.h>
6264
#elif DETECT_OS_OPENBSD || DETECT_OS_FREEBSD
@@ -188,7 +190,7 @@ os_get_android_option(const char *name)
188190
}
189191

190192
const char *opt = NULL;
191-
int len = property_get(key, value, NULL);
193+
int len = __system_property_get(key, value);
192194
if (len > 1) {
193195
opt = ralloc_strdup(options_tbl, value);
194196
}

src/meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,16 @@ video_sources = [
141141
virgl_depends = [
142142
gallium_dep,
143143
epoxy_dep,
144-
libdrm_dep,
145144
thread_dep,
146145
m_dep,
147146
]
148147

148+
if conf_data.get('IS_BIONIC') == true
149+
virgl_depends += [liblog_dep]
150+
else
151+
virgl_depends += [libdrm_dep]
152+
endif
153+
149154
if with_tracing == 'perfetto'
150155
virgl_depends += [vperfetto_min_dep]
151156
endif

src/vrend/vrend_winsys.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static struct virgl_glx *glx_info = NULL;
5555
int vrend_winsys_init(uint32_t flags, int preferred_fd)
5656
{
5757
if (flags & VIRGL_RENDERER_USE_EGL) {
58-
#ifdef ENABLE_GBM
58+
#if defined(ENABLE_GBM) && !IS_BIONIC
5959
/*
6060
* If the user specifies a preferred DRM fd and we can't use it, fail. If the user doesn't
6161
* specify an fd, it's possible to initialize EGL without one.
@@ -75,6 +75,13 @@ int vrend_winsys_init(uint32_t flags, int preferred_fd)
7575
return -1;
7676
}
7777

78+
use_context = CONTEXT_EGL;
79+
#elif IS_BIONIC
80+
(void)preferred_fd;
81+
egl = virgl_egl_init(NULL, flags & VIRGL_RENDERER_USE_SURFACELESS,
82+
flags & VIRGL_RENDERER_USE_GLES);
83+
if (!egl) return -1;
84+
7885
use_context = CONTEXT_EGL;
7986
#else
8087
(void)preferred_fd;

src/vrend/vrend_winsys_egl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <stdbool.h>
4242
#include <unistd.h>
4343

44-
#ifdef ENABLE_LIBDRM
44+
#if defined(ENABLE_LIBDRM) && !IS_BIONIC
4545
#include <xf86drm.h>
4646
#endif
4747

0 commit comments

Comments
 (0)