tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
898 stars 92 forks source link

GPU errors with NixOS Unstable #239

Open gender-combinator opened 1 month ago

gender-combinator commented 1 month ago

I'm having trouble getting the gpu working. It didn't show up in /dev/dri on NixOS 24.05, so I switched to Unstable, which now the card shows up, but throws errors when my wayland compositors try using it (Sway, Jay). I've ran drm_info and that is failing for /dev/dri/card/1.

unstable revision: 27e30d177e57d912d614c88c622dcfdb2e6e6515 nixos configuration includes:

hardware.asahi.useExperimentalGPUDriver = true;
hardware.graphics.enable = true;

drm_info output and logs: info.txt sway logs: without any env: sway-log-default.txt with WLR_DRM_DRIVERS=/dev/dri/card1: sway-log.txt asahi logs in kernel: kernel.txt

Smaug123 commented 1 month ago

This is me too, with my config being https://github.com/Smaug123/nix-dotfiles/blob/d7221c2af1c68422e6f1f73b4cac071c7f8ba1b8/home-manager/earthworm-config.nix . (Looks like the same issue, specifically the error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"; I asked at https://discourse.nixos.org/t/asahi-sway-gpu-failure/54721 before finding this GitHub issue.)

(My knowledge of the graphics stack is too bad to even know who would be best placed to receive a support request, I'm afraid!)

fx-chun commented 1 month ago

@gender-combinator @Smaug123: It sounds like we've had similar issues. That EGL_BAD_PARAMETER error is a bit of a red herring; I'm still able to successfully run hardware-accelerated sway even with that message occurring in the beginning. I believe it occurs as a side effect of the initialization process wlroots does to find a valid DRM configuration to display with & isn't harmful.

When running with sway -d, are you seeing an Operation not supported error from drmSyncobjCreate in the logs? This ultimately ended up being my true problem when trying to diagnose my sway issue: https://github.com/nix-community/nixpkgs-wayland/issues/469

TL;DR: I had to set WLR_RENDER_NO_EXPLICIT_SYNC=1 for sway built against a recent-enough wlroots.

Smaug123 commented 1 month ago

That env var didn't help me I'm afraid. Sorry I'm on my phone, but "DRM device '/dev/dri/card0' has no render mode, falling back to primary node" is the last log line before a segfault in strlen (stack trace is strdup, dri2_initialize_drm, dri2_initialize, eglInitialize, egl_initdisplay, egl_init...). No lines related to drmSyncObjCreate.

gender-combinator commented 1 month ago

My setup seems similar to @Smaug123 , since I'm also getting the same error except with card1.

I probably won't be able to reproduce this after tomorrow as I switch over to the fedora build. (I've been banging my head on this a lot...)

Smaug123 commented 17 hours ago

Some combination of the following fixed this for me, so I now have GPU acceleration as desired: