summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJason Macnak <natsu@google.com>2020-01-10 12:45:36 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-03 11:14:22 +0000
commit327fc2454cdfe36fb612c73c9994435b8602c81a (patch)
treea1fc9a44068612168c1db7884189714d9e4f78ee /src/main.rs
parentbc499ec2780510083f001bef569449808ad55850 (diff)
downloadcrosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.tar
crosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.tar.gz
crosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.tar.bz2
crosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.tar.lz
crosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.tar.xz
crosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.tar.zst
crosvm-327fc2454cdfe36fb612c73c9994435b8602c81a.zip
virtio-gpu: implement 2D GPU Backend
... which does not require virglrenderer (or any renderer).

This will allow the Cuttlefish team to use minigbm as its gralloc
implementation when both hardware acceleration is available and
unavailable.

Adds a GPU `Backend` trait with all of the existing methods of the
current backend and converts the existing `Backend` into
`Virtio3DBackend` which implements the new trait.

Adds a `Virtio2DBackend` which creates resources with byte vectors on
the host and implements transfers via the old code from
gpu_buffer/src/lib.rs.

Adds a runtime flag to select between 2D and 3D mode with 3D mode as
the default.

Moves the process_resource_bridge() function to the `Frontend` and
instead expose a export_resource() function on the `Backend` to avoid
some code duplication.

BUG=b:123764798
TEST=build + launch cuttlefish w/ 2D mode (minigbm + custom hwcomposer)
TEST=built + launch cuttlefish w/ 2D mode (minigbm + drm_hwcomposer)
TEST=built + launch cuttlefish w/ 3D mode (minigbm + drm_hwcomposer)

Change-Id: Ie5b7a6f80f7e0da72a910644ba42d2f34b246be8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1993913
Commit-Queue: Jason Macnak <natsu@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index e053082..fb1be25 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,7 +22,7 @@ use crosvm::{
     linux, BindMount, Config, DiskOption, Executable, GidMap, SharedDir, TouchDeviceOption,
 };
 #[cfg(feature = "gpu")]
-use devices::virtio::gpu::{GpuParameters, DEFAULT_GPU_PARAMS};
+use devices::virtio::gpu::{GpuMode, GpuParameters, DEFAULT_GPU_PARAMS};
 use devices::{SerialParameters, SerialType};
 use disk::QcowFile;
 use msg_socket::{MsgReceiver, MsgSender, MsgSocket};
@@ -124,6 +124,12 @@ fn parse_gpu_options(s: Option<&str>) -> argument::Result<GpuParameters> {
 
         for (k, v) in opts {
             match k {
+                "2d" | "2D" => {
+                    gpu_params.mode = GpuMode::Mode2D;
+                }
+                "3d" | "3D" => {
+                    gpu_params.mode = GpuMode::Mode3D;
+                }
                 "egl" => match v {
                     "true" | "" => {
                         gpu_params.renderer_use_egl = true;