From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id CC5C656F93; Wed, 7 Dec 2022 11:54:49 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 5754D56F39; Wed, 7 Dec 2022 11:54:46 +0000 (UTC) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by atuin.qyliss.net (Postfix) with ESMTPS id C598756F82 for ; Wed, 7 Dec 2022 11:54:42 +0000 (UTC) Received: by mail-ej1-x62e.google.com with SMTP id qk9so13419074ejc.3 for ; Wed, 07 Dec 2022 03:54:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=GX0KJLsb8P0sbolxFy9kNFgUbSVc1M+yNgyorq+7bhA=; b=TVtDODE3uHq1qTqisy0ygUzlqtUj+3yxp9BUeMShtRWlOpo6TyQ2iUaEDY/9yZXyMg DR8J4xmWGpCZiBS+jseoYDy6JasC42CyqdyeaaAHkWeBK16A2cbN8WaR61OOdmK54cKy fbv2Yp+leNxc6fYVGq+HprWbNCLfh5osKlLZM5pUGNvSeu7iDVsATCmoubr2pAG2Jynv ZwOyxXkZFZ+ED8FoKhEL30hABJrRv/LohByHVzOpwLS1Pdo1hZ1DCqq35pFLsiu5nm5I nkJsv7VWXV9Ju1NX6cAbsA2fnfsZtslhcqxNwZH5UmSOBBUPjExahxd4X0TnxaoDrMHJ kVzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GX0KJLsb8P0sbolxFy9kNFgUbSVc1M+yNgyorq+7bhA=; b=Lb3OBBGEtG9WyCU4gYGdjnKj1GtIl2ZiL3Z2c2mh1MuxY94isN6i5BeTmFPCC2TPHq LIGRdHQ4IZm/Yym3DRNwyLw6jobO8PPzPAam7Xxj4KnPS3by7yUHW0QWQp+rD9aBMPNx jMykv9oeEeLaXpSs6S8wmV5OPuF6ttuX528fjxJwH8oR7xWyBZwaaRIItnlgv4XgoM7p s5DrKgslNtww8/n9sKCFYA1l0MV8/yiWMQ4gvXyfHdBKTzEcLyHuP7e8FMXGfOhInpkt 2iubBowC/gzIdO3owXp4K1IyLVHjVW0kR97gBkt6FtUXTm5q2lrnvyDzeDP8UjuYOkOc NH9Q== X-Gm-Message-State: ANoB5pmO9lxhk3ZzJjAZbGX4Yi3m3crNqMPIU+dYZQJHXI7Xd1xBbrdt Vd/1s7Bpv6XqJpUxKETdqr8GkA== X-Google-Smtp-Source: AA0mqf7q/dzP9jW1+tj7viQ4JGYwvU2K5vbDoe3EE89flAaDhioSduN/eMkUXrlJB4/ALlJhQc/EUQ== X-Received: by 2002:a17:907:9253:b0:7c0:e984:e74e with SMTP id kb19-20020a170907925300b007c0e984e74emr12199657ejb.238.1670414082227; Wed, 07 Dec 2022 03:54:42 -0800 (PST) Received: from x220.qyliss.net (p200300ed67055c01000000000000000d.dip0.t-ipconnect.de. [2003:ed:6705:5c01::d]) by smtp.gmail.com with ESMTPSA id o3-20020a170906768300b007b27fc3a1ffsm8404183ejm.121.2022.12.07.03.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 03:54:41 -0800 (PST) Received: by x220.qyliss.net (Postfix, from userid 1000) id F22613B9DD; Wed, 7 Dec 2022 11:54:40 +0000 (UTC) Date: Wed, 7 Dec 2022 11:54:40 +0000 From: Alyssa Ross To: devel@spectrum-os.org Subject: Attempting to use virtio-gpu on Apple Silicon Message-ID: <20221207115440.a3wm4h6lr4gvctpf@x220> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hhs6khc4qzoiicu4" Content-Disposition: inline Message-ID-Hash: LBL2NZKPQVTHVYYE2O3VDSEZLHVY4PGC X-Message-ID-Hash: LBL2NZKPQVTHVYYE2O3VDSEZLHVY4PGC X-MailFrom: alyssa.ross@unikie.com X-Mailman-Rule-Hits: header-match-devel.spectrum-os.org-0 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1 CC: Puck Meerburg , Ville Ilvonen X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --hhs6khc4qzoiicu4 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=E2=80=99s 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_PKGDATAD= IR 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 af7db4903008b012bca13558261= d552ed0828b7d =66rom 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-sele= ct, 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=3Dverbose MESA_DEBUG=3D1 EGL_LOG_LEV= EL=3Ddebug make -j4 run VMM=3Dcrosvm' 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 --hhs6khc4qzoiicu4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEH9wgcxqlHM/ARR3h+dvtSFmyccAFAmOQfvgACgkQ+dvtSFmy ccAS4w/8CHQDsCCw3ZfCx4EGqIsYbJbsXMh5L9814Bx9mOCSfRyJom142KxjjCG6 QHA09Z6lJFNjqdsQf0EZDTAwnswUZwoxIKdqHbM8edv0LBnlcYqrywgkZGEeg0QI PqLzdq7NaK543vm5houcSMlGOPMxEFu8Z4imfk+BT560AedTzugi819oxLw87hlC MGvXWoQYllFuxgM9Bk+BmSES/49SF5KThYBTZ8eKeXV8sWZ0+DWKN4mICi3dMaAA VVMFUO/obtJiAPL4lOAkWqqzSgq9X6EI1s41gIrxUsOhUaSuWTlJGrPfK+98izxT OVa+b+QcziqUtmunbJlPGBn2WKFk4o+vTRQx806rq5K1mqtt3F9SpZTVhgrZGgEB cECn0+gQ68q5CwqedFKBDL4q1COIMZcQskOSrr+n4lAC+rUFm7Lgyo1KavIZ81KJ PRIluRbXd1hAn9wzG2/j5N19Jin076iWdw5e8QBAhNhDHUZ4GM7nRDxyHoM0Q/uP eONqiw3gmBInqdRdmyH3pzEbL5QDvu/6wKWjFRr/4+B1Kal7Tf/vuIoxJOI0Rtu/ vyLKfHD/uzgtKx2aWKVHT3WWIkW40KugOOp7HYRnVE7jPh6DJP8c1iXKBT4kUVuB g6CsrRNPE5B3CxqUogGKGNaK+xI0JQjOZDxKizPlEFJhfGPY1Zg= =fNwU -----END PGP SIGNATURE----- --hhs6khc4qzoiicu4--