D3D10 Alt-Tab

Started by
3 comments, last by gfxCahd 10 years, 3 months ago

Having some trouble with alt-tabing. When I'm fullscreen and alt-tab, I leave my game, and it dissapears completely. Can't "cycle" to it anymore, and clicking on its icon on the taskbar does nothing. Do I need to process a specific windows message, or is there some device state i could poll?

Turning off DXGI with IDXGIFactory::MakeWindowAssociation makes no difference. BTW, I am using sharpDX.

p.s. The Sharpdx d3d10 samples also behave similarly, i.e. the game becomes inaccesible when alt tabbing in fullscreen.

Advertisement

I'll apologize in advance since this may not even apply to the problem you have.

In earlier versions of DirectX you always had to recreate the device after alt-tabbing, since the device would become "lost." That meant releasing every DX resource and calling reset on the device - which would only work if you hadn't leaked any memory.

I'm not sure if that behavior was kept in DX10.

visualnovelty.com - Novelty - Visual novel maker

Yeah, that behaviour applies in Directx9, where alt-tabing results in losing the device. In Directx10 - 11 the device no longer is lost, so I am thinking its got something to do with DXGI not playing nice with winforms.

Check your MakeWindowAssociation call - it may not be correct. The documentation hints at the correct way, but doesn't state it outright, so it's an easy mistake to make.

Basically, if you're creating a new IDXGIFactory and then calling MakeWindowAssociation on it, it would be expected to have no effect. Instead what you need to do is call GetParent on your swapchain to retrieve the IDXGIFactory that was used to create the swapchain, then make your MakeWindowAssociation call using that factory object (remembering to Release it when done as it will have it's reference count incremented).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Yeah, I did it the proper way. Here is the code I use (it's SharpDX/C#, but almost identical to Directx10/c++):


      Factory dxgiFactory = new Factory();
      Adapter dxgiAdapter = dxgiFactory.Adapters[0];
      graphicsDevice = new Device(dxgiAdapter, DeviceCreationFlags.Debug);

      displayMode = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm);
      var swapDesc = new SwapChainDescription()
      {
        ModeDescription = displayMode,
        SampleDescription = new SampleDescription(1, 0),
        Usage = Usage.RenderTargetOutput,
        BufferCount = 1,
        OutputHandle = myForm.Handle,
        IsWindowed = true,
        SwapEffect = SwapEffect.Discard,
        Flags = SwapChainFlags.AllowModeSwitch
      };
      swapChain = new SwapChain(dxgiFactory, graphicsDevice, swapDesc);
   
      dxgiFactory.MakeWindowAssociation(myForm.Handle, WindowAssociationFlags.IgnoreAll);

This topic is closed to new replies.

Advertisement