I am trying to read the contents of the depth buffer into main memory so that my CPU side code can do Some Stuff™ with it.

I am attempting to do this by creating a staging resource which can be read by the CPU, which I will copy the contents of the depth buffer into before reading it. I keep encountering errors however, because of, I believe, incompatibilities between the resource format and the view formats.

Threads like these lead me to believe it is possible in DX11 to access the depth buffer as a resource, and that I can create a resource with a typeless format and have it interpreted in the view as another, but I cannot get it to work.

What are the valid formats for the resource to be used as the depth buffer?Which of these are also valid for a CPU accessible staging resource?

Using this format when declaring a depth stencil buffer, you should be able to copy the depth buffer to another R16_FLOAT/R32_FLOAT...etc. texture.

On a side note, it is often not recommended to read back data on the CPU because of the latency that will be introduced. Current techniques - on Windows Direct3D11 - tend to perform typical CPU computation on the GPU with DirectCompute.

Thank you, that is just what I needed. I have created an R24G8_Typeless buffer with a D24_UNorm_S8_UInt DepthStencilView and a R24_UNorm_X8_Typeless staging resource. I was not aware of DirectCompute but it looks like something I definitely want to know, thanks!
–
sebfApr 3 '12 at 15:35