SteamOS icon indicating copy to clipboard operation
SteamOS copied to clipboard

LIBVA_DRIVER_NAME Variable is not set System wide, causing issues with some Apps when launched in Gamemode.

Open NightHammer1000 opened this issue 3 years ago • 9 comments

  • Steam client version: 1651195429
  • SteamOS version: 20220429.100
  • Opted into Steam client beta?: Yes
  • Opted into SteamOS beta?: Yes
  • Have you checked for updates in Settings > System?: Yes

LIBVA_DRIVER_NAME=radeonsi is not set by default, which causes some Tools that use it Issues in Game mode. SteamOS Game Mode does not honor this Environment Variable if its exported in Desktop Mode, making it necessary to define it in the Games/Tools Launch Arguments.

It should be set system-wide, as radeonsi is the only viable LIBVA Driver anyway.

Workaround Adding LIBVA_DRIVER_NAME=radeonsi %command% to the Launch Arguments of the app that does not work.

NightHammer1000 avatar May 01 '22 13:05 NightHammer1000

One noteable App that is affected by this is Parsec Game Streaming.

radeonsi is the only viable LIBVA Driver in the Steam Deck. Because of this fact it should be set in the System as Default to minimize Issues for the End User.

NightHammer1000 avatar May 02 '22 14:05 NightHammer1000

Hello,

It sounds like this should be a bug reported against Feral's gamemode?

If I understand correctly, your use case is running Parsec Game Streaming, under gamemode, in desktop mode? Any other use cases that you know of?

TTimo avatar May 05 '22 15:05 TTimo

In Gamemode on the Deck.

You also need the Environment Variable to get Browser Hardware Decoding working, and I think even VLC denied my Hardware Decoding without it.

NightHammer1000 avatar May 05 '22 16:05 NightHammer1000

Ok - this suggested LIBVA_DRIVER_NAME doesn't seem right to me. VA-API should find the right driver without needing, especially as you point out there's only one workable solution anyway. So I suspect there is a better root cause and fix?

@smcv @slouken opinion on this?

TTimo avatar May 05 '22 18:05 TTimo

As a general design principle, setting environment variables shouldn't be necessary to make libraries do sensible things.

libva is meant to discover the correct driver name automatically by asking the display server. On the Steam Deck, I believe that means Xwayland, in which case it will use the X11 DRI2 extension.

smcv avatar May 05 '22 18:05 smcv

I have a few Infos from the Bug Testing together with the Parsec Dev. There we had the Issue that libVA itself crashed when LIBVA_DRIVER_NAME was not present.

libva threw us a "0xffffffff" code. This was something he needed to catch first to stop the App from Hard Crashing.

Could it be that more than the only viable Driver is present from stock on the System?

(deck@steamdeck ~)$ ls /usr/lib/dri/
i965_drv_video.so  radeonsi_dri.so        swrast_dri.so
kms_swrast_dri.so  radeonsi_drv_video.so  zink_dri.so

Also to add this happens regardless of Flatpak. We had the same Issue on Parsec from Flatpak and parsec-bin from AUR.

NightHammer1000 avatar May 06 '22 07:05 NightHammer1000

20220506093118_1

Also vainfo fails in Gamemode. See Attached Screenshot It appears that libva is unable to get a Driver if its not supplied as a Variable in that case.

NightHammer1000 avatar May 06 '22 07:05 NightHammer1000

That looks like a bug in either the version of libva on the Steam Deck, or the configuration of the Xwayland server used by gamescope. libva should be able to auto-detect the correct VA-API driver without special environment variables.

smcv avatar May 06 '22 08:05 smcv

in Game mode

Assuming you mean the games-console-like, Steam-only UI, it's probably better to refer to that as "Gamescope mode" to avoid confusion with Feral Interactive's "gamemode".

I don't have a Steam Deck myself, but my understanding is that the situation is something like this:

  • libva is meant to auto-detect the correct VA-API driver from the display server.
  • For X11 apps in desktop mode (KDE Plasma), this auto-detection works: libva uses the DRI2 protocol to ask the X server what driver to use, and the X server replies with something that makes libva choose radeonsi.
  • For native Wayland apps in desktop mode, it's not clear to me whether it works or not. (Is the Steam Deck's desktop mode based on Xorg, or Wayland + Xwayland?)
  • For X11 apps in Gamescope mode, this auto-detection doesn't work: Gamescope is a Wayland session with Xwayland, and libva uses the DRI2 protocol to ask Xwayland what driver to use, but Xwayland only implements DRI3 and not DRI2, so the auto-detection fails.
  • For native Wayland apps in Gamescope mode, this auto-detection probably doesn't work?

For apps run directly on the Steam Deck (either via Steam or in pacman packages), I think the correct solution is probably to improve the libva on the Steam Deck and/or the Xwayland server, so that the auto-detection works as intended. Until that solution can be implemented, LIBVA_DRIVER_NAME=radeonsi is a workaround.

For Flatpak apps, I think the correct solution is similar, but if it involves libva changes, then those changes would additionally need to be sent to https://gitlab.com/freedesktop-sdk/freedesktop-sdk to get them into the Flatpak runtime. Again, LIBVA_DRIVER_NAME=radeonsi is a workaround.

smcv avatar Jun 22 '22 14:06 smcv