Skip to content

Commit

Permalink
Optimize egl driver prop setting logic
Browse files Browse the repository at this point in the history
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
phreer committed Jul 25, 2024
1 parent f9c963b commit fc33116
Showing 1 changed file with 41 additions and 31 deletions.
72 changes: 41 additions & 31 deletions groups/graphics/auto/auto_hal.in
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

0 comments on commit fc33116

Please sign in to comment.