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)
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.
This is just a quick idea (forgive me if you already have tested this, just some input! ), 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!
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.)
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.