[info] How to speed up games loading

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
1,083
Reaction score
921
Credits
8,303
I don't remember if I ever posted this topic here + I searched for anything similar I've posted in "Linux Gaming" and found nothing, so I decided to open this topic and share with you how to speed up the loading of Windows games on Linux. This is for those of us who don't rely on Lutris, bottles, crates, boxes and all kinds of storing objects. :)

Most "experts", like those who develop Lutris (and not only) will keep insisting that games compile shaders only once but that's only half the truth. The whole truth is that games compile shaders but after you close the game, these shaders are being deleted. So the next time you run the game, it will start compiling the shaders again. Which, naturally, takes time - depending on how fast your computer is (mostly).

But I found a way to force the game keep the compiled shaders between gaming sessions. Which means that if you don't change/update the game (for instance, if it's an old single player game, it won't have any updates, therefore it won't change) and if you don't update the video driver, the game will use the generated shaders from your previous session. Some games, like "Mass Effect Andromeda" actually display the process of generating shaders. With my method of running a game you'll notice how quickly it skips from XX thousand shaders down to zero shaders before the game menu appears.

Note: I'm not forcing anyone to use my method. I simply don't care what the "experts" claim and develop my own methods whose results I see every day while playing a game. The results? No stuttering of any kind (compiling shaders takes resources which naturally leads to graphical/sound stuttering until the process is complete), the game loads extremely fast and in many cases - even faster than it would load in Windows.
It's up to you to decide whether you'll trust the experts or my battlehardened method that never fails.

For this example I'll se the game I'm currently replaying for the third time.

1. Go to the main dir of the game: /B/GAMES/MEA and create a directory named ShaderCache.
2. In the same main dir create an empty file with the extension '.sh' (the extension is just for your conveniency), make it executable, then open it in your favorite text editor and paste this code in it:

Code:
#!/usr/bin/env bash

export XDG_CACHE_HOME="./ShaderCache"
export DXVK_STATE_CACHE=1
export DXVK_HUD=fps,compiler
export DXVK_enableStateCache=true
export DXVK_enablePipelineCache=true
export DXVK_numCompilerThreads=0
export WINE_AUDIO_DRIVER=pulse

wine "./MassEffectAndromeda.exe"

then save the file.

When you run the game via this script for the first time, you WILL experience the aforementioned stutter but after that every time you run the game via this script, there won't be any stuttering bc it will simply read from the previously generated shaders. And the game's performance will be so good, you would forget you're playing it on Linux. :D

An important note: I'm using Cinnamon which means XDG_CACHE_HOME works for this DE or any Gnome-like-based DE. But if what I have heard is true and you're on Plasma, it's possible (not quite sure, but it's possible) that XDG won't work for you and you may have to replace "XDG" with "QT". Again, this is what I've heard. Whether it's true or not - that's a whole other matter of which I know nothing about and you'll have to test it for yourselves.

A little translation of the code above. The most of it is pretty clear. But since I was asked about the ./ part a few times, I decided to clarify that.
Since the script is created in the main dir where the game exe is located,
Code:
wine "./MassEffectAndromeda.exe"
translates as "Wine, run MassEffectAndromeda.exe in the current directory". Instead of ./ , it could be $PWD/MassEffectAndromeda.exe but then that would mean complicating the script by defining a variable which is pointless. ./ is simply shorter and simpler without the need to add variables.

Also, many games (if not all of them) would still prefer and look for pulseaudio (whether you have pipewire or not), so I've added the line
Code:
export WINE_AUDIO_DRIVER=pulse
in order to make sure the game will default to pulseaudio.
 


I simply don't care what the "experts" claim and develop
You know that shaders need to be recompiled upon driver update?
So forcing to keep shaders for ever is not good unless one wants also manually recreate them.

Shader complation also is done prior playing game so it doesn't affect gaming performance, only startup is affected.

Most "experts", like those who develop Lutris (and not only) will keep insisting that games compile shaders only once
Whether a game will compile sharers or not depends on game in question.
A game may incrementally compile shaders, on demand as well.

The whole truth is that games compile shaders but after you close the game, these shaders are being deleted.
It depends on game in question.
 
You know that shaders need to be recompiled upon driver update?

Shader complation also is done prior playing game so it doesn't affect gaming performance, only startup is affected.


Whether a game will compile sharers or not depends on game in question.
A game may incrementally compile shaders, on demand as well.


It depends on game in question.
1. I did mention that but you read diagonally and missed it.
2. It's done during the game but you don't see it. There's a way to see it, for as long as the game uses DX11 or lower. Doesn't work with DX12 games, unfortunately.
3. Read #2.
4. Read #3. ALL games compile shaders.
 


Follow Linux.org

Members online

No members online now.

Top