diff --git a/common/gpu/amd/default.nix b/common/gpu/amd/default.nix index 91ba0b7..e86bb01 100644 --- a/common/gpu/amd/default.nix +++ b/common/gpu/amd/default.nix @@ -6,11 +6,30 @@ ) // { default = true; }; + options.hardware.amdgpu.amdvlk = lib.mkEnableOption (lib.mdDoc + "use amdvlk drivers instead mesa radv drivers" + ) // { + default = true; + }; + options.hardware.amdgpu.opencl = lib.mkEnableOption (lib.mdDoc + "rocm opencl runtime (Install rocm-opencl-icd and rocm-opencl-runtime)" + ) // { + default = true; + }; config = lib.mkMerge [ { services.xserver.videoDrivers = lib.mkDefault [ "amdgpu" ]; - + + hardware.opengl = { + driSupport = lib.mkDefault true; + driSupport32Bit = lib.mkDefault true; + }; + } + (lib.mkIf config.hardware.amdgpu.loadInInitrd { + boot.initrd.kernelModules = [ "amdgpu" ]; + }) + (lib.mkIf config.hardware.amdgpu.amdvlk { hardware.opengl.extraPackages = with pkgs; [ rocm-opencl-icd rocm-opencl-runtime @@ -20,16 +39,14 @@ hardware.opengl.extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ]; - - hardware.opengl = { - driSupport = lib.mkDefault true; - driSupport32Bit = lib.mkDefault true; - }; - + environment.variables.AMD_VULKAN_ICD = lib.mkDefault "RADV"; - } - (lib.mkIf config.hardware.amdgpu.loadInInitrd { - boot.initrd.kernelModules = [ "amdgpu" ]; + }) + (lib.mkIf config.hardware.amdgpu.opencl { + hardware.opengl.extraPackages = with pkgs; [ + rocm-opencl-icd + rocm-opencl-runtime + ]; }) ]; } diff --git a/lenovo/legion/16ach6h/default.nix b/lenovo/legion/16ach6h/default.nix index 4041c09..523d9d0 100644 --- a/lenovo/legion/16ach6h/default.nix +++ b/lenovo/legion/16ach6h/default.nix @@ -7,6 +7,12 @@ # This specialisation is for the case where "DDG" (Dual-Direct GFX, A hardware feature that can enable in bios) is enabled, since the amd igpu is blocked at hardware level and the built-in display is directly connected to the dgpu, we no longer need the amdgpu and prime configuration. system.nixos.tags = [ "Dual-Direct-GFX-Mode" ]; services.xserver.videoDrivers = [ "nvidia" ]; # This will override services.xserver.videoDrivers = lib.mkDefault [ "amdgpu" "nvidia" ]; - hardware.nvidia.prime.offload.enable = false; + hardware = { + nvidia.prime.offload.enable = false; + amdgpu = { + amdvlk = false; + opencl = false; + }; + }; }; } \ No newline at end of file diff --git a/lenovo/legion/16ach6h/nvidia/default.nix b/lenovo/legion/16ach6h/nvidia/default.nix index e54fc20..31de5c1 100644 --- a/lenovo/legion/16ach6h/nvidia/default.nix +++ b/lenovo/legion/16ach6h/nvidia/default.nix @@ -3,5 +3,24 @@ { imports = [ ../hybrid ]; services.xserver.videoDrivers = [ "nvidia" ]; # This will override services.xserver.videoDrivers = lib.mkDefault [ "amdgpu" "nvidia" ]; - hardware.nvidia.prime.offload.enable = false; + # When I play the game through proton, I found that in the case of Dual-Direct GFX + # enabled (dGPU disabled), proton will crash directly. But in the case of hybrid, + # the game runs fine with or without nvidia-offload After investigation, this is + # because when writing the specialization of Dual-Direct GFX, I did not completely + # remove all packages for amd igpu. I only removed amdgpu from + # services.xserver.videoDrivers by overriding. This is because the specialization + # of nix cannot implement such an operation as canceling an import. In the end, if + # it is enabled in Dual-Direct GFX In the absence of amd igpu, the amdvlk package + # caused the proton to crash. In order to solve this problem, I add the option of + # whether to enable amdvlk to the configuration file of amd gpu, and open it by + # default, and turn it off in specialization, so as to delete amdvlk package and + # other packages for amd igpu in specialization. At the same time, I also added an + # option to amdgpu's opencl runtime. + hardware = { + nvidia.prime.offload.enable = false; + amdgpu = { + amdvlk = false; + opencl = false; + }; + }; } \ No newline at end of file