Performance problem with glClear(GL_DEPTH_BUFFER_BIT)

Can someone tell me if calling glClear(GL_DEPTH_BUFFER_BIT) multiple times between swapping buffers is supposed to be a performance death sentence?

Some of the time (not all) when I go full screen in my tests my performance drops from a sync rate of 60fps to 15fps. This never happens in windowed mode, only in full screen mode, and only if I leave code in one of my drawing routines which calls glClear(GL_DEPTH_BUFFER_BIT) before every iteration of its drawing code.

I have this problem on both Ubuntu Linux under 12.04 and 13.04 32/64 bit (I reboot and swap out SSDs to change OS). I am using SDL 2.0 RC1. My specs are a laptop with an nvidia 8600M graphics card.

The problem does NOT happen on Windows

I don’t know if the problem is the driver, linux, SDL, or that in general calling glClear(GL_DEPTH_BUFFER_BIT) is a bad thing.

I hope it okay to call glClear(GL_DEPTH_BUFFER_BIT) multiple times because I kind of need to do it for what I am doing.

If you also have a stencil buffer you should always (unless you have a very good reason not to) clear that at the same time as depth; this will enable your driver/GPU to do a faster clear. Remember too that clears are affected by the current write masks.

You may also get faster clears by clearing the full window rect rather than a subrect of it, so check your current viewport and scissor states. This will be hardware/driver dependent, but the theory is that your GPU can just throw away the old depth/stencil buffer and replace it with a new one already in the fully compressed/fully cleared state, rather than having to selectively preserve portions of what you had before.