rutabaga_gfx: nuke unnecessary gfxstream flags

gfxstream has transitioned to simpler ways to configure the renderer,
use them.

BUG=278138335
TEST=launch_cvd

Change-Id: If0918495c2683cd2d99ed5c49c6bf01dd2edfe5f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4470287
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
Gurchetan Singh 2023-04-24 10:35:17 -07:00 committed by crosvm LUCI
parent 70715a0828
commit d18ff41fad
5 changed files with 18 additions and 175 deletions

View file

@ -1141,11 +1141,6 @@ impl Gpu {
.set_use_system_blob(system_blob)
.set_use_render_server(use_render_server);
#[cfg(feature = "gfxstream")]
let rutabaga_builder = rutabaga_builder
.set_use_guest_angle(gpu_parameters.gfxstream_use_guest_angle.unwrap_or_default())
.set_support_gles31(gpu_parameters.gfxstream_support_gles31.unwrap_or_default());
Gpu {
exit_evt_wrtube,
#[cfg(unix)]

View file

@ -55,17 +55,8 @@ pub struct GpuParameters {
pub renderer_use_glx: bool,
#[serde(rename = "surfaceless")]
pub renderer_use_surfaceless: bool,
#[cfg(feature = "gfxstream")]
#[serde(rename = "angle")]
pub gfxstream_use_guest_angle: Option<bool>,
#[serde(rename = "vulkan")]
pub use_vulkan: Option<bool>,
// It is possible that we compile with the gfxstream feature but don't use the gfxstream
// backend, in which case we want to ensure this option is not touched accidentally, so we make
// it an `Option` with default value `None`.
#[cfg(feature = "gfxstream")]
#[serde(rename = "gles31")]
pub gfxstream_support_gles31: Option<bool>,
pub wsi: Option<RutabagaWsi>,
pub udmabuf: bool,
pub cache_path: Option<String>,
@ -85,12 +76,8 @@ impl Default for GpuParameters {
renderer_use_gles: true,
renderer_use_glx: false,
renderer_use_surfaceless: true,
#[cfg(feature = "gfxstream")]
gfxstream_use_guest_angle: None,
use_vulkan: None,
mode: Default::default(),
#[cfg(feature = "gfxstream")]
gfxstream_support_gles31: None,
wsi: None,
cache_path: None,
cache_size: None,

View file

@ -840,8 +840,7 @@ impl RutabagaBuilder {
let virglrenderer_flags = VirglRendererFlags::new()
.use_thread_sync(true)
.use_async_fence_cb(true);
let gfxstream_flags = GfxstreamFlags::new().use_async_fence_cb(true);
let gfxstream_flags = GfxstreamFlags::new();
RutabagaBuilder {
display_width: RUTABAGA_DEFAULT_WIDTH,
display_height: RUTABAGA_DEFAULT_HEIGHT,
@ -900,18 +899,6 @@ impl RutabagaBuilder {
self
}
/// Set use guest ANGLE in gfxstream
pub fn set_use_guest_angle(mut self, v: bool) -> RutabagaBuilder {
self.gfxstream_flags = self.gfxstream_flags.use_guest_angle(v);
self
}
/// Set enable GLES 3.1 support in gfxstream
pub fn set_support_gles31(mut self, v: bool) -> RutabagaBuilder {
self.gfxstream_flags = self.gfxstream_flags.support_gles31(v);
self
}
/// Sets use external blob in gfxstream + virglrenderer.
pub fn set_use_external_blob(mut self, v: bool) -> RutabagaBuilder {
self.gfxstream_flags = self.gfxstream_flags.use_external_blob(v);

View file

@ -440,19 +440,16 @@ impl VirglRendererFlags {
}
/// Flags for the gfxstream renderer.
const GFXSTREAM_RENDERER_FLAGS_USE_EGL: u32 = 1 << 0;
const STREAM_RENDERER_FLAGS_USE_EGL: u32 = 1 << 0;
#[allow(dead_code)]
const GFXSTREAM_RENDERER_FLAGS_THREAD_SYNC: u32 = 1 << 1;
const GFXSTREAM_RENDERER_FLAGS_USE_GLX: u32 = 1 << 2;
const GFXSTREAM_RENDERER_FLAGS_USE_SURFACELESS: u32 = 1 << 3;
const GFXSTREAM_RENDERER_FLAGS_USE_GLES: u32 = 1 << 4;
const GFXSTREAM_RENDERER_FLAGS_NO_VK_BIT: u32 = 1 << 5;
const GFXSTREAM_RENDERER_FLAGS_ENABLE_GLES31_BIT: u32 = 1 << 9;
const GFXSTREAM_RENDERER_FLAGS_USE_EXTERNAL_BLOB: u32 = 1 << 10;
const GFXSTREAM_RENDERER_FLAGS_USE_SYSTEM_BLOB: u32 = 1 << 11;
const GFXSTREAM_RENDERER_FLAGS_GUEST_USES_ANGLE: u32 = 1 << 21;
const GFXSTREAM_RENDERER_FLAGS_VULKAN_NATIVE_SWAPCHAIN_BIT: u32 = 1 << 22;
const GFXSTREAM_RENDERER_FLAGS_ASYNC_FENCE_CB: u32 = 1 << 23;
const STREAM_RENDERER_FLAGS_THREAD_SYNC: u32 = 1 << 1;
const STREAM_RENDERER_FLAGS_USE_GLX: u32 = 1 << 2;
const STREAM_RENDERER_FLAGS_USE_SURFACELESS: u32 = 1 << 3;
const STREAM_RENDERER_FLAGS_USE_GLES: u32 = 1 << 4;
const STREAM_RENDERER_FLAGS_USE_VK_BIT: u32 = 1 << 5;
const STREAM_RENDERER_FLAGS_USE_EXTERNAL_BLOB: u32 = 1 << 6;
const STREAM_RENDERER_FLAGS_USE_SYSTEM_BLOB: u32 = 1 << 7;
const STREAM_RENDERER_FLAGS_VULKAN_NATIVE_SWAPCHAIN_BIT: u32 = 1 << 8;
/// gfxstream flag struct.
#[derive(Copy, Clone, Default)]
@ -481,61 +478,46 @@ impl GfxstreamFlags {
/// Use EGL for context creation.
pub fn use_egl(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_USE_EGL, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_EGL, v)
}
/// Use GLX for context creation.
pub fn use_glx(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_USE_GLX, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_GLX, v)
}
/// No surfaces required when creating context.
pub fn use_surfaceless(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_USE_SURFACELESS, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_SURFACELESS, v)
}
/// Use GLES drivers.
pub fn use_gles(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_USE_GLES, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_GLES, v)
}
/// Support using Vulkan.
pub fn use_vulkan(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_NO_VK_BIT, !v)
}
/// Use ANGLE as the guest GLES driver.
pub fn use_guest_angle(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_GUEST_USES_ANGLE, v)
}
/// Use async fence completion callback.
pub fn use_async_fence_cb(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_ASYNC_FENCE_CB, v)
}
/// Enable GLES 3.1 support.
pub fn support_gles31(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_ENABLE_GLES31_BIT, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_VK_BIT, v)
}
/// Use the Vulkan swapchain to draw on the host window.
pub fn set_wsi(self, v: Option<&RutabagaWsi>) -> GfxstreamFlags {
let use_vulkan_swapchain = matches!(v, Some(RutabagaWsi::Vulkan));
self.set_flag(
GFXSTREAM_RENDERER_FLAGS_VULKAN_NATIVE_SWAPCHAIN_BIT,
STREAM_RENDERER_FLAGS_VULKAN_NATIVE_SWAPCHAIN_BIT,
use_vulkan_swapchain,
)
}
/// Use external blob when creating resources.
pub fn use_external_blob(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_USE_EXTERNAL_BLOB, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_EXTERNAL_BLOB, v)
}
/// Use system blob when creating resources.
pub fn use_system_blob(self, v: bool) -> GfxstreamFlags {
self.set_flag(GFXSTREAM_RENDERER_FLAGS_USE_SYSTEM_BLOB, v)
self.set_flag(STREAM_RENDERER_FLAGS_USE_SYSTEM_BLOB, v)
}
}

View file

@ -55,16 +55,6 @@ pub(crate) fn fixup_gpu_options(
"backend type {:?} is deprecated, please use gfxstream",
gpu_params.mode
));
#[cfg(unix)]
{
if gpu_params.gfxstream_use_guest_angle.is_some() {
return Err("'angle' is only supported for gfxstream backend".to_string());
}
if gpu_params.gfxstream_support_gles31.is_some() {
return Err("'gles31' is only supported for gfxstream backend".to_string());
}
}
}
Ok(FixedGpuParameters(gpu_params))
@ -307,104 +297,6 @@ mod tests {
}
}
#[cfg(feature = "gfxstream")]
#[test]
fn parse_gpu_options_gfxstream_with_guest_angle_specified() {
assert_eq!(
parse_gpu_options("backend=gfxstream")
.unwrap()
.gfxstream_use_guest_angle,
None,
);
assert_eq!(
parse_gpu_options("backend=gfxstream,angle=true")
.unwrap()
.gfxstream_use_guest_angle,
Some(true),
);
assert_eq!(
parse_gpu_options("angle=true,backend=gfxstream")
.unwrap()
.gfxstream_use_guest_angle,
Some(true),
);
assert_eq!(
parse_gpu_options("backend=gfxstream,angle=false")
.unwrap()
.gfxstream_use_guest_angle,
Some(false),
);
assert_eq!(
parse_gpu_options("angle=false,backend=gfxstream")
.unwrap()
.gfxstream_use_guest_angle,
Some(false),
);
assert!(parse_gpu_options("backend=gfxstream,angle=invalid_value").is_err());
assert!(parse_gpu_options("angle=invalid_value,backend=gfxstream").is_err());
}
#[test]
fn parse_gpu_options_not_gfxstream_with_angle_specified() {
assert!(parse_gpu_options("backend=2d,angle=true").is_err());
assert!(parse_gpu_options("angle=true,backend=2d").is_err());
#[cfg(feature = "virgl_renderer")]
{
assert!(parse_gpu_options("backend=virglrenderer,angle=true").is_err());
assert!(parse_gpu_options("angle=true,backend=virglrenderer").is_err());
}
}
#[cfg(feature = "gfxstream")]
#[test]
fn parse_gpu_options_gfxstream_with_gles31_specified() {
assert_eq!(
parse_gpu_options("backend=gfxstream")
.unwrap()
.gfxstream_support_gles31,
None,
);
assert_eq!(
parse_gpu_options("backend=gfxstream,gles31=true")
.unwrap()
.gfxstream_support_gles31,
Some(true),
);
assert_eq!(
parse_gpu_options("gles31=true,backend=gfxstream")
.unwrap()
.gfxstream_support_gles31,
Some(true),
);
assert_eq!(
parse_gpu_options("backend=gfxstream,gles31=false")
.unwrap()
.gfxstream_support_gles31,
Some(false),
);
assert_eq!(
parse_gpu_options("gles31=false,backend=gfxstream")
.unwrap()
.gfxstream_support_gles31,
Some(false),
);
assert!(parse_gpu_options("backend=gfxstream,gles31=invalid_value").is_err());
assert!(parse_gpu_options("gles31=invalid_value,backend=gfxstream").is_err());
}
#[test]
fn parse_gpu_options_not_gfxstream_with_gles31_specified() {
assert!(parse_gpu_options("backend=2d,gles31=true").is_err());
assert!(parse_gpu_options("gles31=true,backend=2d").is_err());
#[cfg(feature = "virgl_renderer")]
{
assert!(parse_gpu_options("backend=virglrenderer,gles31=true").is_err());
assert!(parse_gpu_options("gles31=true,backend=virglrenderer").is_err());
}
}
#[test]
fn parse_gpu_options_context_types() {
use rutabaga_gfx::RUTABAGA_CAPSET_CROSS_DOMAIN;