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 <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
Alexandre Courbot 2022-03-16 14:17:48 +09:00 committed by Commit Bot
parent 0550775207
commit 104b471578

View file

@ -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,