Sign in to follow this  
stdevenling

Why create depth stencil texture failed?

Recommended Posts

stdevenling    122
m_pDevice->CreateTexture(1024, 1024, 1, D3DUSAGE_DEPTHSTENCIL, D3DFMT_D24S8, D3DPOOL_DEFAULT, &m_pTexture, NULL); I use upper code to create a depth stencil texture, at that time, the back buffer size is 800*600, depth stencil format is D3DFMT_D24S8. This code works very well on any NV cards(I tested much NV cards) but works bad on my ATI card. I dont know the result on other ATI cards becase I only have one ATI card(X1300 256MB) for test. so, my question is : Why create depth stencil texture failed on ATI card but succeeded on NV card by the same code? PS: The function return is "invalid call", and the debugging message is: invalid format specialed for create texture

Share this post


Link to post
Share on other sites
stanlo    212
Quote:
Original post by stdevenling
Why create depth stencil texture failed on ATI card but succeeded on NV card by the same code?

You answered your own question. ATI cards are just different from NVidia cards. Check your caps to make sure you can actually create that format on the ATI card. You may need to use a 16 bit depth buffer.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
The simple answer:

ATI cards do not support the creation of Textures with Depth/Stencil buffer formats.
NVIDIA has a special case here, where they allow this and also implement PCF for you automatically ( when sampling from such a texture ).

So you have two paths to write here:
For NVIDIA cards go with your approach, and for ATI create a R32F Render Target Texture with an associated Depth/Stencil Surface ( D24S8 for example ). Then assign a pixel shader which outputs the depth of a fragment into the color so it gets stored in the R32F Render Target.

During rendering you can then sample this R32F texture ( remember no PCF, so you have to implement that yourself in a Pixel Shader )

Share this post


Link to post
Share on other sites
stdevenling    122
"and for ATI create a R32F Render Target Texture with an associated Depth/Stencil Surface"

Associated a surface to a texture?? I cannot found any methods about associated a surface to texture in IDirect3DTexture9 interface. So, how to ?

Share this post


Link to post
Share on other sites
This is a fundamental method in Direct3D.. dev->SetRenderTarget and dev->SetDepthStencilSurface are the key states...

the device automatically associates the current depth buffer with the current render target. How can you do any rendering if you dont know this?

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