Handmade Hero»Forums»Code
Tim Kane
23 posts
Twitter: Tim_Rex_
Window focus and effect on OpenGL performance
Edited by Tim Kane on Reason: Initial post
I've noticed that when I'm developing OpenGL applications (Win32) that the performance drops somewhat if the window is not in focus.
I guess that's not entirely unreasonable, but I'm curious to understand it a little more.. and if there is anything I can realistically do about it.

To illustrate, I'll get a clear 60fps when the window has focus, but it drops to a much less stable 48-55fps when it loses focus (even if only a fraction of the window is visible, but that's not the issue here).

I've tried playing with SetProcessPriorityBoost(), SetProcessPriority() and SetThreadPriority() to marginal effect, nothing compelling.

Setting the window style to include WS_EX_TOPMOST doesn't change things at all.


I think this is still down to scheduling/priority somewhere but I wonder if there is anything else I could be looking at here?
It's not a big deal I suppose, but it is annoying me :)

Simon Anciaux
1341 posts
Window focus and effect on OpenGL performance
Edited by Simon Anciaux on Reason: typo
Have you tried measuring different part of the application and see if there is a particular part that is slower when it doesn't have the focus ?

Is your application covering the entire screen or is it a window ? When a window covers the entire screen, the window compositor behaves differently (DirectX 12: Presentation Modes In Windows 10, I don't think OpenGL is mentioned in the video but I suppose something similar could happen).
Tim Kane
23 posts
Twitter: Tim_Rex_
Window focus and effect on OpenGL performance
I noticed it while running in a window.. though I've not tried to see if there is any effect in release mode.
I half suspect it's the driver, or perhaps Windows 10 itself deciding it will have less priority (though I can't see any evidence of that).

It's no big deal, but thanks for the ideas. I'll try to profile a little further and see where the difference might be occurring.