Thinking on this more, I came up with an approach you can use UAVs(D3D11) to avoid GS overhead. I never did this approach, so, fellow forum users, pointing pitfall on this would be useful, although I dont see any (yet).
Lets assume you have three depth buffers to compute. The idea here is to perform your own depth buffer operation manually, using only VS and PS.
1. Bind 2 UAVs to the PS stage
2. Make sure any frustum culling you are doing on the CPU is aware and considering all ViewProj's in the single pass now. Disable any backface culling you might be doing at Hull Shader ( if it is enabled ).
2. Pseucode below
[source lang="csharp"]//lets say UAV[1-2] are your UAVs and ViewProj[1-2] are your ViewProj matrices.//inPos3D is your 3D position that came from VS//initialize all your UAVs with '1'//disable early-z cullingPS(){ float4 pos1 = mul(inPos3D, ViewProj1); float4 pos2 = mul(inPos3D, ViewProj2); pos1.xyz /= pos1.w; pos2.xyz /= pos1.w; float currentDepth1 = sample(pos1.xy,UAV1); //samples UAV1 at screen pos pos1.xy. //pos1.xy might not be on the screen, in that case you do nothing float currentDepth2 = sample(pos2.xy,UAV2); if(currentDepth1 > pos1.z) { //write currentDepth1 at UAV1 at pos1.xy} if(currentDepth2 > pos2.z) {//write currentDepth2 at UAV2 at pos2.xy} //do other stuff}[/source]
At the end, each of the UAVs are going to have your desired depth buffer
The third depth buffer you dont need a UAV, you gonna use the regular pipeline depth test.
Edited by wiselogi, 05 July 2012 - 04:51 PM.