GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
609 stars 152 forks source link

We are developing an Open-source Low-latency Game Streaming client #244

Closed Opensourcestreamingclient closed 3 years ago

Opensourcestreamingclient commented 3 years ago

Hello everyone,

We are developing an Open-source Low-latency Game Streaming client based on Sunshine. https://open-stream.net

We are facing this strange issue: We manged to get Open-Stream working with our AMD 5700xt systems. However, when we upgraded the drivers from Adrenalin 2020 Edition 20.5.1 to Adrenalin 2020 Edition 20.12.1, there is huge lag in the display with nearly 100% GPU usage (or any version in between). It does not matter if we implement CPU encoding or GPU AMF encoding.

We can see the GPU at less than 10% constantly and when we just rapidly move the mouse cursor, the GPU goes to almost 100% immediately. Is there something we are missing? The same driver versions work perfectly with our AMD RX 480 systems. Also no issues to report with any Nvidia based GPU systems (including our RTX 2080's).

We have already tried upgrading to ffmpeg 4.3.1 along with the h.264 and h.265 codec library's.

Details:

Windows 10 AMD RX 5700xt Adrenalin 2020 Edition 20.121 Processor: AMD 3900x Open-stream version: openstream_alpha_2312.1

Please keep in mind that we are far from being experts at this. There has been a lot of trial-and-error to get to this stage.

We would be happy to offer test accounts for anyone interested in debugging this issue along with a small bounty of $500 Canadian for the first successful solution.

MikhailAMD commented 3 years ago

Few things to note and to check:

Opensourcestreamingclient commented 3 years ago

Thank you for the quick reply. You will find my comments below.

Please note that this bug is also affecting CPU encoding (h.264 and h.265). For what ever reason the GPU goes to 100% while the CPU is barely used.

Any other suggestions would be welcomed.

MikhailAMD commented 3 years ago

You lost me:

Opensourcestreamingclient commented 3 years ago

This bug is visible with both AMD AMF and CPU encoding with any AMD driver version newer than 20.5.1. Maybe we are using a call function that is no longer available in the latest AMD driver versions.

I will run the GPUVIEW log and share it with you.

Opensourcestreamingclient commented 3 years ago

GPU AMF H.264 GPUVIEW log:

https://open-stream.net/wp-content/uploads/2020/12/Merged-GPU-AMF-Encoding-Adrenalin-2020-Edition-20.12.1.etl_.tar.gz https://open-stream.net/wp-content/uploads/2020/12/log.cmd-GPU-AMF-Encoding-Adrenalin-2020-Edition-20.12.1..txt

CPU Encoding H.264 GPUVIEW log: https://open-stream.net/wp-content/uploads/2020/12/Merged-CPU-Encoding-Adrenalin-2020-Edition-20.12.1.etl_.tar.gz https://open-stream.net/wp-content/uploads/2020/12/log.cmd-CPU-Encoding-Adrenalin-2020-Edition-20.12.1..txt

When moving the mouse cursor, the 3D part of GPU goes almost immediately to 100%. With Adrenalin-2020-Edition-20.5 the 3D part of the GPU in the task manager averages around 10-15% while the Video encoder can reach as high as 50%. With Adrenalin-2020-Edition-20.12.1 the Video encoder stays at 0%. This in turn causes massive stutter and a drop in the streaming frame rates.

I find it strange that it's affecting the CPU encoding as well. This leads me to believe it might be unrelated to AMF.

MikhailAMD commented 3 years ago

Thanks for the logs. They explain a lot. The common problem with CPU and with GPU encoder is that the application keeps acquired texture/surface from DD capture for a long time and do not release it. This blocks GPU other operations and DWM present and therefore the next capture. Please check AMF DVR sample and example of Desktop Duplication API capture usage: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/src/components/DisplayCapture/DDAPISource.cpp

See the attached screenshots with explanations: CPU:

CPU

GPU

GPU

Opensourcestreamingclient commented 3 years ago

Your feedback really helped and I can't thank you enough. Please let us know to where this bounty will be sent.

MikhailAMD commented 3 years ago

I work for AMD and the fact that you are adding support for AMD GPUs and AMF is the best reward. Keep doing this. Also you may want to update us on your progress, publicly or privately.