Jump to content
  • Advertisement
Sign in to follow this  
LevyDee

Swap chains(DX9)

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

So I have taken a pretty long break from working on my home grown engine, and I am now getting back into it. Before I quit for the time, I had converted my rendering pipeline from a FFP to a PP(deferred rendering ect...). Before I had converted, I was using swap chains to present to multiple window handles, but I am now implementing that into my new deferred pipeline. My current implementation is simply overriding the window handle parameter on device->Present() . So my question is, why even use swap chains ever? I thought there only functionality was to present to multiple windows, but you can do that by simply overriding the parameter in Present(). Its been a while since I last used swap chains, so I kind of have forgotten their main purpose.

Share this post


Link to post
Share on other sites
Advertisement

If you are drawing to windows with different resolutions, you need multiple swap chains.


Could you explain a little bit? I am currently drawing to my main screen(1024 x 768) and to a mini window(300 x 200) and I have not encountered any issues. Far as I can remember, the d3d device will automatically take care of presenting between different resolutions

Share this post


Link to post
Share on other sites
If you use the same swap chain for both windows, then both images are drawn at exactly the same resolution. When you present, if the window is smaller than the swap chain, the frame is shrunk (and distorted) to fit. If the window is larger, the frame is stretched to fit.

If both windows have nearly the same aspect ratio, this won't be too noticable visually as long as your swap chain is larger than the largest window, but you're still drawing at a higher resolution than necessary and wasting time. If your windows have very different resolutions, (like a main editing window and a long narrow toolbar that has 3d models rendered to it) then you will notice the stretching.

Edit: here's two comparisons. The first is a 1024x768 and 1024x200 window rendering the exact same thing with one swap chain, only the resolutions of the windows are different. As you can see the 768 pixel tall back buffer is getting distorted to fit into a 200 pixel tall window. The second image is the same thing but using 2 swap chains of the appropriate size.

http://img542.imageshack.us/img542/2174/singlee.jpg

http://img13.imageshack.us/img13/1403/multiplep.jpg Edited by turch

Share this post


Link to post
Share on other sites
You have to create your device with your main window normally, because you have to have a window to create a device.
Afterwards you have to call CreateAdditionalSwapChain() for each following window you want to add to your system. You must also create depth/stencil buffers for them manually.

Finally, when rendering to a window, put the correct back buffer as render target 0, clear/render, and call Present() on the correct swap chain.

Then of course you need to resize them each when their respective windows change size, with special-case handling of the main window since you should resize it through the device rather than directly (to allow the depth/buffers for the main window to be resized).


L. Spiro

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!