Jump to content

  • Log In with Google      Sign In   
  • Create Account

[C++ DX9] Slow Down after losing window focus


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 CrescentFresh   Members   -  Reputation: 141

Like
0Likes
Like

Posted 25 October 2011 - 09:12 AM

I have a DX9 application that creates two windows and renders to each of them. These windows are not full-screen mode, they are windowed mode set to the system's resolution size to emulate full-screen. Everything works fine until the user either alt-tabs or minimizes the window, which the framerate is noticeably slower when they return.

-BEFORE LOSING FOCUS-
Update FPS: ~63000
Render FPS: 60 (throttled to match vSync)

-AFTER LOSING FOCUS AND RETURNING-
Update FPS: ~25000
Render FPS: 30

I find it odd that the render frames are cut in half perfectly*, however the update frames are cut significantly as well so it's clear I'm not getting the same CPU time slice from the OS prior to losing focus. This application is running on an XP Embedded OS system that is pretty bare bones. When I test this same scenario on my dev machine, which is Windows 7 64bit, I don't have this issue.

*Now that I think about it... my rendering is on the same thread as the updates are. I just skip the rendering portion if we're not in vSync. I'm starting to think now that since my updates are cut down, I'm missing every other vSync occurrence. It still doesn't explain why my updates are slow when returning focus though, if anyone has any input on that please let me know.

Thanks!

Can I play with madness?


Sponsor:

#2 Zern   Members   -  Reputation: 134

Like
0Likes
Like

Posted 25 October 2011 - 11:10 AM

CrescentFresh,


This is just a quick idea (forgive me if you already have tested this, just some input! :P), but I'd recommend checking your WM_ACTIVATEAPP in the MessageProc, ensuring nothing funky is being altered when the app is reactivated/gains focus. Specifically when you are resetting the device. I assume you are using pDevice->TestCooperativeLevel() and awaiting for a D3DERR_DEVICENOTRESET to reset the device. Ensure that you are setting the D3DPRESENT_PARAMETERS variable that are you using in the pDevice->Reset() function properly. Specifically the FullScreen_RefreshRateInHz variable.

Those are the only two options that come to mind. Good luck!

#3 CrescentFresh   Members   -  Reputation: 141

Like
0Likes
Like

Posted 25 October 2011 - 11:50 AM

That's a good idea to check WM_ACTIVATEAPP for any weird anomalies, and I am handling a lost device properly. However the device doesn't actually get lost when I minimize or alt-tab... probably because I'm in windowed mode. So it must either be something else, or something on the OS level (hope not). I'm not sure what else to check for.

Within the task manager, I can right click a process and increase the priority. Can this value be set by the application itself? Does anyone think this might help?

(As a side note, the only time I've been able to lose the device when in windowed mode is to press alt+ctrl+del.)

Can I play with madness?


#4 CrescentFresh   Members   -  Reputation: 141

Like
0Likes
Like

Posted 25 October 2011 - 12:03 PM

This is odd, but it fixes the issue...

When I return from losing focus and my frame rate is dropped, If I force a lost device and reset it... it fixes the performance issue. I didn't think it was possible to be in some sort of limbo state of a lost device, but apparently something in D3D is slowing down when returning focus, and TestCooperativeLeve() was still returning successfully.

Can I play with madness?





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS