nixos-apple-silicon icon indicating copy to clipboard operation
nixos-apple-silicon copied to clipboard

GPU Slow (Wayland/Hyprland) [M2 Macbook Air]

Open Pickles888 opened this issue 10 months ago • 10 comments

I have not tried going on X11 yet but on wayland my GPU seems to be very slow. I am currently using hyprland but I had the same issue on GNOME. I am not sure if it is a problem with it using the integrated GPU or with GPU acceleration not working. I know its not a hardware issue because previously on asahi with Arch Linux it ran very smoothly. (sorry if my terminology is incorrect)

EDIT: Something else that might be relevant is that my battery drains very fast. (could be caused by the use of integrated graphics?)

I have tried:

  • setting github:tpwrules/nixos-apple-silicon"; in my flake and updating
  • setting environment.sessionVariables.WLR_DRM_DEVICES = "/dev/dri/card0"; (made hyprland work)

output of of nix-shell -p glxinfo --run glxinfo | grep 'OpenGL renderer string':

OpenGL renderer string: Apple M2 (G14G B0)

my configuration.nix (I am using flakes, the firmware directory is not set because I set it in the module :P | EDIT: I put the module back to default and now use the normal way to put it in the flake):

{ config, lib, pkgs, inputs, ... }: {
  imports = [ ./hardware-configuration.nix ./apple-silicon-support ];

  grub.enable = false;
  bluetooth.enable = true;
  workman.enable = true;

  environment.sessionVariables.WLR_DRM_DEVICES = "/dev/dri/card0";

  hardware = {
    opengl = {
      enable = true;
      driSupport32Bit = lib.mkForce false;
      driSupport = true;
    };

    asahi = {
      useExperimentalGPUDriver = true;
      experimentalGPUInstallMode = "overlay";
      withRust = true;
    };
  };

  boot = {
    consoleLogLevel = 0;
    kernelParams = [ "apple_dcp.show_notch=1" ];
  };

  sound.enable = true;

  networking.wireless.iwd = {
    enable = true;
    settings.General.EnableNetworkConfiguration = true;
  };

  networking.hostName = "NixLaptop";
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  system.stateVersion = "23.11"; # Did you read the comment?
}

My hyprland config (home-manager):

{ config, lib, pkgs, inputs, ... }: {
  wayland.windowManager.hyprland = {
    enable = true;
    xwayland.enable = true;
    settings = {
      monitor = "DP-1,1920x1080@240,0x0,1"; # "${config.hyprland.display}";
      env = [
        "XCURSOR_SIZE,24"
        "XCURSOR_THEME,${config.home.pointerCursor.name}"
        "GTK_THEME,${config.gtk.theme.name}"
      ];

      exec-once = [
        "swaybg -i /etc/nixos/assets/evening-sky.png"
        "swaync"
        "hypridle"
        "lxqt-policykit-agent"
      ];

      input = {
        kb_layout = "us,us";
        kb_variant = "workman,,";
        follow_mouse = "1";
        accel_profile = "flat";
        sensitivity = "0.2";
        touchpad = {
          natural_scroll = true;
          scroll_factor = "0.7";
          clickfinger_behavior = true;
          tap-and-drag = true;
          tap-to-click = false;
        };
      };

      general = {
        gaps_in = "10";
        gaps_out = "10";
        border_size = "0";
        layout = "dwindle";
        allow_tearing = "false";
      };

      decoration = {
        rounding = "12";
        blur = {
          enabled = true;
          size = "4";
          passes = "5";
        };

        drop_shadow = "no";
        active_opacity = "0.9";
        inactive_opacity = "0.7";
      };

      animations = {
        enabled = "yes";
        bezier = [
          "linear, 0.5, 0.5, 0.5, 0.5"
          "antiEase, 0.6, 0.4, 0.6, 0.4"
          "ease, 0.4, 0.6, 0.4, 0.6"
          "smooth, 0.5, 0.9, 0.6, 0.95"
          "htooms, 0.95, 0.6, 0.9, 0.5"
          "powered, 0.5, 0.2, 0.6, 0.5"
        ];

        animation = [
          "windows, 1, 2.5, smooth"
          "windowsOut, 1, 1, htooms, popin 80%"
          "fade, 1, 5, smooth"
          "workspaces, 1, 6, default"
        ];
      };

      dwindle = {
        pseudotile = "yes";
        preserve_split = "yes";
      };

      misc = { force_default_wallpaper = "0"; };

      # Cut out binds because it was long and irrelevant #
    };
  };
}

My flake:

{
  description = "asynth's nixos configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nixvim = {
      url = "github:nix-community/nixvim";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    apple-silicon-support.url = "github:tpwrules/nixos-apple-silicon";
  };

  outputs = { nixpkgs, nixvim, home-manager, ... }@inputs:
    let
      customLib =
        import ./customLib/default.nix { inherit inputs home-manager; };
    in with customLib; {
      nixosConfigurations = {
        NixPC = mkSystem "x86_64-linux" ./hosts/pc/configuration.nix
          ./hosts/pc/home.nix { inherit inputs nixvim customLib; };

        liveiso = mkSystem "x86_64-linux" ./hosts/liveiso/configuration.nix
          ./hosts/liveiso/home.nix { inherit inputs; };

        NixLaptop = mkSystem "aarch64-linux" ./hosts/laptop/configuration.nix
          ./hosts/liveiso/home.nix { inherit inputs nixvim customLib; };
      };

      home-managerModules.default = ./home-managerModules;
      modules.default = ./modules;
    };
}

Pickles888 avatar Apr 28 '24 20:04 Pickles888

What do you mean by 'slow' and what's the measure? This line looks a bit suspicious, is this correct resolution and refresh rate?

monitor = "DP-1,1920x1080@240,0x0,1";

zvolin avatar May 05 '24 17:05 zvolin

on M2 Pro I have this:

❯ hyprctl monitors
Monitor eDP-1 (ID 0):
	[email protected] at 0x0

zvolin avatar May 05 '24 17:05 zvolin

One idea is to check if you can find anything suspicios in drm debug log. Another idea is dual booting and comparing glxinfo or drm logs :thinking:

zvolin avatar May 05 '24 17:05 zvolin

Had the same issue when trying out Hyprland on an M2 Air, it's super fast on X11. For me it was "slow" in basic things like window animations or scrolling inside a web browser.

3rd avatar May 05 '24 18:05 3rd

I see my device has the same gpu and I don't experience any slowness. Random idea, but maybe it's this notch?

kernelParams = [ "apple_dcp.show_notch=1" ];

zvolin avatar May 05 '24 19:05 zvolin

󰅷 hyprctl monitors     
Monitor eDP-1 (ID 0):
	[email protected] at 0x0

unsetting the notch thing did not work

I also unset the monitor and it did not help.

Pickles888 avatar May 06 '24 05:05 Pickles888

I did drm debug logging: gist because otherwise it was too long

Pickles888 avatar May 10 '24 03:05 Pickles888

here's mine for comparison

zvolin avatar May 11 '24 16:05 zvolin

I think that amount of DRM_IOCTL_SYNCOBJ_WAIT in your logs may be related to the 'slowness' feeling, but I have no idea what could cause it, not even if they are unexpected

zvolin avatar May 11 '24 17:05 zvolin

using hyprland fine on m2 air with theses settings:

configuration.nix

  hardware.asahi = {
    withRust = true;
    useExperimentalGPUDriver = true;
    experimentalGPUInstallMode = "replace";
    setupAsahiSound = true;
  };

and hyprland.conf

monitor=,highres,auto,2
exec-once=xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2

foldfree avatar Jul 09 '24 06:07 foldfree