Sign in to follow this  

[SlimDX] Multiple Depth Buffers issue

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

Hello!

 

I'm trying to implement depth peeling algorithm for order-independent transparency on DirectX 9 part of SlimDX API. I decided to use two depth buffers which I've created as textures:

 

var dsDescr = device.DepthStencilSurface.Description;

depthSurface1 = new Texture(device, dsDescr.Width, dsDescr.Height, 0, Usage.DepthStencil, dsDescr.Format, Pool.Default);

 

and after that I want to make M passes, drawing each depth layer of transparent object, switching depth buffer textures simultaneously.

 

But I've faced a problem that on some graphics cards (f.e. NVidia GTX 550 Ti) after setting device.DepthStencilSurface to my depthSurface.getSurfaceLevel(0) and calling device.Clear only with flag ClearFlag.ZBuffer without ClearFlag.Target nothing is rendered after each pass.

 

I've simplified program with just creating a texture as DepthStencil, setting it to device and calling device.Clear and figure out that I simply can't clear only ZBuffer without touching back buffer if I want to see something on screen!

 

Before inventing workarounds with multiple render targets for cleaning with depth surfaces (And I'm not sure that it will help me) I decided to ask here.

 

Did anyone faced such problem or maybe I'm doing something wrong? I can provide more detailed code information is needed.

 

Thanks for help!

Share this post


Link to post
Share on other sites
Not sure if this is actually the problem, but when I needed additional depth buffers I used Surface.CreateDepthStencilSurface directly, not through a texture. There's an additional discard flag which could make a difference. Also: Make sure some global card settings don't interfere with your formats (e.g. automatic MSAA for your backbuffer). Haven't touched the DX9 MSAA stuff, but IIRC depth and render target need to match.

If you think you got some driver issue, run your program with the reference device and also watch the debug output (enable the DirectX debug layer!). It will be slow but can show you if there's actually a driver issue. Also: Some drivers will allow "bad" calls and still render perfectly fine, so you might be doing something wrong without knowing (other than it breaks on a different system).

Share this post


Link to post
Share on other sites

Thank you for your answer.

 

At least I figured out, that Multisample state for my custom DepthStencil textures and device default DepthStencil are different, but the problem here is that I can't use Surface.CreateDepthStencil method because I need to use my Z-buffers as texture on each rendering pass (actually, at each pass one acts as Depth buffer and second as texture for shader, on next pass they are swapped).

 

Is there a way to create a proper depthstecil surface from texture with appropriate MultiSampleType and Quality?

Share this post


Link to post
Share on other sites
Huh ? Now I'm surprised. I thought sampling depth isn't possible with plain vanilla D3D 9. Maybe your original system allows that. There are also vendor extensions which make it possible. Really check what the reference device has to say.

Usually in D3D9 you output depth to an additional target (e.g. with R32F format), maybe using multiple render targets. Check out any shadow mapping or deferred rendering sample. So you have a (normal) render target texture and your custom depth surface which you create independantly.

Is there a way to create a proper depthstecil surface from texture with appropriate MultiSampleType and Quality?

Can't help you there, sorry, as stated I have no experience with MSAA.

Share this post


Link to post
Share on other sites

This topic is 1704 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.

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