Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


DirectX Performance issues when using different window style


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
9 replies to this topic

#1 MartinSmith160   Members   -  Reputation: 146

Like
0Likes
Like

Posted 21 May 2012 - 08:48 AM

Hi All,

I have wrote a simple DirectX 2D game engine and im having some issues when running the game applications on different computers. I developed the engine and demos on a windows 7 dual core with an NVIDIA GeForce GT 520. I can run the game over two monitors and its performance is 60+ FPS.

The platform I need to run my games on is a dual core, XP system with an ATi HD 3200 across dual monitors. I setup the games to look fullscreen by using the WS_POPUP window style, using one window which is 2048 x 768 running on a 1024 x 768 resolution.

This works brilliant on my computer but im having some issues on other computers.

The problems I am having are:
  • If I use WS_POPUP the first monitor is just a black screen
  • If I use WS_POPUPWINDOW it works and draws to both monitors but its really slow
  • If I set the game to not be borderless, E.g use WS_OVERLAPPEDWINDOW instead, the performace shoots up from around 10 FPS to 25 FPS but it no longer looks fullscreen.

This is my window style setup code:


if (g_engine->getFullscreen())
{
DEVMODE dm;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
dm.dmPelsWidth = g_engine->getScreenWidth();
dm.dmPelsHeight = g_engine->getScreenHeight();
dm.dmBitsPerPel = g_engine->getColorDepth();
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
MessageBox(NULL, "Display mode failed", NULL, MB_OK);
g_engine->setFullscreen(false);
}

dwStyle = WS_POPUP;
dwExStyle = WS_EX_APPWINDOW;
ShowCursor(FALSE);
}
else if(g_engine->getBorderless())
{
dwStyle = WS_POPUP;
dwExStyle = WS_EX_APPWINDOW | WS_EX_TOPMOST ;
}
else {
dwStyle = WS_OVERLAPPEDWINDOW;
dwExStyle = WS_EX_APPWINDOW | WS_EX_TOPMOST ;
}

Im very confused with these issues and any help would be greatly appreciated.

Thanks,
Martin

Sponsor:

#2 codeToad   Members   -  Reputation: 142

Like
0Likes
Like

Posted 21 May 2012 - 05:45 PM

Are you enumerating the display modes from the adapters and outputs, or are you using a hardcoded value?

MS says that any kind of windowed mode will be slower than fullscreen, because rendering must be done by a blt instead of a flip. (However, Washu says that he's seen games where the difference is negligible).


Are you using DX11? I recently found out that DXGI can tinker with your window settings behind the scene. You can use the following method to prevent it from doing so.
dxgiFactory->MakeWindowAssociation(g_hWnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN);

Note that you must call this method on the DXGIFactory object that created your swap chain. So you will have to create your swap chain with dxgiFactory->CreateSwapChain. Another option is to get a reference to the DXGIFactory object that created your swap chain by calling adapter->GetParent (or maybe d3dDevice->GetParent).

#3 MartinSmith160   Members   -  Reputation: 146

Like
0Likes
Like

Posted 22 May 2012 - 01:46 AM

Hi CoadToad,

Im using DirectX 9 so im not to sure about the dxgiFactory stuff. Im not sure about how to enumerate the adapter outputs. I Have one DirectX device and that is setup after the default adapters are aquires E.G

this->p_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);

Could It be that I only have one device and I need two because im running on two monitors.

Thanks for the help,
Martin

#4 mhagain   Crossbones+   -  Reputation: 8275

Like
0Likes
Like

Posted 22 May 2012 - 03:57 AM

IDirect3D9::GetAdapterCount and IDirect3D9::EnumAdapterModes will get your modes under D3D9. You also don't need to use ChangeDisplaySettings to go fullscreen or otherwise change the mode with D3D - D3D will do that automatically for you, and a ChangeDisplaySettings call may actually cause you more problems if it triggers a lost device.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 MartinSmith160   Members   -  Reputation: 146

Like
0Likes
Like

Posted 22 May 2012 - 04:39 AM

Thanks for the advice.

Im still confused tho, the

GetAdapterCount() should return 2 on a dual monitor system I assume but how do I use the

EnumAdapterModes() to tell my D3D device to render to both monitors. On some computers one window that stretches across both displays fine. on others the secondary monitor doesnt display (just a black screen).



Thanks



#6 MartinSmith160   Members   -  Reputation: 146

Like
0Likes
Like

Posted 22 May 2012 - 05:18 AM

Also I cant work out why when WS_OVERLAPPEDWINDOW windows style is chosen, the frame rate is twice as fast as it is when using WS_POPUPWINDOW.

#7 mhagain   Crossbones+   -  Reputation: 8275

Like
0Likes
Like

Posted 22 May 2012 - 06:21 AM

Also I cant work out why when WS_OVERLAPPEDWINDOW windows style is chosen, the frame rate is twice as fast as it is when using WS_POPUPWINDOW.

You may have a mismatch between your backbuffer size and your window size; if so D3D will need to do a stretch operation during Present which would slow you down. It's more likely to occur when using styles with title bars/borders, but possible nonetheless. You can double-check using GetBackBuffer, then GetDesc on the returned backbuffer to get it's size (and not forgetting to Release the backbuffer surface when done).

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#8 codeToad   Members   -  Reputation: 142

Like
0Likes
Like

Posted 22 May 2012 - 08:26 PM

Good point, mhagain.

Are you changing window styles at runtime, or do you have a hardcoded value that you are changing?

If you're changing window styles at runtime, you may have confused your window's client area with the overall window size. When you call CreateWindow, the dimensions you specify include any area taken up by whatever titlebars and borders get created according to the window style you specify. There is a Win32 method called GetClientRect that tells you the area of your window excluding any titlebars and borders. So maybe your backbuffer is created with the dimensions that GetClientRect gives you, and then when you change to popup mode, your backbuffer is not getting resized.

Of course that's all assuming you're changing the window style at runtime.

Edited by codeToad, 22 May 2012 - 08:27 PM.


#9 MartinSmith160   Members   -  Reputation: 146

Like
0Likes
Like

Posted 23 May 2012 - 05:46 AM

He all,

Thanks for the input, I checked the buffer size and its correct. Im not changing the style at runtime, its set once and thats it. Ive been told I should setup two D3D devices one for each monitor. Does this sound correct.

#10 MartinSmith160   Members   -  Reputation: 146

Like
0Likes
Like

Posted 28 May 2012 - 08:56 AM

Hi Guys

I was wrong, the client rect was 2046 x 766 and the back buffer was 2048 x 768. This would have caused the StrechBlit. Fixing this got me some more FPS's. went from around 11 to 24. problem is its still not fast enough. I was starting to think the hardware just wasnt good enough but we have other directx games that run really well on them so it must be my code somewhere. Would it be better performance wise to be able to create a window class each of which had its own directx device. Then independent windows could be created. I would have to specify the window that my game objects belong to but that wouldn't be to bad. Its a complete overall of the engine so would it be worth it performance wise.

Thanks,
Martin




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