Graphics: Difference between revisions

Klinger (talk | contribs)
Likivik (talk | contribs)
m 'glxinfo' has been renamed to/replaced by 'mesa-demos'
 
(4 intermediate revisions by 3 users not shown)
Line 22: 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 28: 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 42: 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 76: 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 ==