obs-spout2-plugin icon indicating copy to clipboard operation
obs-spout2-plugin copied to clipboard

Very high GPU usage

Open febox6 opened this issue 2 years ago • 4 comments

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:

  • OBS 27.2.4
  • OBS Spout 2 Source Plugin Version 1.2

About Your Machine :

  • OS: Windows 11
  • GPU NVIDIA GeForce RTX 2070 SUPER
  • GeForce Game Ready Driver Version 512.15
  • RAM 32GB
  • Desktop - AMD Ryzen 9 3900X

febox6 avatar Apr 20 '22 18:04 febox6

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:

  • Spout should not consume any computational resources on the GPU. All it does is at most copy textures to the GPU (and only when it can't access existing GPU textures).
  • If you have very large textures, it is possible that it could be consuming more GPU RAM, but no shaders are being executed on the GPU and therefore it should not be consuming computational resources on the GPU

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

campbellwmorgan avatar Apr 22 '22 10:04 campbellwmorgan

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:

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

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

febox6 avatar Apr 22 '22 21:04 febox6

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

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

campbellwmorgan avatar Apr 22 '22 22:04 campbellwmorgan

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

MiraSynth avatar Jul 05 '22 19:07 MiraSynth

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!

y2kcyborg avatar Sep 11 '22 21:09 y2kcyborg