[RESPONDED] DRI_PRIME not correctly using the dGPU in some games

I had some issues getting Remnant 2 to work on Fedora 39 with a fresh install. Using DRI_PRIME=1 the game would start, CPU usage would be minimal, and iGPU usage would spike to 70% in the loading screen but would drop to 0% after reaching the character selection screen. At this point both iGPU and dGPU usage would be 0%. The game would drop to < 1 fps upon entering the character selection screen and would be completely unusable.

The Framework dGPU utility reported the game as using the dGPU but it was interesting that both iGPU and dGPU showed no usage. I was surprised the game would get 1fps using the iGPU with 1200x800 resolution and “potato” quality settings, and since it showed 0% usage, obviously it wasn’t working correctly either.

Anyway, after a bunch of trial and error with different flags and proton versions, the magical incantation that worked was DRI_PRIME=1 DXVK_FILTER_DEVICE_NAME="AMD Radeon RX 7700S (RADV NAVI33)" %command%. After adding that, the game runs great on the default Proton version and shows 100% dGPU usage. The game gets ~60fps on medium settings with the laptops default monitor resolution. The game actually runs better than on Windows!

I’m not sure if this flag is necessary for other games yet, but wanted to call it out in case someone else runs into a similar issue. Hopefully others find this helpful!

And if anyone has any thoughts on why this flag is necessary or if there’s another way to get this to work, I’d love any feedback.

Loving this laptop so far. Thanks FW team! <3

6 Likes

According to this post [RESPONDED] MUX switch toggle in BIOS? - #48 by John_Obscurant dxvk may automatically prefer dGPU. So maybe dxvk automatically prefers dgpu and so DRI_PRIME=1 is switching back to iGPU. This is just a theory I’m not sure what’s really going on. What happens if you run the game without any launch parameter?

The performance you describe might even indicate it uses neither dGPU nor iGPU but a software emulation device (llvmpipe) that is usually also available on a standard Fedora installation.
Please try running vulkaninfo. You might want to check the output of:

vulkaninfo | grep "GPU[0123]" -A 10

This will give you a list of the available Vulkan devices. If your dGPU is e.g. GPU2 you could run your dxvk game with DRI_PRIME=2! <command>

3 Likes

I tried this, and the game performs the same. It maxes out the iGPU memory, spikes iGPU usage to 100%, then immediately falls to 0 and gives 1fps…

This was a really interesting idea and I gave this a shot. It lists the iGPU at the 0th index, the dGPU at the 1st index, and llvmpipe at the 2nd index. So I think this is the order expected for DRI_PRIME=1 to work correctly?

I tried running Remnant 2 with DRI_PRIME=[0,1,2] and all options performed basically the same (although with [2] the game almost crashed, so it may be correctly leveraging llvmpipe in that case?)

Unfortunately, I also tried running Rise of the Tomb Raider with both the DRI_PRIME and DXVK_FILTER_DEVICE_NAME arguments, and neither allowed the game to leverage the dGPU :cry: . I may mess around with this a bit to see if other options or Proton compatibility allows this game to run correctly.

I definitely appreciate all the feedback and ideas y’all!

1 Like

Did you also try DRI_PRIME=1! ? (note the exclamation mark after the device number!) According to the docs that should force the use of a certain device.
DXVK might check for some capability which is provided by the virtual llvmpipe “gpu” but not the dGPU driver.
In the end, it might also be a completely different problem though.

1 Like

If I’m not mistaken, Rise of the Tomb Raider has a native Linux version. Are you certain that you’re running the Windows version via Proton? Because DXVK_FILTER_DEVICE_NAME wouldn’t work for the native Linux version. Additionally, if you are indeed using the Proton version, wouldn’t the native Linux version work better?

This is correct. Some games will have their own preference. Some games also have their own config setup tool that sets the graphics from a GUI, Marvel’s Guardians of the Galaxy for example.

When in doubt, this is correct.

1 Like

This was the key! Thank you for being patient @John_Obscurant , I definitely missed the bang ! operator in the first post. This allows both Remnant II and Rise of the Tomb Raider to run correctly.

As a side note, does this verify that dxvk wasn’t prefering the dGPU at all, and instead the game was just trying to rely on the iGPU? Since the games didn’t run correctly without DRI_PRIME with the forcing flag, that makes it seem like it wasn’t attempting to leverage the dGPU at all. It also seems that because the forcing flag worked, it wasn’t swapping the primary/secondary GPU indexes either.

I do wonder if the Framework DRI_PRIME documentation should mention the forcing ! flag? I don’t understand why my setup would require anything special, as I didn’t deviate from the setup instructions at all.

Thanks for the help all!

2 Likes

I’m having issues getting minecraft to use the dgpu on ubuntu.

A bug has been reported at https://bugs.mojang.com/browse/MCL-10738, so I’m not sure if this solution will work, but you can give it a try:

1.Create a file with the following content:

#! /bin/sh
DRI_PRIME=1 exec java "$@"
  1. Save it as something.sh
  2. Make it executable. There should be an option for this in the file properties.
  3. In the minecraft launcher settings there will be a path to java. Replace it with the path to something.sh that you created.
1 Like

I would need to test using ! before including it or at least see a screenshot of its placement. Was this done in Steam, game properties, command box?

Yup! The “Launch Options” box. The prefix is DRI_PRIME=1!, no spaces.

1 Like

Appreciate it.

Did some digging. Technically, ! does nothing. My best guess, DRI_PRIME=1 didn’t take the first time.

It does appear that ! passes along seamlessly, but it doesn’t actually have a function with DRI_PRIME.

In digging into this title, it appears this is what is needed:

sudo dnf install vulkan-tools -y && vulkaninfo | grep "GPU[0123]" -A 10

Looking at GPU1, AMD Radeon RX 7700S (RADV NAVI33)
So I would put this in.

DRI_PRIME=1 DXVK_FILTER_DEVICE_NAME="AMD Radeon RX 7700S (RADV NAVI33)" %command%

This should be what gets us going with this title.

One of the things I am doing today is testing with this title, so I will grab a copy and do a quick launch test and verify the parameters works. If successfully, I will update the docs to reflect that same games may need the parameters above.

2 Likes

The documentation states the following: In the case of Vulkan it is possible to connect !, in this case only the selected GPU will be made available to the application (e.g.: DRI_PRIME=1!).

DXVK_FILTER_DEVICE_NAME only works on games run via proton. So it doesn’t work for native Linux versions of games. DRI_PRIME=1! should theoretically work for any Vulkan game.

2 Likes

I think this is in line with my experience. The bang ! operator definitely seems to be doing something, as I just tried both Shadow of the Tomb Raider and Remnant II with and without it. Without the operator, it only leverages the iGPU. With it, it correctly leverages the dGPU in both games.

Additionally, this explains why the DXVK_FILTER_DEVICE_NAME works for a game that runs using Proton (Remnant II), but didn’t work for a native game (Shadow of the Tomb Raider).

Fair, fair. Wild, I cannot figure out what bang would be doing. But, if something is working, it’s working. I cannot disagree with that.

Truth - with the prevalence of Windows games pushing proton, I forget about native games - and I do have a few! Yeah, DRI_PRIME=1 %command% would be what I would use.

@Mario_Limonciello I need a sanity check.

Can you think of any universe where DRI_PRIME=1! (bang) would be used? DRI_PRIME=1 (sans the bang) I understand.

To my best knowledge and my own extensive digging, I cannot finding anywhere where a bang would be used for DRI_PRIME. I’d appreciate your insights. :pray:

If the game is doing it’s own detection and does it wrong maybe?

2 Likes

The docs say that for Vulkan applications, DRI_PRIME=n simply moves device n up to be the first device in the list, while DRI_PRIME=n! hides all other devices and thus forces to use device n.

A Vulkan application usually selects a device by certain capabilities, how exactly the selection process works is up to the programmer. There might e.g. be something about the advertised memory types or color formats or … that the applications prefers about the iGPU (or maybe even llvmpipe). For dxvk, someone might actually look up the responsible code in their github repo. I did try, but the code was far too complex for me …

2 Likes

Matt, if you do a simple text search on the docs available at the link that John Obscurant posted above for an “!” exclamation point (no quotes) you’ll find what you’re looking for. It’s easy to miss.
Apparently, specifying the PRIME=1 just puts that card first in a list that is supplied to the .exe. The exe is still free to pick LLVM_PIPE and run at 1 FPS if it feels like it. Or there’s another bug at play.
By the way, if you’re running a game at, like, 1 FPS, you’re probably on the LLVM_PIPE software emulation. The iGPU is no slouch; it can run a modern game at ~medium settings and medium frame rates.
ETA: The “!” forces the list supplied to the exe to contain only the card you specify. So, no list.
EETA: Just realized I repeated half of what John said in the last post. Imma gonna go take the dog for a walk and get some air.

3 Likes