Jump to content
  • Advertisement
Sign in to follow this  

SwapChains with BackBuffers

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

Hey, I'm having some issues with the rendering of objects in my swapchains. While my device swapchain renders as it should, the swapchains seem to have a higher depthbias. So things that are further away are being rendered on top instead of behind. I have the wbuffer and zbuffer enabled. My presentparams:
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.BackBufferFormat = DXdisplay.Format;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
presentParams.PresentationInterval = PresentInterval.Immediate;
If someone could tell me what might be causing this effect, that would help narrow it down. Thanks.

Share this post

Link to post
Share on other sites
What's probably happening is that you're rendering to the swapchain surface, but still using the original Z buffer.

You probably query the swapchain for it's backbuffer, set it as active, render, ask the device for it's backbuffer, set it as active, render, forever in a loop. You'll notice you never touched the Z surface.

I'll wait here while you query your swapchain for your depth surface...

Ok, so you can't query the depth surface from your swap chain, making AutoDepthStencil useless for swapchains. You'll need to manually CreateDepthStencilSurface. When you switch render targets, also switch Z buffers. It's a good idea to SetViewport too. After you're done, simply switch back to the device Z buffer when you switch back to the device backbuffer.

I'll wait here while you attempt to restore the original Z surface...

Ok, so you can't query the implicit depth buffer, only the active one (which after you enable your swapchain one, will be that one). There isn't a call like GetBackBuffer for the depth surface, only a GetDepthStencilSurface, which acts like GetRenderTarget. What you need to do is upon create and Reset to query the depthbuffer to get the one associated with the device, and hang onto that pointer. Release it upon exit or before Reset only.

Another option is to create depth surfaces manually even for the device, and skip AutoDepthStencil altogether. Either way works.

Alright, now you can switch RenderTargets, DepthSurfaces, as well as set viewports... you should be good to go.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!