Handmade Hero » Forums » Code » Window focus and effect on OpenGL performance
TimRex
Tim Kane
22 posts
Twitter: Tim_Rex_
#21712 Window focus and effect on OpenGL performance
5 days, 1 hour ago Edited by Tim Kane on Oct. 10, 2019, 8:09 p.m. 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 :)

mrmixer
Simon Anciaux
673 posts
#21721 Window focus and effect on OpenGL performance
3 days, 8 hours ago Edited by Simon Anciaux on Oct. 13, 2019, 3:24 p.m. 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).