Graphics: Difference between revisions

Created page with "This is intended to be an overview of how setting up graphics on NixOS works. == Hardware-Specific Pages == * Intel Graphics == Kernel-Level == Kernel-level GPU support is provided by a kernel module. E.g. for AMD GPUs (including iGPUs) that's <code>amdgpu</code>. The module is loaded automatically based on the detected hardware. On x86 devices, detection is done automatically through ACPI. On ARM devices such as the Raspberry Pi, information about hardware is pr..."
 
Likivik (talk | contribs)
m 'glxinfo' has been renamed to/replaced by 'mesa-demos'
 
(6 intermediate revisions by 5 users not shown)
Line 4: Line 4:


* [[Intel Graphics]]
* [[Intel Graphics]]
* [[AMD GPU]]
* [[Nvidia]]


== Kernel-Level ==
== Kernel-Level ==
Line 20: Line 22:
== OpenGL ==
== OpenGL ==


{{Note|<code>hardware.opengl</code> will be renamed to <code>hardware.graphics</code> in NixOS 24.11.}}
{{Note|<code>hardware.opengl</code> was renamed to <code>hardware.graphics</code> in NixOS 24.11.}}


Userspace-level graphics support is provided through OpenGL. The kernel module is used just for interfacing with the hardware, the OpenGL driver is what Wayland (or the X server) actually uses for rendering.
Userspace-level graphics support is provided through OpenGL. The kernel module is used just for interfacing with the hardware, the OpenGL driver is what Wayland (or the X server) actually uses for rendering.
Line 26: Line 28:
The OpenGL implementation used on Linux is the [[Mesa|Mesa graphics library]]. Mesa contains drivers for various hardware, the exact driver is selected automatically. Note that Mesa also supports software rendering if no compatible hardware driver is available, but this is very slow.
The OpenGL implementation used on Linux is the [[Mesa|Mesa graphics library]]. Mesa contains drivers for various hardware, the exact driver is selected automatically. Note that Mesa also supports software rendering if no compatible hardware driver is available, but this is very slow.


Mesa can installed using the option <code>hardware.opengl.enable</code>, but note that most desktop environment modules set this themselves anyway. This option writes the driver files to <code>/run/opengl-driver</code>. Additional graphics drivers packages can be added using <code>hardware.opengl.extraPackages</code>.
Mesa can installed using the option <code>hardware.graphics.enable</code>, but note that most desktop environment modules set this themselves anyway. This option writes the driver files to <code>/run/opengl-driver</code>. Additional graphics drivers packages can be added using <code>hardware.graphics.extraPackages</code>.


To verify which Mesa driver is used: <code>nix shell nixpkgs#glxinfo -c glxinfo</code>
To verify which Mesa driver is used: <code>nix shell nixpkgs#mesa-demos -c glxinfo</code>




Line 40: Line 42:
== OpenCL ==
== OpenCL ==


Computing things on the GPU is supported through the OpenCL API. To enable OpenCL support, add the right packages for your hardware to <code>hardware.opengl.extraPackages</code>. See also [https://wiki.archlinux.org/title/GPGPU the Arch Wiki].
Computing things on the GPU is supported through the OpenCL API. To enable OpenCL support, add the right packages for your hardware to <code>hardware.graphics.extraPackages</code>. See also [https://wiki.archlinux.org/title/GPGPU the Arch Wiki].


To verify OpenCL support: <code>nix shell nixpkgs#clinfo -c clinfo</code>
To verify OpenCL support: <code>nix shell nixpkgs#clinfo -c clinfo</code>
Line 74: Line 76:


To verify VDPAU support and view supported codecs: <code>nix shell nixpkgs#vdpauinfo -c vdpauinfo</code>
To verify VDPAU support and view supported codecs: <code>nix shell nixpkgs#vdpauinfo -c vdpauinfo</code>
Note that VDPAU will not be able to detect the correct drive to use in most Wayland enviroments, as there is no DRI2 support. The driver will always fall back to <code>nvidia</code> if it wasn't set using <code>VDPAU_DRIVER</code>.<ref>[https://gitlab.freedesktop.org/vdpau/libvdpau/-/blob/2afa3f989af24a922692ac719fae23c321776cdb/src/vdpau_wrapper.c#L129]</ref>


== See also ==
== See also ==
Line 79: Line 83:
* The Arch Wiki has good articles on a lot of these topics, which are linked above.
* The Arch Wiki has good articles on a lot of these topics, which are linked above.
* [https://git.eisfunke.com/config/nixos/-/blob/main/docs/graphics.md?ref_type=heads writeup about setting up graphics] in Eisfunke's NixOS config repo (this article was originally based on that)
* [https://git.eisfunke.com/config/nixos/-/blob/main/docs/graphics.md?ref_type=heads writeup about setting up graphics] in Eisfunke's NixOS config repo (this article was originally based on that)
[[Category:Video]]