Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Swap chains(DX9)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Slig Commando   Members   -  Reputation: 208

Like
0Likes
Like

Posted 16 September 2012 - 02:51 PM

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.

Sponsor:

#2 turch   Members   -  Reputation: 571

Like
0Likes
Like

Posted 17 September 2012 - 09:07 AM

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

#3 Slig Commando   Members   -  Reputation: 208

Like
0Likes
Like

Posted 17 September 2012 - 05:14 PM

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

#4 turch   Members   -  Reputation: 571

Like
0Likes
Like

Posted 18 September 2012 - 07:23 AM

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, 18 September 2012 - 07:46 AM.


#5 L. Spiro   Crossbones+   -  Reputation: 5187

Like
0Likes
Like

Posted 19 September 2012 - 04:57 AM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS