devices: gpu: gfxstream: Add ANGLE flag for Gfxstream

... to allow configuring Gfxstream host renderer based
on whether or not the guest Android is using ANGLE as
its native OpenGL driver.

BUG=b:165022040
TEST=launch_cvd --gpu_mode=gfxstream

Change-Id: I566ed1e7590f7f3db99960440421fd65bba08f7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2466604
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
This commit is contained in:
Jason Macnak 2020-10-08 09:11:53 -07:00 committed by Commit Bot
parent 0c4bba741a
commit 046ed143a7
3 changed files with 33 additions and 1 deletions

View file

@ -74,6 +74,8 @@ pub struct GpuParameters {
pub renderer_use_glx: bool, pub renderer_use_glx: bool,
pub renderer_use_surfaceless: bool, pub renderer_use_surfaceless: bool,
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
pub gfxstream_use_guest_angle: bool,
#[cfg(feature = "gfxstream")]
pub gfxstream_use_syncfd: bool, pub gfxstream_use_syncfd: bool,
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
pub gfxstream_support_vulkan: bool, pub gfxstream_support_vulkan: bool,
@ -101,6 +103,8 @@ impl Default for GpuParameters {
renderer_use_glx: false, renderer_use_glx: false,
renderer_use_surfaceless: true, renderer_use_surfaceless: true,
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
gfxstream_use_guest_angle: false,
#[cfg(feature = "gfxstream")]
gfxstream_use_syncfd: true, gfxstream_use_syncfd: true,
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
gfxstream_support_vulkan: true, gfxstream_support_vulkan: true,
@ -1143,6 +1147,7 @@ impl Gpu {
.use_surfaceless(gpu_parameters.renderer_use_surfaceless); .use_surfaceless(gpu_parameters.renderer_use_surfaceless);
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
let renderer_flags = renderer_flags let renderer_flags = renderer_flags
.use_guest_angle(gpu_parameters.gfxstream_use_guest_angle)
.use_syncfd(gpu_parameters.gfxstream_use_syncfd) .use_syncfd(gpu_parameters.gfxstream_use_syncfd)
.support_vulkan(gpu_parameters.gfxstream_support_vulkan); .support_vulkan(gpu_parameters.gfxstream_support_vulkan);

View file

@ -228,6 +228,12 @@ impl RendererFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_NO_VK_BIT, !v) 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 { pub fn use_external_blob(self, v: bool) -> RendererFlags {
self.set_flag(VIRGL_RENDERER_USE_EXTERNAL_BLOB, v) self.set_flag(VIRGL_RENDERER_USE_EXTERNAL_BLOB, v)
} }

View file

@ -162,6 +162,8 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result<GpuParameters> {
let mut vulkan_specified = false; let mut vulkan_specified = false;
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
let mut syncfd_specified = false; let mut syncfd_specified = false;
#[cfg(feature = "gfxstream")]
let mut angle_specified = false;
if let Some(s) = s { if let Some(s) = s {
let opts = s let opts = s
@ -283,6 +285,24 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result<GpuParameters> {
} }
} }
#[cfg(feature = "gfxstream")] #[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" => {
vulkan_specified = true; vulkan_specified = true;
match v { match v {
@ -337,7 +357,7 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result<GpuParameters> {
#[cfg(feature = "gfxstream")] #[cfg(feature = "gfxstream")]
{ {
if vulkan_specified || syncfd_specified { if vulkan_specified || syncfd_specified || angle_specified {
match gpu_params.mode { match gpu_params.mode {
GpuMode::ModeGfxStream => {} 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. 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. 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. 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 syncfd[=true|=false] - If the gfxstream backend should support EGL_ANDROID_native_fence_sync
vulkan[=true|=false] - If the gfxstream backend should support vulkan vulkan[=true|=false] - If the gfxstream backend should support vulkan
"), "),