[SDL] Speeding up glClear?

Nicolai Haehnle prefect_ at gmx.net
Sat Jan 8 08:47:29 PST 2005


On Thursday 06 January 2005 19:52, Gabriel wrote:
> > My second thought is that in my projection matrix, the near z plane is 
> > too close to the camera - it's at a distance of 0.2.  I've encountered
> > other problems with the near plane being too close to the camera, but 
> > those were all with rendering errors, not with slow performance, but 
> > I'm wondering if perhaps the depth clearing will be faster if the near
> > z plane is at least a distance of 1.0 from the camera.  Call it
> > intuition.
> 
> Probably not. Clearing the depth buffer involves writing 0s to every
> pixel, so what's on the pixel before doesn't matter.
> 
> What you can do though, if you don't need a lot of depth buffer
> precission, is to use the range 0 - 0.5 in one frame, and then 0.5 - 1
> in the next, then 0-0.5 and so on, thus removing the neccessity to
> clear. I don't remember the specifics but there was a way to do that.

It has been said more than once by developers from both ATI and NVidia that 
this is a bad idea. It might have been useful in older generation graphics 
cards, but modern graphics cards are highly optimized for this kind of 
thing (fast clear etc.), so you're wasting a lot of depth buffer precision 
for a laughable gain.

Besides, as others have pointed out, most real games won't need color clear 
at all because they always render a background, and the depth clear is well 
covered by advanced Z buffering tricks done by the hardware. Don't try to 
be too clever, you'll actually make the driver's life harder.

cu,
Nicolai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050108/20aaf027/attachment-0008.pgp>


More information about the SDL mailing list