GLWpfControl icon indicating copy to clipboard operation
GLWpfControl copied to clipboard

High GPU Usage without rendering anything on the screen.

Open SqueakyBed opened this issue 2 years ago • 4 comments

Hi,

I am having issues with GPU usage where a simple test app is using 20% to 30% GPU while idle and without calling the Clear() method or even rendering anything on the screen.

The GPU usage starts at around 4% and within a few seconds it jump to like 15% and if I hit ALT + Enter to switch to full screen mode it climbs to 30% + which is a hell of a lot of usage for a blank screen. I don't have any issues with any other apps on my machine so I am very confidant it's related to GLWpfControl.

My machine specs: Windows 10 image

Test app GPU usage in task manager:

image

Sample test app:

https://easyupload.io/jifxac Sorry but Girhub wouldn't let me upload a zip file so I hosted it somewhere else.

Thanks in advance.

SqueakyBed avatar Sep 04 '22 20:09 SqueakyBed

Likely this is related to V-Sync. If you are not limiting the frame rate the GPU will work as fast as it can, which will use as much GPU as possible. And GPU usage going up with increased resolution is nothing weird, and 15% to 30% for full speed clearing doesn't sound weird to me.

I would recommend you try enabling V-Sync and seeing if GPU usage goes down.

NogginBops avatar Sep 04 '22 21:09 NogginBops

What version of GLWpfControl does this relate too?

NogginBops avatar Sep 04 '22 21:09 NogginBops

Likely this is related to V-Sync. If you are not limiting the frame rate the GPU will work as fast as it can, which will use as much GPU as possible. And GPU usage going up with increased resolution is nothing weird, and 15% to 30% for full speed clearing doesn't sound weird to me.

I would recommend you try enabling V-Sync and seeing if GPU usage goes down.

I failed to mention this but the sample I attached is actually running at 60 fps, And in my project I am actually limiting the frame rate to 30 fps by calling GLWpfControl.InvalidateVisual(); from a separate thread at 30fps and setting RenderContinuously = false. Still it would use the same GPU % which is around 20% to 30% when in full screen.

Also, It doesn't matter which resolution I run it at it still uses the same amount of GPU as soon as I enter full screen mode. I have a multi monitor setup and switching monitors to 1920x1080 doesn't make a difference.

It's super weird because the project I am porting to WPF was built using C++ and directx 11 and even after rendering everything on the screen at 60 fps full screen it would use an average of 2.5% gpu so you can see why I am shocked by the amount of GPU GLWpfControl uses with just a blank canvas.

And I am using version 4.2.2 btw

SqueakyBed avatar Sep 05 '22 01:09 SqueakyBed

OK, Some progress finally.

I found that adding an app.manifest to the project with the following content for DPI awareness spikes the GPU usage randomly.

<windowsSettings> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware> <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness> </windowsSettings>

If I remove the manifest and run the app it would consume a steady ~12% GPU (which is still pretty high when running at 30 fps tbh ) If I Re-Add the manifest, build and run the app again, The GPU usage becomes erratic and fluctuates between 5% high as 43% (still blank canvas capped at 30 fps).

If I remove the GLWpfControl from the app, The GPU usage drops to 0 regardless of what the resolution is btw. Idk how to proceed from here because multi monitor support and DPI awareness are a must for my app and I can't just remove the manifest permanently.

SqueakyBed avatar Sep 05 '22 03:09 SqueakyBed