ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.22k stars 174 forks source link

Use hardware encoding on AMD RX480 for In-Home Streaming. #4890

Closed toojays closed 2 years ago

toojays commented 7 years ago

My GPU is an RX 480. When streaming to the steam link from Linux, my streaming_log.txt shows:

[2017-03-09 22:54:10] >>> Capture method set to Desktop OpenGL NV12 + scale + libx264 main (3 threads)
[2017-03-09 22:54:10] >>> Capture resolution set to 1280x720

Whereas from Windows, I get:

[2017-01-12 06:55:24] >>> Capture method set to Steam D3D10 NV12 + AMF H264
[2017-01-12 06:55:24] >>> Capture resolution set to 1920x1080

Unsurprisingly, I get a better picture, and smoother performance when streaming from Windows.

Recent versions of Mesa support hardware encoding of H264 on this GPU:

┌(toojays@kano)─(9993)─(0)─(2017 03 10 20:16:12)
└─(~)─> vainfo | grep Entry
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      <unknown profile>               : VAEntrypointVLD
      <unknown profile>               : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

Please enhance the Steam Linux client to take advantage of this for streaming to the Steam Link.

kisak-valve commented 2 years ago

Hello, per "Added support for VA-API hardware encoding on Linux (can be disabled by turning off AMD and Intel hardware encoding in the Remote Play advanced host settings)" in the 2021-11-02 Steam client beta update, please opt into Steam's client beta and retest this issue.

tullo-x86 commented 2 years ago

Statistics show VA-API encoding when connected via the Steam Link app on Android!

hschen2 commented 2 years ago

EDIT: I solved it, i just had to install the 32 bit version of VAAPI, i forgot that steam needs 32 bit libraries, now it works

streaming_log.txt Not working for me, running an RX 480 and still getting "Game Vulkan RGB + libyuv + libx264 main (4 threads)", i enabled hardware encoding in steam settings and made sure VAAPI is installed

nicocarbone commented 2 years ago

Seems to be working here. Ubuntu 21.10 + rx5500xt. Thanks! :)

slouken commented 2 years ago

Thanks everyone!

ghost commented 2 years ago

it's working on Ubuntu 20.04 LTS + RX 470. thank you very much for your hard work!

... btw, is there any way to select GPU for encoding on multiple GPU machine? ;)

PC1

$ lspci | grep VGA 01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev cf) 09:00.0 VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 730] (rev a1) 0a:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] (rev c8) $ ls /dev/dri/ by-path card0 card1 renderD128 renderD129

PC2

$ lspci | grep VGA 01:00.0 VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 710] (rev a1) 04:00.0 VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 710] (rev a1) 06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev cf) $ ls /dev/dri/ by-path card0 renderD128

kparal commented 2 years ago

I quickly tested on Fedora 34 with Radeon 580, it seems to be working. Thanks!

rventers commented 2 years ago

Can't seem to get this working on Kubuntu 21.10. Using the latest Steam beta client, Settings > Remote Play > ADVANCED HOST OPTIONS > "Enable hardware encoding" is enabled.

My streaming client is still reporting the encoder as "Desktop OpenGL NV12 + Libx264 main (3 threads)".

lspci | grep VGA:

01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev e7)

vainfo:

libva info: VA-API version 1.12.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_12
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.12 (libva 2.10.0)
vainfo: Driver version: Mesa Gallium driver 21.2.2 for Radeon RX 580 Series (POLARIS10, DRM 3.41.0, 5.13.0-20-generic, LLVM 12.0.1)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

I also tried setting exporting LIBVA_DRIVER_NAME as "radeonsi" but that did not make a difference.

kisak-valve commented 2 years ago

Hello @Thrickles, you're testing 64 bit VA-API, but Steam can be using 32 bit VA-API. Please verify you have mesa-va-drivers:i386 with something like apt policy mesa-va-drivers mesa-va-drivers:i386 and install the 32 bit package variant if it isn't already.

rventers commented 2 years ago

Thank you @kisak-valve! Really appreciate the quick response and overall support here. I do have i386 mesa packages installed, but I did not have libva2:i386 installed. Once installed, my streams now show "VAAPI H264" for the encoder.

falk4243 commented 2 years ago

Question to all testers: Does HEVC (H.265) work or is VA-API support limited to H.264 for now? I have only tested against the Steam flatpak and suspect that it might be a limitation (or missing dependency?) there, but am curious what native users are reporting.

ieyi4ooPAig1ui5U commented 2 years ago

Seems to work with the RX 5500 XT 8GB mostly, but the screen occasionally goes black for a moment. Sometimes every few seconds, sometimes it'll go for minutes at a time with no interruption. It seems like maybe the stream is restarting or something, because sometimes when it comes back up it takes a couple moments for it to come up to full encoding quality. Could it be something weird with the 8GB model or do I need to update the Steam Link I'm using to the beta too? Oh, and I noticed the fast/balanced/beautiful selector in Remote Play client settings doesn't do anything either. Not sure if that's related or not. The quality and latency are both good while it's working.

@falk4243 I'm only seeing it come up in H.264 mode but I don't know how to change it for testing anything else.

Urfoex commented 2 years ago

Kind of works for me on RX 480 showing VAAPI 264. But it seems, when the GPU load is high, the game freezes (tested with GRIP: Combat Racing (Coop) and Redout: Enhanced Edition (Coop)). Menus worked fine, but shortly after the races started, the game froze. With a bit of waiting the game continued, until it froze again. Without GPU acceleration it works without problem. (There was no obvious problem logged in journalctl.)

parkerlreed commented 2 years ago

@Urfoex This is a limitation of VAPPI with that hardware. The encoder will freeze up if the GPU runs out of resources. If the game is running over 60FPS, capping it with something in game or Mangohud can help lower the usage and get a stable stream.

vaskozl commented 2 years ago

For those running archlinux based systems, other than installing lib32-libva-mesa-driver (in addition to libva-mesa-driver), you also need to run with the native runtime by installing steam-native-runtime and running steam through the steam-native script.

l3iggs commented 2 years ago

Works like a charm for me now under Arch Linux. VAAPI picks up the Intel GPU on my laptop and uses the hardware H264 encoder there to provide a hugely improved streaming experience! Thanks!

falk4243 commented 2 years ago

@ieyi4ooPAig1ui5U Very late answer, but you can change the setting client-side on the iOS and the Android Steam Link app. No support for HEVC when streaming from PC to PC (whether Linux or Windows) it seems.

In the meantime, I tinkered a bit more and could only get h264 encoding to work, which is a shame with AMD hardware since their h265 encoding is better by miles and leagues. Streaming with Sunshine instead (which supports HEVC encoding), the difference is like night and day.

RMStyle commented 2 years ago

Sadly it's still not working for me on Manjaro. Every time I start the stream steam just crashes and restarts. About my system: Manjaro with Gnome DE, AMD CPU and GPU.

What I've done:

Steam itself gives these logs:

Switching video stream from NONE to Desktop_MovieStream
ffmpeg verbose: libva: VA-API version 1.13.0
ffmpeg verbose: libva: User environment variable requested driver 'radeonsi'
ffmpeg verbose: libva: Trying to open /usr/lib32/dri/radeonsi_drv_video.so
ffmpeg verbose: libva: Found init function __vaDriverInit_1_13
ac: Unknown GPU, using 0 for raster_config
CLIENT: Got control packet k_EStreamControlSetTargetBitrate
CLIENT: Got control packet k_EStreamControlSetSpectatorMode
CLIENT: Got control packet k_EStreamControlSetCaptureSize
CLIENT: Got control packet k_EStreamControlSetTitle
CLIENT: Got control packet k_EStreamControlSetIcon
CLIENT: Got control packet k_EStreamControlSetActivity