Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

feat(capture): add AMD Display Capture for AFMF

Open radugrecu97 opened this issue 1 year ago • 15 comments

Description

This PR adds a new capture option under advanced settings - AMD Display capture. The main purpose of this new capture method would be to capture AFMF frames.

Type of Change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Dependency update (updates to dependencies)
  • [ ] Documentation update (changes to documentation)
  • [ ] Repository update (changes to repository files, e.g. .github/...)

Checklist

  • [ ] My code follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Known bugs

  • Mouse isn't captured unless it's of a very large size
  • When using AFMF, frames might be captured out of order during and could result in temporary "ghosted" image. Some testing showed that it's caused by display changes and moonlight pause and resume. This is fixed after disabling and re-enabling AFMF or sometimes waiting. Different capturing mode parameters might fix this issue and a proper testing methodology should prove the current best approach.

Known limitations

  • AMD card is required to use this capturing mode, regardless of use of AFMF
  • AFMF can't be used with VDD because it Adrenaline doesn't recognize the virtual display and therefore no special features can be used. So a monitor or edid emulator has to be used as the capturing display.

To do:

  • Fix mouse cursor streaming
  • Add screenshot showing new UI option
  • Fix quality check
  • Maybe add a new field for changing Display Capture, capturing mode parameter.

radugrecu97 avatar Sep 11 '24 19:09 radugrecu97

Hello, this PR fix Amd Frame generation ? On Nvidia too ? Thanks

moi952 avatar Sep 12 '24 05:09 moi952

Hello, this PR fix Amd Frame generation ? On Nvidia too ? Thanks

Yes, this pr supports AMD frame generation and requires an AMD card. I'll add to notes

Nvidia doesn't have a driver level frame generation. The Desktop duplication API mode should already support DLSS frames.

This PR might capture more Lossless Scaling modes though.

radugrecu97 avatar Sep 12 '24 06:09 radugrecu97

Hello, this PR fix Amd Frame generation ? On Nvidia too ? Thanks

Yes, this pr supports AMD frame generation and requires an AMD card. I'll add to notes

Nvidia doesn't have a driver level frame generation. The Desktop duplication API mode should already support DLSS frames.

This PR might capture more Lossless Scaling modes though.

Currently if I activate the AMD frame generation integrated into the games it does not work (on nvidia card), this pr will not correct this problem? Thank you

moi952 avatar Sep 12 '24 06:09 moi952

Hello, this PR fix Amd Frame generation ? On Nvidia too ? Thanks

Yes, this pr supports AMD frame generation and requires an AMD card. I'll add to notes Nvidia doesn't have a driver level frame generation. The Desktop duplication API mode should already support DLSS frames. This PR might capture more Lossless Scaling modes though.

Currently if I activate the AMD frame generation integrated into the games it does not work (on nvidia card), this pr will not correct this problem? Thank you

Please explain your setup, you have both an AMD and Nvidia card?

AMD Driver lever frame generation is called AMD Fluid motion frames (AFMF). The frame generation that's integrated into the game is called FidelityX Super Resolution (FSR). Which one are you talking about?

radugrecu97 avatar Sep 12 '24 09:09 radugrecu97

Bonjour, ce PR corrige la génération de trames AMD ? Sur Nvidia aussi ? Merci

Oui, ce PR prend en charge la génération de trames AMD et nécessite une carte AMD. J'ajouterai aux notes que Nvidia ne dispose pas d'une génération de trames au niveau du pilote. Le mode API de duplication du bureau devrait déjà prendre en charge les trames DLSS. Ce PR pourrait cependant capturer davantage de modes de mise à l'échelle sans perte.

Actuellement si j'active la génération de frame AMD intégrée aux jeux ça ne fonctionne pas (sur carte nvidia), ce pr ne corrigera pas ce problème ? Merci

Veuillez expliquer votre configuration, vous avez à la fois une carte AMD et une carte Nvidia ?

La génération d'images du levier AMD Driver s'appelle AMD Fluid Motion Frames (AFMF). La génération d'images intégrée au jeu s'appelle FidelityX Super Resolution (FSR). De laquelle parlez-vous ?

Hello, this PR fix Amd Frame generation ? On Nvidia too ? Thanks

Yes, this pr supports AMD frame generation and requires an AMD card. I'll add to notes Nvidia doesn't have a driver level frame generation. The Desktop duplication API mode should already support DLSS frames. This PR might capture more Lossless Scaling modes though.

Currently if I activate the AMD frame generation integrated into the games it does not work (on nvidia card), this pr will not correct this problem? Thank you

Please explain your setup, you have both an AMD and Nvidia card?

AMD Driver lever frame generation is called AMD Fluid motion frames (AFMF). The frame generation that's integrated into the game is called FidelityX Super Resolution (FSR). Which one are you talking about?

My GPU is an RTX 4070.

I'm talking about the FSR frame generation (not the upscale but the frame generation that is integrated in some games)

Currently the FSR frame generation is not captured on my GPU (I don't know what it is on an AMD card)

moi952 avatar Sep 12 '24 11:09 moi952

Bonjour, ce PR corrige la génération de trames AMD ? Sur Nvidia aussi ? Merci

Oui, ce PR prend en charge la génération de trames AMD et nécessite une carte AMD. J'ajouterai aux notes que Nvidia ne dispose pas d'une génération de trames au niveau du pilote. Le mode API de duplication du bureau devrait déjà prendre en charge les trames DLSS. Ce PR pourrait cependant capturer davantage de modes de mise à l'échelle sans perte.

Actuellement si j'active la génération de frame AMD intégrée aux jeux ça ne fonctionne pas (sur carte nvidia), ce pr ne corrigera pas ce problème ? Merci

Veuillez expliquer votre configuration, vous avez à la fois une carte AMD et une carte Nvidia ? La génération d'images du levier AMD Driver s'appelle AMD Fluid Motion Frames (AFMF). La génération d'images intégrée au jeu s'appelle FidelityX Super Resolution (FSR). De laquelle parlez-vous ?

Hello, this PR fix Amd Frame generation ? On Nvidia too ? Thanks

Yes, this pr supports AMD frame generation and requires an AMD card. I'll add to notes Nvidia doesn't have a driver level frame generation. The Desktop duplication API mode should already support DLSS frames. This PR might capture more Lossless Scaling modes though.

Currently if I activate the AMD frame generation integrated into the games it does not work (on nvidia card), this pr will not correct this problem? Thank you

Please explain your setup, you have both an AMD and Nvidia card? AMD Driver lever frame generation is called AMD Fluid motion frames (AFMF). The frame generation that's integrated into the game is called FidelityX Super Resolution (FSR). Which one are you talking about?

My GPU is an RTX 4070.

I'm talking about the FSR frame generation (not the upscale but the frame generation that is integrated in some games)

Currently the FSR frame generation is not captured on my GPU (I don't know what it is on an AMD card)

This PR introduces a new capturing method that only works on AMD GPUs not on Nvidia. If your issue hasn't been recorded on the issue tracker, you can do so.

radugrecu97 avatar Sep 12 '24 13:09 radugrecu97

AFMF2 can twice frames for almost games ,I really need this feature added

HibernalGlow avatar Oct 02 '24 02:10 HibernalGlow

Quality Gate Failed Quality Gate failed

Failed conditions
10 New issues
9.8% Duplication on New Code (required ≤ 2%)
2 Duplicated Blocks on New Code (required ≤ 0)
10 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

sonarqubecloud[bot] avatar Oct 09 '24 19:10 sonarqubecloud[bot]

So the latest AMD driver seems to have had a quality regression for AFMF 2 compared to the preview.

I'll test again later but AFMF 2 looked so blurry and jittery on the latest drivers.

radugrecu97 avatar Oct 10 '24 17:10 radugrecu97

So the latest AMD driver seems to have had a quality regression for AFMF 2 compared to the preview.

I'll test again later but AFMF 2 looked so blurry and jittery when streamed compared to the preview.

Possibly another regression exposed with the ffmpeg 7.1 update?

ReenigneArcher avatar Oct 10 '24 17:10 ReenigneArcher

Codecov Report

:x: Patch coverage is 0% with 130 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 7.56%. Comparing base (d378c18) to head (38763bb). :warning: Report is 375 commits behind head on master.

Files with missing lines Patch % Lines
src/platform/windows/display_amd.cpp 0.00% 82 Missing :warning:
src/platform/windows/display_vram.cpp 0.00% 38 Missing :warning:
src/platform/windows/display_base.cpp 0.00% 7 Missing :warning:
src/platform/windows/display.h 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3171      +/-   ##
=========================================
- Coverage    9.74%   7.56%   -2.18%     
=========================================
  Files         101     102       +1     
  Lines       17975   18038      +63     
  Branches     8420    8477      +57     
=========================================
- Hits         1751    1364     -387     
- Misses      13330   13858     +528     
+ Partials     2894    2816      -78     
Flag Coverage Δ
Linux 7.27% <ø> (ø)
Windows 0.00% <0.00%> (-5.11%) :arrow_down:
macOS-13 10.54% <ø> (-0.04%) :arrow_down:
macOS-14 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/video.cpp 26.15% <ø> (-1.03%) :arrow_down:
src/platform/windows/display.h 0.00% <0.00%> (-7.25%) :arrow_down:
src/platform/windows/display_base.cpp 0.00% <0.00%> (-13.60%) :arrow_down:
src/platform/windows/display_vram.cpp 0.00% <0.00%> (-1.85%) :arrow_down:
src/platform/windows/display_amd.cpp 0.00% <0.00%> (ø)

... and 39 files with indirect coverage changes

codecov[bot] avatar Oct 10 '24 18:10 codecov[bot]

So the latest AMD driver seems to have had a quality regression for AFMF 2 compared to the preview. I'll test again later but AFMF 2 looked so blurry and jittery when streamed compared to the preview.

Possibly another regression exposed with the ffmpeg 7.1 update?

FFmpeg 7.1 changelog doesn't tell me much, BUT I was surprised that a different Display Capture mode is not displaying frames out of order any more compared to previous experience.

The AMF sdk release does mention that they updated ffmpeg to 7.0, so maybe they didn't test with 7.1.

radugrecu97 avatar Oct 11 '24 07:10 radugrecu97

So the latest AMD driver seems to have had a quality regression for AFMF 2 compared to the preview. I'll test again later but AFMF 2 looked so blurry and jittery when streamed compared to the preview.

Possibly another regression exposed with the ffmpeg 7.1 update?

FFmpeg 7.1 changelog doesn't tell me much, BUT I was surprised that a different Display Capture mode is not displaying frames out of order any more compared to previous experience.

The AMF sdk release does mention that they updated ffmpeg to 7.0, so maybe they didn't test with 7.1.

Hi, I would like to know where the development of AFMF capture is? In this issue https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/514 , I have the impression that it works.

Thanks

moi952 avatar Dec 30 '24 19:12 moi952

I don't know if this can help, but AMD just released an SDK for streaming https://github.com/GPUOpen-LibrariesAndSDKs/Streaming-SDK

In the sample they and using AMD Direct Capture

rafaelndev avatar Mar 09 '25 01:03 rafaelndev

It looks like this PR has been idle for 90 days. If it's still something you're working on or would like to pursue, please leave a comment or update your branch. Otherwise, we'll be closing this PR in 10 days to reduce our backlog. Thanks!

LizardByte-bot avatar Jun 07 '25 10:06 LizardByte-bot

This PR was closed because it has been stalled for 10 days with no activity.

LizardByte-bot avatar Jun 18 '25 10:06 LizardByte-bot