Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High GPU Usage without rendering anything on the screen. #89

Open
SqueakyBed opened this issue Sep 4, 2022 · 4 comments
Open

High GPU Usage without rendering anything on the screen. #89

SqueakyBed opened this issue Sep 4, 2022 · 4 comments

Comments

@SqueakyBed
Copy link

SqueakyBed commented Sep 4, 2022

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.

@NogginBops
Copy link
Member

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
Copy link
Member

What version of GLWpfControl does this relate too?

@SqueakyBed
Copy link
Author

SqueakyBed commented Sep 5, 2022

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
Copy link
Author

SqueakyBed commented Sep 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants