   Help with capturing the depth buffer
  Hi guysMaybe someone can help whit this?I try to capture the depth buffer, but it don't work, my code look like this:descNormal=*pBackBufferSurfaceDesc;pd3dDevice->CreateDepthStencilSurface(descNormal.Width, descNormal.Height, D3DFMT_D16_LOCKABLE, descNormal.MultiSampleType, descNormal.MultiSampleQuality, FALSE, &g_pDepthSurface, NULL);V(pd3dDevice->GetDepthStencilSurface(&g_pDepthSurface));IDirect3DDevice9::GetDepthStencilSurface don't return any error message but g_pDepthSurface is a bad pointer.Thanks[Edited by - Xmon on June 13, 2006 7:23:49 AM]
  If you've received a bad pointer (is it NULL, or does it just not change?) then it almost certainly means that CreateDepthStencilSurface() has failed.Two things in particular:1. You're using D3DFMT_D16_LOCKABLE - is it supported by your hardware? The card-caps spreadsheet indicates ATI hardware will handle it but Nvidia's wont. Either way you should make sure you check before just using it [wink]2. Multisampling with depth/stencil's isn't always guaranteed - are you sure that you're passing in an acceptable format? Also note that it should match whatever the render-targets MSAA settings are.Finally - what do the debug runtimes tell you? Normally they'll elaborate on any failed calls by telling you which parameter is incorrect.hthJack   ;Quote:Original post by jollyjeffersIf you've received a bad pointer (is it NULL, or does it just not change?) then it almost certainly means that CreateDepthStencilSurface() has failed.Two things in particular:1. You're using D3DFMT_D16_LOCKABLE - is it supported by your hardware? The card-caps spreadsheet indicates ATI hardware will handle it but Nvidia's wont. Either way you should make sure you check before just using it [wink]2. Multisampling with depth/stencil's isn't always guaranteed - are you sure that you're passing in an acceptable format? Also note that it should match whatever the render-targets MSAA settings are.Finally - what do the debug runtimes tell you? Normally they'll elaborate on any failed calls by telling you which parameter is incorrect.hthJackMy card (6600GT) did'nt support D3DFMT_D16_LOCKABLE just D3DFMT_D16 does this mean that i cant have the CPU operate on the values in the depthbuffer :(;  If D3DFMT_D32F_LOCKABLE doesn't work either, then no - you can't lock the depth buffer.   ;Quote:Original post by Evil SteveIf D3DFMT_D32F_LOCKABLE doesn't work either, then no - you can't lock the depth buffer.OK, so there is no way to stream it over. I could allways render it to a seperate color buffer but it had been convinient to use the depth buffer directly.   ;Quote:Original post by XmonQuote:Original post by Evil SteveIf D3DFMT_D32F_LOCKABLE doesn't work either, then no - you can't lock the depth buffer.OK, so there is no way to stream it over. I could allways render it to a seperate color buffer but it had been convinient to use the depth buffer directly.Convenient for you as the programmer, but not so good for the hardware. Messing with the implicit (or explicit) render targets and depth/stencils is often a good way of killing your performance.Doing a render-to-texture and reading back can still be slow, but the added flexibility and some smart thinking allows you to get pretty good performance.hthJack   