Off-World-Live / obs-spout2-plugin

A Plugin for OBS Studio to enable Spout2 (https://github.com/leadedge/Spout2) input / output
https://knowledge.offworld.live/en/spout-plugin-for-obs-studio
GNU General Public License v2.0
523 stars 49 forks source link

Very high GPU usage #42

Closed febox6 closed 1 year ago

febox6 commented 2 years ago

Describe the bug Every SPOUT output uses around 9% of my GPU (even when the filter is disabled in OBS).

To Reproduce Steps to reproduce the behavior:

  1. Open Task Manager (CTRL + SHIFT + ESC)
  2. Locate OBS process
  3. Add SPOUT output filter to a scene in OBS
  4. Check GPU percentage growth Bonus: 5. Disable SPOUT output filter in the scene (don't remove it) and check the task manager for any changes.

Expected behavior Better performance? For some reason I'm getting worse performance than when using NDI. Also, shouldn't the GPU usage decreases when the filter is disabled? This would at least allow the user to programmatically disable SPOUT outputs for better GPU performance while streaming.

About the Software:

About Your Machine :

campbellwmorgan commented 2 years ago

Hi @febox6 thanks for taking the time to write this to us. I think it may be you has been in touch with us on our discord, but in case its not:

Where are you sending your Spout filter to? Do you have any other filters on your output? What resolution is the OBS workspace?

febox6 commented 2 years ago

Thanks for the reply. It's not me on discord though.

For my project I'm sending the Spout output to an Unity project - but the issue happens no matter if the receiver is open or not. My resolution is 1920x1080.

I just tested this:

0) Backed up my OBS; 1) Added new empty scene; 2) Removed all other scenes; 3) GPU is back to 0%; 4) Added Spout filter to empty scene; 5) GPU shows ~ 8.6% usage; 6) Added a second scene with the Spout output filter; 7) GPU usage goes to ~ 17.5%.

In the task manager for the OBS process the GPU engine is "GPU 0 - 3D".

campbellwmorgan commented 2 years ago

Thanks a lot for that information. I have been able to replicate locally.

We'll look into it and get back to you.

MiraSynth commented 1 year ago

Do you have any updates on this?

I managed to replicate the issue on my end, changing the FPS value in OBS Settings > Video > FPS makes the GPU usage go lower.

I also have an issue with my DAC, seems like the high GPU usage is producing a crackle and pop in my sound, the frequency of the sound artifacts increase and decrease with the FPS I set.

60 FPS - High GPU Usage - Higher Frequency of Audio pop and crackle 30 FPS - Half the GPU Usage relative to 60 - Half the Pop and crackle 1 FPS - Virtually no GPU usage - 1 pop and crackle per couple of seconds

It seems like the texture PULL is causing the GPU to take up a lot of resources, and the possible fix needs to be implemented in the code found in this file.

https://github.com/Off-World-Live/obs-spout2-plugin/blob/master/source/win-spout-filter.cpp#L94-L178

y2kcyborg commented 1 year ago

I messed around with this today, using Spout2 SendTexture lets us avoid multiple copies GPU->CPU, CPU->CPU and then CPU->GPU.

https://github.com/millenium-cyborg/obs-spout2-plugin/tree/spout-sendtexture

From early experiments this makes the render time in OBS drop by a few ms per frame when using Spout2 sources. I haven't made a PR yet because the colours on the output texture are wrong, I suspect it's to do with the sRGB handling. Still just getting started learning how the OBS rendering works!