Jump to content
  • Advertisement
Sign in to follow this  
Balk

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

This topic is 2607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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[size="4"]*, 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.

[size="4"]*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!

Share this post


Link to post
Share on other sites
Advertisement
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!

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!