   DepthStencilBuffer in HLSL
  I've just stumbled upon a presentation of the deferred renderer pipeline in killzone2, and it occured to me, that they are directly using the depth-buffer as depth-texture.So I tried to do the same thing to measure some performance over default rendertargets, but somehow I'm unable to retrieve any value besides 1 from the buffer.Creation of depth-buffer-texture:IDirect3DTexture9 *pTex;HR(GetDevice()->CreateTexture(GetWidth(), GetHeight(), 1, D3DUSAGE_DEPTHSTENCIL, D3DFMT_D24S8, D3DPOOL_DEFAULT, &pTex, NULL));pTex->GetSurfaceLevel(0, &m_pSurface);Next I set this surface as the active DepthStencilSurfaceHR(GetDevice()->GetDepthStencilSurface(&m_pBackup));And I send the texture itself to my postprocessing-shaderCorresponding HLSL-code to display the Depth--buffer on screen:texture2D Depth : TEXTUREDEPTH;sampler2D DepthSampler {TEXTURE = <Depth>;};float4 PixelShader(...) : COLOR {return float4(tex2D(DepthSampler, In.Tex).x, 0, 0, 1);}Anbody knows/sees what's going wrong here ?Reference to KZ2-presentation: http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf   
  The KZ2 devs can do this because their game runs on a console, and they have access to low-level stuff like this.  D3D9 doesn't expose any such functionality.  The only think you can do with a depthstencil surface in legal, valid D3D9 is set it as the current depthstencil surface for the device (unless it's lockable, but that's slow as hell so you wouldn't want to do that).Nvidia and ATI both have "extensions" (more like driver hacks) that allow limited access to hardware depth buffers, but they're really aimed at shadow mapping.  You wouldn't be able to use it for depth reconstruction.In practice it's not much of a big deal, anyway.  You typically render depth out with the rest of G-Buffer so it's not like you could take advantage of double-speed depth-only rendering, and it also lets you use linear depth if you want to avoid precision issues associated with using post-projection z/w.   