sway: restrict WLR_RENDERER workaround to kvm

pixman is known to not work at least on vmware, so we don't want to be
setting WLR_RENDERER indiscriminately.
This commit is contained in:
Aleksei Bavshin 2023-02-20 23:10:57 -08:00
commit 66f553d999
No known key found for this signature in database
GPG key ID: 4F071603387A382A

View file

@ -10,14 +10,32 @@ export XDG_SESSION_TYPE=wayland
## Hardware compatibility
# We can't be sure that the virtual GPU is compatible with Sway.
if systemd-detect-virt --quiet --vm; then
# https://github.com/swaywm/sway/issues/6581
export WLR_NO_HARDWARE_CURSORS=1
# Fallback to the pixman renderer as it has a higher chance to work
# and will be faster than llvmpipe anyways.
# See https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2871
export WLR_RENDERER=pixman
fi
# We should be attempting to detect an EGL driver instead, but that appears
# to be a bit more complicated.
case $(systemd-detect-virt --vm) in
"none"|"")
;;
"kvm")
# https://github.com/swaywm/sway/issues/6581
export WLR_NO_HARDWARE_CURSORS=1
# There's two drivers we can get here, depending on the 3D acceleration
# flag state: either virtio_gpu/virgl or kms_swrast/llvmpipe.
#
# The former one causes graphical glitches in OpenGL apps when using
# 'pixman' renderer. The latter will crash 'gles2' renderer outright.
# Neither of those support 'vulkan'.
#
# The choice is obvious, at least until we learn to detect the driver
# instead of abusing the virtualization technology identifier.
#
# See also: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2871
export WLR_RENDERER=pixman
;;
*)
# https://github.com/swaywm/sway/issues/6581
export WLR_NO_HARDWARE_CURSORS=1
;;
esac
## Load system environment customizations
if [ -f /etc/sway/environment ]; then