• Advertisement
Sign in to follow this  

DepthPass firstly:is it beneficial?

This topic is 4405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
thats about correct,
another benifit to if u lay down a depthpass firest is to also do occlusion testing with this first depthpass

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
VSync is OFF for sure.
I've tested my prog on GFFX,FPS is significantly bigger,so the perfomance is as smooth as silk.
Supposedly,my ATi drivers can't deal with the situation properly,whereas NV has good-optimized early z-cull mechanizm.NV rules!

Share this post


Link to post
Share on other sites
I wouldnt count on that, the GFFX is a pretty poor card when it comes to fragment shaders, as such the early z-cull might well be giving it a speed boost, where as the 9700 Mobility (which, to add to the confusion is based on the PC 9800 cards...) probably has superious shader performance and thus isnt the bottle neck in its rendering pipeline.

Share this post


Link to post
Share on other sites
to help you find that bottleneck:
http://www.ati.com/developer/gdc/GDC2005_OpenGL_Performance.pdf

Share this post


Link to post
Share on other sites
fwiw from memory with my shader heavy game using no half values (on my gffx) i only see ~5 % performance increase by laying down a depth pass first. so dont expect a lot with normal games

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i remember an interview with carmack and he said he does a depth pass first (like you describe) in the doom3 engine.......if he does it, its gotta be good :P

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
i remember an interview with carmack and he said he does a depth pass first (like you describe) in the doom3 engine.......if he does it, its gotta be good :P


No, it's not good. It's good in his specific case. Not in general. If you do a depth-pass first while you're not fillrate limited, you're going to loose performance, due to the additional transformations and bandwidth for rendering the depth-pass geometry.

Y.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement