Jump to content
  • Advertisement
Sign in to follow this  
ronan.thibaudau

DX11 SharpDX (DX11) : How to toggle windowed / full screen fast?

This topic is 2104 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 tried the default mechanism (everything works automagically letting DXGI do the work as i specify in MakeWindowAssociation

 

However that's "really" slow, i doubt it's reloading the ressources that is slow (i'm only using 1 mesh, albeit large & a single texture, drawing a single object, nothing fancy here). It's taking a solid 4-5 seconds to switch from or to fullscreen mode!

 

While not crazy this does seem very slow to me, is there an alternative that could ideally get me <1sec times at least? I'm only targeting DX11.2 so no need for the alternative to be backward compatible, i'll take anything

 

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

What resolution is your fullscreen mode and how does this compare to your standard desktop resolution?  This is important, because if you're switching to the same resolution as your desktop is running at it should go quite fast, definitely under the 1 second you're aiming for.  If switching to a different fullscreen resolution it will involve a mode change, so it's naturally going to be slower.

Share this post


Link to post
Share on other sites

in case you do not want to alter resolution, there is a neat trick to do this. Create device in windowed mode, and, realize that if you press F11 at any window in windows, it will scale to screen, making header and borders history. So dispatch this event to your render window.

Share this post


Link to post
Share on other sites

You don't have to reload all of the resources when switching to fullscreen. You just do swapchain->ResizeBuffers, recreate the depth/stencil buffers, and set the viewports, as you would normally do during a windowed resize. You don't even have to re-bind shaders/resources to the pipeline.

 

There are also some performance considerations for full screen switching, described in this article: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205075(v=vs.85).aspx

If you enable the Direct3D debug messages for your application, you will get some warnings during the switch to fullscreen. I found those messages really helpful.

 

One thing that I noticed causes bad performance (low framerates, or delays) with Direct3D (even 11) is using double-precision floating points in your program. When you do that, (assuming you're building 32-bit code) the FPU is set into double precision mode, and then DirectX will reset it back to single-precision - this FPU set/reset caused me a lot of grief until I detected it. So maybe, make sure you don't use any doubles during your full-screen switching code?

 

You can also record a PIXRun to see what Direct3D API takes so long...

Edited by tonemgub

Share this post


Link to post
Share on other sites

in case you do not want to alter resolution, there is a neat trick to do this. Create device in windowed mode, and, realize that if you press F11 at any window in windows, it will scale to screen, making header and borders history. So dispatch this event to your render window.

This is not a standard windows fucntion - AFAIK, it is implemented only by browsers and Explorer. It won't work in Notepad for example. Some manufacturers also provide a tool that adds that function to other apps, which they install with the default Windows installation.

Share this post


Link to post
Share on other sites

Borderless, fullscreen windows can be implemented in any application, but that's not the same as a fullscreen Direct3D application. When an application runs in Direct3D fullscreen mode, it has the whole graphics card to itself (aside from some background resource caching done by the DWM), so it will usually run better than in windowed mode. When Direct3D runs in a window, the graphics card is shared with other applications, so it runs slower. This is only noticeable with lower-end graphic cards, though.

Share this post


Link to post
Share on other sites

Hey, thanks for all the answers

@mhagain : you're probably on to something there as i was at 1000X1000 in windowed mode, however i don't see how i could (except if i go borderless) go for the same resolution windowed, what is the good windowed alternative if i want fast switching? Is it go render at desktop resolution or to go borderless or something else entirely?

@JohnnyCode : i'm already doing the first thing you suggested, however thanks for the link / tip

@tonemgub : exactly, i'm looking to switch to real full screen (not borderless), else switching to borderless is pretty much instant (like a resize). Currently resizing is instant, but switching is slow.

Share this post


Link to post
Share on other sites
Did you log actual time stamps to make sure you got such long delay ? Maybe even use D3D11 timer queries (e.g. after the first present after the switch). It could just be your monitor needing that long to resync wink.png

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!