A possible enhancement of the method detailed by MJP would be to create a staging texture of the size of one pixel (or the area you want to sample) and simply use DeviceContext.CopySubresourceRegion.
Note If you use CopySubresourceRegion with a depth-stencil buffer or a multisampled resource, you must copy the whole subresource. In this situation, you must pass 0 to the DstX, DstY, and DstZ parameters and NULL to the pSrcBox parameter.
Good catch! Though it should be still possible: ;)
- Create a texture with same size as depth buffer, not bindable to any stage (but not staging) and format R24G8_Typeless (assuming the depth buffer is for example a D24_UNorm_S8_UInt)
- Create a 1x1 staging texture with again this format R24G8_Typeless.
- Copy the whole depth buffer to the first texture with DeviceContext.CopyResource()
- Copy from first texture to staging texture on a 1x1 region with DeviceContext.CopySubresourceRegion()
I tested this scenario and it seems to work with a d3d11 device.