From 028b8044bc67ec8eeb4749ec10653273062ede1a Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Mon, 14 Dec 2020 15:20:45 -0800 Subject: [PATCH] crosvm: clearer naming about GPU features It's possible to compile the gpu device without virgl_renderer. In fact, in many instances, this may be required. This builds the gpu device default, but only with --gpu do I see /dev/dri/renderN128, so this should be safe. BUG=b:173630595 TEST=compile and run Cq-Depend: chromium:2592111 Change-Id: I5fbf2de8a2f818a9ca2e5ac4a1a02c7797cff927 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2592089 Tested-by: Gurchetan Singh Tested-by: Daniel Verkamp Auto-Submit: Gurchetan Singh Reviewed-by: Daniel Verkamp Commit-Queue: Gurchetan Singh --- Cargo.toml | 5 +++-- devices/Cargo.toml | 3 ++- rutabaga_gfx/Cargo.toml | 4 ++-- rutabaga_gfx/src/virgl_renderer.rs | 22 +++++++++++----------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4a2eccdcd9..be8e5e4678 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ exclude = [ ] [features] -default = ["audio"] +default = ["audio", "gpu"] chromeos = ["base/chromeos"] default-no-sandbox = [] audio = ["devices/audio"] @@ -43,8 +43,9 @@ video-decoder = ["devices/video-decoder"] video-encoder = ["devices/video-encoder"] wl-dmabuf = ["devices/wl-dmabuf", "gpu_buffer", "resources/wl-dmabuf"] x = ["devices/x"] -virtio-gpu-next = ["rutabaga_gfx/virtio-gpu-next"] +virgl_renderer_next = ["rutabaga_gfx/virgl_renderer_next"] composite-disk = ["protos/composite-disk", "protobuf", "disk/composite-disk"] +virgl_renderer = ["devices/virgl_renderer"] gfxstream = ["devices/gfxstream"] gdb = ["gdbstub", "thiserror", "arch/gdb", "vm_control/gdb", "x86_64/gdb"] diff --git a/devices/Cargo.toml b/devices/Cargo.toml index 66aa19b2f6..8c35682f4d 100644 --- a/devices/Cargo.toml +++ b/devices/Cargo.toml @@ -6,12 +6,13 @@ edition = "2018" [features] audio = [] -gpu = ["gpu_buffer", "gpu_display", "rutabaga_gfx/virgl_renderer"] +gpu = ["gpu_buffer", "gpu_display","rutabaga_gfx"] tpm = ["protos/trunks", "tpm2"] video-decoder = ["libvda"] video-encoder = ["libvda"] wl-dmabuf = [] x = ["gpu_display/x"] +virgl_renderer = ["gpu", "rutabaga_gfx/virgl_renderer"] gfxstream = ["gpu", "rutabaga_gfx/gfxstream"] [dependencies] diff --git a/rutabaga_gfx/Cargo.toml b/rutabaga_gfx/Cargo.toml index bde3d825ba..14aed81033 100644 --- a/rutabaga_gfx/Cargo.toml +++ b/rutabaga_gfx/Cargo.toml @@ -5,9 +5,9 @@ authors = ["The Chromium OS Authors"] edition = "2018" [features] -virgl_renderer = [] -virtio-gpu-next = [] gfxstream = [] +virgl_renderer = [] +virgl_renderer_next = [] [dependencies] data_model = { path = "../data_model" } diff --git a/rutabaga_gfx/src/virgl_renderer.rs b/rutabaga_gfx/src/virgl_renderer.rs index 95c476afe2..fa084c83bf 100644 --- a/rutabaga_gfx/src/virgl_renderer.rs +++ b/rutabaga_gfx/src/virgl_renderer.rs @@ -134,7 +134,7 @@ fn export_query(resource_id: u32, export_fd: bool) -> RutabagaResult { #[allow(unused_variables)] fn map_func(resource_id: u32) -> ExternalMappingResult<(u64, usize)> { - #[cfg(feature = "virtio-gpu-next")] + #[cfg(feature = "virgl_renderer_next")] { let mut map: *mut c_void = null_mut(); let map_ptr: *mut *mut c_void = &mut map; @@ -147,13 +147,13 @@ fn map_func(resource_id: u32) -> ExternalMappingResult<(u64, usize)> { Ok((map as u64, size as usize)) } - #[cfg(not(feature = "virtio-gpu-next"))] + #[cfg(not(feature = "virgl_renderer_next"))] Err(ExternalMappingError::Unsupported) } #[allow(unused_variables)] fn unmap_func(resource_id: u32) { - #[cfg(feature = "virtio-gpu-next")] + #[cfg(feature = "virgl_renderer_next")] { unsafe { // Usually, process_gpu_command forces ctx0 when processing a virtio-gpu command. @@ -412,7 +412,7 @@ impl RutabagaComponent for VirglRenderer { resource_create_blob: ResourceCreateBlob, mut iovecs: Vec, ) -> RutabagaResult { - #[cfg(feature = "virtio-gpu-next")] + #[cfg(feature = "virgl_renderer_next")] { let resource_create_args = virgl_renderer_resource_create_blob_args { res_handle: resource_id, @@ -436,7 +436,7 @@ impl RutabagaComponent for VirglRenderer { resource_2d: None, }) } - #[cfg(not(feature = "virtio-gpu-next"))] + #[cfg(not(feature = "virgl_renderer_next"))] Err(RutabagaError::Unsupported) } @@ -450,7 +450,7 @@ impl RutabagaComponent for VirglRenderer { #[allow(unused_variables)] fn map_info(&self, resource_id: u32) -> RutabagaResult { - #[cfg(feature = "virtio-gpu-next")] + #[cfg(feature = "virgl_renderer_next")] { let mut map_info = 0; let ret = @@ -459,7 +459,7 @@ impl RutabagaComponent for VirglRenderer { Ok(map_info) } - #[cfg(not(feature = "virtio-gpu-next"))] + #[cfg(not(feature = "virgl_renderer_next"))] Err(RutabagaError::Unsupported) } @@ -482,7 +482,7 @@ impl RutabagaComponent for VirglRenderer { #[allow(unused_variables)] fn export_blob(&self, resource_id: u32) -> RutabagaResult> { - #[cfg(feature = "virtio-gpu-next")] + #[cfg(feature = "virgl_renderer_next")] { let mut fd_type = 0; let mut fd = 0; @@ -505,13 +505,13 @@ impl RutabagaComponent for VirglRenderer { handle_type: RUTABAGA_MEM_HANDLE_TYPE_DMABUF, })) } - #[cfg(not(feature = "virtio-gpu-next"))] + #[cfg(not(feature = "virgl_renderer_next"))] Err(RutabagaError::Unsupported) } #[allow(unused_variables)] fn export_fence(&self, fence_id: u32) -> RutabagaResult { - #[cfg(feature = "virtio-gpu-next")] + #[cfg(feature = "virgl_renderer_next")] { // Safe because the parameters are stack variables of the correct type. let mut fd: i32 = 0; @@ -526,7 +526,7 @@ impl RutabagaComponent for VirglRenderer { handle_type: RUTABAGA_FENCE_HANDLE_TYPE_SYNC_FD, }) } - #[cfg(not(feature = "virtio-gpu-next"))] + #[cfg(not(feature = "virgl_renderer_next"))] Err(RutabagaError::Unsupported) }