tpwrules / nixos-apple-silicon

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

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

Open Pickles888 opened 7 months ago

Pickles888 commented 7 months ago

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:

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;
    };
}
zvolin commented 6 months ago

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 commented 6 months ago

on M2 Pro I have this:

❯ hyprctl monitors
Monitor eDP-1 (ID 0):
    2560x1600@60.00000 at 0x0
zvolin commented 6 months ago

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:

3rd commented 6 months ago

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.

zvolin commented 6 months ago

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" ];
Pickles888 commented 6 months ago
󰅷 hyprctl monitors     
Monitor eDP-1 (ID 0):
    2560x1664@60.00000 at 0x0

unsetting the notch thing did not work

I also unset the monitor and it did not help.

Pickles888 commented 6 months ago

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

zvolin commented 6 months ago

here's mine for comparison

zvolin commented 6 months ago

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

foldfree commented 4 months ago

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