Managing Overlapping Multiple Viewports

Started by
3 comments, last by Chris_J_H 11 years ago

Hi - I am having a bit of difficulty getting my head around how I should be approaching the following problem in D3D11:

My (simple) 3D game has 2 players, split screen showing the main forward views. Overwriting each of the 2 main views there are 2 smaller rectangles with the left & right side views. So in total: 2 main (non-overlapping) views and then 4 additional sub-views (overlapping). In D3D9 it was no problem I could clear the DepthStencilBuffer for each view's view-port and keep rendering to the back buffer in my swap chain. Not so easy in D3D11: I cannot seem to easily partially clear the DepthStencil Buffer.

I have a skybox effect that I can employ with a depthbuffer overwrite which, if I render first, should do the job... but is this the best way? - what if I have no sky...

This must be a common problem, and have seen some discussion in the forums on related issues but don't seem to have a clear understanding of alternative approaches. Insight appreciated.

Advertisement

It doesn't appear that there is any way to clear portions of a DSV. However, I would recommend just clearing the whole DSV at once, and then repopulating the content. Do you have the same update rates with each of the sub-views?

It doesn't appear that there is any way to clear portions of a DSV. However, I would recommend just clearing the whole DSV at once, and then repopulating the content. Do you have the same update rates with each of the sub-views?

I hear you on clearing the whole DepthStencilBuffer and then repopulating (works for the 2 non-overlapping main views)... however, not for the overlapping sub-views.The sub-views are currently updating at the same rate... If they weren't I guess I would have to render them to a texture and render that texture to the screen each frame - right? In fact I may move to something like that in due course as I may need a mini-HUD/frame around the subviews and it does seem a waste to render them as frequently as the main view... Anyway - interested to hear general approaches to this that would be used... Thanks.

That is how I would handle it - use separate render targets for each of your sub-views, and then just render a textured quad that copies the data into your final render target. That will allow you to optimize the most, by skipping updating any of the subportions until they really need to be.

If you absolutely must be able to keep everything within a single render target, you can render a quad instead of clearing the screen. Then you just make sure that the depth stencil state is set such that the depth test always passes, and you update the depth to be the 'reset' value that you would normally have just cleared to. That should work for render targets too if you need to clear their contents.

But like I mentioned before, I would prefer to use the separate render targets - it will make your life easier!

Thanks - that's helpful.

This topic is closed to new replies.

Advertisement