-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'gpu-pull-request' of https://gitlab.com/marcandre.lureau/qemu
into staging virtio-gpu rutabaga support # -----BEGIN PGP SIGNATURE----- # # iQJQBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmUtP5YcHG1hcmNhbmRy # ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5X9CD/4s1n/GZyDr9bh04V03 # otAqtq2CSyuUOviqBrqxYgraCosUD1AuX8WkDy5cCPtnKC4FxRjgVlm9s7K/yxOW # xZ78e4oVgB1F3voOq6LgtKK6BRG/BPqNzq9kuGcayCHQbSxg7zZVwa702Y18r2ZD # pjOhbZCrJTSfASL7C3e/rm7798Wk/hzSrClGR56fbRAVgQ6Lww2L97/g0nHyDsWK # DrCBrdqFtKjpLeUHmcqqS4AwdpG2SyCgqE7RehH/wOhvGTxh/JQvHbLGWK2mDC3j # Qvs8mClC5bUlyNQuUz7lZtXYpzCW6VGMWlz8bIu+ncgSt6RK1TRbdEfDJPGoS4w9 # ZCGgcTxTG/6BEO76J/VpydfTWDo1FwQCQ0Vv7EussGoRTLrFC3ZRFgDWpqCw85yi # AjPtc0C49FHBZhK0l1CoJGV4gGTDtD9jTYN0ffsd+aQesOjcsgivAWBaCOOQWUc8 # KOv9sr4kLLxcnuCnP7p/PuVRQD4eg0TmpdS8bXfnCzLSH8fCm+n76LuJEpGxEBey # 3KPJPj/1BNBgVgew+znSLD/EYM6YhdK2gF5SNrYsdR6UcFdrPED/xmdhzFBeVym/ # xbBWqicDw4HLn5YrJ4tzqXje5XUz5pmJoT5zrRMXTHiu4pjBkEXO/lOdAoFwSy8M # WNOtmSyB69uCrbyLw6xE2/YX8Q== # =5a/Z # -----END PGP SIGNATURE----- # gpg: Signature made Mon 16 Oct 2023 09:50:14 EDT # gpg: using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5 # gpg: issuer "marcandre.lureau@redhat.com" # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full] # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full] # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * tag 'gpu-pull-request' of https://gitlab.com/marcandre.lureau/qemu: docs/system: add basic virtio-gpu documentation gfxstream + rutabaga: enable rutabaga gfxstream + rutabaga: meson support gfxstream + rutabaga: add initial support for gfxstream gfxstream + rutabaga prep: added need defintions, fields, and options virtio-gpu: blob prep virtio-gpu: hostmem virtio-gpu: CONTEXT_INIT feature virtio: Add shared memory capability Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
- Loading branch information
Showing
19 changed files
with
1,495 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
.. | ||
SPDX-License-Identifier: GPL-2.0-or-later | ||
virtio-gpu | ||
========== | ||
|
||
This document explains the setup and usage of the virtio-gpu device. | ||
The virtio-gpu device paravirtualizes the GPU and display controller. | ||
|
||
Linux kernel support | ||
-------------------- | ||
|
||
virtio-gpu requires a guest Linux kernel built with the | ||
``CONFIG_DRM_VIRTIO_GPU`` option. | ||
|
||
QEMU virtio-gpu variants | ||
------------------------ | ||
|
||
QEMU virtio-gpu device variants come in the following form: | ||
|
||
* ``virtio-vga[-BACKEND]`` | ||
* ``virtio-gpu[-BACKEND][-INTERFACE]`` | ||
* ``vhost-user-vga`` | ||
* ``vhost-user-pci`` | ||
|
||
**Backends:** QEMU provides a 2D virtio-gpu backend, and two accelerated | ||
backends: virglrenderer ('gl' device label) and rutabaga_gfx ('rutabaga' | ||
device label). There is a vhost-user backend that runs the graphics stack | ||
in a separate process for improved isolation. | ||
|
||
**Interfaces:** QEMU further categorizes virtio-gpu device variants based | ||
on the interface exposed to the guest. The interfaces can be classified | ||
into VGA and non-VGA variants. The VGA ones are prefixed with virtio-vga | ||
or vhost-user-vga while the non-VGA ones are prefixed with virtio-gpu or | ||
vhost-user-gpu. | ||
|
||
The VGA ones always use the PCI interface, but for the non-VGA ones, the | ||
user can further pick between MMIO or PCI. For MMIO, the user can suffix | ||
the device name with -device, though vhost-user-gpu does not support MMIO. | ||
For PCI, the user can suffix it with -pci. Without these suffixes, the | ||
platform default will be chosen. | ||
|
||
virtio-gpu 2d | ||
------------- | ||
|
||
The default 2D backend only performs 2D operations. The guest needs to | ||
employ a software renderer for 3D graphics. | ||
|
||
Typically, the software renderer is provided by `Mesa`_ or `SwiftShader`_. | ||
Mesa's implementations (LLVMpipe, Lavapipe and virgl below) work out of box | ||
on typical modern Linux distributions. | ||
|
||
.. parsed-literal:: | ||
-device virtio-gpu | ||
.. _Mesa: https://www.mesa3d.org/ | ||
.. _SwiftShader: https://github.com/google/swiftshader | ||
|
||
virtio-gpu virglrenderer | ||
------------------------ | ||
|
||
When using virgl accelerated graphics mode in the guest, OpenGL API calls | ||
are translated into an intermediate representation (see `Gallium3D`_). The | ||
intermediate representation is communicated to the host and the | ||
`virglrenderer`_ library on the host translates the intermediate | ||
representation back to OpenGL API calls. | ||
|
||
.. parsed-literal:: | ||
-device virtio-gpu-gl | ||
.. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ | ||
.. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ | ||
|
||
virtio-gpu rutabaga | ||
------------------- | ||
|
||
virtio-gpu can also leverage rutabaga_gfx to provide `gfxstream`_ | ||
rendering and `Wayland display passthrough`_. With the gfxstream rendering | ||
mode, GLES and Vulkan calls are forwarded to the host with minimal | ||
modification. | ||
|
||
The crosvm book provides directions on how to build a `gfxstream-enabled | ||
rutabaga`_ and launch a `guest Wayland proxy`_. | ||
|
||
This device does require host blob support (``hostmem`` field below). The | ||
``hostmem`` field specifies the size of virtio-gpu host memory window. | ||
This is typically between 256M and 8G. | ||
|
||
At least one virtio-gpu capability set ("capset") must be specified when | ||
starting the device. The currently capsets supported are ``gfxstream-vulkan`` | ||
and ``cross-domain`` for Linux guests. For Android guests, the experimental | ||
``x-gfxstream-gles`` and ``x-gfxstream-composer`` capsets are also supported. | ||
|
||
The device will try to auto-detect the wayland socket path if the | ||
``cross-domain`` capset name is set. The user may optionally specify | ||
``wayland-socket-path`` for non-standard paths. | ||
|
||
The ``wsi`` option can be set to ``surfaceless`` or ``headless``. | ||
Surfaceless doesn't create a native window surface, but does copy from the | ||
render target to the Pixman buffer if a virtio-gpu 2D hypercall is issued. | ||
Headless is like surfaceless, but doesn't copy to the Pixman buffer. | ||
Surfaceless is the default if ``wsi`` is not specified. | ||
|
||
.. parsed-literal:: | ||
-device virtio-gpu-rutabaga,gfxstream-vulkan=on,cross-domain=on, | ||
hostmem=8G,wayland-socket-path=/tmp/nonstandard/mock_wayland.sock, | ||
wsi=headless | ||
.. _gfxstream: https://android.googlesource.com/platform/hardware/google/gfxstream/ | ||
.. _Wayland display passthrough: https://www.youtube.com/watch?v=OZJiHMtIQ2M | ||
.. _gfxstream-enabled rutabaga: https://crosvm.dev/book/appendix/rutabaga_gfx.html | ||
.. _guest Wayland proxy: https://crosvm.dev/book/devices/wayland.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
||
#include "qemu/osdep.h" | ||
#include "qapi/error.h" | ||
#include "qemu/module.h" | ||
#include "hw/pci/pci.h" | ||
#include "hw/qdev-properties.h" | ||
#include "hw/virtio/virtio.h" | ||
#include "hw/virtio/virtio-bus.h" | ||
#include "hw/virtio/virtio-gpu-pci.h" | ||
#include "qom/object.h" | ||
|
||
#define TYPE_VIRTIO_GPU_RUTABAGA_PCI "virtio-gpu-rutabaga-pci" | ||
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPURutabagaPCI, VIRTIO_GPU_RUTABAGA_PCI) | ||
|
||
struct VirtIOGPURutabagaPCI { | ||
VirtIOGPUPCIBase parent_obj; | ||
|
||
VirtIOGPURutabaga vdev; | ||
}; | ||
|
||
static void virtio_gpu_rutabaga_initfn(Object *obj) | ||
{ | ||
VirtIOGPURutabagaPCI *dev = VIRTIO_GPU_RUTABAGA_PCI(obj); | ||
|
||
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), | ||
TYPE_VIRTIO_GPU_RUTABAGA); | ||
VIRTIO_GPU_PCI_BASE(obj)->vgpu = VIRTIO_GPU_BASE(&dev->vdev); | ||
} | ||
|
||
static const TypeInfo virtio_gpu_rutabaga_pci_info[] = { | ||
{ | ||
.name = TYPE_VIRTIO_GPU_RUTABAGA_PCI, | ||
.parent = TYPE_VIRTIO_GPU_PCI_BASE, | ||
.instance_size = sizeof(VirtIOGPURutabagaPCI), | ||
.instance_init = virtio_gpu_rutabaga_initfn, | ||
.interfaces = (InterfaceInfo[]) { | ||
{ INTERFACE_CONVENTIONAL_PCI_DEVICE }, | ||
} | ||
}, | ||
}; | ||
|
||
DEFINE_TYPES(virtio_gpu_rutabaga_pci_info) | ||
|
||
module_obj(TYPE_VIRTIO_GPU_RUTABAGA_PCI); | ||
module_kconfig(VIRTIO_PCI); | ||
module_dep("hw-display-virtio-gpu-pci"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.