User:Maffblaster/Drafts/Graphics
This meta article is a primer to explain the composition and configuration of the modern graphics stack on Linux systems. Historical aspects will be reviewed when necessary, including the X.org server, however the expectation of this primer is to use a Wayland supported desktop environment with a focus on graphic intensive applications, such as games.
Introduction
Historically running a modern graphics stack on POSIX systems was somewhat challenging. Either graphics drivers for the latest hardware was months or years behind the same level of support in Microsoft Windows, or the software compatibility layers were not well supported for the latest games. As of the March, 2021, 70% of the top 50 games available on Steam[1] are support from launch on POSIX systems. This is largely the result of continued effort to develop emulation layers to make software written for non-POSIX systems run on them.
Stakeholders
Corporate and enterprise
There are several parties interested in running software designed for Microsoft Windows - including games - on POSIX compliant systems. Game companies, such as Valve, have been hedging against Microsoft changing licensing terms of Windows. In other words, Valve has been investing in Linux and it's graphics stack in order to have an alternative platform to Microsoft Windows.
Companies that sell Linux commercial and enterprise support, such as Canonical and Red Hat, and open source consulting companies such as Collabora and CodeWeavers also hold interest in Windows software running on POSIX compliant systems. These companies run their businesses on helping software run on POSIX systems.
Game developers and players
Certain game development studios, such as Feral Interactive work to transition games to natively run on Linux.
The players themselves hold interest in running Windows software. Privacy conscious players have concerns surrounding data collection from Big Tech. This generally occurs at the operating system, but also other layers surrounding gaming such as programmable keyboard software such as Razer Synapse, which is "Cloud enabled" and requires a "valid e-mail, software download, license acceptance, and internet connection needed to activate full features and for software updates".[2]
Hardware considerations
When considering hardware for a modern graphic experience on Linux, one should consider support from the hardware manufacturer. Some manufacturers seek to work with Linux kernel developers and open source standards groups to certify their hardware will be operational on Linux from release day. These companies include AMD and Intel.
NVIDIA, while being the largest retailer of full size personal computer graphics hardware in the world, has historically not taken a supportive position on helping their hardware be compatible with an open stack. They have, however, released proprietary software that integrates with the Linux kernel. For this reason, NVIDIA should be avoided.
Software considerations
Certain software will not work correctly due to anti-cheat. Easy Anti-Cheat (EAC) software, which is integrated into certain online games, currently does not work with the software compatibly modes necessary on Linux.
Graphics stack
Kernel
With the exception of firmware, configuring the Linux kernel to support the graphics adapter is mostly straightforward.
PREEMPT
Better support for a low latency desktop can be enabled via PREEMPT kernel symbol.
Todo:
- Flush out PREEMPT section with kernel box.
DRM subsystem
Modern kernels include a subsystem called Direct Rendering Manager (DRM) which is responsible for handling acceleration requests by user space program.
AMD
As outlined in the AMD meta article, there are a view viable options when configuring AMD graphic cards. See the kernel section of the AMD article.
For card firmware, some precision is needed.
Intel
NVIDIA
Closed source NVIDIA drivers lack Generic Buffer Manager (GBM) support, which means so support for QEMU VirGL, bad performance under Wayland, no easy multi-GPU support, and several other issues.
User space
Software that provides user space support is any software component that does not reside inside the Linux kernel itself. This is the largest portion of the graphics stack on Linux systems.
Xorg
Meh... Xorg is old and crusty...
Wayland
https://wayland.freedesktop.org/xserver.html
Testing apps on Wayland with Weston
Switch to another vt (use chvt), and issue:
user $
weston-launch
Then try to open the application on Weston.
Mesa
Mesa is a FreeDesktop.org project dedicated to open source drivers for graphics cards.
Current status of OpenGL and OpenCL implementations on a per-driver basis can be found on the MesaMatrix site (also available here).
Shader cache
Support for a shader cache is available in Mesa. The shader cache can be used to enhance the speed of operations. When in enabled, it will exist under the following directory: ~/.cache/mesa_shader_cache
Support for the cache can be controlled with the MESA_GLSL_CACHE_DISABLE environment variable. Set to 1
to disable the cache and 0
to enable caching.
The MESA_DISK_CACHE_SINGLE_FILE environment variable also exists for Mesa version 21.1 and higher. Set to 1
to eanble the single file cache and 0
to disable. A single file cache is avoids duplicated data that could occur when using a multiple file cache by up to three times the space savings.[3] [4]
Todo:
- Investigate Steam shader cache paths.
Wine
Wine is a software library translation layer that enables Windows API calls on POSIX compliant operating systems such as Linux. It is an important piece of software for gaming on Linux since many game development studios do not put in effort to create games for operating systems other than Microsoft Windows. An application database called WineDB exists to track the operational status of software on Wine.
Valve software has created a fork of Wine called Proton that seeks to integrate changes that may be backported into Wine and additionally provides other components. Proton is primarily meant to accompany and assist the Steam client, however is itself open source software.
Drivers
DPI
For HiDPI displays (such as running a 4K resolution on a 13" or 14" display), it will likely be necessary to change the console font to a size that will be legible.
setupcon setfont ter-132n
Larget fonts may need to be included in the initramfs. Investigate how to do this with genkernel. Certain distributions set the font in the /etc/vconsole.conf file and add the consolefont hook /etc/mkinitcpio.conf, before finally regenerating the initramfs. "setconsolefont" will create a /etc/rc.d/rc.font file with the setfont command, and will run at boot.
Testing
A few tools are available to help test graphics acceleration capabilities.
mesa-progs
- x11-apps/mesa-progs - glxgears glxinfo
vulkan-tools
Testing vulkan on Wayland or X:
- dev-util/vulkan-tools - vkcube, vulkaninfo
The vkcube graphic demo can used to test vulkan based 3D acceleration:
user $
vkcube
MangoHud
MangoHud can be combined with graphic demos such as vkcube or glxgears to provide a FPS overlay.
user $
mangohud vkcube
Acceleration
Cover hardware acceleration vs. software acceleration.
To verify the system is running accelerated graphics, try the following (requires x11-apps/mesa-progs which contains glcgears and glxinfo commands):
user $
glxinfo | grep -i accelerated
Accelerated: yes
If the output of the previous command is anything is a "no" then system graphics are not being accelerated.
System running Intel graphics chipsets may find the tools available in x11-apps/igt-gpu-tools useful for diagnostic and testing.
Troubleshooting
Debug variables
Debug output should be enabled when attempting to troubleshoot graphical issues.
See also
- Wayland — a replacement for the X11 window system protocol and architecture with the aim to be easier to develop, extend, and maintain
- Xorg — an open source implementation of the X server.
- Wine — an application compatibility layer that allows Microsoft Windows software to run on Linux and other POSIX-compliant operating systems.
External resources
- https://unix.stackexchange.com/questions/17027/how-to-set-the-resolution-in-text-consoles-troubleshoot-when-any-vga-fail - Information for changing console resolution at boot time.
- https://blog.yossarian.net/2020/12/24/A-few-HiDPI-tricks-for-Linux - Blog post detailing a HiDPI setup on Linux.
References
- ↑ https://boilingsteam.com/out-of-the-top-50-games-70-work-on-linux-now/
- ↑ https://www.razer.com/synapse-2
- ↑ https://www.phoronix.com/scan.php?page=news_item&px=Mesa-Single-File-Cache
- ↑ https://www.phoronix.com/forums/forum/linux-graphics-x-org-drivers/opengl-vulkan-mesa-gallium3d/1240111-mesa-lands-new-single-file-cache-to-help-steam-s-pre-compiled-shaders-space-savings?p=1240193#post1240193