Sign in to follow this  
schupf

DX9 Swap chains

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:
[code]
// 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
[/code]
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
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!

[quote name='MJP' timestamp='1307640617' post='4821394']
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.
[/quote]
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this