mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
gpu_renderer: add syncfd flag for gfxstream
Add a gpu argument to control the syncfd of gfxstream implemented in these CL: https://android-review.googlesource.com/q/topic:%22gfxstream-sync-fd%22+(status:open%20OR%20status:merged). Default to enabled. BUG=None TEST=launch_cvd Change-Id: Id4933b8654fc1b1bb73784bd8e1a85e73d0266d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2286237 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
4462eabaab
commit
6404e457b5
6 changed files with 33 additions and 4 deletions
|
@ -11,7 +11,7 @@ video-decoder = ["libvda"]
|
|||
video-encoder = ["libvda"]
|
||||
wl-dmabuf = []
|
||||
x = ["gpu_display/x"]
|
||||
gfxstream = ["gpu"]
|
||||
gfxstream = ["gpu", "gpu_renderer/gfxstream"]
|
||||
|
||||
[dependencies]
|
||||
acpi_tables = {path = "../acpi_tables" }
|
||||
|
|
|
@ -67,6 +67,8 @@ pub struct GpuParameters {
|
|||
pub renderer_use_gles: bool,
|
||||
pub renderer_use_glx: bool,
|
||||
pub renderer_use_surfaceless: bool,
|
||||
#[cfg(feature = "gfxstream")]
|
||||
pub gfxstream_use_syncfd: bool,
|
||||
pub mode: GpuMode,
|
||||
}
|
||||
|
||||
|
@ -88,6 +90,8 @@ impl Default for GpuParameters {
|
|||
renderer_use_gles: true,
|
||||
renderer_use_glx: false,
|
||||
renderer_use_surfaceless: true,
|
||||
#[cfg(feature = "gfxstream")]
|
||||
gfxstream_use_syncfd: true,
|
||||
mode: GpuMode::Mode3D,
|
||||
}
|
||||
}
|
||||
|
@ -1030,6 +1034,8 @@ impl Gpu {
|
|||
.use_gles(gpu_parameters.renderer_use_gles)
|
||||
.use_glx(gpu_parameters.renderer_use_glx)
|
||||
.use_surfaceless(gpu_parameters.renderer_use_surfaceless);
|
||||
#[cfg(feature = "gfxstream")]
|
||||
let renderer_flags = renderer_flags.use_syncfd(gpu_parameters.gfxstream_use_syncfd);
|
||||
|
||||
let backend_kind = match gpu_parameters.mode {
|
||||
GpuMode::Mode2D => BackendKind::Virtio2D,
|
||||
|
|
|
@ -216,6 +216,7 @@ impl VirtioGfxStreamBackend {
|
|||
display: GpuDisplay,
|
||||
display_width: u32,
|
||||
display_height: u32,
|
||||
renderer_flags: RendererFlags,
|
||||
_gpu_device_socket: VmMemoryControlRequestSocket,
|
||||
_pci_bar: Alloc,
|
||||
) -> VirtioGfxStreamBackend {
|
||||
|
@ -224,8 +225,6 @@ impl VirtioGfxStreamBackend {
|
|||
fence_state: Rc::clone(&fence_state),
|
||||
}));
|
||||
|
||||
let renderer_flags: RendererFlags = RendererFlags::new().use_surfaceless(true);
|
||||
|
||||
let display_rc_refcell = Rc::new(RefCell::new(display));
|
||||
|
||||
let scanout_surface = match (display_rc_refcell.borrow_mut()).create_surface(
|
||||
|
@ -284,7 +283,7 @@ impl Backend for VirtioGfxStreamBackend {
|
|||
display: GpuDisplay,
|
||||
display_width: u32,
|
||||
display_height: u32,
|
||||
_renderer_flags: RendererFlags,
|
||||
renderer_flags: RendererFlags,
|
||||
_event_devices: Vec<EventDevice>,
|
||||
gpu_device_socket: VmMemoryControlRequestSocket,
|
||||
pci_bar: Alloc,
|
||||
|
@ -293,6 +292,7 @@ impl Backend for VirtioGfxStreamBackend {
|
|||
display,
|
||||
display_width,
|
||||
display_height,
|
||||
renderer_flags,
|
||||
gpu_device_socket,
|
||||
pci_bar,
|
||||
)))
|
||||
|
|
|
@ -6,6 +6,7 @@ edition = "2018"
|
|||
|
||||
[features]
|
||||
virtio-gpu-next = []
|
||||
gfxstream = []
|
||||
|
||||
[dependencies]
|
||||
data_model = { path = "../data_model" }
|
||||
|
|
|
@ -211,6 +211,12 @@ impl RendererFlags {
|
|||
pub fn use_gles(self, v: bool) -> RendererFlags {
|
||||
self.set_flag(VIRGL_RENDERER_USE_GLES, v)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gfxstream")]
|
||||
pub fn use_syncfd(self, v: bool) -> RendererFlags {
|
||||
const GFXSTREAM_RENDERER_FLAGS_NO_SYNCFD_BIT: u32 = 1 << 20;
|
||||
self.set_flag(GFXSTREAM_RENDERER_FLAGS_NO_SYNCFD_BIT, !v)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RendererFlags> for i32 {
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -217,6 +217,21 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result<GpuParameters> {
|
|||
});
|
||||
}
|
||||
},
|
||||
#[cfg(feature = "gfxstream")]
|
||||
"syncfd" => match v {
|
||||
"true" | "" => {
|
||||
gpu_params.gfxstream_use_syncfd = true;
|
||||
}
|
||||
"false" => {
|
||||
gpu_params.gfxstream_use_syncfd = false;
|
||||
}
|
||||
_ => {
|
||||
return Err(argument::Error::InvalidValue {
|
||||
value: v.to_string(),
|
||||
expected: String::from("gpu parameter 'syncfd' should be a boolean"),
|
||||
});
|
||||
}
|
||||
},
|
||||
"width" => {
|
||||
gpu_params.display_width =
|
||||
v.parse::<u32>()
|
||||
|
@ -1417,6 +1432,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.
|
||||
syncfd[=true|=false] - If the gfxstream backend should support EGL_ANDROID_native_fence_sync
|
||||
"),
|
||||
#[cfg(feature = "tpm")]
|
||||
Argument::flag("software-tpm", "enable a software emulated trusted platform module device"),
|
||||
|
|
Loading…
Reference in a new issue