Sign in to follow this  
freka586

Device w.o Control/Window? (Off-screen rendering)

Recommended Posts

I have a problem that at first glance seems easy but there are a few quirks... I want to do a bunch of small off-screen renders (to bitmaps, sort of like thumbnails). Since I want to be able to continue with my main rendering without interuption this needs to be done asynchronously. The 2 renderers each have their own device, to minimize concurrency issues. My problem now is that each device seems to require a Control (window). I could assign the "main" Control to both devices, but that might give me problems if the off-screen renderer does device.Present(). I have not been able to create a device without giving it a Control handle. So, what is your take on this issue? Is there a way to have a truly "disconnected" device?

Share this post


Link to post
Share on other sites
On the secondary device, you would not need to call Present unless you want antialiased thumbnails (not really needed in my insignificant opinion.
Get the back buffer instead of presenting.

Hope this helps

Share this post


Link to post
Share on other sites
This is definetly not the most optimal way of doing this. While it may seem like you are doing things asynchronously, you really aren't. When multiple Direct3D devices are active at the same time, the driver is forced to switch between them. These context switches are extremely costly.

Using multiple swap chains is recommended if you need to render to separated windows (as opposed to creating multiple devices per application). Do this with IDirect3DDevice9::CreateAdditionalSwapChain(). You can find a tutorial on using these over at CodeSampler.

Share this post


Link to post
Share on other sites
Also, you might consider simply rendering to a texture. Might be much faster despite being done in your main loop. Just be sure not to use up too much time per frame :).

Share this post


Link to post
Share on other sites
Actually, I have been thinking about *how* costly multiple devices really is...
This is because with my current design I would have 3 of them.
Using only one device is alot more painful design-wise and I am still abit worried about getting that synchronous feeling..

To describe a bit more what I want (without telling more than I'm allowed...) consider this example:

The screen consists of 3 controls (window parts).
The top one is sort of a platform game, the middle is a 3D FPS and the bottom one shows thumbnails.
The two games are actually 2 different ways of presenting the same "world" -
if the player moves/acts in one control the view in the other one is updated accordingly.
I would also like to be able to have a mode where only one of the two controls is used (w. twice its normal size), together with the thumbnails.

Currently, this would be done using 3 renderers, each with its own device.
The device renders to one of the controls.
Having 1 or 2 "main" controls is only a matter of creating 1 or 2 renderers as they are completely self-contained.

Since everything must feel "connected" there is great need for asynchronousy (real word?).
I also very much like the idea of keeping the different renderers as self-contained as possible.
Adding or removing one of them would almost be drag-and-drop then..
So, could this be done in a nice, maintainable way without requiring multiple devices, and still having a very responsive feeling?

If so, please give me a very rough sketch of how the 3 renderers should "communicate" to be as self-contained as possible!
Is there maybe even a best-practice / design pattern thing for this scenario?

[Edited by - freka586 on December 2, 2004 1:56:41 AM]

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