From 104b471578bb709f8b12bc721e54e831e60f9806 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Wed, 16 Mar 2022 14:17:48 +0900 Subject: [PATCH] devices: gpu: fallback to 2d rendering if virgl is not enabled The virgl renderer was unconditionally selected as the default backend for crosvm, even if the "virgl_renderer" feature is not enabled. This forces the user to explicitly specify the 2d backend with the --gpu option, which can be confusing for new users. Simplify things a bit by using the 2D renderer as default if the "virgl_renderer" feature is not enabled - that way the GPU can be used without having to specify a backend explicitly. BUG=b:213532598 TEST=successfully run crosvm without the "virgl_renderer" feature and without specifying the "backend" GPU option. Change-Id: Ib36b7d92cef62d9dd91b0a41051362d1c57e0536 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3528233 Reviewed-by: Keiichi Watanabe Reviewed-by: Daniel Verkamp Tested-by: kokoro Commit-Queue: Alexandre Courbot --- devices/src/virtio/gpu/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs index e40b3d599d..8b1c3df4cf 100644 --- a/devices/src/virtio/gpu/mod.rs +++ b/devices/src/virtio/gpu/mod.rs @@ -119,7 +119,11 @@ impl Default for GpuParameters { gfxstream_use_guest_angle: false, gfxstream_use_syncfd: true, use_vulkan: false, - mode: GpuMode::ModeVirglRenderer, + mode: if cfg!(feature = "virgl_renderer") { + GpuMode::ModeVirglRenderer + } else { + GpuMode::Mode2D + }, cache_path: None, cache_size: None, udmabuf: false,