general high-level discussion about spectrum
 help / color / mirror / Atom feed
From: Thomas Leonard <talex5@gmail.com>
To: Alyssa Ross <hi@alyssa.is>
Cc: discuss@spectrum-os.org
Subject: Re: Using virtio-gpu instead of virtwl
Date: Sun, 15 May 2022 15:20:24 +0000	[thread overview]
Message-ID: <CAG4opy-3QMbGpLOgAqqbjVp1jyE1tqP+EM6ffc-A+w6nwRG79g@mail.gmail.com> (raw)
In-Reply-To: <20220414135737.lvfbrch34kjojn3s@eve>

On Thu, 14 Apr 2022 at 13:57, Alyssa Ross <hi@alyssa.is> wrote:
>
> On Wed, Apr 13, 2022 at 05:12:13PM +0000, Thomas Leonard wrote:
> > On Wed, 6 Apr 2022 at 12:19, Thomas Leonard <talex5@gmail.com> wrote:
> > [ converting from virtwl to virtio-gpu ]
> > > I tried, but failed, to figure out the protocol. I did manage to get a
> > > test application showing a little animation, but it crashes after a
> > > few seconds.
> >
> > OK, I found a solution to this: you can just open the device file
> > twice and use one instance for Wayland messages and the other for
> > allocating images. This avoids the first race. With that, I got the
> > proxy converted:
> >
> >   https://github.com/talex5/wayland-proxy-virtwl/pull/28
> >
> > Though I'm not sure it's an improvement: +1,819 −577 lines!
> >
> > Instructions for configuring crosvm to use it:
> >
> >   https://github.com/talex5/wayland-proxy-virtwl#virtio-gpu-support
> >
> > And I wrote up my guesses about the protocol here:
> >
> >   https://github.com/talex5/wayland-proxy-virtwl/blob/master/virtio-spec.md
>
> That's extremely helpful, thanks for writing it up!

A small update on this:

First, I got virtio-gpu working with the jail. It just needs a couple
of extra paths for NixOS:

diff --git a/src/linux.rs b/src/linux.rs
index ad031749..52d3142f 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -790,6 +790,8 @@ fn gpu_jail(cfg: &Config, policy: &str) ->
Result<Option<Minijail>> {
             jail_mount_bind_if_exists(
                 &mut jail,
                 &[
+                    "/run/opengl-driver",
+                    "/nix/store",
                     "/usr/lib",
                     "/usr/lib64",
                     "/lib",

Secondly, I realised that the "video" memory returned by virtio-gpu
was just regular host memory (from stracing crosvm). This is because
crosvm is compiled without minigbm support and falls back to this.

After enabling minigbm and its amdgpu support (which also required
adding a dependency on mesa) it started allocating vram. However, this
broke the proxy because vram can't be used with the Wl_shm protocol.

I updated the proxy's test.ml code (which opens a window with a
scrolling pattern) to use Linux_dmabuf_unstable_v1, and that almost
worked. But some of the pixels are wrong and it often crashes the
whole VM. Possibly some of the output is getting stuck in a cache
somewhere and is not actually flushed to the graphics card in time?
Unfortunately, I don't know anything about GPUs.

Anyway, I merged the changes I had, in case anyone else wants to try
to get it working:

  https://github.com/talex5/wayland-proxy-virtwl/pull/33

If it did work, it should make things a bit more efficient by avoiding
one copy. At the moment, I think the process is:

1. Application renders to guest memory.
2. Proxy copies to host memory.
3. Compositor copies to graphics card.

If the mingbm stuff worked, the proxy could copy directly to the
graphics card. And possibly the application could render there
directly in the first place, but that would need more work.


-- 
talex5 (GitHub/Twitter)
http://roscidus.com/blog/


  parent reply	other threads:[~2022-05-15 14:20 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 19:27 New user getting started questions Thomas Leonard
2021-01-05 20:09 ` Michael Raskin
2021-01-06  7:04   ` Alyssa's break Alyssa Ross
2021-01-06  9:11     ` Michał "rysiek" Woźniak
2021-01-06  7:00 ` New user getting started questions Alyssa Ross
2021-01-06 15:56   ` Thomas Leonard
2021-01-07 11:38     ` Thomas Leonard
2021-01-07 15:33     ` Thomas Leonard
2021-01-14 12:29     ` Alyssa Ross
2021-01-14 12:51       ` Alyssa Ross
2021-01-20 13:04         ` Thomas Leonard
2021-01-27 17:31           ` Thomas Leonard
2021-03-07 12:52             ` Thomas Leonard
2021-03-09 16:59               ` Qubes-lite With KVM and Wayland Alyssa Ross
2021-03-10 14:19                 ` Thomas Leonard
2021-03-10 22:34                   ` Alyssa Ross
2021-03-09 16:25             ` New user getting started questions Alyssa Ross
2021-03-13  7:21               ` Thomas Leonard
2021-03-13 13:52                 ` Alyssa Ross
2021-10-30 12:58                 ` Thomas Leonard
2021-11-03 11:36                   ` Alyssa Ross
2021-11-03 18:27                     ` Thomas Leonard
2021-11-10 12:58                       ` Alyssa Ross
2021-11-10 12:00                         ` Thomas Leonard
2021-11-11 11:09                           ` Alyssa Ross
2021-11-11 16:12                             ` Thomas Leonard
2021-11-12 10:47                               ` Alyssa Ross
2022-03-13 15:08                         ` Thomas Leonard
2022-03-15 14:06                           ` Alyssa Ross
2022-03-15 20:23                             ` Alyssa Ross
2022-03-16 16:18                               ` Using virtio-gpu instead of virtwl Thomas Leonard
2022-03-16 16:54                                 ` Alyssa Ross
2022-03-21 12:10                                 ` Thomas Leonard
2022-03-21 16:05                                   ` Alyssa Ross
2022-03-22 11:08                                     ` Thomas Leonard
2022-03-22 11:16                                       ` Alyssa Ross
2022-03-22 20:05                                         ` Thomas Leonard
2022-04-06 12:19                                           ` Thomas Leonard
2022-04-13 17:12                                             ` Thomas Leonard
2022-04-14 13:57                                               ` Alyssa Ross
2022-04-19 12:58                                                 ` Thomas Leonard
2022-04-19 12:01                                                   ` Alyssa Ross
2022-05-15 15:20                                                 ` Thomas Leonard [this message]
2022-05-16 11:55                                                   ` Alyssa Ross
2022-05-18  9:55                                                     ` Thomas Leonard
2022-06-05 16:29                                                       ` Thomas Leonard
2022-08-09 12:00                                     ` Alyssa Ross
2022-10-10 15:16                                       ` Thomas Leonard
2022-10-10 16:53                                         ` Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG4opy-3QMbGpLOgAqqbjVp1jyE1tqP+EM6ffc-A+w6nwRG79g@mail.gmail.com \
    --to=talex5@gmail.com \
    --cc=discuss@spectrum-os.org \
    --cc=hi@alyssa.is \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).