mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +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"]
|
video-encoder = ["libvda"]
|
||||||
wl-dmabuf = []
|
wl-dmabuf = []
|
||||||
x = ["gpu_display/x"]
|
x = ["gpu_display/x"]
|
||||||
gfxstream = ["gpu"]
|
gfxstream = ["gpu", "gpu_renderer/gfxstream"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
acpi_tables = {path = "../acpi_tables" }
|
acpi_tables = {path = "../acpi_tables" }
|
||||||
|
|
|
@ -67,6 +67,8 @@ pub struct GpuParameters {
|
||||||
pub renderer_use_gles: bool,
|
pub renderer_use_gles: bool,
|
||||||
pub renderer_use_glx: bool,
|
pub renderer_use_glx: bool,
|
||||||
pub renderer_use_surfaceless: bool,
|
pub renderer_use_surfaceless: bool,
|
||||||
|
#[cfg(feature = "gfxstream")]
|
||||||
|
pub gfxstream_use_syncfd: bool,
|
||||||
pub mode: GpuMode,
|
pub mode: GpuMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +90,8 @@ impl Default for GpuParameters {
|
||||||
renderer_use_gles: true,
|
renderer_use_gles: true,
|
||||||
renderer_use_glx: false,
|
renderer_use_glx: false,
|
||||||
renderer_use_surfaceless: true,
|
renderer_use_surfaceless: true,
|
||||||
|
#[cfg(feature = "gfxstream")]
|
||||||
|
gfxstream_use_syncfd: true,
|
||||||
mode: GpuMode::Mode3D,
|
mode: GpuMode::Mode3D,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1030,6 +1034,8 @@ impl Gpu {
|
||||||
.use_gles(gpu_parameters.renderer_use_gles)
|
.use_gles(gpu_parameters.renderer_use_gles)
|
||||||
.use_glx(gpu_parameters.renderer_use_glx)
|
.use_glx(gpu_parameters.renderer_use_glx)
|
||||||
.use_surfaceless(gpu_parameters.renderer_use_surfaceless);
|
.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 {
|
let backend_kind = match gpu_parameters.mode {
|
||||||
GpuMode::Mode2D => BackendKind::Virtio2D,
|
GpuMode::Mode2D => BackendKind::Virtio2D,
|
||||||
|
|
|
@ -216,6 +216,7 @@ impl VirtioGfxStreamBackend {
|
||||||
display: GpuDisplay,
|
display: GpuDisplay,
|
||||||
display_width: u32,
|
display_width: u32,
|
||||||
display_height: u32,
|
display_height: u32,
|
||||||
|
renderer_flags: RendererFlags,
|
||||||
_gpu_device_socket: VmMemoryControlRequestSocket,
|
_gpu_device_socket: VmMemoryControlRequestSocket,
|
||||||
_pci_bar: Alloc,
|
_pci_bar: Alloc,
|
||||||
) -> VirtioGfxStreamBackend {
|
) -> VirtioGfxStreamBackend {
|
||||||
|
@ -224,8 +225,6 @@ impl VirtioGfxStreamBackend {
|
||||||
fence_state: Rc::clone(&fence_state),
|
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 display_rc_refcell = Rc::new(RefCell::new(display));
|
||||||
|
|
||||||
let scanout_surface = match (display_rc_refcell.borrow_mut()).create_surface(
|
let scanout_surface = match (display_rc_refcell.borrow_mut()).create_surface(
|
||||||
|
@ -284,7 +283,7 @@ impl Backend for VirtioGfxStreamBackend {
|
||||||
display: GpuDisplay,
|
display: GpuDisplay,
|
||||||
display_width: u32,
|
display_width: u32,
|
||||||
display_height: u32,
|
display_height: u32,
|
||||||
_renderer_flags: RendererFlags,
|
renderer_flags: RendererFlags,
|
||||||
_event_devices: Vec<EventDevice>,
|
_event_devices: Vec<EventDevice>,
|
||||||
gpu_device_socket: VmMemoryControlRequestSocket,
|
gpu_device_socket: VmMemoryControlRequestSocket,
|
||||||
pci_bar: Alloc,
|
pci_bar: Alloc,
|
||||||
|
@ -293,6 +292,7 @@ impl Backend for VirtioGfxStreamBackend {
|
||||||
display,
|
display,
|
||||||
display_width,
|
display_width,
|
||||||
display_height,
|
display_height,
|
||||||
|
renderer_flags,
|
||||||
gpu_device_socket,
|
gpu_device_socket,
|
||||||
pci_bar,
|
pci_bar,
|
||||||
)))
|
)))
|
||||||
|
|
|
@ -6,6 +6,7 @@ edition = "2018"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
virtio-gpu-next = []
|
virtio-gpu-next = []
|
||||||
|
gfxstream = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
data_model = { path = "../data_model" }
|
data_model = { path = "../data_model" }
|
||||||
|
|
|
@ -211,6 +211,12 @@ impl RendererFlags {
|
||||||
pub fn use_gles(self, v: bool) -> RendererFlags {
|
pub fn use_gles(self, v: bool) -> RendererFlags {
|
||||||
self.set_flag(VIRGL_RENDERER_USE_GLES, v)
|
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 {
|
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" => {
|
"width" => {
|
||||||
gpu_params.display_width =
|
gpu_params.display_width =
|
||||||
v.parse::<u32>()
|
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.
|
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.
|
||||||
|
syncfd[=true|=false] - If the gfxstream backend should support EGL_ANDROID_native_fence_sync
|
||||||
"),
|
"),
|
||||||
#[cfg(feature = "tpm")]
|
#[cfg(feature = "tpm")]
|
||||||
Argument::flag("software-tpm", "enable a software emulated trusted platform module device"),
|
Argument::flag("software-tpm", "enable a software emulated trusted platform module device"),
|
||||||
|
|
Loading…
Reference in a new issue