[One of my new year's resolution](/2024/1/12/happy-new-year-2024/) are related to playing videogames on GNU/Linux rather than resorting to dual booting as I did for the last 15 years. This blogpost aims to be a continuosly updated guide to my journey in having a proper gaming setup on my Gentoo workstation. My main resources are the [Gentoo wiki](https://wiki.gentoo.org/wiki/Wine) and the [Arch Wiki](https://wiki.archlinux.org/title/Wine). These objectives should be clear: - I will not use steam: I only buy from [GOG](https://www.gog.com/games) or use CDs - I want to use one of my controllers for games that need it - use as much software from the Gentoo repos as possible; this means avoiding [Bottles](https://usebottles.com/) and [Lutris](https://lutris.net/) ## Hardware ``` user ~> sudo inxi -AGSC System: Host: ____ Kernel: 6.1.69-gentoo-dist arch: x86_64 bits: 64 Desktop: spectrwm Distro: Gentoo Base System release 2.14 CPU: Info: 6-core model: AMD Ryzen 5 2600 bits: 64 type: MT MCP cache: L2: 3 MiB Speed (MHz): avg: 1858 min/max: 1550/3400 cores: 1: 3400 2: 1550 3: 1550 4: 1550 5: 1550 6: 1550 7: 1550 8: 1550 9: 3400 10: 1550 11: 1550 12: 1550 Graphics: Device-1: AMD Navi 22 [Radeon RX 6700/6700 XT/6750 XT / 6800M/6850M XT] driver: amdgpu v: kernel Device-2: Logitech C920 HD Pro Webcam driver: usbfs type: USB Display: server: X.org v: 1.21.1.11 driver: X: loaded: amdgpu unloaded: modesetting,radeon dri: radeonsi gpu: amdgpu resolution: 1920x1200~60Hz API: EGL v: 1.5 drivers: radeonsi,swrast platforms: gbm,x11,surfaceless,device API: OpenGL v: 4.6 vendor: amd mesa v: 23.3.5 renderer: AMD Radeon RX 6750 XT (radeonsi navi22 LLVM 17.0.6 DRM 3.49 6.1.69-gentoo-dist) API: Vulkan v: 1.3.275 drivers: N/A surfaces: xcb,xlib Audio: Device-1: AMD Navi 21/23 HDMI/DP Audio driver: snd_hda_intel Device-2: AMD Family 17h HD Audio driver: snd_hda_intel Device-5: Focusrite-Novation Focusrite Scarlett 2i2 driver: snd-usb-audio type: USB API: ALSA v: k6.1.69-gentoo-dist status: kernel-api Server-1: PulseAudio v: 16.1 status: active (root, process) USB: Device-1: 1-4:2 info: splitkb.com Kyria rev2 type: keyboard,HID rev: 2.0 Device-2: 1-7:4 info: Microsoft Xbox360 Controller type: rev: 2.0 Device-3: 3-2:3 info: Focusrite-Novation Focusrite Scarlett 2i2 type: audio rev: 2.0 Device-4: 3-4:6 info: ThrustMaster XB1 Classic Controller type: rev: 2.0 ``` ## Drivers For the kernel, I am using the `gentoo-kernel` seed. For the GPU setup you need: - the open source drivers, see https://wiki.gentoo.org/wiki/AMDGPU - the proprietary drivers, see https://wiki.gentoo.org/wiki/AMDGPU-PRO - the vulkan drivers, see https://wiki.gentoo.org/wiki/AMDVLK These are useful commands to check if the drivers are loaded correctly: ``` user ~> lspci -k | grep -A 3 -E "(VGA|3D)" 08:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 22 [Radeon RX 6700/6700 XT/6750 XT / 6800M/6850M XT] (rev c0) Subsystem: Tul Corporation / PowerColor Navi 22 [Radeon RX 6700/6700 XT/6750 XT / 6800M/6850M XT] Kernel driver in use: amdgpu Kernel modules: amdgpu ``` ``` user ~> glxinfo -B name of display: :0 display: :0 screen: 0 direct rendering: Yes Extended renderer info (GLX_MESA_query_renderer): Vendor: AMD (0x1002) Device: AMD Radeon RX 6750 XT (radeonsi, navi22, LLVM 17.0.6, DRM 3.49, 6.1.69-gentoo-dist) (0x73df) Version: 23.3.5 Accelerated: yes Video memory: 12288MB Unified memory: no Preferred profile: core (0x1) Max core profile version: 4.6 Max compat profile version: 4.6 Max GLES1 profile version: 1.1 Max GLES[23] profile version: 3.2 Memory info (GL_ATI_meminfo): VBO free memory - total: 11874 MB, largest block: 11874 MB VBO free aux. memory - total: 32064 MB, largest block: 32064 MB Texture free memory - total: 11874 MB, largest block: 11874 MB Texture free aux. memory - total: 32064 MB, largest block: 32064 MB Renderbuffer free memory - total: 11874 MB, largest block: 11874 MB Renderbuffer free aux. memory - total: 32064 MB, largest block: 32064 MB Memory info (GL_NVX_gpu_memory_info): Dedicated video memory: 12288 MB Total available memory: 44400 MB Currently available dedicated video memory: 11874 MB OpenGL vendor string: AMD OpenGL renderer string: AMD Radeon RX 6750 XT (radeonsi, navi22, LLVM 17.0.6, DRM 3.49, 6.1.69-gentoo-dist) OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.3.5 OpenGL core profile shading language version string: 4.60 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL version string: 4.6 (Compatibility Profile) Mesa 23.3.5 OpenGL shading language version string: 4.60 OpenGL context flags: (none) OpenGL profile mask: compatibility profile OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.3.5 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20 ``` ``` user ~> vulkaninfo --summary ac_compute_device_uuid's output is based on invalid pci bus info. ========== VULKANINFO ========== Vulkan Instance Version: 1.3.275 Instance Extensions: count = 22 ------------------------------- VK_EXT_acquire_drm_display : extension revision 1 VK_EXT_acquire_xlib_display : extension revision 1 VK_EXT_debug_report : extension revision 10 VK_EXT_debug_utils : extension revision 2 VK_EXT_direct_mode_display : extension revision 1 VK_EXT_display_surface_counter : extension revision 1 VK_EXT_surface_maintenance1 : extension revision 1 VK_EXT_swapchain_colorspace : extension revision 4 VK_KHR_device_group_creation : extension revision 1 VK_KHR_display : extension revision 23 VK_KHR_external_fence_capabilities : extension revision 1 VK_KHR_external_memory_capabilities : extension revision 1 VK_KHR_external_semaphore_capabilities : extension revision 1 VK_KHR_get_display_properties2 : extension revision 1 VK_KHR_get_physical_device_properties2 : extension revision 2 VK_KHR_get_surface_capabilities2 : extension revision 1 VK_KHR_portability_enumeration : extension revision 1 VK_KHR_surface : extension revision 25 VK_KHR_surface_protected_capabilities : extension revision 1 VK_KHR_xcb_surface : extension revision 6 VK_KHR_xlib_surface : extension revision 6 VK_LUNARG_direct_driver_loading : extension revision 1 Instance Layers: count = 3 -------------------------- VK_LAYER_AMD_switchable_graphics_32 AMD switchable graphics layer 1.3.241 version 1 VK_LAYER_AMD_switchable_graphics_64 AMD switchable graphics layer 1.3.241 version 1 VK_LAYER_MESA_device_select Linux device selection layer 1.3.211 version 1 Devices: ======== GPU0: apiVersion = 1.3.260 driverVersion = 2.0.279 vendorID = 0x1002 deviceID = 0x73df deviceType = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU deviceName = AMD Radeon RX 6750 XT driverID = DRIVER_ID_AMD_PROPRIETARY driverName = AMD proprietary driver driverInfo = (AMD proprietary shader compiler) conformanceVersion = 1.3.3.1 deviceUUID = driverUUID = 414d442d-4c49-4e55-582d-445256000000 GPU1: apiVersion = 1.3.241 driverVersion = 2.0.257 vendorID = 0x1002 deviceID = 0x73df deviceType = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU deviceName = AMD Radeon RX 6750 XT driverID = DRIVER_ID_AMD_OPEN_SOURCE driverName = AMD open-source driver driverInfo = 2023.Q1.3 (LLPC) conformanceVersion = 1.3.0.0 deviceUUID = driverUUID = 414d442d-4c49-4e55-582d-445256000000 ``` The most important bits are: - `Kernel driver in use: amdgpu` - `direct rendering: Yes` - that `vulkaninfo` doesn't produce any errors ## Wine and other software packages These are my current useflags: - wine: `+abi_x86_32 +abi_x86_64 +proton` - wine-staging: `+X +abi_x86_32 +abi_x86_64 +fontconfig +gecko +gstreamer +mingw +mono +nls +opengl +pulseaudio +sdl +ssl +strip +truetype +unwind +usb +vulkan +xcomposite -wow64` - wine-proton: `+X +abi_x86_32 +abi_x86_64 +fontconfig +gecko +gstreamer +mingw +mono +nls +opengl +pulseaudio +sdl +ssl +strip +truetype +unwind +vulkan +xcomposite -wow64` - [ ] wine-vanilla: `+abi_x86_32 +abi_x86_64 +fontconfig +gecko +gstreamer +mono +nls +pulseaudio +sdl +ssl +strip +unwind +usb +video_cards_amdgpu +xcomposite -wow6` Notice that I am targeting all WINE packages in order to test slightly different configurations. Use `eselect wine` to switch between versions. Until the Gentoo devs says that wow64 feature is stable and fully functional, I will keep it off. I have enable the `abi_x86_32` use flag for many packages, probably more than needed. This is to ensure that I avoid problems related to my configuration. Enabling the flag globally seems like a waste of cpu and disk. These are the additional WINE related packages that I installed: - app-emulation/winetricks: `+gtk +rar` - app-emulation/vkd3d-proton: `+abi_x86_32 +strip` - app-emulation/dxvk: `+d3d10 +d3d11 +d3d9 +dxgi +strig +abi_x86_32` GPU related packages: - dev-util/DirectXShaderCompiler: necessary for proper directX support with vulkan - media-libs/vulkan-loader: `+X +abi_x86_32 +layers` - dev-util/vulkan-tools: `+X` - media-libs/amdgpu-pro-vulkan: `+abi_x86_32 +video_cards_amdgpu` - media-libs/amdvlk: `+abi_x86_32 +raytracing` but I am not sure my gpu supports raytracing - media-libs/shaderc I am using spectrwm as my windows manager. It is not the best option and I would suggest to use a more featured DE. This is an example of an innocous error that is caused by spectrwm when using WINE: ``` ERROR: ld.so: object '/usr/lib64/libswmhack.so.0.0' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored. ``` Consider that WMs need a compositor to avoid some clashes with WINE. I am using x11-misc/picom with drm and opengl support. ## Using WINE If you have no clue about how WINE works, start by reading the [FAQs](https://wiki.winehq.org/FAQ#Wineprefixes). The biggest considerations you have to make when using WINE are the software dependencies of the Windows program you want to use. For the moment I have been able to survive with only two prefixes, one for 32 bits games and one for more recent software. What all of this means, is that I have two folders in my home, `.wine` and `.wine32` in which I instruct WINE to start a new program using the environment variable (that is what WINEPREFIX is all about). When I feel lazy, I select the WINE prefix using winetricks, then navigate to the game using explorer.exe. It's important to remember that whenever you create a new WINE prefix, you need to symlink the correct directx dependencies, as the Gentoo ebuilds suggests: - `WINEPREFIX=/home/user/.wine setup_vkd3d_proton.sh install --symlink` for directx12 - `WINEPREFIX=/home/user/.wine setup_dxvk.sh install --symlink` for directx11 and earlier Usually WINE takes care of starting up necessary processes inside the prefixes. This is done by the `wineboot` program so I suggest to read its manpage. To install software dependencies, I use winetricks. If a dependency is not available through winetricks, it's always possible to install the .exe as you would on Windows. Take in mind that WINE uses some Linux specific software in place of some Windows libraries. Some key replacements include: - wine-mono in place of dotnet - dxvk and vkd3d in place of directx - gallium-nine and wined3d, in place of directx but I had better experience with dxvk and vkd3d - wine-gecko in place of whatever web view IE was offering - wineconsole in place of the Windows cmd program - your dotnet installation is usually enough for WINE, you don't need to install the dotnet runtimes, although I have to check this assertion on a fresh installation ### Dependencies rules of thumb 1. lots of games prompt you to install dependencies such as directx. Avoid it as much as possible and rely on WINE specific libraries 2. winetricks can manage most if not all of those dependencies for you. It will save you time to figure out the correct paths for each library and automate the install as much as possible 3. recent games usually want the Visual C++ libraries. You can install them all with the vcrun2022 package 4. older games usually want Visual C++ libraries, but you need to install the different yearly versions one by one 5. you can backup or modify the winetricks installers. They are in you cache directory, usually `~/.cache/winetricks` ### Debugging In all honesty, it's too early in this journey to write a comprehensive chapter on this topic. The `winedbg` command is still shrouded in mystery. At the moment I am keeping a small set of games that are self contained and allows me to check if WINE inside the wineprefix is working as I expect. I have uploaded some mostly self contained demos that you can use to test that directx and you GPU is working as it should: - [https://archive.org/details/elemental-demo-dx-12-guru-3-d.com](UnrealEngine4 tech demo for directx12) - [https://archive.org/details/ue-4-elemental-demo](the same demo, but for directx11) - [https://archive.org/details/ati-radeon-9700-debevec-rnl-demo-v-1.1.7z](ATI Radeon 9700 Debevec RNL Demo v1.1ATI Radeon 9700 Debevec RNL Demo for directx9) You can find more video card demos at [https://soggi.org/video-cards/tech-demos.htm](soggi.org). For controllers, you can use two tools: - `wine dxdiag` that launches the directx toolbox, useful not only for the gpu, but also for audio and input devices - `wine control joy.cpl`, a cool utility to see your XInput and DInput compatible hardware