Termux proot mesa freedreno kgsl 빌드하기
안녕하세요? 아래 깃을 보고 proot 에서 사용할 수 있는 mesa를 빌드해보겠습니다.
https://github.com/xMeM/termux-packages/actions/runs/10418112154
일단 패치내용이 정식 mesa 에는 머지되지 않은게 있음으로 수동으로 패치를 머지해야합니다.
일단 이전글을 보고 오시면 컴파일하기 수월합니다.
https://blog.djjproject.com/830
1. mesa download
root@localhost:~# mkdir -p mesa root@localhost:~/mesa# wget https://archive.mesa3d.org/mesa-24.2.0.tar.xz root@localhost:~/mesa# tar xf mesa-24.2.0.tar.xz |
2. termux 소스 다운로드
root@localhost:~# git clone https://github.com/xMeM/termux-packages.git -b dev/mesa --single-branch |
그리고 아래 패치들을 확인합니다.
root@localhost:~/termux-packages/packages/mesa# ls 0001-disable-multithreading-for-llvmpipe.patch 0002-fix-detect-os.patch 0003-fix-for-anon-file.patch 0004-do-not-check-xlocale.patch 0005-virgl-socket-path.patch 0006-wsi-no-pthread_cancel.patch 0007-use-mtx_t-operations-in-turnip.patch 0008-workaround-fortify-check.patch 0009-disable-resource_create_front-for-vtest.patch 0010-zink-fixes.patch 0011-freedreno-drm-kgsl-Add-KGSL-backend-for-freedreno.patch 0012-freedreno-drm-Add-more-APIs-to-per-backend-API.patch 0013-fix-bad-syscall.patch 0014-freedreno-HACK-GL_ARB_timer_query.patch 0015-termux-x11-kgsl.patch build.sh cmake-wrapper.in mesa-dev.subpackage.sh mesa-vulkan-icd-freedreno.subpackage.sh mesa-vulkan-icd-swrast.subpackage.sh osmesa.subpackage.sh |
여기서 0008 번은 proot 환경에서 컴파일 할 때 에러가 발생합니다.
그래서 8번은 빼고 적용해야합니다.
3. mesa 소스 패치 적용
root@localhost:~/termux-packages/packages/mesa# cd ~/mesa/mesa-24.2.0/ |
아래 순서대로 적용합니다.
patch -p1 < ../../termux-packages/packages/mesa/0001-disable-multithreading-for-llvmpipe.patch patch -p1 < ../../termux-packages/packages/mesa/0002-fix-detect-os.patch patch -p1 < ../../termux-packages/packages/mesa/0003-fix-for-anon-file.patch patch -p1 < ../../termux-packages/packages/mesa/0004-do-not-check-xlocale.patch patch -p1 < ../../termux-packages/packages/mesa/0005-virgl-socket-path.patch patch -p1 < ../../termux-packages/packages/mesa/0006-wsi-no-pthread_cancel.patch patch -p1 < ../../termux-packages/packages/mesa/0007-use-mtx_t-operations-in-turnip.patch patch -p1 < ../../termux-packages/packages/mesa/0008-workaround-fortify-check.patch patch -p1 < ../../termux-packages/packages/mesa/0009-disable-resource_create_front-for-vtest.patch patch -p1 < ../../termux-packages/packages/mesa/0010-zink-fixes.patch patch -p1 < ../../termux-packages/packages/mesa/0011-freedreno-drm-kgsl-Add-KGSL-backend-for-freedreno.patch patch -p1 < ../../termux-packages/packages/mesa/0012-freedreno-drm-Add-more-APIs-to-per-backend-API.patch patch -p1 < ../../termux-packages/packages/mesa/0013-fix-bad-syscall.patch patch -p1 < ../../termux-packages/packages/mesa/0014-freedreno-HACK-GL_ARB_timer_query.patch patch -p1 < ../../termux-packages/packages/mesa/0015-termux-x11-kgsl.patch |
그리고 아래 패키지 설정을 합니다.
root@localhost:~/mesa/mesa-24.2.0# meson build -Dgbm=enabled -Dopengl=true -Degl=enabled -Degl-native-platform=x11 -Dgles1=disabled -Dgles2=enabled -Ddri3=enabled -Dglx=dri -Dllvm=enabled -Dshared-llvm=disabled -Dplatforms=x11,wayland -Dgallium-drivers=swrast,virgl,zink,freedreno -Dvulkan-drivers=swrast,freedreno -Dfreedreno-kmds=msm,kgsl -Dosmesa=true -Dglvnd=true -Dxmlconfig=disabled --reconfigure --prefix=/usr --libdir=/usr/lib/aarch64-linux-gnu |
특히 컴파일 옵션에 freedreno-kmds=msm,kgsl 그리고 vulkan-drivers=freedreno 부분이 중요합니다.
중간에 vulkan-drivers 옵션에서 swrast intel <--- intel 이 선언되어 있으면 컴파일 에러가 발생하니 주의하세요.
최종 컴파일 옵션입니다.
libarchive 3.7.2 regex support: glibc mesa 24.2.0 Directories prefix : /usr libdir : lib/aarch64-linux-gnu includedir : include Common C and C++ arguments c_cpp_args : -mtls-dialect=desc OpenGL OpenGL : YES ES1 : NO ES2 : YES Shared glapi : YES GLVND : YES DRI Platform : drm Driver dir : /usr/lib/aarch64-linux-gnu/dri GLX Enabled : YES Provider : dri EGL Enabled : YES Drivers : builtin:egl_dri2 builtin:egl_dri3 Platforms : x11 wayland surfaceless drm xcb GBM Enabled : YES Backends path : /usr/lib/aarch64-linux-gnu/gbm Vulkan Drivers : swrast freedreno Platforms : x11 wayland surfaceless drm xcb ICD dir : share/vulkan/icd.d Intel Ray tracing : NO Video Codecs : av1dec av1enc vp9dec APIs : vdpau va vulkan xa LLVM Enabled : YES Version : 15.0.6 Gallium Enabled : YES Drivers : swrast virgl zink freedreno Platforms : x11 wayland surfaceless drm xcb Frontends : mesa xa vdpau va Off-screen rendering (OSMesa): libOSMesa HUD lm-sensors : YES Perfetto Enabled : NO Teflon (TensorFlow Lite delegate) Enabled : NO Subprojects libarchive : YES lua : YES User defined options libdir : /usr/lib/aarch64-linux-gnu prefix : /usr dri3 : enabled egl : enabled egl-native-platform : x11 freedreno-kmds : msm,kgsl gallium-drivers : swrast,virgl,zink,freedreno gbm : enabled gles1 : disabled gles2 : enabled glvnd : true glx : dri llvm : enabled opengl : true osmesa : true platforms : x11,wayland shared-llvm : disabled vulkan-drivers : swrast,freedreno xmlconfig : disabled |
아래 명령으로 컴파일하고 설치합니다.
root@localhost:~/mesa/mesa-24.2.0# ninja -C build install |
4. freedreno kgsl 드라이버 적용
termux 에서 proot 환경을 실행하는데 아래와 같이 수정합니다.
#!/bin/sh rm -rf ${TMPDIR}/* pkill -9 -ef "pulseaudio" pkill -9 -ef "termux.x11.Loader" # Termux-X11 start am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :0 -ac -extension MIT-SHM & sleep 1 pulseaudio --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1 & sleep 1 touch ~/bind proot-distro login debian --shared-tmp --no-sysvipc -- bash -c "rm -rf /root/.cache" proot-distro login debian --bind ~/bind:/proc/bus/pci/devices --shared-tmp --no-sysvipc -- bash -c "export DISPLAY=:0; export PULSE_SERVER=tcp:127.0.0.1:4713; MESA_LOADER_DRIVER_OVERRIDE=kgsl dbus-launch --exit-with-session xfce4-session" |
MESA_LOADER_DRIVER_OVERRIDE 를 kgsl 로 설정합니다.
환경을 다시 시작하면 turnip 로 표시되던 환경이 아래와 같이 FD740으로 표시됩니다.
glxinfo -B 는 실행에 실패하네요.
root@localhost:~# glxinfo -B name of display: :0.0 X Error of failed request: 135 Major opcode of failed request: 133 () Minor opcode of failed request: 15 Value in failed request: 0x0 Serial number of failed request: 37 Current serial number in output stream: 39 |
5. 벤치마킹
1) 이전 glxmark (turnip / zink)
root@localhost:~# glmark2 ======================================================= glmark2 2023.01 ======================================================= OpenGL Information GL_VENDOR: Mesa GL_RENDERER: zink Vulkan 1.3(Turnip Adreno (TM) 740 (MESA_TURNIP)) GL_VERSION: 4.6 (Compatibility Profile) Mesa 24.2.0-devel (git-93f790b04a) Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0 Surface Size: 800x600 windowed ======================================================= [build] use-vbo=false: FPS: 416 FrameTime: 2.406 ms [build] use-vbo=true: FPS: 512 FrameTime: 1.956 ms [texture] texture-filter=nearest: FPS: 516 FrameTime: 1.940 ms [texture] texture-filter=linear: FPS: 496 FrameTime: 2.020 ms [texture] texture-filter=mipmap: FPS: 501 FrameTime: 1.998 ms |
2) freedreno kgsl
oot@localhost:~# glmark2 ======================================================= glmark2 2023.01 ======================================================= OpenGL Information GL_VENDOR: freedreno GL_RENDERER: FD740 GL_VERSION: 4.6 (Compatibility Profile) Mesa 24.2.0 Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0 Surface Size: 800x600 windowed ======================================================= [build] use-vbo=false: FPS: 1244 FrameTime: 0.804 ms [build] use-vbo=true: FPS: 1368 FrameTime: 0.731 ms [texture] texture-filter=nearest: FPS: 1331 FrameTime: 0.752 ms [texture] texture-filter=linear: FPS: 1305 FrameTime: 0.767 ms [texture] texture-filter=mipmap: FPS: 1610 FrameTime: 0.621 ms |
이야.. ㄷㄷㄷ
프레임이 너무 잘나옵니다.... ㄷㄷㄷ
3) web aquarium
대략 50프레임이 나오네요. 이전에는 이게 .. 42프레임 정도로 측정되었습니다.
6. 이전글
Termux 한글 입력 설정하기
https://blog.djjproject.com/829
Termux proot mesa 빌드하기 (kgsl / dri3 / zink / turnip)
https://blog.djjproject.com/830
Termux proot 크롬브라우저 그림판 스크린샷 스티커메모 어플리케이션
https://blog.djjproject.com/831
7. 번외 / ksgl 장치가 실제로 활용 중?
root@localhost:~# lsof /dev/kgsl-3d0 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME main 8383 root mem CHR 474,0 1356 /dev/kgsl-3d0 main 8383 root 63u CHR 474,0 0t0 1356 /dev/kgsl-3d0 xfce4-ses 8998 root 4u CHR 474,0 0t0 1356 /dev/kgsl-3d0 xfce4-ses 8998 root 5u CHR 474,0 0t0 1356 /dev/kgsl-3d0 xfce4-ses 8998 root 6u CHR 474,0 0t0 1356 /dev/kgsl-3d0 xfwm4 9053 root 11u CHR 474,0 0t0 1356 /dev/kgsl-3d0 xfwm4 9053 root 12u CHR 474,0 0t0 1356 /dev/kgsl-3d0 xfwm4 9053 root 13u CHR 474,0 0t0 1356 /dev/kgsl-3d0 thorium 11190 root 18u CHR 474,0 0t0 1356 /dev/kgsl-3d0 thorium 11190 root 19u CHR 474,0 0t0 1356 /dev/kgsl-3d0 thorium 11190 root 20u CHR 474,0 0t0 1356 /dev/kgsl-3d0 kolourpai 18614 root 13u CHR 474,0 0t0 1356 /dev/kgsl-3d0 kolourpai 18614 root 14u CHR 474,0 0t0 1356 /dev/kgsl-3d0 kolourpai 18614 root 15u CHR 474,0 0t0 1356 /dev/kgsl-3d0 |
사용중입니다.