Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize egl driver prop setting logic #1983

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 45 additions & 31 deletions groups/graphics/auto/auto_hal.in
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
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" = "0x8086" ]; then
found=1
break
fi
done
echo $found
}

has_virgl() {
# Assume that virgl is always available unless it's explicitly ruled out.
local found=1
for f in /sys/kernel/debug/dri/*; do
if [ ! -e "$f/virtio-gpu-features" ]; then
continue
fi
# Note that it's likely that we don't have debugfs in user build,
# but we don't have better way to check accessibility of virgl
# for now.
if [ "$(cat $f/virtio-gpu-features |grep virgl |awk '{print $3}')" = "no" ]; then
found=0
break
fi
done
echo $found
}

update_graphics_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_graphics_driver_prop

Loading