Skip to main content
GameDev.net gamedev.net
🔒 Locked

100% CPU when D3D window is obstructed?

Started by HaywireGuy May 14, 2005 at 12:46 PM 3 replies 1.1k views
Original Post
HaywireGuy
HaywireGuy
Greetings people, just a simple one: Why does CPU usage gone sky-rocketting when a non-fullscreen Direct3D window is in the background? Take any of the DirectX SDK tutorial samples, if the window is partially obstructed the CPU usage is only 2 percent, but when it is totally blocked by another window, it is using 100% CPU. What's the cause of it and how can this be addressed? Thanks in advance!
Jiia
Jiia
When your program gets an unfocus message, call WaitMessage().

The CPU will still roar when a window is in the process of being moved around over the app, because it will probably use ON_PAINT to redraw the window.
HaywireGuy
HaywireGuy
Jiia, that works for me. Thanks! 3 points for ya.
jollyjeffers
jollyjeffers
Quote:
Original post by HaywireGuy
What's the cause of it and how can this be addressed? Thanks in advance!

I forget the exact reasoning - but I did see an explanation of this "issue" from one of the DirectX developers a while back. Gonna bug me now [oh]

IIRC, it's something to do with the way that the runtime has to do extra clipping/copying operations so as to "play nice" with the other windows. Things are a bit easier for it when it's in focus [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
HaywireGuy
HaywireGuy
Jack, it happens when the D3D is TOTALLY obstructed by other window. Even if
there is 1% of the client area that is visible, the CPU usage remains at 2%.
What I think could be the possibility was that the rendering routine pass
without rendering anything (since the window is invisible to the user), so the
message pump goes looping with literally nothing in it, causing the CPU usage
to go all the way up.

Just like what Jiia said, I use GetMessage() when the window does not have the
focus, this problem goes away. Thanks anyway Jack for your help :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.