diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs index 97f70b70be..b1ff831ab3 100644 --- a/devices/src/virtio/gpu/mod.rs +++ b/devices/src/virtio/gpu/mod.rs @@ -74,6 +74,8 @@ pub struct GpuParameters { pub renderer_use_glx: bool, pub renderer_use_surfaceless: bool, #[cfg(feature = "gfxstream")] + pub gfxstream_use_guest_angle: bool, + #[cfg(feature = "gfxstream")] pub gfxstream_use_syncfd: bool, #[cfg(feature = "gfxstream")] pub gfxstream_support_vulkan: bool, @@ -101,6 +103,8 @@ impl Default for GpuParameters { renderer_use_glx: false, renderer_use_surfaceless: true, #[cfg(feature = "gfxstream")] + gfxstream_use_guest_angle: false, + #[cfg(feature = "gfxstream")] gfxstream_use_syncfd: true, #[cfg(feature = "gfxstream")] gfxstream_support_vulkan: true, @@ -1143,6 +1147,7 @@ impl Gpu { .use_surfaceless(gpu_parameters.renderer_use_surfaceless); #[cfg(feature = "gfxstream")] let renderer_flags = renderer_flags + .use_guest_angle(gpu_parameters.gfxstream_use_guest_angle) .use_syncfd(gpu_parameters.gfxstream_use_syncfd) .support_vulkan(gpu_parameters.gfxstream_support_vulkan); diff --git a/gpu_renderer/src/lib.rs b/gpu_renderer/src/lib.rs index c7351707a1..10e84bd706 100644 --- a/gpu_renderer/src/lib.rs +++ b/gpu_renderer/src/lib.rs @@ -228,6 +228,12 @@ impl RendererFlags { self.set_flag(GFXSTREAM_RENDERER_FLAGS_NO_VK_BIT, !v) } + #[cfg(feature = "gfxstream")] + pub fn use_guest_angle(self, v: bool) -> RendererFlags { + const GFXSTREAM_RENDERER_FLAGS_GUEST_USES_ANGLE: u32 = 1 << 21; + self.set_flag(GFXSTREAM_RENDERER_FLAGS_GUEST_USES_ANGLE, v) + } + pub fn use_external_blob(self, v: bool) -> RendererFlags { self.set_flag(VIRGL_RENDERER_USE_EXTERNAL_BLOB, v) } diff --git a/src/main.rs b/src/main.rs index 8b025c087b..9eb42df6da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -162,6 +162,8 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result { let mut vulkan_specified = false; #[cfg(feature = "gfxstream")] let mut syncfd_specified = false; + #[cfg(feature = "gfxstream")] + let mut angle_specified = false; if let Some(s) = s { let opts = s @@ -283,6 +285,24 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result { } } #[cfg(feature = "gfxstream")] + "angle" => { + angle_specified = true; + match v { + "true" | "" => { + gpu_params.gfxstream_use_guest_angle = true; + } + "false" => { + gpu_params.gfxstream_use_guest_angle = false; + } + _ => { + return Err(argument::Error::InvalidValue { + value: v.to_string(), + expected: String::from("gpu parameter 'angle' should be a boolean"), + }); + } + } + } + #[cfg(feature = "gfxstream")] "vulkan" => { vulkan_specified = true; match v { @@ -337,7 +357,7 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result { #[cfg(feature = "gfxstream")] { - if vulkan_specified || syncfd_specified { + if vulkan_specified || syncfd_specified || angle_specified { match gpu_params.mode { GpuMode::ModeGfxStream => {} _ => { @@ -1543,6 +1563,7 @@ writeback=BOOL - Indicates whether the VM can use writeback caching (default: fa egl[=true|=false] - If the virtio-gpu backend should use a EGL context for rendering. glx[=true|=false] - If the virtio-gpu backend should use a GLX context for rendering. surfaceless[=true|=false] - If the virtio-gpu backend should use a surfaceless context for rendering. + angle[=true|=false] - If the guest is using ANGLE (OpenGL on Vulkan) as its native OpenGL driver. syncfd[=true|=false] - If the gfxstream backend should support EGL_ANDROID_native_fence_sync vulkan[=true|=false] - If the gfxstream backend should support vulkan "),