patches and low-level development discussion
 help / color / mirror / code / Atom feed
* Attempting to use virtio-gpu on Apple Silicon
@ 2022-12-07 11:54 Alyssa Ross
  2022-12-08  8:53 ` vadik likholetov
  0 siblings, 1 reply; 3+ messages in thread
From: Alyssa Ross @ 2022-12-07 11:54 UTC (permalink / raw)
  To: devel; +Cc: Puck Meerburg, Ville Ilvonen

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Attempting to use virtio-gpu on Apple Silicon
  2022-12-07 11:54 Attempting to use virtio-gpu on Apple Silicon Alyssa Ross
@ 2022-12-08  8:53 ` vadik likholetov
  2022-12-09 10:14   ` Alyssa Ross
  0 siblings, 1 reply; 3+ messages in thread
From: vadik likholetov @ 2022-12-08  8:53 UTC (permalink / raw)
  To: Alyssa Ross; +Cc: devel, Puck Meerburg, Ville Ilvonen

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

On ke, joulu 7 2022 at 11.54.40 +00:00:00, Alyssa Ross 
<alyssa.ross@unikie.com> wrote:
> 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

If you're going to update Mesa package -- I could try to enable 
acceleration in waypipe if I have Mesa build ?

-- 
vadik likholetov


[-- Attachment #2: Type: text/html, Size: 1238 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Attempting to use virtio-gpu on Apple Silicon
  2022-12-08  8:53 ` vadik likholetov
@ 2022-12-09 10:14   ` Alyssa Ross
  0 siblings, 0 replies; 3+ messages in thread
From: Alyssa Ross @ 2022-12-09 10:14 UTC (permalink / raw)
  To: vadik likholetov; +Cc: devel, Puck Meerburg, Ville Ilvonen

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

On Thu, Dec 08, 2022 at 10:53:08AM +0200, vadik likholetov wrote:
> On ke, joulu 7 2022 at 11.54.40 +00:00:00, Alyssa Ross <alyssa.ross@unikie.com> wrote:
> > 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
>
> If you're going to update Mesa package -- I could try to enable acceleration
> in waypipe if I have Mesa build ?

Well, this attempt was a failure, so I won't be bringing in these Mesa
updates, but I will soon be rebasing the Wayland branches onto
Spectrum's rootfs branch, which will bring in a recent Mesa.

I don't think it will help you with the acceleration, though.  Mesa just
isn't really compatible with static linking.  For acceleration, you
probably need to be using pkgsMusl.waypipe, which will be dynamically
linked and probably have working Mesa.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-09 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 11:54 Attempting to use virtio-gpu on Apple Silicon Alyssa Ross
2022-12-08  8:53 ` vadik likholetov
2022-12-09 10:14   ` Alyssa Ross

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