Playing videogames with WINE on Gentoo


One of my new year's resolution 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 and the Arch Wiki.

These objectives should be clear:

  • I will not use steam: I only buy from GOG 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 and Lutris

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: <vendor specific>
    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: <vendor specific> 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.

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:

You can find more video card demos at https://soggi.org/video-cards/tech-demos.htm.

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



Welkom 2024!


Il 2023 è stato un anno molto molto intenso, sia dal punto di vista lavorativo che personale. Per quanto riguarda il lavoro uno dei più grandi cambiamenti è stato l'arrivo del nuovo CTO (direttore tecnico) in azienda, a Dicembre 2022. Avevo una collaborazione molto stretta con il precedente e questo mi ha permesso non solo di catapultare la mia carriera, ma soprattutto di acquisire tantissima conoscenza dei meccanismi aziendali e finanziari da vicino, spalla a spalla con le persone coinvolte invece di vivere soltanto di resoconti ed esperienze indirette.

Nel corso di questi tre anni, il mio ruolo ha subito una brusca trasformazione, passando da un focus sulla ricerca e sviluppo a una posizione di sviluppo strettamente legata al front office aziendale. In questo contesto, ho frequentemente affrontato le mie lacune nel campo econometrico e finanziario. In breve, ho dovuto esplorare diversi settori, occupandomi di risk management, portofolio research e acquisizione dati, spesso completando il doppio del lavoro necessario: prima la fase esplorativa e successivamente quella esecutiva.

Questo percorso è stato affrontato con le spalle cariche di responsabilità per il mio minuscolo team formatosi a Settembre 2022. In quest'anno che si è appena concluso ho vissuto il ruolo di manager con grandissima soddisfazione e ho potuto constatare una significativa crescita professionale del mio collaboratore durante la valutazione delle performance di fine anno.

Per quanto riguarda la mia vita personale, il 2023 ha segnato l'inizio del mio esperimento di vita in Olanda, che posso dichiarare concluso con successo. Mi sono davvero innamorato di questo paese, dei suoi abitanti e della sua cultura. Scrivere nel dettaglio le mie motivazioni va ben oltre l'intenzione di questo post, però voglio accennare alcuni elementi.

Dal punto di vista culturale: ho apprezzato l'atteggiamento in cui la religione occupa uno spazio secondario, l'assenza di ostentazione, la frugalità.

Dal punto di vista sociale: ho notato un'attitudine progressiva che differisce notevolmente dal medioevo che caratterizza molti dei paesi in cui ho vissuto. Rispetto a ciò, ho percepito come una sorta di parodia per edgy teenagers i paesi auto-proclamati "progressivi" in cui ho vissuto, come la California e Londra. Infine, una menzione d'onore va fatta alla bespreekbaarheid. Ben Coates nel suo libro "Why the Dutch are Different: A Journey into the Hidden Heart of the Netherlands" la definisce come la capacità di affrontare e discutere apertamente di determinati argomenti, anche quelli sensibili o difficili. Quando un argomento è "bespreekbaar" significa che è possibile parlarne in modo aperto, onesto e diretto, senza timori o tabù.

Queste invece sono gli argomenti che sto esplorando attualmente:

  • la cultura sociale e politica della bici in Olanda, ma anche dei restanti paesi del Nord Europa
  • la musica classica olandese, da Jan Pieterszoon Sweelinck a Bernard Haitink

Questa esplorazione della cultura olandese e della città di Amsterdam è vissuta nella cornice di convivenza da poco iniziata. Un percorso arduo ma piacevoli per questi due nuovi expat.

Fatta questa lunghissima premessa arriviamo all'obiettivo di questo post, ovvero elencare i buoni propositi dell'anno appena iniziato:

  • lavorare meno: la quantità di stress che ho vissuto quest'anno è stata notevole. Devo essere più distaccato dal lavoro e ritrovare i miei spazi personali.
  • pensare meno ai soldi: tre anni in finanza sono stati proficui e mi hanno avvicinato moltissimo all'obiettivo di comprare casa. Ora posso rilassarmi da questo punto di vista e ristabilire le mie priorità
  • mangiare meno: dedicare tanto tempo al lavoro significa che le uniche pause che ho potuto permettermi sono state quelle per il cibo
  • offrire del lavoro volontario ad un'associazione di mio interesse
  • dal punto di vista informatico, ritornare alle radici: devo tornare ad utilizzare il pc fisso, Gentoo, che per pigrizia ho soppiantato da Debian negli ultimi due anni per il mio portatile, ed utilizzare software ancora più minimale. Troppo spesso sento di usare il pc senza conoscere il software che sto digitando nel dettaglio
  • giocare tutta la mia libreria su WINE: questo non dipende certo da me, ma di sicuro la situazione negli ultimi anni è migliorata notevolmente per il panorama dei videogiochi. Devo sforzarmi ad esplorare la compatibilità con Linux ogni volta che voglio rigiocare qualcosa o provare una novità
  • continuare gli studi di cucina: in particolare riprendere a tracciare tutto sul mio ricettario
  • nel 2023 ho adottato molto rigore nella gestione del patrimonio personale, tracciando tutte le spese su homebank e avendo un rapporto costante e continuativo con il mio consulente finanziario. Voglio continuare in questa direzione
  • usare il venerdì come giorno di scrittura, sia per i progetti personali come questo blog, che per il worklog e altra comunicazione aziendale e lavorativa
  • uno dei tasti dolenti del 2023 è che spesso ho sostituito il libro a letto con la lettura di siti web attraverso il cellulare. Questa abitudine va assolutamente persa nel 2024. Insomma, riprendere a leggere prima di andare a dormire.

Fortuna opes auferre, non animum, potest.




Three years later


More than three years have passed since my last blogpost. I used to believe that a more hectic life would provide me with a surplus of things to write about. While that holds true, the flip side is that I now find myself with less and less time for writing.

Let's be honest, it's not just that. I have been growing a little bit unsatisfied with the current evolution of the corporate web.

I have already touched this topic when I stopped using reddit for good (here, in italian) but I really stopped to reflect when AOL-Time-Warner-Pepsico-Viacom-Halliburton-Skynet-Toyota-Trader-Joe'sMicrosoft bought Github. At the time I removed the dust from my personal git server and moved most of my stuff there. For more than a year now my GitHub heatmap has remained empty, despite it being one of the platforms where I used to engage the most frequently.

It's not that I'm exposed to more sunlight these days: I still utilize the internet, albeit in a more pseudonymous manner now.

As I mastered the art of evading the corporate web everyday I gallivanted my way across three relocations: from Paris to London and finally to Amsterdam. My faithful companion through it all? None other than my (t)rusty server. I bid adieu to all of the social networks in favor of selfhosted and federated solutions. Email is now king in my social online life but I still indulge lurking on the orange site.

A bunch of good friends joined me on this adventure, and we formed a close-knit community around the services we host ourselves. We interact daily through our servers. We also worked on a few art projects, if you'll permit the exageration, embodying the essence of the bygone web era. The pièce de résistance among these creations can be accessed by playfully prodding at my IP address.

To be continued.