Exemplo n.º 1
0
void GFXPCD3D9WindowTarget::createAdditionalSwapChain()
{
   AssertFatal(!mImplicit, "Invalid swap chain type!  Implicit swap chains use the device");

   // Since we're not going to do a device reset for an additional swap
   // chain, we can just release our resources and regrab them.
   SAFE_RELEASE(mSwapChain);
   SAFE_RELEASE(mDepthStencil);
   SAFE_RELEASE(mBackbuffer);

   // If there's a fullscreen window active, don't try to create these additional swap chains.
   // CodeReview, we need to store the window target with the implicit swap chain better, this line below 
   // could fail if the current render target isn't what we expect.
   GFXPCD3D9WindowTarget* currTarget = dynamic_cast<GFXPCD3D9WindowTarget*>(mDevice->getActiveRenderTarget());
   if (currTarget && currTarget->getWindow()->getVideoMode().fullScreen)
      return;

   // Setup our presentation params.
   initPresentationParams();

   // Create our resources!
   D3D9Assert(mDevice->getDevice()->CreateAdditionalSwapChain(&mPresentationParams, &mSwapChain),
      "GFXPCD3D9WindowTarget::createAdditionalSwapChain - couldn't reallocate additional swap chain!");
   D3D9Assert(mDevice->getDevice()->CreateDepthStencilSurface(mPresentationParams.BackBufferWidth, mPresentationParams.BackBufferHeight,
      D3DFMT_D24S8, mPresentationParams.MultiSampleType, mPresentationParams.MultiSampleQuality, false, &mDepthStencil, NULL), 
      "GFXPCD3D9WindowTarget::createAdditionalSwapChain: Unable to create stencil/depth surface");
   D3D9Assert(mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mBackbuffer),
      "GFXPCD3D9WindowTarget::createAdditionalSwapChain: Unable to get backbuffer!");   
}
Exemplo n.º 2
0
void GFXPCD3D9WindowTarget::resetMode()
{
   mWindow->setSuppressReset(true);

   if (mSwapChain)
   {
      // The current video settings.
      D3DPRESENT_PARAMETERS pp;
      mSwapChain->GetPresentParameters(&pp);      
      bool ppFullscreen = !pp.Windowed;
      Point2I backbufferSize(pp.BackBufferWidth, pp.BackBufferHeight);

      // The settings we are now applying.
      const GFXVideoMode &mode = mWindow->getVideoMode();
      
      // Convert the current multisample parameters into something
      // we can compare with our GFXVideoMode.antialiasLevel value.
      U32 ppAntiAliaseLevel = 0;
      if ( pp.MultiSampleType != D3DMULTISAMPLE_NONE )      
         ppAntiAliaseLevel = pp.MultiSampleQuality + 1;

      // Early out if none of the settings which require a device reset
      // have changed.      
      if ( backbufferSize == getSize() && 
           ppFullscreen == mode.fullScreen &&
           ppAntiAliaseLevel == mode.antialiasLevel )
         return;   
   }

   // So, the video mode has changed - if we're an additional swap chain
   // just kill the swapchain and reallocate to match new vid mode.
   if(mImplicit == false)
   {
      createAdditionalSwapChain();
   }
   else
   {
      // Setup our presentation params.
      initPresentationParams();

      // Otherwise, we have to reset the device, if we're the implicit swapchain.
      mDevice->reset(mPresentationParams);
   }

   // Update our size, too.
   mSize = Point2I(mPresentationParams.BackBufferWidth, mPresentationParams.BackBufferHeight);      

   mWindow->setSuppressReset(false);
}
Exemplo n.º 3
0
void GFXD3D11WindowTarget::resetMode()
{
   mWindow->setSuppressReset(true);

   // Setup our presentation params.
   initPresentationParams();

   // Otherwise, we have to reset the device, if we're the implicit swapchain.
   D3D11->reset(mPresentationParams);

   // Update our size, too.
   mSize = Point2I(mPresentationParams.BufferDesc.Width, mPresentationParams.BufferDesc.Height);

   mWindow->setSuppressReset(false);
   GFX->beginReset();
}