is there an early stencil test?

Any of you IHV guys have thoughts on how fast a stencil test with GL_EQUAL is now-a-days? Is it possible to leverage this test to save on fragment processing? Obviously in the GL spec it happens post fragment, but is there an early stencil like there is an early Z?


Humus was playing around with using early stencil with D3D a few years ago (2004)

Although I suggested using an incrementing stencil reference value other than clearing the buffer between lights:

I assume it is supported in most Nvidia/ATI hardware now, but if the limitations still exist for Nvidia I don’t know. (Nvidia did not have early stencil if you updated the stencil while stencil testing)

Your best bet is to use GL_EQUAL and disable stencil updates. I’ve seen speed improvements of some form or another from this all the way back to the 9800 Pro… though it may be even more effective on more recent cards.


all HW from AMD (previously ATI) has had early stencil test since r3xx. it has similar in general the same limitation to the early depth test. (i.e., alpha test, texkill, chroma key, depth output can disable it)


Pierre B.
AMD Fellow