From 91df65629142929f2d66d0b5944885cc50c730cb Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 12 Apr 2021 09:47:38 -0700 Subject: [PATCH] devices: disable vulkan by default Because the default value for mode is GpuMode::ModeVirglRenderer, make the default value for use_vulkan false as well. Set use_vulkan to true when mode is set to GpuMode::ModeGfxstream for backward compatibility. BUG=b:178104043 TEST=cargo build Change-Id: Idf1417f04d23999cf5a03b0bf640973b69de93e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2823012 Reviewed-by: Gurchetan Singh Reviewed-by: Zach Reizner Reviewed-by: David Riley Tested-by: kokoro Tested-by: Chia-I Wu Commit-Queue: Chia-I Wu --- devices/src/virtio/gpu/mod.rs | 2 +- src/main.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs index 55ecbe94c8..3367fe682b 100644 --- a/devices/src/virtio/gpu/mod.rs +++ b/devices/src/virtio/gpu/mod.rs @@ -97,7 +97,7 @@ impl Default for GpuParameters { renderer_use_surfaceless: true, gfxstream_use_guest_angle: false, gfxstream_use_syncfd: true, - use_vulkan: true, + use_vulkan: false, mode: GpuMode::ModeVirglRenderer, cache_path: None, cache_size: None, diff --git a/src/main.rs b/src/main.rs index 6ae5856e05..43434ea34d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -369,6 +369,10 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result { #[cfg(feature = "gfxstream")] { + if !vulkan_specified && gpu_params.mode == GpuMode::ModeGfxstream { + gpu_params.use_vulkan = true; + } + if vulkan_specified || syncfd_specified || angle_specified { match gpu_params.mode { GpuMode::ModeGfxstream => {} @@ -2796,6 +2800,21 @@ mod tests { ); } + #[cfg(all(feature = "gpu", feature = "gfxstream"))] + #[test] + fn parse_gpu_options_default_vulkan_support() { + assert!( + !parse_gpu_options(Some("backend=virglrenderer")) + .unwrap() + .use_vulkan + ); + assert!( + parse_gpu_options(Some("backend=gfxstream")) + .unwrap() + .use_vulkan + ); + } + #[cfg(all(feature = "gpu", feature = "gfxstream"))] #[test] fn parse_gpu_options_gfxstream_with_vulkan_specified() {