qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v11 6/9] gfxstream + rutabaga: add initial support for gfxstr


From: Akihiko Odaki
Subject: Re: [PATCH v11 6/9] gfxstream + rutabaga: add initial support for gfxstream
Date: Wed, 23 Aug 2023 18:59:19 +0900
User-agent: Mozilla Thunderbird

On 2023/08/23 10:25, Gurchetan Singh wrote:
This adds initial support for gfxstream and cross-domain.  Both
features rely on virtio-gpu blob resources and context types, which
are also implemented in this patch.

gfxstream has a long and illustrious history in Android graphics
paravirtualization.  It has been powering graphics in the Android
Studio Emulator for more than a decade, which is the main developer
platform.

Originally conceived by Jesse Hall, it was first known as "EmuGL" [a].
The key design characteristic was a 1:1 threading model and
auto-generation, which fit nicely with the OpenGLES spec.  It also
allowed easy layering with ANGLE on the host, which provides the GLES
implementations on Windows or MacOS enviroments.

gfxstream has traditionally been maintained by a single engineer, and
between 2015 to 2021, the goldfish throne passed to Frank Yang.
Historians often remark this glorious reign ("pax gfxstreama" is the
academic term) was comparable to that of Augustus and both Queen
Elizabeths.  Just to name a few accomplishments in a resplendent
panoply: higher versions of GLES, address space graphics, snapshot
support and CTS compliant Vulkan [b].

One major drawback was the use of out-of-tree goldfish drivers.
Android engineers didn't know much about DRM/KMS and especially TTM so
a simple guest to host pipe was conceived.

Luckily, virtio-gpu 3D started to emerge in 2016 due to the work of
the Mesa/virglrenderer communities.  In 2018, the initial virtio-gpu
port of gfxstream was done by Cuttlefish enthusiast Alistair Delva.
It was a symbol compatible replacement of virglrenderer [c] and named
"AVDVirglrenderer".  This implementation forms the basis of the
current gfxstream host implementation still in use today.

cross-domain support follows a similar arc.  Originally conceived by
Wayland aficionado David Reveman and crosvm enjoyer Zach Reizner in
2018, it initially relied on the downstream "virtio-wl" device.

In 2020 and 2021, virtio-gpu was extended to include blob resources
and multiple timelines by yours truly, features gfxstream/cross-domain
both require to function correctly.

Right now, we stand at the precipice of a truly fantastic possibility:
the Android Emulator powered by upstream QEMU and upstream Linux
kernel.  gfxstream will then be packaged properfully, and app
developers can even fix gfxstream bugs on their own if they encounter
them.

It's been quite the ride, my friends.  Where will gfxstream head next,
nobody really knows.  I wouldn't be surprised if it's around for
another decade, maintained by a new generation of Android graphics
enthusiasts.

Technical details:
   - Very simple initial display integration: just used Pixman
   - Largely, 1:1 mapping of virtio-gpu hypercalls to rutabaga function
     calls

Next steps for Android VMs:
   - The next step would be improving display integration and UI interfaces
     with the goal of the QEMU upstream graphics being in an emulator
     release [d].

Next steps for Linux VMs for display virtualization:
   - For widespread distribution, someone needs to package Sommelier or the
     wayland-proxy-virtwl [e] ideally into Debian main. In addition, newer
     versions of the Linux kernel come with DRM_VIRTIO_GPU_KMS option,
     which allows disabling KMS hypercalls.  If anyone cares enough, it'll
     probably be possible to build a custom VM variant that uses this display
     virtualization strategy.

[a] https://android-review.googlesource.com/c/platform/development/+/34470
[b] 
https://android-review.googlesource.com/q/topic:%22vulkan-hostconnection-start%22
[c] 
https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/761927
[d] https://developer.android.com/studio/releases/emulator
[e] https://github.com/talex5/wayland-proxy-virtwl

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Alyssa Ross <hi@alyssa.is>
Tested-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
---
v1: Incorported various suggestions by Akihiko Odaki and Bernard Berschow
     - Removed GET_VIRTIO_GPU_GL / GET_RUTABAGA macros
     - Used error_report(..)
     - Used g_autofree to fix leaks on error paths
     - Removed unnecessary casts
     - added virtio-gpu-pci-rutabaga.c + virtio-vga-rutabaga.c files

v2: Incorported various suggestions by Akihiko Odaki, Marc-André Lureau and
     Bernard Berschow:
     - Parenthesis in CHECK macro
     - CHECK_RESULT(result, ..) --> CHECK(!result, ..)
     - delay until g->parent_obj.enable = 1
     - Additional cast fixes
     - initialize directly in virtio_gpu_rutabaga_realize(..)
     - add debug callback to hook into QEMU error's APIs

v3: Incorporated feedback from Akihiko Odaki and Alyssa Ross:
     - Autodetect Wayland socket when not explicitly specified
     - Fix map_blob error paths
     - Add comment why we need both `res` and `resource` in create blob
     - Cast and whitespace fixes
     - Big endian check comes before virtio_gpu_rutabaga_init().
     - VirtIOVGARUTABAGA --> VirtIOVGARutabaga

v4: Incorporated feedback from Akihiko Odaki and Alyssa Ross:
     - Double checked all casts
     - Remove unnecessary parenthesis
     - Removed `resource` in create_blob
     - Added comment about failure case
     - Pass user-provided socket as-is
     - Use stack variable rather than heap allocation
     - Future-proofed map info API to give access flags as well

v5: Incorporated feedback from Akihiko Odaki:
     - Check (ss.scanout_id < VIRTIO_GPU_MAX_SCANOUTS)
     - Simplify num_capsets check
     - Call cleanup mapping on error paths
     - uint64_t --> void* for rutabaga_map(..)
     - Removed unnecessary parenthesis
     - Removed unnecessary cast
     - #define UNIX_PATH_MAX sizeof((struct sockaddr_un) {}.sun_path)
     - Reuse result variable

v6: Incorporated feedback from Akihiko Odaki:
     - Remove unnecessary #ifndef
     - Disable scanout when appropriate
     - CHECK capset index within range outside loop
     - Add capset_version

v7: Incorporated feedback from Akihiko Odaki:
     - aio_bh_schedule_oneshot_full --> aio_bh_schedule_oneshot

v9: Incorportated feedback from Akihiko Odaki:
     - Remove extra error_setg(..) after virtio_gpu_rutabaga_init(..)
     - Add error_setg(..) after rutabaga_init(..)

v10: Incorportated feedback from Akihiko Odaki:
     - error_setg(..) --> error_setg_errno(..) when appropriate
     - virtio_gpu_rutabaga_init returns a bool instead of an int

v11: Incorportated feedback from Philippe Mathieu-Daudé:
     - C-style /* */ comments and avoid // comments.
     - GPL-2.0 --> GPL-2.0-or-later

  hw/display/virtio-gpu-pci-rutabaga.c |   50 ++
  hw/display/virtio-gpu-rutabaga.c     | 1121 ++++++++++++++++++++++++++
  hw/display/virtio-vga-rutabaga.c     |   53 ++
  3 files changed, 1224 insertions(+)
  create mode 100644 hw/display/virtio-gpu-pci-rutabaga.c
  create mode 100644 hw/display/virtio-gpu-rutabaga.c
  create mode 100644 hw/display/virtio-vga-rutabaga.c

diff --git a/hw/display/virtio-gpu-pci-rutabaga.c 
b/hw/display/virtio-gpu-pci-rutabaga.c
new file mode 100644
index 0000000000..311eff308a
--- /dev/null
+++ b/hw/display/virtio-gpu-pci-rutabaga.c
@@ -0,0 +1,50 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */

For an one-line comment, just do:
/* SPDX-License-Identifier: GPL-2.0-or-later */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]