patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <alyssa.ross@unikie.com>
To: devel@spectrum-os.org
Cc: Puck Meerburg <puck@puckipedia.com>,
	Ville Ilvonen <ville.ilvonen@unikie.com>
Subject: Attempting to use virtio-gpu on Apple Silicon
Date: Wed, 7 Dec 2022 11:54:40 +0000	[thread overview]
Message-ID: <20221207115440.a3wm4h6lr4gvctpf@x220> (raw)

[-- Attachment #1: Type: text/plain, Size: 3549 bytes --]

Just a quick write-up of my most recent attempt to use virtio-gpu on my
M2 MacBook Pro, so I (or anybody else) has something to refer to when
trying again in future.

I decided to try again today because Asahi Linux just released their GPU
driver[1].  The result of the experiment was the discovery that
virglrenderer requires OpenGL (ES) 3.1[2], but Asahi's driver currently
only supports OpenGL (ES) 2.  Quoting the release announcement:

> What’s next? Supporting more applications. While OpenGL (ES) 2
> suffices for some applications, newer ones (especially games) demand
> more OpenGL features. OpenGL (ES) 3 brings with it a slew of new
> features, like multiple render targets, multisampling, and transform
> feedback. Work on these features is well under way, but they will each
> take a great deal of additional development effort, and all are needed
> before OpenGL (ES) 3.0 is available.

So for us, it sounds like the thing to do is to wait until newer OpenGL (ES)
is supported, and then try again.

Anyway, here's what I did:

First, I installed installed the GPU drivers on my Asahi install
following the instructions in the release announcement.  Then, I checked
out the wayland branches for Spectrum and Spectrum's Nixpkgs, and
grabbed the CARGO_TARGET_*_LINKER and PKG_CONFIG_WAYLAND_PROTOCOLS_PKGDATADIR
fixes from commit fb60a5c9473b0796738aa1b1443b8ee5e5ecd1cb to fix the
crosvm build on ARM.

Then I checked the AsahiLinux/PKGBUILDs repository to see where their
mesa sources lived, and found them using commit af7db4903008b012bca13558261d552ed0828b7d
from https://gitlab.freedesktop.org/asahi/mesa.git.

This Mesa tree was more recent than the one in our Wayland branch, so I
needed to backport some Nixpkgs changes to be able to build it.  I
cherry-picked the following commits:

    952dbf0a4ae mesa: build more Vulkan drivers on aarch64-linux
    906947555d2 mesa: 22.2.2 -> 22.2.3
    7a222ffee31 mesa: fix build on darwin
    8d7db0597f9 mesa: rm unused attributes
    aa8d873a4eb mesa: 22.2.1 -> 22.2.2
    33a5279d620 mesa: add vulkanLayers option and default it to device-select, overlay
    b4b99f16da9 mesa: re-enable video-codecs
    445887f636e mesa: 22.1.7 -> 22.2.1
    dd3fc581129 mesa: Install radv override configs into $out
    40ee116f25a spirv-llvm-translator_14: init at 14.0.0
    ea2ca5e6394 spirv-llvm-translator: version depends on llvm version

And then I applied Nixpkgs PR #204125, which at the time of writing is
still a draft.

At this point, I was able to build Mesa 22.3, and then swap in the asahi
sources.  To get the right drivers to build, I set galliumDrivers to
["swrast" "virgl" "kmsro" "asahi"] and enableGalliumNine to false.

Finally, I set up /run/opengl-driver to be a symlink to mesa's drivers
output, since that path doesn't usually exist on non-NixOS.

To debug why it wasn't working, on Puck's advice I ran the VM in the
img/app development shell like this:

    nix-shell --arg run ../../vm/app/hello-wayland.nix \
      --run 'make clean && LIBGL_DEBUG=verbose MESA_DEBUG=1 EGL_LOG_LEVEL=debug make -j4 run VMM=crosvm'

This produced (among others) the following message:

    libEGL debug: context api is 0x40 while config supports 0xd

Puck looked up the value of these constants, and determined that it
means it doesn't find the required OpenGL (ES) version.

[1]: https://asahilinux.org/2022/12/gpu-drivers-now-in-asahi-linux/
[2]: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/202

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2022-12-07 11:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 11:54 Alyssa Ross [this message]
2022-12-08  8:53 ` vadik likholetov
2022-12-09 10:14   ` 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=20221207115440.a3wm4h6lr4gvctpf@x220 \
    --to=alyssa.ross@unikie.com \
    --cc=devel@spectrum-os.org \
    --cc=puck@puckipedia.com \
    --cc=ville.ilvonen@unikie.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

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).