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

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.

3 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 …

3 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

Yeah, this was my thought as well, but when I force the usage of the iGPU only with DRI_PRIME=0! (after verifying GPU0 is the iGPU), Remnant II still runs with 1FPS. I think this is something specific to this game, as it seems poorly optimized in general. I’m not too worried about it, but would be curious if anyone has further explanation on this.

Hat tip @John_Obscurant. Was able to locate a clear, defined definition here. Same link, but included the page link this time.

TIL. :slight_smile: I’ll add the link into the docs as a FYI for those interested or needing it.

4 Likes

Hey gang, I’m still having trouble here. I just got my FW 16 from batch 4, and it looks like NVTOP reports the iGPU is working at 100% while the dGPU reports minimal usage when I play games with DRI_PRIME=1 or DRI_PRIME=1!.

My screen shot is taken after I closed a Steam game called Crab Champions, which showed the iGPU at 100% while the dGPU was low. The process names both Graphic and Compute on the GPU in position 0, but it should be 1. This is the command line I’m running from Steam for this game: DRI_PRIME=1! DXVK_FILTER_DEVICE_NAME="AMD Radeon RX 7700S (RADV NAVI33)" mangohud %command%

Additional info would be here:

            -```````````                   bhibb@bframework
          `-+/------------.`               ----------------
       .---:mNo---------------.            OS: Solus resilience 4.5 x86_64
     .-----yMMMy:---------------.          Host: Laptop 16 (AMD Ryzen 7040 Series) (AJ)
   `------oMMMMMm/----------------`        Kernel: 6.6.21-280.current
  .------/MMMMMMMN+----------------.       Uptime: 4 hours, 55 mins
 .------/NMMMMMMMMm-+/--------------.      Packages: 1341 (eopkg), 47 (flatpak)
`------/NMMMMMMMMMN-:mh/-------------`     Shell: fish 3.7.0
.-----/NMMMMMMMMMMM:-+MMd//oso/:-----.     Display (eDP-2): 2560x1600 @ 60Hz
-----/NMMMMMMMMMMMM+--mMMMh::smMmyo:--     DE: KDE Plasma 5.27.10
----+NMMMMMMMMMMMMMo--yMMMMNo-:yMMMMd/.    WM: KWin (Wayland)
.--oMMMMMMMMMMMMMMMy--yMMMMMMh:-yMMMy-`    WM Theme: Breeze
`-sMMMMMMMMMMMMMMMMh--dMMMMMMMd:/Ny+y.     Theme: Breeze (SolusDark) [QT], Breeze [GTK2/3]
`-/+osyhhdmmNNMMMMMm-/MMMMMMMmh+/ohm+      Icons: breeze-dark [QT], breeze-dark [GTK2/3/4]
  .------------:://+-/++++++oshddys:       Font: Noto Sans (10pt) [QT], Noto Sans (10pt) [GTK2/3/4]
   -hhhhyyyyyyyyyyyhhhhddddhysssso-        Cursor: breeze (24px)
    `:ossssssyysssssssssssssssso:`         Terminal: konsole 23.8.5
      `:+ssssssssssssssssssss+-            Terminal Font: Hack (12pt)
         `-/+ssssssssssso+/-`              CPU: AMD Ryzen 9 7940HS w/ Radeon 780M Graphics (16) @ 6.23 GHz
              `.-----..`                   GPU 1: AMD Radeon RX 7700S
                                           GPU 2: AMD Phoenix1
                                           Memory: 8.88 GiB / 27.11 GiB (33%)
                                           Swap: 9.00 MiB / 41.61 GiB (0%)
                                           Disk (/): 954.03 GiB / 1.76 TiB (53%) - ext4
                                           Local IP (wlp4s0): 192.168.68.65/22 *
                                           Battery: 60% [Charging]
                                           Locale: en_US.UTF-8

Any help would be appreciated.

First of all @Bryson , love the terminal background.

Could you paste the output of the following command?
vulkaninfo | grep "GPU[0123]" -A 10
Remember, these lists are 0 based, so if it lists the DGPU 7700S first in the list with index 0, you may want to try DRI_PRIME=0! instead.

I think you may have already tried this, but wanted to double check.

I myself do not have a Framework 16 on order yet, as I’m saving the funds for it. That noted, has anyone here tried GloriousEggroll’s Nobara distro on their Framework 16 with dGPU yet? He’s made a bunch of changes in there for GPU switching so I’m wondering if the DRI_PRIME issue was also resolved: https://nobaraproject.org/

For reference, the framework dgpu utility only looks for the environment variable, not if it has had any effect (based on the sourcecode last time I checked). Also I seem to remember reading that DRI_PRIME was only for OpenGL applications (with vulkan allowing applications to select the gpu themselves)

You know, I think I misread this information from nvtop. After a little more digging it seems like this is expected behavior. I’m seeing that the dGPU is in fact ‘in use’ because there’s activity, number one, and that there is another version of the same process running directly on the dGPU (at dev 1) farther down in the list. Still, here’s the output you requested:

the mesa documentation (linked by matt_hartley above) indicates this applies for both opengl and vulkan applications. sure, without the ! it’s just putting the preferred device at the top of the list of devices, and a vulkan app CAN select a different device if it insists, but with ! only the preferred device should be presented to the vulkan app. any other behavior indicates a severe bug in either the documentation or the implementation.

1 Like

Good morning/day/evening/night everyone!

Today, I eventually found the time to game a bit with my Batch 5 FW16.

System
  • CPU: 7840HS
  • GPU: 7700S
  • OS: Manjaro Linux
    • Kernel: 6.6.19-1-MANJARO
    • DE: Budgie

Problem

I am a bit confused by my output of vulkaninfo and the implications on the launch options I have to give to the apps/steam games I want to use.

Output of vulkaninfo
$ vulkaninfo | grep "GPU[0123]" -A 10                                         
GPU0:
VkPhysicalDeviceProperties:
---------------------------
	apiVersion        = 1.3.274 (4206866)
	driverVersion     = 24.0.2 (100663298)
	vendorID          = 0x1002
	deviceID          = 0x7480
	deviceType        = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
	deviceName        = AMD Radeon RX 7700S (RADV NAVI33)
	pipelineCacheUUID = 0d2f0510-8f8f-6504-4f27-9363d0e5cfea

--
GPU1:
VkPhysicalDeviceProperties:
---------------------------
	apiVersion        = 1.3.274 (4206866)
	driverVersion     = 24.0.2 (100663298)
	vendorID          = 0x1002
	deviceID          = 0x15bf
	deviceType        = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
	deviceName        = AMD Radeon Graphics (RADV GFX1103_R1)
	pipelineCacheUUID = 6c9c03dd-f74e-6101-c3d6-15a857a7d326

The dGPU is GPU0.

Following the instructions in the Linux Guide by FW and the tips in this thread, I would have to use DRI_PRIME=0 DXVK_FILTER_DEVICE_NAME="AMD Radeon RX 7700S (RADV NAVI33)" %command% for Steam Games and, in case of other applications, omit the %.
But in fact, it seems that the dGPU is addressed by DRI_PRIME=1. When starting Heaven benchmark from the terminal, I would get 25ish FPS using DRI_PRIME=0. If I use DRI_PRIME=1 instead, I get 120 to 130 FPS.
While most games on steam (native or not) don’t care about this and no matter if I specify DRI_PRIME=1, DRI_PRIME=0, with or without exclamation mark or string, or if I completely omit launch options. At least steam’s FPS counter and radeontop’s output indicate that.
Some games that seem to not care are:

  • Doom (2016) and Doom Eternal (both through Proton)
  • Shadow of the Tomb Raider (native)
  • Hollow Knight (native)
  • Euro Truck Simulator 2 (native)
  • CS2 (native)

One game that does care about if I specify the dGPU is Deponia (through Proton).

I am confused about this inconsistency. Am I doing something wrong?

Some questions now:

  1. Why could it be that my dGPU is GPU0 while for everyone else it is GPU1?
  2. Why do some games ignore the launch options, while others do not and use the dGPU anyway? Is it because it is the first in the list when querying vulkaninfo? Isn’t that in conflict with 1.?

Kind regards :blush: