Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

Remove the need for a patched nvidia library for NvFBC.

Open hgaiser opened this issue 1 year ago • 8 comments

Description

This PR is based on https://github.com/hgaiser/nvfbc-rs/pull/5 , which in turn is based on https://github.com/keylase/nvidia-patch/blob/master/win/nvfbcwrp/nvfbcwrp_main.cpp#L23-L25 .

With this change you don't need a patched NVIDIA library to use NvFBC. My best guess is that this is what GeForce Experience uses to allow it to work on GTX / RTX cards.

Screenshot

N/A

Issues Fixed or Closed

N/A

Type of Change

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

Checklist

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

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch must be updated before it can be merged. You must also Allow edits from maintainers.

  • [x] I want maintainers to keep my branch updated

hgaiser avatar Apr 26 '24 21:04 hgaiser

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 26 '24 21:04 CLAassistant

Thank you for the PR! I also didn't know we could handle it like this.

If this affects NVENC as well, I think there might need to be an additional change somewhere in https://github.com/LizardByte/Sunshine/blob/nightly/src/nvenc/nvenc_base.cpp

ReenigneArcher avatar Apr 26 '24 22:04 ReenigneArcher

Yeah so I'm a bit confused by NVENC. It almost seems like enabling this patch also allows NVENC.. I never thought about it but using Moonshine I never use a patched NVIDIA library and NVENC encoding works fine there.

I feel like this might trigger something in the NVIDIA library that also allows encoding, but I'm not sure. I tried rebooting, but I still see that I can encode, even if I use nightly and not this PR.

[2024:04:27:00:38:36]: Error: Failed to create session: This hardware does not support NvFBC
[2024:04:27:00:38:37]: Info: Found H.264 encoder: h264_nvenc [nvenc]
[2024:04:27:00:38:37]: Info: Found HEVC encoder: hevc_nvenc [nvenc]

It might also mean that if you use NVENC, but not NvFBC, that you still need a patched driver :shrug: . I haven't been able to trigger this case at least.

Can you test this to see how this works for you? Whether you can capture & encode using this PR but can't capture nor encode without this PR?

hgaiser avatar Apr 26 '24 22:04 hgaiser

There might be some confusion. The ./src/nvenc code is only used on Windows (as far as I know), since nvfbc is deprecated on Windows. For reference, it was introduced here: https://github.com/LizardByte/Sunshine/pull/1427

Currently I don't have a quick way to test your PR, but I could ask for testers on our Discord server?

ReenigneArcher avatar Apr 26 '24 23:04 ReenigneArcher

There might be some confusion. The ./src/nvenc code is only used on Windows (as far as I know), since nvfbc is deprecated on Windows. For reference, it was introduced here: #1427

Ah I see. I'm curious, why isn't ffmpeg used on Windows? I never looked into it much but I thought it was cross platform?

Currently I don't have a quick way to test your PR, but I could ask for testers on our Discord server?

Yeah I think that would be nice 👍

hgaiser avatar Apr 26 '24 23:04 hgaiser

We do use ffmpeg on Windows as well. I'm not up to speed on the standalone nvenc encoder, but I know the other capture methods do use ffmpeg.

ReenigneArcher avatar Apr 27 '24 00:04 ReenigneArcher

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 7.98%. Comparing base (17e0f1a) to head (e850162). Report is 154 commits behind head on master.

Files with missing lines Patch % Lines
src/platform/linux/cuda.cpp 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #2471      +/-   ##
=========================================
- Coverage    8.02%   7.98%   -0.04%     
=========================================
  Files          88      88              
  Lines       18036   18039       +3     
  Branches     8596    8596              
=========================================
- Hits         1447    1441       -6     
+ Misses      13839   13761      -78     
- Partials     2750    2837      +87     
Flag Coverage Δ
Linux 6.05% <0.00%> (-0.07%) :arrow_down:
Windows 3.76% <ø> (ø)
macOS-12 9.03% <ø> (+0.01%) :arrow_up:
macOS-13 8.93% <ø> (ø)
macOS-14 9.22% <ø> (ø)

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

Files with missing lines Coverage Δ
src/platform/linux/cuda.cpp 1.81% <0.00%> (-0.02%) :arrow_down:

... and 25 files with indirect coverage changes

codecov[bot] avatar May 01 '24 18:05 codecov[bot]

I'm not sure anyone has been able to test this. I do have an extra Quadro M4000 card (I guess it has native NvFBC, but I'm not 100% sure), but I will have to deploy a linux environment to use it in so might take me a little bit.

If anyone else already has the os/hardware combination to test this build it would be greatly appreciated.

ReenigneArcher avatar May 16 '24 16:05 ReenigneArcher