Fixing TF2 Crashing on Linux with Vulkan

Team Fortress 25 · 223 ratings368 views7 favorites7 min readby fleariddenUpdated Jun 19View on Steam ↗

tl;dr

tl;dr
For those who just want it fixed now. These commands will work for the majority of users. These commands also work for other Source engine games.
You will need to add these commands to your launch options:
DRI_PRIME=1 %command% -w (your desired width) -h (your desired height) -refresh (the refresh rate of your monitor) -nojoy

Of course. remove the () and just add your values.

If you'd like the game windowed add -windowed
If you'd like it fullscreened add -fullscreen
If you'd like it borderless fullscreen (recommended for Wayland users, if
you're on Fedora use this) add -borderless

Example for a 1080p 16:9 monitor at 144hz:
DRI_PRIME=1 %command% -w 1920 -h 1080 -refresh 144 -borderless -nojoy

More important information before leaving
If you're running the "legacy" branch, it runs on OpenGL. You can also
force OpenGL by adding -gl to your launch options.
I highly recommend this branch, as the Vulkan branch tends to cause issues.
Though, some have the opposite problem.
Here's a great guide if you're running the OpenGL branch for any issues you may
encounter there: AspenJag's Team Fortress 2 Linux Guide.
If you're running the Vulkan branch, some of these commands can still be useful,
such as -threads and -nojoy. Add these if you encounter further issues with the Vulkan branch.

Explaining the Core Issue and Fixing It

What's the Deal with Vulkan?
I've always had many issues with the main branch, I will call it the Vulkan branch from here on out, as it makes more sense to do so.

Many such issues including:

-Crashing X
-Rendering incorrectly on Vulkan
-Crashing the entirety of my desktop environment
-Running extremely poorly, even on modern GPUs and CPUs
-Attempting to display on a disconnected monitor or secondary monitor
-Display options being broken in game

If you have encountered some, or all of these, I'm going to explain my thoughts on why it happens, but also on how to fix it. Please note I am NOT a *nix guru by any means lol.

From looking at crash reports, it seems that the Vulkan branch gives bogus
information to the X server. One of the biggest is the refresh rate.
It tends to default to 60hz, even on higher refresh rate displays. However,
I've encountered it also attempting to display at much higher refresh rates.
I'm not exactly sure why this is, my first thought is that 60hz is hard coded
into the game, and that's what it defaults to. My second, is that when it retrieves display information from X, it gets confused, and can accidentally latch onto a secondary monitor, leading to bogus data being used. This is what causes it to crash, or even crash X itself. I've had issues on Wayland, as well, but I do not remember if they were to the degree they were on X.

Fixing the Core Issue
So how do we fix this problem? Well, Team Fortress 2 gives us some handy commands we can have it execute on launch.
The most important is -refresh.
With -refresh we can give Team Fortress 2 the refresh rate of our monitor, rather than having it try and pull that information itself.
-refresh itself will fix most crashes, just put the refresh rate of your monitor at the end of the command:
-refresh 60

Rendering on the Wrong Monitor

What if it's Using the Wrong Monitor?
Okay, now, what if Team Fortress 2 is still trying to display onto the wrong monitor, or one that doesn't exist at all?
It's actually very easy to fix! (Thankfully!) Though, quick explaination so we understand how to use this properly.
X sessions have a display, and that's not your monitor! It's rather where applications are rendering to for your X server. I know, I know, confusing. For simplicity sake, 0 is your main display and that's your desktop. Connected to this display is your monitors. So how do we change which monitor to use?
Easily! Assuming you're display 0, apply this command to the beginning of your launch options:

DISPLAY=:0.(your display number) %command%

Your main display will be 0 as well. So the full command would be:
DISPLAY=:0.0 %command%

If you wanted it on your second monitor, which would be 1, it would be:
DISPLAY=:0.1 %command%

The full format of this command is:
DISPLAY=:(display).(monitor) %command%

In computer-land, we start with 0, and add up from there.
Remember to type these exactly or otherwise Team Fortress 2 will not launch.
You must add %command% afterward, as any command after will be Source commands, not those intended for Linux.

Display Options Not Functioning In-Game

What if My Display Options Don't Work in Game?
I've encountered this issue on the Vulkan branch, where my display options do not work in game. Sadly you cannot fix this issue, but we can work around it!

Adding to your launch options, you can include:
-windowed (the game will be windowed)
-fullscreen (the game will take over the entire screen, the default behaviour)
-borderless (uses a window with no frame or ui above or around it)

If you are on Wayland I would highly suggest using the -borderless option if you want a fullscreen experience, as fullscreen tends to render incorrectly. If you are unsure if you are on Wayland, it may be best to use borderless in case, or just experiment to see what works best for you.

The Game is Using Integrated Graphics

Issues with Integrated Graphics Being Used
I would also recommend forcing your primary GPU. For some reason, Steam and Source games will always favour your integrated graphics rather than the dedicated card. I doubt for most this will be an issue, but I've had this on nearly every machine I've had that included integrated graphics. If Steam is complaining about your Intel architecture not supporting Vulkan, it is defaulting to your integrated graphics! If you don't have Integrated graphics, ignore this option. If you do have it, put this at the beginning of the launch options, before any other options:

DRI_PRIME=1 %command%

If you're using an nVidia GPU on a laptop, you may want to use this instead:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only %command%

Now, if you've used the monitor command from earlier DO NOT add %command% twice.

Misc. Issues Related with the Vulkan Branch

What if I'm having issues with XYZ?
Though, I cannot predict all the issues you may encounter, even then I probably won't know how to fix them all, I can give you a few basic fixes for what you will probably endure.

Game randomly crashes or not accepting input
Add the -nojoy and -nosteamcontroller commands to the end of your launch options. For some reason, Team Fortress 2 struggles with trying to receive non-existent controller input. This will occur even if no controller is connected to the PC, nor has ever been connected to your PC.
These commands tell Team Fortress 2 to ignore all controller input.

Game runs horribly, with low utilization
Make sure Mutli-Core Rendering is enabled in Team Fortress 2's option menu. It can be found at the bottom of the same menu where you change your graphical settings. For some reason, Team Fortress 2 tends to turn this setting off, even if you've already enabled it.
However, I have noticed the Vulkan branch will still tend to only use a single thread. This is awful for modern CPUs! You can try this command (taken from AspenJag's Team Fortress 2 Linux Guide) to tell Team Fortress 2 how many threads it can utilize:

-threads (your cpu's thread count)

Though, I cannot attest to if it will fix the issue or not. If you are still experiencing issues with low framerate and low utilization, please change over to the Legacy branch.
I noticed several hundred FPS increase from switching over.

Conclusion and Example Options

Conclusion
I hope this may have been a help to whoever comes upon this, as I do not see many talking about a solution to this problem.
If you're using the OpenGL branch (named Legacy in the launch menu), I would recommend AspenJag's Team Fortress 2 Linux Guide as she has some great and valuable information available. Many of the commands she mentions will also work on the Vulkan branch, and may be of great use to you.

For an idea of how your launch options could be, here you go:

DRI_PRIME=1 DISPLAY=:0.0 %command% -w 1600 -h 900 -refresh 75 -fullscreen -nojoy

Thank you for reading :3

This guide was created by its original author on the Steam Community. Are you the author and want it removed? Request removal.