View Full Version : is there an early stencil test?

Keith Z. Leonard
09-24-2009, 09:05 PM
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?


09-25-2009, 05:37 AM
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)

09-27-2009, 07:17 PM
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.

Pierre Boudier
11-20-2009, 08:13 AM

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