DepthPass firstly:is it beneficial?

Started by
17 comments, last by DarkMessiaH 18 years, 2 months ago
Hi! I've read in NVDocs recently that it's much better to render our geometry with no texture or shading applied to it,with glDepthMask(1) and glColorMask(0,0,0,0). After that we should perform more expensive main pass with shaders and all the stuff,after setting glDepthMask(0) and glColorMask(1,1,1,1). I've attempted to take the advantage of the approach aforementioned,but noticed no difference.Has anyone been more successful at it?
Advertisement
You'll only notice a difference is you are using heavy shaders which do alot of per-pixel work
This technique is beneficial when you have a lot of depth complexity and you don't sort your geometry. If you render front-to-back, early Z rejection may accomplish the same effect, i.e. occluded pixels are discarded before they reach the shader. In any case, unless you are fill limited you may not see a benefit. Fill limits can occur even with short shaders if you are memory bandwidth limited (really high resolution and/or multisample).
There are two reasons to do it that way:

1) It makes sure that you get exactly 1x overdraw if you have expensive pixel shaders. (You draw everything with the simplest possible color shader, and discard the color output, in the first pass)

2) NVIDIA hardware is peculiar, in that if you don't write to color, only to depth, you can actually get twice the bandwidth through the pixel generation, so the depth pass is half the cost of an equivalent "simple color" pass. I know this was true for the 5000 series; I don't know if it's still true for 6x/7x.

If you can load up useful, cheap work in your depth pass, such as an ambient coloring shader, and can sort your geometry roughly near-to-far before rendering, then there may not be any benefit in doing the depth-only pass. You must profile on your typical scenes and typical shaders to figure out what to do.
enum Bool { True, False, FileNotFound };
And,as far as I can see,it works only on NV-based hardware,so if I try to do it on ATi,I won't get any perfomance boost?
No, it works on all hardware, if you depth only you'll get the biggest boost on NV hardware as they can write two z-writes per clock when colour output is disabled, however in a shader heavy system you should see some improvements on any hardware which has early-z rejections enabled.
Ok.
And how should I setup the passes?

glDepthMask(1);glColorMask(0,0,0,0);
glDepthFunc(GL_LESS);
//Depth pass
glDepthMask(0);glColorMask(1,1,1,1);
glDepthFunc(GL_LEQUAL);
//Main pass

Is it correct?And are there any specific instructions to make sure that early z-cull optimization is enabled?
thats about correct,
another benifit to if u lay down a depthpass firest is to also do occlusion testing with this first depthpass
Yep,everything seems to be absolutely right.
But still,I can not manage to get any perfomance superiority of this technique to the traditional one!
I think my ATi 9700 Mobility is to be blamed.Any ideas?
How long is your pixel shader ?

If you do not get any performance boost, you're most likely not pixel shader limited (or not enough to get a better framerate). Which means you're trying to optimize the wrong bottleneck..

Y.

This topic is closed to new replies.

Advertisement