   does D3D has this function?
  DirectX documentation says:only depth buffer with D3DFMT_D16_LOCKABLE can be locked.how can I get z value from a D3DFMT_D24S8 depthstencil buffer? 
  You can''t, because it''s not lockable. ;  The best thing to do is to tell us why you need the depth value. There are many different approaches for doing the same thing, and I fear that your approach (retrieving z-values from the z-buffer) isn''t a good one. The current hardware is really designed with uni-directional data transfer in mind. Locking z-buffers - on cards that support it - will slow things down horribly.You can always output the z-value to a texture, using a pixel shader. If it''s not a floating-point texture, you''ll need to do some tricks to pack the z-data (say, 24 bits of precision) to the texture''s channels, and then some more trickery when unpacking them later. If you use floating point textures, things are straightforward (though you won''t support none of the current nVidia hardware that way, because they don''t have floating-point textures exposed, as far as I know).   Muhammad Haggag 