Hello,
I am using deferred rendering, and I want to reconstruct view-space positions from depth so I bind it as an SRV, however at the same time I need to have the same depth buffer texture bound as a depth stencil view to use it for depth comparison.
In short, this:
// disable further depth writing
context->OMSetDepthStencilState(mDepthStencilState, 0);
context->PSSetShaderResources(DX11Texture::SHADER_TEXTURE_SLOT_DEPTH, 1, &mDepthSRV.p);
context->OMSetRenderTargets(1, &mBackbufferRTV.p, mDepthStencilView);
Upon which visual studio goes nuts and forces OMSetRenderTargets() to use NULL as DSV since the same texture is already bound as a shader resource, to prevent it from being written and read at the same time.
But I already disabled writing by setting my depth stencil state!
The only solution I've found is to copy the depth texture into a separate texture and use that as the SRV. I'm not sure how expensive operation this is however and maybe it is totally unnecessary because I've missed something; is there a more clean solution available?