ValveSoftware / SteamOS

SteamOS community tracker
1.54k stars 69 forks source link

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

Open NightHammer1000 opened 2 years ago

NightHammer1000 commented 2 years ago

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 commented 2 years ago

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.

TTimo commented 2 years ago

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?

NightHammer1000 commented 2 years ago

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.

TTimo commented 2 years ago

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?

smcv commented 2 years ago

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.

NightHammer1000 commented 2 years ago

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 commented 2 years ago

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.

smcv commented 2 years ago

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 commented 2 years ago

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:

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.