keylase / nvidia-patch

This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
3.5k stars 276 forks source link

When applying x64 library patch for GeForce cards, breaks Shield TV streaming. #215

Closed stevenmcgeorge closed 4 years ago

stevenmcgeorge commented 4 years ago

When applying x64 library patch for GeForce cards on Windows 10, it breaks Shield TV streaming.

Streaming a game before the patch is applied works fine, but once the patch is applied, Shield TV reports error code: 80330209 when attempting to stream.

Shield TV is on latest software version: 8.0.1 (32.5.205.75).

Reverting back the changes fixes the issue.

Snawoot commented 4 years ago

I don't know how to approach to solution of this issue. Requesting help.

mafarioch commented 4 years ago

441.20 is the last driver version which still works after patching (in my case, at least.) I'm not using Shield, but I'm using Moonlight Streaming app which utilizes same protocol shield devices do to stream games.

So something after that driver release got changed, which breaks things after patching.

stevenmcgeorge commented 4 years ago

Yes, Moonlight streaming still works fine. I have also tested this previously, it is unaffected.

Shield does not work though. Shield stops working after patching on Shield's latest software version, which doesn't let you downgrade. When reverting patch, Shield starts working again.

On Mon, 6 Jan 2020, 02:09 Mafa Rioch, notifications@github.com wrote:

441.20 is the last driver version which still works after patching (in my case, at least.) I'm not using Shield, but I'm using Moonlight Streaming app which utilizes same protocol shield devices do to stream games.

So something after that driver release got changed, which breaks things after patching.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keylase/nvidia-patch/issues/215?email_source=notifications&email_token=AOA7WOEONBQDLOMK2WUOIF3Q4KHEBA5CNFSM4J2MITXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIEGVYY#issuecomment-570976995, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOA7WOFBIVTF3CA5CK2P3WDQ4KHEBANCNFSM4J2MITXA .

Snawoot commented 4 years ago

So I guess it can be not a problem with driver patch itself but rather Shield software somehow verifies driver integrity?

PizzaManOmar commented 4 years ago

I am having this issue as well. Please fix. I tested 441.20 & 441.87 with shield and moonlight neither work with the patch.

reloxx13 commented 4 years ago

Got the same, nvstreamersrv log says:

Failed to load library C:\Windows\system32\nvEncodeAPI64.dll due to error 2148081673
#5(D)[2020-01-23 17:15:59,681]=18:15:59={0000215C}<VideoEncoder>     Creating NvEnc9VideoEncoder.
#6(I)[2020-01-23 17:15:59,681]=18:15:59={0000215C}<VideoEncoder>     Initializing NvEnc9VideoEncoder.
#7(I)[2020-01-23 17:15:59,681]=18:15:59={0000215C}<NvEnc9VideoEncod> Using NvEnc header version 9.0.
#8(E)[2020-01-23 17:15:59,681]=18:15:59={0000215C}<GsLoadLibrary>    Failed to load library C:\Windows\system32\nvEncodeAPI64.dll due to error 2148081673
#9(E)[2020-01-23 17:15:59,681]=18:15:59={0000215C}<NvEnc9VideoEncod> Failed to load NvEnc DLL from '\nvEncodeAPI64.dll'.
#0(E)[2020-01-23 17:15:59,681]=18:15:59={0000215C}<NvEncUtil>        Failed to initialize encoder for RTSP SPS/PPS header generation.

My guess is, its checking for the digital signature on the ddl and this is missing on the "hacked" dll.

stevenmcgeorge commented 4 years ago

Just to let you guys know, I don't think this patch is needed anymore. In recent driver updates, Nvidia appears to have unlocked the maximum number of simultaneous NVENC video encoding sessions in their own driver, probably to make their cards more competitive against AMD's lineup. I'm running a RTX 2060 and when I'm running Plex, my NVENC streams are unlimited without the use of this patch, and Shield works too. I don't know if the same has happened for GTX cards though.

PizzaManOmar commented 4 years ago

Just to let you guys know, I don't think this patch is needed anymore. In recent driver updates, Nvidia appears to have unlocked the maximum number of simultaneous NVENC video encoding sessions in their own driver, probably to make their cards more competitive against AMD's lineup. I'm running a RTX 2060 and when I'm running Plex, my NVENC streams are unlimited without the use of this patch, and Shield works too. I don't know if the same has happened for GTX cards though.

Just started up multiple transcoded streams to test this theory and did not work. Some streams were kicked out to the CPU for transcoding. i have the latest driver for RTX 2070 441.87

Snawoot commented 4 years ago

@reloxx13 Thank you for information you provided. It was very useful.

Indeed, GsLoadLibrary function from NvStreamBase.dll implements some code signing check. However, even if code signing check fails, function continues normal operation if some magic keys exist in registry with non-zero value.

One can apply this simple registry file and bypass signature verification.

Instructions:

  1. Download raw file. Right click on "Raw" button on this page and then click "Save as...".
  2. Apply (merge) file. Double click on downloaded file and confirm.

Please let me know if it resolves your issue. I have no Shield TV, so I tested it only by indirect means.

reloxx13 commented 4 years ago

Please let me know if it resolves your issue. I have no Shield TV, so I tested it only by indirect means.

Note: Im not using a Shield. Gaming/Streaming PC -> AndroidTVBox/Win10 with moonlight.

Ill try your fix and give feedback, thank you for investigating 👍

PizzaManOmar commented 4 years ago

@reloxx13 Thank you for information you provided. It was very useful.

Indeed, GsLoadLibrary function from NvStreamBase.dll implements some code signing check. However, even if code signing check fails, function continues normal operation if some magic keys exist in registry with non-zero value.

One can apply this simple registry file and bypass signature verification.

Instructions:

1. Download raw file. Right click on "Raw" button on [this page](https://gist.github.com/Snawoot/2ef1ddff113f05b3551f6c51db047b93) and then click "Save as...".

2. Apply (merge) file. Double click on downloaded file and confirm.

Please let me know if it resolves your issue. I have no Shield TV, so I tested it only by indirect means.

Just Tested! It seems to have fixed the problem! i ran moonlight on nvidia shield and it started up with no problems. i ran 4 transcodes just to double check the patch works and all 4 were transcoding on GPU!

Snawoot commented 4 years ago

@PizzaManOmar Thank you!

Ok, going to prepare PR to introduce this patch in mainline...

reloxx13 commented 4 years ago

Works for me! 👍

stevenmcgeorge commented 4 years ago

It's never stopped working on Moonlight, it's always worked on Moonlight fine? It's only Shield TV that's affected. Testing it on Moonlight is pointless.

Snawoot commented 4 years ago

Merged via #229

PizzaManOmar commented 4 years ago

It's never stopped working on Moonlight, it's always worked on Moonlight fine? It's only Shield TV that's affected. Testing it on Moonlight is pointless.

Moonlight and nvidia games/shield where both broken for me and i assume @reloxx13 aswell. i am 100% sure moonlight uses the same nvidia gamestream backbone as nvidia games/shield. if it was working for you, you might want to double check and see that your patch is still functional

reloxx13 commented 4 years ago

It's never stopped working on Moonlight, it's always worked on Moonlight fine? It's only Shield TV that's affected. Testing it on Moonlight is pointless.

Nope, it did not work for me with moonlight without the signing skip fix on the host.

sabaatworld commented 4 years ago

Can't this be fixed?

Snawoot commented 4 years ago

@sabaatworld It's already fixed. See posts above and ../tree/master/win/README.md for instructions.