obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
57.78k stars 7.74k forks source link

OBS uses an additional DirectX Context for GPU encoding #6647

Open theHamsta opened 2 years ago

theHamsta commented 2 years ago

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

Git

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/l3JZQfAboldVzSMe

OBS Studio Crash Log URL

No response

Expected Behavior

OBS just uses a single DirectX context when using jim-nvenc (see below). This is the recommendation Nvidia gives in their Video SDK samples (https://developer.nvidia.com/video_codec_sdk/downloads/v11-1-5, Nvidia Developer account necessary for download)

Current Behavior

jim-nvenc, like other GPU encoders, creates a dedicated DirectX context (https://github.com/obsproject/obs-studio/blob/master/plugins/obs-ffmpeg/jim-nvenc.c#L290-L340) that is not shared with the rendering context. This does not follow the recommendation in the official samples https://developer.nvidia.com/video_codec_sdk/downloads/v11-1-5 (Nvidia developer account necessary for download) where GPU encoding is performed using the same context shared with rendering.

At Nvidia, we performed benchmarks that showed that following the recommended API usage would increase game FPS (on average by 1.5% on the 5 tested games. We shared detailed results with OBS core devs in discord earlier).

The disadvantage of using separate contexts are:

We can help you to fix this problem. Please let us know whether you would be interested in such a change!

Steps to Reproduce

Bug does not become apparent at runtime, but hurts game performance. To check whether that was really the case we performed benchmark using only a single context which improved performance.

Anything else we should know?

No response

TheRealDadbeard commented 2 years ago

More performance? Yes please thank you