summaryrefslogtreecommitdiffstats
path: root/display/renderer/device-files/llvmpipe.sh
blob: d40c4ec30a8c2cca5d7bb2c47b6f5c8c17e38155 (plain)
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
#!/system/xbin/bash
#
# Copyright (C) 2017 Jeremy Rand <jeremy@veclabs.net>
# Partially based on code by Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> and Filippo Fil Bergamo
#
# This file is part of "Replicant Renderer Switcher", a set of shell scripts to switch between
# the Android Software Renderer and the llvmpipe renderer in Replicant.
#
# Replicant Renderer Switcher is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Replicant Renderer Switcher is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set -euf -o pipefail

grep -q "ro.libagl=0" /system/build.prop && renderer="llvmpipe" || renderer="android"

if [ "${renderer}" == "llvmpipe" ]
then
    echo "llvmpipe is already enabled!"
    exit 1
fi

echo "Remounting system partition as writable..."
mount -o rw,remount /system

echo "Enabling llvmpipe..."
sed "s/ro.libagl=1/ro.libagl=0/" -i /system/build.prop

echo "Syncing filesystem..."
sync
sync

echo "Remounting system partition as read-only..."
mount -o ro,remount /system

echo "Syncing filesystem..."
sync
sync

# https://android.stackexchange.com/a/139139
echo "llvmpipe will be enabled after we reboot now..."
am start -a android.intent.action.REBOOT