-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize egl driver prop setting logic
We want to enable hardware rendering as long as if Intel GPU is present. Previously only /proc/fb and card0 were considered. Test-done: Boot AAOS with virtio-GPU as card0. Tracked-On: OAM-122705 Signed-off-by: Weifeng Liu <[email protected]>
- Loading branch information
Showing
1 changed file
with
41 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,47 @@ | ||
update_graphics() { | ||
case "$(cat /proc/fb)" in | ||
*i915*) | ||
echo "i915 rendering" | ||
has_intel_gpu() { | ||
local found=0 | ||
for f in /sys/class/drm/card*; do | ||
if [ ! -e "$f"/device/vendor ]; then | ||
continue | ||
fi | ||
local vendor=$(cat "$f"/device/vendor) | ||
if [ "$vendor" = "0x1a03" ]; then | ||
found=1 | ||
break | ||
fi | ||
done | ||
echo $found | ||
} | ||
|
||
has_virgl() { | ||
local found=0 | ||
for f in /sys/kernel/debug/dri/*; do | ||
if [ ! -e "%f/virtio-gpu-features" ]; then | ||
continue | ||
fi | ||
if [ "$(cat $f/virtio-gpu-features |grep virgl |awk '{print $3}')" = "yes" ]; then | ||
found=1 | ||
return | ||
fi | ||
done | ||
echo $found | ||
} | ||
|
||
update_egl_driver_prop() { | ||
if [ "$(has_intel_gpu)" = "1" ]; then | ||
echo "Use Intel GPU for rendering" | ||
setprop vendor.egl.set mesa | ||
setprop vendor.vulkan.set intel | ||
;; | ||
*intel*) | ||
echo "intel rendering" | ||
elif [ "$(has_virgl)" = "1" ]; then | ||
echo "use virtio-GPU for rendering" | ||
setprop vendor.egl.set mesa | ||
setprop vendor.vulkan.set intel | ||
;; | ||
*virtio*) | ||
if [ "$(cat /sys/kernel/debug/dri/0/name |awk '{print $1}')" = "i915" ];then | ||
echo "sriov rendering" | ||
setprop vendor.egl.set mesa | ||
setprop vendor.vulkan.set intel | ||
else | ||
if [ "$(cat /sys/kernel/debug/dri/0/virtio-gpu-features |grep virgl |awk '{print $3}')" = "no" ];then | ||
echo "angle rendering" | ||
setprop vendor.egl.set angle | ||
setprop vendor.vulkan.set pastel | ||
else | ||
echo "virtio rendering" | ||
setprop vendor.egl.set mesa | ||
setprop vendor.vulkan.set pastel | ||
fi | ||
fi | ||
;; | ||
*) | ||
echo "sw rendering" | ||
setprop vendor.vulkan.set pastel | ||
else | ||
echo "use software rendering" | ||
setprop vendor.egl.set angle | ||
setprop vendor.vulkan.set pastel | ||
;; | ||
esac | ||
fi | ||
} | ||
update_graphics | ||
|
||
update_egl_driver_prop | ||
|