mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 20:04:20 +00:00
rutabaga_gfx: allow running context types without 3D component
It's not necessary to build 3D rendering support to run the cross-domain context type. Default implementations are added for some hypercalls, since the guest kernel may still think it's running a KMS display. That adds log-spam if errors are present. BUG=b:173630595 TEST=Run weston terminal in the guest Change-Id: I8155cf9d9867a329927b7dd4bb22c385510966a2 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3961536 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
parent
5f4321b0a3
commit
9142190652
3 changed files with 37 additions and 27 deletions
|
@ -1299,27 +1299,24 @@ impl VirtioDevice for Gpu {
|
|||
}
|
||||
|
||||
fn features(&self) -> u64 {
|
||||
let rutabaga_features = match self.rutabaga_component {
|
||||
RutabagaComponentType::Rutabaga2D => 1 << VIRTIO_GPU_F_EDID,
|
||||
_ => {
|
||||
let mut features_3d = 0;
|
||||
let mut virtio_gpu_features = 1 << VIRTIO_GPU_F_EDID;
|
||||
|
||||
features_3d |= 1 << VIRTIO_GPU_F_VIRGL
|
||||
| 1 << VIRTIO_GPU_F_RESOURCE_UUID
|
||||
| 1 << VIRTIO_GPU_F_RESOURCE_BLOB
|
||||
| 1 << VIRTIO_GPU_F_CONTEXT_INIT
|
||||
| 1 << VIRTIO_GPU_F_EDID
|
||||
| 1 << VIRTIO_GPU_F_RESOURCE_SYNC;
|
||||
// If a non-2D component is specified, enable 3D features. It is possible to run display
|
||||
// contexts without 3D backend (i.e, gfxstream / virglrender), so check for that too.
|
||||
if self.rutabaga_component != RutabagaComponentType::Rutabaga2D || self.context_mask != 0 {
|
||||
virtio_gpu_features |= 1 << VIRTIO_GPU_F_VIRGL
|
||||
| 1 << VIRTIO_GPU_F_RESOURCE_UUID
|
||||
| 1 << VIRTIO_GPU_F_RESOURCE_BLOB
|
||||
| 1 << VIRTIO_GPU_F_CONTEXT_INIT
|
||||
| 1 << VIRTIO_GPU_F_EDID
|
||||
| 1 << VIRTIO_GPU_F_RESOURCE_SYNC;
|
||||
|
||||
if self.udmabuf {
|
||||
features_3d |= 1 << VIRTIO_GPU_F_CREATE_GUEST_HANDLE;
|
||||
}
|
||||
|
||||
features_3d
|
||||
if self.udmabuf {
|
||||
virtio_gpu_features |= 1 << VIRTIO_GPU_F_CREATE_GUEST_HANDLE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
self.base_features | rutabaga_features
|
||||
self.base_features | virtio_gpu_features
|
||||
}
|
||||
|
||||
fn ack_features(&mut self, value: u64) {
|
||||
|
|
|
@ -16,11 +16,10 @@ Make sure your guest kernel is either this version or a more recent one, and tha
|
|||
|
||||
## Crosvm requirements
|
||||
|
||||
Wayland forwarding requires the GPU feature and any non-2d virtio-gpu mode to be enabled, so pass
|
||||
them to your `cargo build` or `cargo run` command, e.g:
|
||||
Wayland forwarding requires the GPU feature and the virtio-gpu cross domain mode to be enabled.
|
||||
|
||||
```sh
|
||||
cargo build --features "gpu,virgl_renderer,virgl_renderer_next"
|
||||
```
|
||||
cargo build --features "gpu"
|
||||
```
|
||||
|
||||
## Building sommelier
|
||||
|
@ -62,7 +61,9 @@ from all Wayland guest applications to it. To enable this you need to know the s
|
|||
server running on your host - typically it would be `$XDG_RUNTIME_DIR/wayland-0`.
|
||||
|
||||
Once you have confirmed the socket, create a GPU device and enable forwarding by adding the
|
||||
`--gpu --wayland-sock $XDG_RUNTIME_DIR/wayland-0` arguments to your crosvm command-line.
|
||||
`--gpu=context-types=cross-domain --wayland-sock $XDG_RUNTIME_DIR/wayland-0` arguments to your
|
||||
crosvm command-line. Other context types may be also enabled for those interested in 3D
|
||||
acceleration.
|
||||
|
||||
You can now run Wayland clients through sommelier, e.g:
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ pub trait RutabagaComponent {
|
|||
/// Implementations must create a fence that represents the completion of prior work. This is
|
||||
/// required for synchronization with the guest kernel.
|
||||
fn create_fence(&mut self, _fence: RutabagaFence) -> RutabagaResult<()> {
|
||||
Err(RutabagaError::Unsupported)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Used only by VirglRenderer to poll when its poll_descriptor is signaled.
|
||||
|
@ -85,10 +85,22 @@ pub trait RutabagaComponent {
|
|||
/// buffer. Vulkan components should use blob resources instead.
|
||||
fn create_3d(
|
||||
&self,
|
||||
_resource_id: u32,
|
||||
resource_id: u32,
|
||||
_resource_create_3d: ResourceCreate3D,
|
||||
) -> RutabagaResult<RutabagaResource> {
|
||||
Err(RutabagaError::Unsupported)
|
||||
Ok(RutabagaResource {
|
||||
resource_id,
|
||||
handle: None,
|
||||
blob: false,
|
||||
blob_mem: 0,
|
||||
blob_flags: 0,
|
||||
map_info: None,
|
||||
info_2d: None,
|
||||
info_3d: None,
|
||||
vulkan_info: None,
|
||||
backing_iovecs: None,
|
||||
import_mask: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/// Implementations must attach `vecs` to the resource.
|
||||
|
@ -114,7 +126,7 @@ pub trait RutabagaComponent {
|
|||
_resource: &mut RutabagaResource,
|
||||
_transfer: Transfer3D,
|
||||
) -> RutabagaResult<()> {
|
||||
Err(RutabagaError::Unsupported)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implementations must perform the transfer read operation. For 2D rutabaga components, this
|
||||
|
@ -126,7 +138,7 @@ pub trait RutabagaComponent {
|
|||
_transfer: Transfer3D,
|
||||
_buf: Option<VolatileSlice>,
|
||||
) -> RutabagaResult<()> {
|
||||
Err(RutabagaError::Unsupported)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Implementations must flush the given resource to the display.
|
||||
|
|
Loading…
Reference in a new issue