forked from sabamdarif/termux-desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenable-hw-acceleration
executable file
·222 lines (204 loc) · 11.4 KB
/
enable-hw-acceleration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/data/data/com.termux/files/usr/bin/bash
function check_termux() {
if [[ $HOME != *termux* ]]; then
echo "${R}[${R}☓${R}]${R}${BOLD}Please run it inside termux${W}"
exit 0
fi
}
function hw_install_required_packages() {
banner
# Determine device architecture
device_arch=$(uname -m)
case "$device_arch" in
aarch64|arm64)
archtype="aarch64"
;;
arm|armhf|armv7l)
archtype="arm"
;;
*)
print_failed "Unsupported architecture"
return
;;
esac
if [[ "$confirmation_mesa_vulkan_icd_wrapper" == "y" ]]; then
if [[ "$archtype" == "aarch64" || "$archtype" == "arm" ]]; then
echo "${R}[${C}-${R}]${G}${BOLD} Installing mesa-vulkan-icd-wrapper Driver...${W}"
echo
download_file "mesa-vulkan-icd-wrapper.deb" "https://github.com/sabamdarif/termux-desktop/releases/download/mesa-vulkan-24.3.1-3/mesa-vulkan-icd-wrapper_24.3.1-3_${archtype}.deb"
apt install ./mesa-vulkan-icd-wrapper.deb -y
check_and_delete "mesa-vulkan-icd-wrapper.deb"
fi
fi
# Remove existing conflicting packages if using pacman
if [[ "$PACKAGE_MANAGER" == "pacman" ]]; then
package_check_and_remove "mesa vulkan-loader"
fi
case "$termux_hw_answer" in
"zink"|"zink_virgl"|"zink_with_mesa_zink")
package_install_and_check "mesa-zink virglrenderer-mesa-zink vulkan-loader-generic angle-android virglrenderer-android"
;;
"zink_with_mesa")
# if [[ "$archtype" == "aarch64" || "$archtype" == "arm" ]]; then
# wget -O mesa.deb https://github.com/sabamdarif/termux-desktop/releases/download/mesa-vulkan/mesa_24.2.6-1_${archtype}.deb
# apt install ./mesa.deb -y
# check_and_delete "mesa.deb"
# fi
package_install_and_check "mesa virglrenderer vulkan-loader-generic angle-android virglrenderer-android"
;;
"virgl")
package_install_and_check "angle-android virglrenderer-android"
;;
"virgl_vulkan")
package_install_and_check "mesa virglrenderer vulkan-loader-generic angle-android virglrenderer-android"
;;
"freedreno")
# package_install_and_check "mesa-zink mesa-zink-vulkan-icd-freedreno mesa-vulkan-icd-freedreno-dri3"
if [[ "$archtype" == "aarch64" || "$archtype" == "arm" ]]; then
echo "${R}[${C}-${R}]${G}${BOLD} Installing mesa-vulkan-icd-freedreno Driver...${W}"
echo
download_file "mesa-freedreno.deb" "https://github.com/sabamdarif/termux-desktop/releases/download/mesa-vulkan/mesa-vulkan-icd-freedreno_24.3.1-1_${archtype}.deb"
apt install ./mesa-freedreno.deb -y
check_and_delete "mesa-freedreno.deb"
download_file "mesa-vulkan-icd-swrast.deb" "https://github.com/sabamdarif/termux-desktop/releases/download/mesa-vulkan/mesa-vulkan-icd-swrast_24.3.1-1_${archtype}.deb"
apt install ./mesa-vulkan-icd-swrast.deb -y
check_and_delete "mesa-vulkan-icd-swrast.deb"
fi
package_install_and_check "mesa mesa-dev osmesa"
;;
*)
package_install_and_check "mesa-zink virglrenderer-mesa-zink vulkan-loader-generic angle-android virglrenderer-android"
;;
esac
if [[ "$confirmation_mesa_vulkan_icd_wrapper" == "y" ]]; then
package_install_and_check "clvk"
# package_install_and_check "opencl-vendor-driver"
fi
if [[ "$termux_hw_answer" == "virgl_vulkan" ]]; then
if [[ ! -f /data/data/com.termux/files/usr/opt/angle-android/vulkan/libEGL.so.1 ]]; then
ln -s /data/data/com.termux/files/usr/opt/angle-android/vulkan/libEGL_angle.so /data/data/com.termux/files/usr/opt/angle-android/vulkan/libEGL.so.1
fi
if [[ ! -f /data/data/com.termux/files/usr/opt/angle-android/vulkan/libGLESv1_CM.so.1 ]]; then
ln -s /data/data/com.termux/files/usr/opt/angle-android/vulkan/libGLESv1_CM_angle.so /data/data/com.termux/files/usr/opt/angle-android/vulkan/libGLESv1_CM.so.1
fi
if [[ ! -f /data/data/com.termux/files/usr/opt/angle-android/vulkan/libGLESv2.so.2 ]]; then
ln -s /data/data/com.termux/files/usr/opt/angle-android/vulkan/libGLESv2_angle.so /data/data/com.termux/files/usr/opt/angle-android/vulkan/libGLESv2.so.2
fi
fi
}
#########################################################################
#
# Set HW Environment Variables
#
#########################################################################
function setup_hw_environment_variables() {
case "$termux_hw_answer" in
"zink")
set_to_export="MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 ZINK_DESCRIPTORS=lazy"
hw_method="GALLIUM_DRIVER=zink MESA_GL_VERSION_OVERRIDE=4.0"
initialize_server_method="virgl_test_server --use-egl-surfaceless --use-gles"
pd_hw_method="${hw_method}"
;;
"virgl")
set_to_export="MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.1COMPAT MESA_GLES_VERSION_OVERRIDE=3.2"
hw_method="GALLIUM_DRIVER=virpipe"
initialize_server_method="virgl_test_server_android --angle-gl"
pd_hw_method="${hw_method}"
;;
"virgl_vulkan")
set_to_export="MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.1COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 MESA_GLSL_VERSION_OVERRIDE=410 LIBGL_DRI3_DISABLE=1 EPOXY_USE_ANGLE=1 LD_LIBRARY_PATH=/data/data/com.termux/files/usr/opt/angle-android/vulkan"
hw_method="GALLIUM_DRIVER=virpipe"
initialize_server_method="virgl_test_server --use-egl-surfaceless --use-gles"
pd_hw_method="${hw_method}"
;;
"zink_virgl")
set_to_export="MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy"
initialize_server_method="virgl_test_server --use-egl-surfaceless --use-gles"
hw_method="GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0"
pd_hw_method="${hw_method}"
;;
"zink_with_mesa")
set_to_export="MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2"
hw_method="GALLIUM_DRIVER=zink"
initialize_server_method=" "
pd_hw_method="${hw_method}"
;;
"zink_with_mesa_zink")
set_to_export="MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2"
hw_method="GALLIUM_DRIVER=zink"
initialize_server_method=" "
pd_hw_method="${hw_method}"
;;
"freedreno")
set_to_export="MESA_NO_ERROR=1 vblank_mode=0"
initialize_server_method=" "
hw_method="MESA_LOADER_DRIVER_OVERRIDE=kgsl MESA_GL_VERSION_OVERRIDE=3.3"
pd_hw_method="${hw_method}"
;;
esac
case "$pd_hw_answer" in
"zink")
pd_hw_method="GALLIUM_DRIVER=zink MESA_GL_VERSION_OVERRIDE=4.0"
;;
virgl|zink_virgl)
pd_hw_method="GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0"
;;
"turnip")
pd_hw_method="MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform"
;;
"freedreno")
pd_hw_method="MESA_LOADER_DRIVER_OVERRIDE=kgsl MESA_GL_VERSION_OVERRIDE=3.3"
;;
*)
echo "${R}[${C}-${R}]${G} Uses The Previous Selection For Distro${W}"
echo
;;
esac
}
function setup_gpu_specific_environment_variables() {
if [[ "$confirmation_mesa_vulkan_icd_wrapper" == "y" ]]; then
if [[ "$device_gpu_model_name" == "adreno" ]]; then
gpu_environment_variable="VK_ICD_FILENAMES=$PREFIX/share/vulkan/icd.d/wrapper_icd.aarch64.json MESA_SHADER_CACHE=512MB MESA_SHADER_CACHE_DISABLE=false vblank_mode=0"
elif [[ "$device_gpu_model_name" == "mali" ]]; then
gpu_environment_variable="VK_ICD_FILENAMES=$PREFIX/share/vulkan/icd.d/wrapper_icd.aarch64.json MESA_VK_WSI_PRESENT_MODE=mailbox MESA_VK_WSI_DEBUG=blit MESA_SHADER_CACHE=512MB MESA_SHADER_CACHE_DISABLE=false vblank_mode=0"
elif [[ "$device_gpu_model_name" == "xclipse" ]]; then
gpu_environment_variable="VK_ICD_FILENAMES=$PREFIX/share/vulkan/icd.d/wrapper_icd.aarch64.json vblank_mode=0"
else
gpu_environment_variable="VK_ICD_FILENAMES=$PREFIX/share/vulkan/icd.d/wrapper_icd.aarch64.json MESA_SHADER_CACHE=512MB MESA_SHADER_CACHE_DISABLE=false vblank_mode=0"
fi
fi
}
# function set_mesa_extension() {
# if [[ virgl d3d ]]; then
# export MESA_EXTENSION_OVERRIDE="+GL_3DFX_texture_compression_FXT1 +GL_AMD_vertex_shader_viewport_index +GL_AMD_vertex_shader_layer +GL_ARB_vertex_type_10f_11f_11f_rev +GL_ARB_texture_view +GL_ARB_texture_query_lod +GL_ARB_texture_filter_minmax +GL_ARB_shading_language_100 +GL_ARB_shader_viewport_layer_array +GL_ARB_shader_texture_image_samples +GL_ARB_shader_stencil_export +GL_ARB_shader_group_vote +GL_ARB_compute_shader +GL_ARB_compute_variable_group_size +GL_ARB_shader_draw_parameters +GL_ARB_seamless_cubemap_per_texture +GL_ARB_depth_clamp +GL_ARB_blend_func_extended +GL_ARB_ES3_1_compatibility +GL_ARB_ES3_compatibility +GL_ARM_shader_framebuffer_fetch_depth_stencil +GL_ARB_shader_atomic_counters +GL_ARB_shader_atomic_counter_ops"
# else
# export MESA_EXTENSION_OVERRIDE="+GL_3DFX_texture_compression_FXT1 +GL_AMD_vertex_shader_viewport_index +GL_AMD_vertex_shader_layer +GL_ARB_vertex_type_10f_11f_11f_rev +GL_ARB_texture_view +GL_ARB_texture_query_lod +GL_ARB_texture_filter_minmax +GL_ARB_shading_language_100 +GL_ARB_shader_viewport_layer_array +GL_ARB_shader_texture_image_samples +GL_ARB_shader_stencil_export +GL_ARB_shader_group_vote +GL_ARB_compute_shader +GL_ARB_compute_variable_group_size +GL_ARB_shader_draw_parameters +GL_ARB_seamless_cubemap_per_texture +GL_ARB_depth_clamp +GL_ARB_blend_func_extended +GL_ARB_ES3_1_compatibility +GL_ARB_ES3_compatibility -GL_EXT_texture_sRGB -GL_EXT_texture_sRGB_R8 -GL_EXT_texture_sRGB_RG8 +GL_ARM_shader_framebuffer_fetch_depth_stencil +GL_ARB_shader_atomic_counters +GL_ARB_shader_atomic_counter_ops"
# fi
# }
#########################################################################
#
# Setup Turnip
#
#########################################################################
function setup_turnip_proot() {
banner
echo "${R}[${C}-${R}]${G}${BOLD} Setting up Turnip for $selected_distro ...${W}"
echo
if [[ "$selected_distro" == "debian" ]] || [[ "$selected_distro" == "ubuntu" ]]; then
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 apt install xdg-desktop-portal libgl1 libgl1-mesa-dri libvulkan1 glmark2 -y
if [[ "$selected_distro" == "ubuntu" ]]; then
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 apt install mesa-vulkan-drivers libllvm15t64 -y
fi
download_file "mesa-vulkan-kgsl_arm64.deb" "https://github.com/sabamdarif/termux-desktop/releases/download/mesa-vulkan/mesa-vulkan-kgsl_24.1.0-devel-20240120_arm64.deb"
mv mesa-vulkan-kgsl_arm64.deb $distro_path/root/
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 dpkg -i mesa-vulkan-kgsl_arm64.deb
proot-distro login $selected_distro --shared-tmp -- env DISPLAY=:1.0 rm mesa-vulkan-kgsl_arm64.deb
fi
}
check_termux
hw_install_required_packages
setup_hw_environment_variables
setup_gpu_specific_environment_variables
if [[ "$pd_hw_answer" == "turnip" ]] || [[ "$device_gpu_model_name" == "adreno" && "$pd_hw_answer" == "turnip" ]]; then
setup_turnip_proot
fi