Jump to content
  • Advertisement
Sign in to follow this  
schupf

DX9 Swap chains

This topic is 2543 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

Hello!

I have some (hopefully) simple questions about DX9 swapchains:

Let's say I want to render into 3 windows.

1) When I have created the device I already have created a swapchain, haven't I (I call it the implicit swapchain)? So I just need to create 2 additional swapchains in order to render into 3 windows?

2) A swapchain has a backbuffer and a depth/stencil surface. Both of them are available in the implicit device swapchain when I set AutoDepthStencil to true. But for the additional swapchains (created by device->createAdditionalSwapChain(pp) setting AutoDepthStencil to true has no effect and I have to manually create the depth/stencil surfaces for my additional swapchains. Is this correct?

3) Now I want to render into my 3 swapchains. Is this pseudo code correct:

// Render 1. (implicit) device swapchain
device->setRenderTarget(swapChain0BackBuffer); // Fetched per device->getBackBuffer(0);
device->setDepthStencilSurface(swapChain0DepthStencilSurface); // Fetched per device->GetDepthStencilSurface();
device->clear();
render...
device->present();

// Render 2nd swapchain:
device->setRenderTarget(swapChain1BackBuffer); // Fetched per swapChain1->getBackBuffer(0);
device->setDepthStencilSurface(swapChain1DepthStencilSurface); // Created per device-CreateDepthStencilSurface();
device->clear();
render...
swapChain1->present();

// 3rd is the same as 2nd swapchain

Is this correct?

4) When I want to resize all of my 3 swapChains: To resize the implicit device swapchain I just refill a presetParams structure (with the new size), release DEFAULT resource and call device->reset(pp). But I haven't found a IDirect3DSwapChain9::Reset() Method. Does this mean I have to release the swapchain resources (backbuffer,depthstencilsurface), then the swapchains, reset the device and create all swapchains again from scratch with new presentparams struct?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
1. Yup.

2. Additional swap chains don't have depth stencil surfaces created with them. You'll have to create them manually.

3. Yup, that looks about right.

4. You only need to reset the device if you need to resize the window being used by the implicit swap chain. For the other swap chains, you can just Release the swap chain for the window you need to resize and make a new one with the appropriate dimensions.

Share this post


Link to post
Share on other sites
Thanks for your answer MJP!


4. You only need to reset the device if you need to resize the window being used by the implicit swap chain. For the other swap chains, you can just Release the swap chain for the window you need to resize and make a new one with the appropriate dimensions.

Ok. So I guess it is the best to consider the device as device AND swapchain 0.

Oh, 2 more littles question (don't want to start a new thread): If I want to check for lost devices I have to check the device AND all swap chains, don't I?
What do you think is the best method? A test with TestCooperativeLevel() before rendering or check the HRESULT of Present() for the device AND all swapchains?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!